Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS deployment Etcd cluster

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

I. introduction of the environment

Operating system information: CentOS 7 64-bit

Server information:

192.168.80.130 Etcd-master

192.168.80.131 Etcd-node1

192.168.80.132 Etcd-node2

II. Pre-deployment preparation

1. Set secret-free login

[Master]

[root@Etcd-master ~] # ssh-keygen

[root@Etcd-master] # ssh-copy-id-I / root/.ssh/id_rsa.pub Etcd-node1

[root@Etcd-master] # ssh-copy-id-I / root/.ssh/id_rsa.pub Etcd-node2

2. Operate on all machines

A, add hosts

[root@Etcd-master] # 192.168.80.130 Etcd-master

[root@Etcd-master] # 192.168.80.131 Etcd-node1

[root@Etcd-master] # 192.168.80.132 Etcd-node2

B. Synchronization time

[root@Etcd-master ~] # yum-y lrzsz git wget python-devel ntp net-tools curl cmake epel-release rpmdevtools openssl-devel kernel-devel gcc redhat-rpm-config bridge-utils

[root@Etcd-master ~] # yum groupinstall "Development Tools"-y

[root@Etcd-master ~] # cp-Rf / usr/share/zoneinfo/Asia/Shanghai / etc/localtime

[root@Etcd-master ~] # ntpdate 133.100.11.8

[root@Etcd-master ~] # sed-I's ZONE= Zone = "America/New_York" # ZONE= "Asia/Shanghai" # g'/ etc/sysconfig/clock

[root@Etcd-master] # hwclock-w

[root@Etcd-master] # date-R

3. Deploy Etcd

[Master]

1. Install and configure Master nodes

[root@Etcd-master ~] # yum-y install etcd

[root@Etcd-master ~] # cat / etc/etcd/etcd.conf

# [member]

ETCD_NAME= "etcd-master"

ETCD_DATA_DIR= "/ var/lib/etcd/default.etcd"

# ETCD_WAL_DIR= ""

# ETCD_SNAPSHOT_COUNT= "10000"

# ETCD_HEARTBEAT_INTERVAL= "100s"

# ETCD_ELECTION_TIMEOUT= "1000"

ETCD_LISTEN_PEER_URLS= "http://0.0.0.0:2380"

ETCD_LISTEN_CLIENT_URLS= "http://0.0.0.0:4001,http://0.0.0.0:2379"

# ETCD_MAX_SNAPSHOTS= "5"

# ETCD_MAX_WALS= "5"

# ETCD_CORS= ""

#

# [cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS= "http://etcd-master:2380"

# if you use different ETCD_NAME (e.g. Test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test= http://..."

ETCD_INITIAL_CLUSTER= "etcd-node1= http://etcd-node1:2380,etcd-node2=http://etcd-node2:2380,etcd-master=http://etcd-master:2380"

ETCD_INITIAL_CLUSTER_STATE= "new"

ETCD_INITIAL_CLUSTER_TOKEN= "etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS= "http://Etcd-master:2379,http://Etcd-master:4001"

[Node]

2. Install and configure Node1 nodes

[root@Etcd-node1 ~] # yum-y install etcd

[root@Etcd-node1 ~] # cat / etc/etcd/etcd.conf

# [member]

ETCD_NAME= "etcd-node1"

ETCD_DATA_DIR= "/ var/lib/etcd/default.etcd"

# ETCD_WAL_DIR= ""

# ETCD_SNAPSHOT_COUNT= "10000"

# ETCD_HEARTBEAT_INTERVAL= "100s"

# ETCD_ELECTION_TIMEOUT= "1000"

ETCD_LISTEN_PEER_URLS= "http://0.0.0.0:2380"

ETCD_LISTEN_CLIENT_URLS= "http://0.0.0.0:4001,http://0.0.0.0:2379"

# ETCD_MAX_SNAPSHOTS= "5"

# ETCD_MAX_WALS= "5"

# ETCD_CORS= ""

#

# [cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS= "http://etcd-node1:2380"

# if you use different ETCD_NAME (e.g. Test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test= http://..."

ETCD_INITIAL_CLUSTER= "etcd-node1= http://etcd-node1:2380,etcd-node2=http://etcd-node2:2380,etcd-master=http://etcd-master:2380"

ETCD_INITIAL_CLUSTER_STATE= "new"

ETCD_INITIAL_CLUSTER_TOKEN= "etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS= "http://etcd-node1:2379,http://etcd-node1:4001"

3. Install and configure Node2 nodes:

[root@Etcd-node2 ~] # yum-y install etcd

[root@Etcd-node2 ~] # cat / etc/etcd/etcd.conf

# [member]

ETCD_NAME= "etcd-node2"

ETCD_DATA_DIR= "/ var/lib/etcd/default.etcd"

# ETCD_WAL_DIR= ""

# ETCD_SNAPSHOT_COUNT= "10000"

# ETCD_HEARTBEAT_INTERVAL= "100s"

# ETCD_ELECTION_TIMEOUT= "1000"

ETCD_LISTEN_PEER_URLS= "http://0.0.0.0:2380"

ETCD_LISTEN_CLIENT_URLS= "http://0.0.0.0:4001,http://0.0.0.0:2379"

# ETCD_MAX_SNAPSHOTS= "5"

# ETCD_MAX_WALS= "5"

# ETCD_CORS= ""

#

# [cluster]

ETCD_INITIAL_ADVERTISE_PEER_URLS= "http://etcd-node2:2380"

# if you use different ETCD_NAME (e.g. Test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test= http://..."

ETCD_INITIAL_CLUSTER= "etcd-node1= http://etcd-node1:2380,etcd-node2=http://etcd-node2:2380,etcd-master=http://etcd-master:2380"

ETCD_INITIAL_CLUSTER_STATE= "new"

ETCD_INITIAL_CLUSTER_TOKEN= "etcd-cluster"

ETCD_ADVERTISE_CLIENT_URLS= "http://etcd-node2:2379,http://etcd-node2:4001"

4. Start the Etcd service

[master]

[root@Etcd-master ~] # systemctl restart etcd

[node1]

[root@Etcd-node1 ~] # systemctl restart etcd

[node2]

[root@Etcd-node2 ~] # systemctl restart etcd

5. Check the service status

[master]

[root@Etcd-master ~] # etcdctl member list

6c74f3fd7534bb5: name=etcd-node1 peerURLs= http://etcd-node1:2380 clientURLs= http://etcd-node1:2379,http://etcd-node1:4001 isLeader=false

A57a17f287dbe7bb: name=etcd-node2 peerURLs= http://etcd-node2:2380 clientURLs= http://etcd-node2:2379,http://etcd-node2:4001 isLeader=true

Ffe21a7812eb7c5f: name=etcd-master peerURLs= http://etcd-master:2380 clientURLs= isLeader=false

[node1]

[root@Etcd-node1 ~] # etcdctl member list

6c74f3fd7534bb5: name=etcd-node1 peerURLs= http://etcd-node1:2380 clientURLs= http://etcd-node1:2379,http://etcd-node1:4001 isLeader=false

A57a17f287dbe7bb: name=etcd-node2 peerURLs= http://etcd-node2:2380 clientURLs= http://etcd-node2:2379,http://etcd-node2:4001 isLeader=true

Ffe21a7812eb7c5f: name=etcd-master peerURLs= http://etcd-master:2380 clientURLs= isLeader=false

[node2]

[root@Etcd-node2 ~] # etcdctl member list

6c74f3fd7534bb5: name=etcd-node1 peerURLs= http://etcd-node1:2380 clientURLs= http://etcd-node1:2379,http://etcd-node1:4001 isLeader=false

A57a17f287dbe7bb: name=etcd-node2 peerURLs= http://etcd-node2:2380 clientURLs= http://etcd-node2:2379,http://etcd-node2:4001 isLeader=true

Ffe21a7812eb7c5f: name=etcd-master peerURLs= http://etcd-master:2380 clientURLs= isLeader=false

Test the synchronization of the cluster

[master]

[root@Etcd-master ~] # etcdctl set zlyangdir/zlyangkeys0 0

0

[root@Etcd-master ~] # etcdctl ls zlyangdir

Zlyangdir/zlyangkeys0

[root@Etcd-master ~] # etcdctl get zlyangdir/zlyangkeys0

0

[node1]

[root@Etcd-node1 ~] # etcdctl ls zlyangdir

Zlyangdir/zlyangkeys0

[root@Etcd-node1 ~] # etcdctl get zlyangdir/zlyangkeys0

0

[node2]

[root@Etcd-node2 ~] # etcdctl ls zlyangdir

Zlyangdir/zlyangkeys0

[root@Etcd-node2 ~] # etcdctl get zlyangdir/zlyangkeys0

0

Official deployment plan: https://coreos.com/etcd/docs/latest/op-guide/clustering.html

So far, the Etcd cluster has been set up. If you have any questions, please contact: DBA_Master@163.com

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report