GBase 8c distributed high availability service is controlled by related components, supporting DCS (equivalent to etcd) to manage the startup, shutdown, and high availability of cluster services. If the etcd cluster is unstable or down, it will directly affect the high availability service. Additionally, if other services on the same host as the database also use etcd, there may be conflicts between the etcd service managing the GBase 8c database and other components' etcd services, posing a threat to the high availability service. When facing etcd service conflicts, manual redeployment is required, divided into the following two situations:
- Other components on the server have already occupied the default etcd service (etcd.service) or etcd running directory (/var/lib/etcd).
- The etcd service for GBase 8c needs to be deployed under a specified cluster, sharing the etcd cluster with other service components.
In these cases, we can manually install the etcd cluster and isolate or share the etcd service through service names, ports, running directories, etc. This article is recommended for DBAs or database practitioners with certain technical foundations.
Steps to Manually Configure the GBase 8c etcd Cluster
(1) Plan etcd Cluster Configuration
etcd Node Name | IP | Port | etcd Running Directory |
---|---|---|---|
etcd-1 | 192.168.0.100 | 12379 | /var/lib/etcd_gbase |
etcd-2 | 192.168.0.101 | 12379 | /var/lib/etcd_gbase |
etcd-3 | 192.168.0.102 | 12379 | /var/lib/etcd_gbase |
(2) Create the etcd service running directory on each of the three servers. The directory name must not be the same as the etcd running directory required by other services.
$ mkdir -p /var/lib/etcd_gbase
(3) Manually edit the etcd configuration files on the 3 nodes
Note: When configuring etcd on an ARM server, you need to add an extra configuration item:
ETCD_UNSUPPORTED_ARCH=arm64
1) Configuration file for etcd-1 on node 192.168.0.100
$ cat /etc/etcd/etcd.conf
ETCD_NAME=etcd-1
ETCD_DATA_DIR="/var/lib/etcd_gbase"
ETCD_LISTEN_PEER_URLS="http://192.168.0.100:12380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.0.100:12379,http://192.168.0.100:12379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.0.100:12380"
ETCD_INITIAL_CLUSTER="etcd-1=http://192.168.0.100:12380,etcd-2=http://192.168.0.101:12380,etcd-3=http://192.168.0.102:12380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="singless"
2) Configuration file for etcd-2 on node 192.168.0.101
$ cat /etc/etcd/etcd.conf
ETCD_NAME=etcd-2
ETCD_DATA_DIR="/var/lib/etcd_gbase"
ETCD_LISTEN_PEER_URLS="http://192.168.0.101:12380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.0.101:2379,http://192.168.0.101:12379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.0.101:12380"
ETCD_INITIAL_CLUSTER="etcd-2=http://192.168.0.100:12380,etcd-2=http://192.168.0.101:12380,etcd-3=http://192.168.0.102:12380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="singless"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.101:12379"
3) Configuration file for etcd-3 on node 192.168.0.102
$ cat /etc/etcd/etcd.conf
ETCD_NAME=etcd-3
ETCD_DATA_DIR="/var/lib/etcd_gbase"
ETCD_LISTEN_PEER_URLS="http://192.168.0.102:12380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.0.102:12379,http://192.168.0.102:12379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.0.101:12380"
ETCD_INITIAL_CLUSTER="etcd-2=http://192.168.0.100:12380,etcd-2=http://192.168.0.101:12380,etcd-3=http://192.168.0.102:12380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="singless"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.102:12379"
(4) Edit the etcd server service. If etcd.server already exists and is running, modify the server name. The configuration is the same for each node.
$ cat /usr/lib/systemd/system/etcd.service
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
User=root
Type=notify
EnvironmentFile=-/etc/etcd/etcd.conf
ExecStart=/usr/local/bin/etcd
Restart=on-failure
RestartSec=10s
LimitNOFILE=40000
[Install]
WantedBy=multi-user.target
(5) Start the etcd service and enable it to start on boot
systemctl start etcd
systemctl enable etcd
(6) The etcd service configuration is complete.
(7) View the etcd cluster member information
$ etcdctl --endpoints http://192.168.0.101:12379 member list
897226ebfbede926: name=etcd-1 peerURLs=http://192.168.0.100:12380 clientURLs=http://192.168.0.100:12379 isLeader=false
938287ed98cae601: name=etcd-2 peerURLs=http://192.168.0.101:12380 clientURLs=http://192.168.0.101:12379 isLeader=true
b5fb7b1cab0fff45: name=etcd-3 peerURLs=http://192.168.0.101:12380 clientURLs=http://192.168.0.102:12379 isLeader=false