ETCD部署

实验环境Centos7.3

一、单节点部署

1、etcd下载地址(内置启动脚本)

etcd-3.4.9.tar.gz资源-CSDN文库

2、解压安装包

[root@centos_mn ]# tar -xf etcd-3.4.9.tar.gz -C /data
[root@centos_mn ]# ls /data
etcd-3.4.9 

3、修改etcd配置文件

[root@centos_mn ]# vim /data/etcd-3.4.9/cfg/etcd.conf
#[Member]
ETCD_NAME="etcd-1"
ETCD_DATA_DIR="/data/mydata_etcd_3.4.9"
ETCD_LISTEN_PEER_URLS="http://10.2.20.77:2380"
ETCD_LISTEN_CLIENT_URLS="http://10.2.20.77:2379"

#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.2.20.77:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://10.2.20.77:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://10.2.20.77:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"

4、配置启动脚本

[root@centos_mn ~]# ls /data/etcd-3.4.9
bin  cfg  etcd.service  ssl
[root@centos_mn ~]# mv /data/etcd-3.4.9/etcd.service /usr/lib/systemd/system/
[root@centos_mn ~]# systemctl daemon-reload

5、启动etcd服务

systemctl start etcd

6、查看etcd状态。如下:表示单节点启动成功

[root@centos_mn cfg]# netstat -anpt | grep etcd
tcp        0      0 10.2.20.77:2379         0.0.0.0:*               LISTEN      2304/etcd           
tcp        0      0 10.2.20.77:2380         0.0.0.0:*               LISTEN      2304/etcd           
tcp        0      0 10.2.20.77:49888        10.2.20.77:2379         ESTABLISHED 2304/etcd           
tcp        0      0 10.2.20.77:2379         10.2.20.77:49888        ESTABLISHED 2304/etcd 

二、集群安装

etcd-1

10.2.20.77

etcd-2

10.2.20.88

etcd-3

10.2.20.99

1、在每台机器部署etcd服务

[root@centos_mn ]# tar -xf etcd-3.4.9.tar.gz -C /data
[root@centos_mn ]# ls /data
etcd-3.4.9 

2、etcd-1配置文件

[root@etcd-1 ]# vim /data/etcd-3.4.9/cfg/etcd.conf
#[Member]
ETCD_NAME="etcd-1"
ETCD_DATA_DIR="/data/mydata_etcd_3.4.9"
ETCD_LISTEN_PEER_URLS="http://10.2.20.77:2380"    #集群内部通讯端口
ETCD_LISTEN_CLIENT_URLS="http://10.2.20.77:2379"  #监听端口

#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.2.20.77:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://10.2.20.77:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://10.2.20.77:2380,etcd-2=http://10.2.20.88:2380,etcd-3=http://10.2.20.99:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"

3、etcd-2配置文件

[root@etcd-1 ]# vim /data/etcd-3.4.9/cfg/etcd.conf
#[Member]
ETCD_NAME="etcd-2"
ETCD_DATA_DIR="/data/mydata_etcd_3.4.9"
ETCD_LISTEN_PEER_URLS="http://10.2.20.88:2380"    #集群内部通讯端口
ETCD_LISTEN_CLIENT_URLS="http://10.2.20.88:2379"  #监听端口

#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.2.20.88:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://10.2.20.88:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://10.2.20.77:2380,etcd-2=http://10.2.20.88:2380,etcd-3=http://10.2.20.99:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"

4、etcd-3配置文件

[root@etcd-1 ]# vim /data/etcd-3.4.9/cfg/etcd.conf
#[Member]
ETCD_NAME="etcd-3"
ETCD_DATA_DIR="/data/mydata_etcd_3.4.9"
ETCD_LISTEN_PEER_URLS="http://10.2.20.99:2380"    #集群内部通讯端口
ETCD_LISTEN_CLIENT_URLS="http://10.2.20.99:2379"  #监听端口

#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.2.20.99:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://10.2.20.77:2379"
ETCD_INITIAL_CLUSTER="etcd-1=http://10.2.20.77:2380,etcd-2=http://10.2.20.88:2380,etcd-3=http://10.2.20.99:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"

5、配置启动脚本

[root@centos_mn ~]# ls /data/etcd-3.4.9
bin  cfg  etcd.service  ssl
[root@centos_mn ~]# mv /data/etcd-3.4.9/etcd.service /usr/lib/systemd/system/
[root@centos_mn ~]# systemctl daemon-reload

6、启动服务

systemctl start etcd

7、查看etcd集群状态

ETCDCTL_API=3 /data/etcd-3.4.9/bin/etcdctl  --endpoints="http://10.2.20.77:2379,http://10.2.20.88:2379,http://10.2.20.99:2379" endpoint health

你可能感兴趣的:(etcd,数据库)