Step 2 – Configuration of the etcd
In this step, you configure and start the etcd service on Database Server 1, Database Server 2, and the Dedicated etcd Server.
Configure and start the etcd service on Database Server 1, Database Server 2 and the dedicated etcd Server:
- Copy the template file <WinCC OA Installation>/data/NGA/PostgreSQL/HAC/etcd.template.conf to /etc/etcd/etcd.conf.
- Fill in the placeholders in /etc/etcd/etcd.conf
- Set the
ETCD_NAMEbased on the local server:"etcd-1" on Database Server 1 "etcd-2" on Database Server 2 "etcd-3" on the Dedicated etcd Server - Set the
ETCD_INITIAL_CLUSTERfield to:
.etcd-1=http://<IP of Database Server 1>:2380, etcd-2=http://<IP of Database Server 2>:2380, etcd-3=http://<IP of Database Server 3>:2380 - Fill in the placeholders in the fields
ETCD_LISTEN_CLIENT_URLS,ETCD_ADVERTISE_CLIENT_URLS,ETCD_LISTEN_PEER_URLS, andETCD_INITIAL_ADVERTISE_PEER_URLSaccording to the local IP address on each etcd server.Ensure that /etc/etcd/etcd.conf can be read by all users:sudo chmod a+r /etc/etcd/etcd.confAs an example, consider the following IP addresses:192.168.178.88 for Database Server 1, 192.168.178.89 for Database Server 2, 192.168.178.90 for the dedicated etcd server.In this case, the /etc/etcd/etcd.conf file on Database Server 2 would look like this:ETCD_NAME="etcd-2" ETCD_INITIAL_CLUSTER="etcd-1=http://192.168.178.88:2380,etcd-2=http://192.168.178.89:2380,etcd-3=http://192.168.178.90:2380" ETCD_LISTEN_CLIENT_URLS="http://192.168.178.89:2379,http://127.0.0.1:2379" ETCD_ADVERTISE_CLIENT_URLS="http://192.168.178.89:2379" ETCD_LISTEN_PEER_URLS="http://192.168.178.89:2380,http://127.0.0.1:7001" ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.178.89:2380" ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster" ETCD_INITIAL_CLUSTER_STATE="new" ETCD_DATA_DIR="/var/lib/etcd" ETCD_ELECTION_TIMEOUT="5000" ETCD_HEARTBEAT_INTERVAL="1000" ETCD_ENABLE_V2="true"
- Set the
- Create a service on each server to run etcd. To do this, copy the service file from
<WinCC OA
installation>/data/NGA/PostgreSQL/HAC/etcd.service to
/etc/systemd/system/. Then, load the service using the
following command:
systemctl daemon-reload systemctl enable etcd.service - Start the etcd service on all three servers one after another using:
systemctl start etcd.serviceand check the status of etcd using:
systemctl status etcd.service - Check the availability of the etcd-Cluster by using the
putcommand to store and retrieve a test key-value pair on one etcd machine:etcdctl put testKey testValOK - On all etcd machines, use the get command:
The
etcdctl get testKeytestKey testValgetcommand should return the value testVal on all machines, as shown above. This confirms that all three etcd nodes are communicating properly. - Furthermore, the status of the entire
etcdcluster can be queried:etcdctl endpoint status --cluster -w=table+----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | ENDPOINT | ID | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX | ERRORS | +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ | http://192.168.178.88:2379 | 5664a8f05990a10 | 3.5.21 | 98 kB | false | false | 2 | 286 | 286 | | | http://192.168.178.89:2379 | d2fe156a4f8f92ae | 3.5.21 | 98 kB | false | false | 2 | 286 | 286 | | | http://192.168.178.90:2379 | dd30186661e66c2c | 3.5.21 | 98 kB | true | false | 2 | 286 | 286 | | +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+ - The health status of each individual etcd node can also be queried separately:
etcdctl endpoint health127.0.0.1:2379 is healthy: successfully committed proposal: took = 4.7686ms
