Catalog
1 Preface
Introduction to 2 etcd
3 etcd architecture
4 etcd installation
5 etcd startup and setup startup
6 Set up etcd cluster
7 Verify etcd cluster
8 etcd operation
1 Preface
If you have any questions about your blog, please let me know.
Introduction to 2 etcd
Etcd is a distributed key-value pair storage system developed by coreos and open source. The underlying uses raft consensus algorithm to achieve strong consistency, de-centralization, and high availability.Etcd not only can save data reliably and quickly, but also provides an interface for external access.In addition, etcd can achieve reliable distributed collaboration through distributed locks, leader elections, and write barriers.
3 etcd architecture
4 etcd installation
etcd is installed in yum mode, if you can't install it in yum mode for other reasons, you can go directly to Github website Download the binary installation package.
This article will use three virtual machines to form an etcd cluster, each of which will have etcd installed.The host name and ip are shown in the following table:
k8s-m-1 192.168.182.181
k8s-m-2 192.168.182.182
k8s-m-3 192.168.182.183
Install etcd on each virtual machine using the following commands:
yum -y install etcd
5 etcd startup and setup startup
Start and set the boot start etcd on each machine using the following commands:
systemctl start etcd
systemctl enable etcd
systemctl status etcd
The following screenshots of successful command execution:
6 Set up etcd cluster
Each etcd needs to be clustered after it is installed.
The k8s-m-1 node executes the following commands:
nohup etcd --name k8s-m-1 --data-dir=data.etcd --initial-advertise-peer-urls http://192.168.182.181:2380 --listen-peer-urls http://192.168.182.181:2380 --advertise-client-urls http://192.168.182.181:2379 --listen-client-urls http://192.168.182.181:2379 --initial-cluster k8s-m-1=http://192.168.182.181:2380,k8s-m-2=http://192.168.182.182:2380,k8s-m-3=http://192.168.182.183:2380 --initial-cluster-state new --initial-cluster-token jiuxi_token >> etcd.log 2>&1 &
export ETCDCTL_API=3
The k8s-m-2 node executes the following commands:
nohup etcd --name k8s-m-2 --data-dir=data.etcd --initial-advertise-peer-urls http://192.168.182.182:2380 --listen-peer-urls http://192.168.182.182:2380 --advertise-client-urls http://192.168.182.182:2379 --listen-client-urls http://192.168.182.182:2379 --initial-cluster k8s-m-1=http://192.168.182.181:2380,k8s-m-2=http://192.168.182.182:2380,k8s-m-3=http://192.168.182.183:2380 --initial-cluster-state new --initial-cluster-token jiuxi_token >> etcd.log 2>&1 &
export ETCDCTL_API=3
The k8s-m-3 node executes the following commands:
nohup etcd --name k8s-m-3 --data-dir=data.etcd --initial-advertise-peer-urls http://192.168.182.183:2380 --listen-peer-urls http://192.168.182.183:2380 --advertise-client-urls http://192.168.182.183:2379 --listen-client-urls http://192.168.182.183:2379 --initial-cluster k8s-m-1=http://192.168.182.181:2380,k8s-m-2=http://192.168.182.182:2380,k8s-m-3=http://192.168.182.183:2380 --initial-cluster-state new --initial-cluster-token jiuxi_token >> etcd.log 2>&1 &
export ETCDCTL_API=3
The following screenshot of etcd.log after successful command execution:
7 Verify etcd cluster
Perform the following statement to verify the etcd cluster:
etcdctl --endpoints=192.168.182.181:2379,192.168.182.182:2379,192.168.182.183:2379 member list
The screenshot below shows that the status is started:
8 etcd operation
The etcd cluster has been successfully created above, and the insertion and query operations are demonstrated by a simple sample below:
Insert operation on k8s-m-3 node:
etcdctl --endpoints=192.168.182.181:2379,192.168.182.182:2379,192.168.182.183:2379 put nickname jiuxi
etcdctl --endpoints=192.168.182.181:2379,192.168.182.182:2379,192.168.182.183:2379 get nickname
The results of execution are as follows:
Query operations on k8s-m-2 nodes:
The entire etcd cluster has since been easily exploded.