真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

K8S——ETCD部署-創(chuàng)新互聯(lián)

K8S——ETCD部署

成都創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站制作、網(wǎng)站設(shè)計、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)八公山,10多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792

角色分配:

K8S——ETCD部署

環(huán)境部署

所有虛擬機(jī)均已關(guān)閉防火墻以及selinux核心防護(hù)功能

實(shí)操

建工作目錄存放二進(jìn)制軟件包

[root@master ~]# cd /
[root@master /]# mkdir k8s

安裝ETCD數(shù)據(jù)庫(三副本機(jī)制)
master(下載ca證書創(chuàng)建、管理工具cfssl)

[root@master k8s]# curl -L https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -o /usr/local/bin/cfssl
[root@master k8s]# curl -L https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -o /usr/local/bin/cfssljson
[root@master k8s]# curl -L https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -o /usr/local/bin/cfssl-certinfo
[root@master k8s]# chmod +x /usr/local/bin/cfssl /usr/local/bin/cfssljson /usr/local/bin/cfssl-certinfo

生成ca證書

//定義ca證書,生成ca證書配置文件
[root@master k8s]# cat > ca-config.json < ca-csr.json <

生成etcd各節(jié)點(diǎn)之間通信證書(注意IP地址的變化)

//生成etcd節(jié)點(diǎn)之間的通信驗(yàn)證簽名
//節(jié)點(diǎn)地址必須要更改
[root@master k8s]# cat > server-csr.json <

配置etcd二進(jìn)制文件包

//解壓安裝etcd
[root@master k8s]# tar zxf etcd-v3.3.10-linux-amd64.tar.gz

//建立存放etcd配置文件、命令、證書的目錄
[root@master k8s]# mkdir -p /opt/etcd/{cfg,bin,ssl}
[root@master k8s]# ls /opt/etcd/
bin  cfg  ssl

//將etcd中的文件分門別類存放
[root@master k8s]# mv etcd-v3.3.10-linux-amd64/etcd /opt/etcd/bin/
[root@master k8s]# mv etcd-v3.3.10-linux-amd64/etcdctl /opt/etcd/bin/
[root@master k8s]# cp -p *.pem /opt/etcd/ssl/

//etcd命令文件
[root@master k8s]# ls /opt/etcd/bin/
etcd  etcdctl

//etcd證書
[root@master k8s]# ls /opt/etcd/ssl/
ca-key.pem  ca.pem  server-key.pem  server.pem

建立etcd配置文件

[root@master k8s]# cat </opt/etcd/cfg/etcd
//[Member]
ETCD_NAME="etcd01"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="https://192.168.142.220:2380"
ETCD_LISTEN_CLIENT_URLS="https://192.168.142.220:2379"

//[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.142.220:2380"
ETCD_ADVERTISE_CLIENT_URLS="https://192.168.142.220:2379"
ETCD_INITIAL_CLUSTER="etcd01=https://192.168.142.220:2380,etcd02=https://192.168.142.136:2380,etcd03=https://192.168.142.132:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_INITIAL_CLUSTER_STATE="new"
EOF

建立etcd啟動腳本

[root@master k8s]# 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
EnvironmentFile=/opt/etcd/cfg/etcd
ExecStart=/opt/etcd/bin/etcd \
--name=etcd01 \
--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=/opt/etcd/ssl/server.pem \
--key-file=/opt/etcd/ssl/server-key.pem \
--peer-cert-file=/opt/etcd/ssl/server.pem \
--peer-key-file=/opt/etcd/ssl/server-key.pem \
--trusted-ca-file=/opt/etcd/ssl/ca.pem \
--peer-trusted-ca-file=/opt/etcd/ssl/ca.pem
Restart=on-failure
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
EOF

推送證書、配置文件、啟動腳本至node節(jié)點(diǎn)上

//將證書、配置文件推送至其它節(jié)點(diǎn)
[root@master ~]# scp -r /opt/etcd/ root@192.168.142.136:/opt/
[root@master ~]# scp -r /opt/etcd/ root@192.168.142.132:/opt/

//推送啟動腳本
[root@master ~]# scp /usr/lib/systemd/system/etcd.service root@192.168.142.136:/usr/lib/systemd/system/
[root@master ~]# scp /usr/lib/systemd/system/etcd.service root@192.168.142.132:/usr/lib/systemd/system/

node端方面

更改各node節(jié)點(diǎn)收到的配置文件
node1

[root@node1 etcd]# vim /opt/etcd/cfg/etcd
//[Member]
ETCD_NAME="etcd02"                      //節(jié)點(diǎn)名稱
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="https://192.168.142.136:2380"               //節(jié)點(diǎn)地址
ETCD_LISTEN_CLIENT_URLS="https://192.168.142.136:2379"               //節(jié)點(diǎn)地址

//[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.142.136:2380"               //節(jié)點(diǎn)地址
ETCD_ADVERTISE_CLIENT_URLS="https://192.168.142.136:2379"               //節(jié)點(diǎn)地址

node 2

[root@node2 ~]# vim /opt/etcd/cfg/etcd
//[Member]
ETCD_NAME="etcd03"
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="https://192.168.142.132:2380"                      //節(jié)點(diǎn)名稱
ETCD_LISTEN_CLIENT_URLS="https://192.168.142.132:2379"                      //節(jié)點(diǎn)名稱

//[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.142.132:2380"                      //節(jié)點(diǎn)名稱
ETCD_ADVERTISE_CLIENT_URLS="https://192.168.142.132:2379"                      //節(jié)點(diǎn)名稱

所有節(jié)點(diǎn)開啟服務(wù)

//各節(jié)點(diǎn)關(guān)防火墻
[root@node1 etcd]# systemctl stop firewalld.service
[root@node1 etcd]# setenforce 0
[root@node1 etcd]# systemctl disable firewalld.service

//開啟etcd服務(wù)
[root@node1 etcd]# systemctl start etcd
[root@node1 etcd]# systemctl enable etcd

群集健康檢查,查看群集成員

//群集各節(jié)點(diǎn)健康檢查
[root@master ~]# /opt/etcd/bin/etcdctl --ca-file=/opt/etcd/ssl/ca.pem \
--cert-file=/opt/etcd/ssl/server.pem --key-file=/opt/etcd/ssl/server-key.pem \
--endpoints="https://192.168.142.220:2379,https://192.168.142.136:2379,https://192.168.142.132:2379" \
cluster-health

//查看etcd群集成員
[root@master ~]# /opt/etcd/bin/etcdctl --ca-file=/opt/etcd/ssl/ca.pem \
--cert-file=/opt/etcd/ssl/server.pem --key-file=/opt/etcd/ssl/server-key.pem \
--endpoints="https://192.168.142.220:2379,https://192.168.142.136:2379,https://192.168.142.132:2379" member list

etcd群集由此搭建成功!!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


本文題目:K8S——ETCD部署-創(chuàng)新互聯(lián)
本文鏈接:http://weahome.cn/article/coopji.html

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部