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:

  1. Copy the template file <WinCC OA Installation>/data/NGA/PostgreSQL/HAC/etcd.template.conf to /etc/etcd/etcd.conf.
  2. Fill in the placeholders in /etc/etcd/etcd.conf
    • Set the ETCD_NAME based 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_CLUSTER field 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, and ETCD_INITIAL_ADVERTISE_PEER_URLS according 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.conf
      As 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"
  3. 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
  4. Start the etcd service on all three servers one after another using:
    systemctl start etcd.service

    and check the status of etcd using:

    systemctl status etcd.service
  5. Check the availability of the etcd-Cluster by using the put command to store and retrieve a test key-value pair on one etcd machine:
    etcdctl put testKey testVal
    OK
  6. On all etcd machines, use the get command:
    etcdctl get testKey
    testKey
    testVal
    The get command should return the value testVal on all machines, as shown above. This confirms that all three etcd nodes are communicating properly.
  7. Furthermore, the status of the entire etcd cluster 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 |        |
    +----------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+--------+
  8. The health status of each individual etcd node can also be queried separately:
     etcdctl endpoint health
     127.0.0.1:2379 is healthy: successfully committed proposal: took = 4.7686ms