1.根据规划我们要在master、node1、node2上部署etcd集群
etcd下载地址:
https://mirrors.huaweicloud.com/etcd/v3.3.12/etcd-v3.3.12-linux-amd64.tar.gz
2.创建相应的目录:
mkdir /home/app/ksource/etcd/{bin,cfg,ssl,data}
3.解压etcd-v3.3.12-linux-amd64.tar.gz
cp etcd-v3.3.12-linux-amd64/{etcd,etcdctl} /home/app/ksource/etcd/bin
4.添加认证
cp /home/app/ksource/cert/*pem /home/app/ksource/etcd/ssl
5.创建配置文件:
vim /home/app/ksource/etcd/cfg/etcd
#[Member]
ETCD_NAME="etcd01" #每一个节点都不一样
ETCD_DATA_DIR="/home/app/ksource/etcd/data" #数据存放位置
ETCD_LISTEN_PEER_URLS="https://192.168.30.24:2380" #集群的加入访问链接,集群互访是2380端口
ETCD_LISTEN_CLIENT_URLS="https://192.168.30.24:2379" #当前客户端的访问链接,单独访问是2379端口
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.30.24:2380"
ETCD_ADVERTISE_CLIENT_URLS="https://192.168.30.24:2379"
ETCD_INITIAL_CLUSTER="etcd01=https://192.168.30.24:2380,etcd02=https://192.168.30.25:2380,etcd03=https://192.168.30.27:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
6.添加etcd.service服务:
[Unit]
Description=Etcd Server
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
EnvironmentFile=/home/app/ksource/etcd/cfg/etcd
ExecStart=/home/app/ksource/etcd/bin/etcd --name=${ETCD_NAME} --data-dir=${ETCD_DATA_DIR} --listen-peer-urls=${ETCD_LISTEN_PEER_URLS} --listen-client-urls=${ETCD_LISTEN_CLIENT_URLS},http://127.0.0.1:2379 --advertise-client-urls=${ETCD_ADVERTISE_CLIENT_URLS} --initial-advertise-peer-urls=${ETCD_INITIAL_ADVERTISE_PEER_URLS} --initial-cluster=${ETCD_INITIAL_CLUSTER} --initial-cluster-token=${ETCD_INITIAL_CLUSTER_TOKEN} --initial-cluster-state=new --cert-file=/home/app/ksource/etcd/ssl/server.pem --key-file=/home/app/ksource/etcd/ssl/server-key.pem --peer-cert-file=/home/app/ksource/etcd/ssl/server.pem --peer-key-file=/home/app/ksource/etcd/ssl/server-key.pem --trusted-ca-file=/home/app/ksource/etcd/ssl/ca.pem --peer-trusted-ca-file=/home/app/ksource/etcd/ssl/ca.pem --enable-v2
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
7.将etcd打包发送到192.168.30.25和192.168.30.27上。并修改配置文件信息 /home/app/ksource/etcd/cfg/etcd
主要修改ip地址和ETCD_NAME
8.启动etcd服务:
systemctl start etcd
systemctl status etcd
systemctl enable etcd
9.查看集群信息:
/home/app/ksource/etcd/bin/etcdctl member list
集群信息10.docker安装:
yum -y install yum-utils device-mapper-persistent-data lvm2
curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
如果下载很慢可以尝试下载国内源:
wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce
修改仓库地址:
vim /etc/docker/daemon.json
{
"registry-mirrors":[ "https://81l9w6xn.mirror.aliyuncs.com" ]
}
启动docker:
systemctl start docker
补录信息:
etcd相关信息:
etd 简单介绍 https://www.jianshu.com/p/dd7c08d9668f
etcd相关选举内容:https://www.jianshu.com/p/531e26d45bb8
etcd简单操作数据:https://www.jianshu.com/p/a63efc9e24d6
网友评论