温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

cenots7 部署etcd集群

发布时间:2020-05-28 02:15:30 来源:网络 阅读:864 作者:collglle_cx 栏目:建站服务器


ip角色
192.168.1.101master
192.168.1.102
node1
192.168.1.103node2


1. 安装etcd

yum install -y etcd

2. 配置文件

# master配置
ETCD_NAME=etcdmaster 
ETCD_DATA_DIR="/var/lib/etcd/etcd-master.etcd"    
ETCD_LISTEN_PEER_URLS="http://192.168.1.101:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.101:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.101:2380"
ETCD_INITIAL_CLUSTER="etcdmaster=http://192.168.1.101:2380,etcdnode1=http://192.168.1.102:2380,etcdnode2=http://192.168.1.103:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.101:2379"
# etcdnode01
ETCD_NAME=etcdnode01
ETCD_DATA_DIR="/var/lib/etcd/etcd-master.etcd"    
ETCD_LISTEN_PEER_URLS="http://192.168.1.102:2380"
ETCD_LISTEN_CLIENT_URLS="http://1092.168.1.102:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.6.74.6:2380"
ETCD_INITIAL_CLUSTER="etcdmaster=http://192.168.1.101:2380,etcdnode1=http://192.168.1.102:2380,etcdnode2=http://192.168.1.103:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.102:2379"
# etcdnode02
ETCD_NAME=etcdnode02
ETCD_DATA_DIR="/var/lib/etcd/etcd-master.etcd"    
ETCD_LISTEN_PEER_URLS="http://192.168.1.103:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.103:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.1.103:2380"
ETCD_INITIAL_CLUSTER="etcdmaster=http://192.168.1.101:2380,etcdnode1=http://192.168.1.102:2380,etcdnode2=http://192.168.1.103:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.1.103:2379"


3. 配置启动命令

cat /usr/lib/systemd/system/etcd.service

[Unit]

Description=Etcd Server

After=network.target

After=network-online.target

Wants=network-online.target

[Service]

Type=notify

WorkingDirectory=/var/lib/etcd/

EnvironmentFile=-/etc/etcd/etcd.conf

User=etcd

ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\" \
--data-dir=\"${ETCD_DATA_DIR}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\" \
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\" \
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\" \
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""

Restart=on-failure

LimitNOFILE=65536

[Install]

WantedBy=multi-user.target


4. 管理  

   分别启动各种节点 systemctl start etcd

# 查看群集状态命令
etcdctl member list


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI