博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
etcd节点扩容至两个节点
阅读量:4950 次
发布时间:2019-06-11

本文共 4024 字,大约阅读时间需要 13 分钟。

本篇已经安装了单个etcd,然后进行扩容etcd节点至2个,安装单节点请参照:https://www.cnblogs.com/effortsing/p/10295261.html实验架构test1: 192.168.0.91    etcd test2: 192.168.0.92    etcdtest3: 192.168.0.93    无需求:test1节点已经安装了etcd, 现在要把test2节点作为etcd节点添加进来1、环境配置# 如下操作在所有节点操作修改主机名# 注意修改 各自节点对应的 主机名sed -i '$a\hostname=test2' /etc/hostnamesed -i '$a\hostname=test2' /etc/sysconfig/network && hostnamectl set-hostname test2配置hosts解析cat >>/etc/hosts<
> /etc/sysctl.d/k8s.conf <
> /etc/pki/tls/certs/ca-bundle.crt添加etcd 证书到linux系统受信任列表cd /etc/etcd/cert/cat etcd.pem >> /etc/pki/tls/certs/ca-bundle.crt5、添加新成员5.1、注册新节点# 在test1节点上操作# etcdctl 在注册完新节点后,会返回一段提示,包含3个环境变量,需要在etcd启动脚本中修改成这3个环境变量[root@test1 ~]# etcdctl --ca-file /root/ssl/ca.pem --cert-file /root/ssl/etcd.pem --key-file /root/ssl/etcd-key.pem member add test2 http://192.168.0.92:2380Added member named test2 with ID 2eb21869c9f27e29 to clusterETCD_NAME="test2"ETCD_INITIAL_CLUSTER="test2=http://192.168.0.92:2380,test1=https://192.168.0.91:2380"ETCD_INITIAL_CLUSTER_STATE="existing"5.2、修改test2节点的peer url为httpsetcdctl --ca-file /etc/kubernetes/cert/ca.pem --cert-file /etc/etcd/cert/etcd.pem --key-file /etc/etcd/cert/etcd-key.pem member update test2 https://192.168.0.92:2380如果执行失败,先跳过,不影响6、 配置环境变量# 在 test2 节点上操作cat >> /etc/profile << EOFexport ETCD_NAME=$(hostname)export INTERNAL_IP=$(hostname -i | awk '{print $NF}')export ECTD_CLUSTER='test1=https://192.168.0.91:2380'EOFsource /etc/profile7、配置启动脚本# 在 test2 节点操作# 把第5 步 生成的结果写到 etcd启动脚本中,mkdir -p /data/etcdcat> /etc/systemd/system/etcd.service<< EOF[Unit]Description=Etcd ServerAfter=network.targetAfter=network-online.targetWants=network-online.targetDocumentation=https://github.com/coreos[Service]Type=notifyWorkingDirectory=/data/etcdEnvironmentFile=-/etc/etcd/etcd.confExecStart=/opt/k8s/bin/etcd \--name ${ETCD_NAME} \--cert-file=/etc/etcd/cert/etcd.pem \--key-file=/etc/etcd/cert/etcd-key.pem \--peer-cert-file=/etc/etcd/cert/etcd.pem \--peer-key-file=/etc/etcd/cert/etcd-key.pem \--trusted-ca-file=/etc/kubernetes/cert/ca.pem \--peer-trusted-ca-file=/etc/kubernetes/cert/ca.pem \--initial-advertise-peer-urls https://${INTERNAL_IP}:2380 \--listen-peer-urls https://${INTERNAL_IP}:2380 \\--listen-client-urls https://${INTERNAL_IP}:2379,http://127.0.0.1:2379 \--advertise-client-urls https://${INTERNAL_IP}:2379 \--initial-cluster-token my-etcd-token \--initial-cluster $ECTD_CLUSTER,test2=http://192.168.0.92:2380 \--initial-cluster-state existing \--data-dir=/data/etcdRestart=on-failureRestartSec=5LimitNOFILE=65536[Install]WantedBy=multi-user.targetEOF8、启动新节点systemctl daemon-reload #一定要执行,否则报错systemctl start etcdsystemctl status etcdsystemctl enable etcd9、查看集群成员和安全状态# 在test1节点上操作[root@test1 ~]# etcdctl --ca-file /etc/kubernetes/cert/ca.pem --cert-file /etc/etcd/cert/etcd.pem --key-file /etc/etcd/cert/etcd-key.pem member list2eb21869c9f27e29: name=test2 peerURLs=http://192.168.0.92:2380 clientURLs=https://192.168.0.92:2379 isLeader=false42f7141ed6110de1: name=test1 peerURLs=https://192.168.0.91:2380 clientURLs=https://192.168.0.91:2379 isLeader=true[root@test1 ~]# etcdctl --ca-file /etc/kubernetes/cert/ca.pem --cert-file /etc/etcd/cert/etcd.pem --key-file /etc/etcd/cert/etcd-key.pem cluster-healthmember 2eb21869c9f27e29 is healthy: got healthy result from https://192.168.0.92:2379member 42f7141ed6110de1 is healthy: got healthy result from https://192.168.0.91:2379cluster is healthy9.2、修改所有节点启动文件一致,然后重启报错解决:[root@test2 k8s]# etcdctl --ca-file /etc/kubernetes/cert/ca.pem --cert-file /etc/etcd/cert/etcd.pem --key-file /etc/etcd/cert/etcd-key.pem member listError: client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:4001: getsockopt: connection refused; error #1: dial tcp 127.0.0.1:2379: getsockopt: connection refusederror #0: dial tcp 127.0.0.1:4001: getsockopt: connection refusederror #1: dial tcp 127.0.0.1:2379: getsockopt: connection refused启动文件需要添加:http://127.0.0.1:2379其他报错,删除etcd数据目录重启

 

转载于:https://www.cnblogs.com/effortsing/p/10296424.html

你可能感兴趣的文章
链接元素<a>
查看>>
Binding object to winForm controller through VS2010 Designer(通过VS2010设计器将对象绑定到winForm控件上)...
查看>>
Spring Boot实战笔记(二)-- Spring常用配置(Scope、Spring EL和资源调用)
查看>>
前端性能优化集【持续更新】
查看>>
第二章:webdriver 控制浏览器窗口大小
查看>>
四则运算2初步构思
查看>>
Break the Chocolate(规律)
查看>>
C#jbox小节
查看>>
结构体指针释放的问题
查看>>
C#枚举Enum[轉]
查看>>
第三百五十七天 how can I 坚持
查看>>
【动态规划】流水作业调度问题与Johnson法则
查看>>
startActivityForResult不起作用
查看>>
Python&Selenium&Unittest&BeautifuReport 自动化测试并生成HTML自动化测试报告
查看>>
活现被翻转生命
查看>>
POJ 1228
查看>>
SwaggerUI+SpringMVC——构建RestFul API的可视化界面
查看>>
springmvc怎么在启动时自己执行一个线程
查看>>
流操作的规律
查看>>
Python基础学习15--异常的分类与处理
查看>>