码迷,mamicode.com
首页 > Web开发 > 详细

kubernetes 基础-安装部署etcd集群

时间:2019-12-06 19:24:29      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:ntp   tar   sig   serial   tde   star   config   ges   rsa   

HDSS7-200上:

~]# wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 -O /usr/bin/cfssl
~]# wget https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 -O /usr/bin/cfssl-json
~]# wget https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 -O /usr/bin/cfssl-certinfo
~]# chmod +x /usr/bin/cfssl*
~]# vi /opt/certs/ca-csr.json
{
    "CN": "OldboyEdu",
    "hosts": [
    ],
    "key": {
        "algo": "rsa",
        "size": 2048
    },
    "names": [
        {
            "C": "CN",
            "ST": "beijing",
            "L": "beijing",
            "O": "od",
            "OU": "ops"
        }
    ],
    "ca": {
        "expiry": "175200h"
    }
}
certs]# cfssl gencert -initca ca-csr.json | cfssl-json -bare ca
~]# vi /opt/certs/ca-config.json
{
    "signing": {
        "default": {
            "expiry": "175200h"
        },
        "profiles": {
            "server": {
                "expiry": "175200h",
                "usages": [
                    "signing",
                    "key encipherment",
                    "server auth"
                ]
            },
            "client": {
                "expiry": "175200h",
                "usages": [
                    "signing",
                    "key encipherment",
                    "client auth"
                ]
            },
            "peer": {
                "expiry": "175200h",
                "usages": [
                    "signing",
                    "key encipherment",
                    "server auth",
                    "client auth"
                ]
            }
        }
    }
}
~]# vi etcd-peer-csr.json
{
    "CN": "k8s-etcd",
    "hosts": [
        "10.4.7.11",
        "10.4.7.12",
        "10.4.7.21",
        "10.4.7.22"
    ],
    "key": {
        "algo": "rsa",
        "size": 2048
    },
    "names": [
        {
            "C": "CN",
            "ST": "beijing",
            "L": "beijing",
            "O": "od",
            "OU": "ops"
        }
    ]
}
certs]# cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=peer etcd-peer-csr.json |cfssl-json -bare etcd-peer
下载安装包:
~]# tar xf etcd-v3.1.20-linux-amd64.tar.gz -C /opt/
~]# ln -s /opt/etcd-v3.1.20-linux-amd64 /opt/etcd      ## 便于后期升级做软连
~]# useradd -s /sbin/nologin -M etcd           ## 添加运行etcd普通用户
~]# mkdir -p /opt/etcd/certs /data/etcd /data/logs/etcd-server     ## 创建数据目录以及日志目录
~]# vi /opt/etcd/etcd-server-startup.sh
#!/bin/sh
/opt/etcd/etcd --name etcd-server-7-12        --data-dir /data/etcd/etcd-server        --listen-peer-urls https://10.4.7.12:2380        --listen-client-urls https://10.4.7.12:2379,http://127.0.0.1:2379        --quota-backend-bytes 8000000000        --initial-advertise-peer-urls https://10.4.7.12:2380        --advertise-client-urls https://10.4.7.12:2379,http://127.0.0.1:2379        --initial-cluster  etcd-server-7-12=https://10.4.7.12:2380,etcd-server-7-21=https://10.4.7.21:2380,etcd-server-7-22=https://10.4.7.22:2380        --ca-file /opt/etcd/certs/ca.pem        --cert-file /opt/etcd/certs/etcd-peer.pem        --key-file /opt/etcd/certs/etcd-peer-key.pem        --client-cert-auth         --trusted-ca-file /opt/etcd/certs/ca.pem        --peer-ca-file /opt/etcd/certs/ca.pem        --peer-cert-file /opt/etcd/certs/etcd-peer.pem        --peer-key-file /opt/etcd/certs/etcd-peer-key.pem        --peer-client-cert-auth        --peer-trusted-ca-file /opt/etcd/certs/ca.pem        --log-output stdout

安装管理工具supervisor

~]# yum install supervisor -y
~]# systemctl start supervisord 
~]# systemctl enable supervisord

配置管理工具

~]# vi /etc/supervisord.d/etcd-server.ini
[program:etcd-server-7-12]
command=/opt/etcd/etcd-server-startup.sh                        ; the program (relative uses PATH, can take args)
numprocs=1                                                      ; number of processes copies to start (def 1)
directory=/opt/etcd                                             ; directory to cwd to before exec (def no cwd)
autostart=true                                                  ; start at supervisord start (default: true)
autorestart=true                                                ; retstart at unexpected quit (default: true)
startsecs=30                                                    ; number of secs prog must stay running (def. 1)
startretries=3                                                  ; max # of serial start failures (default 3)
exitcodes=0,2                                                   ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT                                                 ; signal used to kill process (default TERM)
stopwaitsecs=10                                                 ; max num secs to wait b4 SIGKILL (default 10)
user=etcd                                                       ; setuid to this UNIX account to run the program
redirect_stderr=true                                            ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/etcd-server/etcd.stdout.log           ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=64MB                                    ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=4                                        ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB                                     ; number of bytes in 'capturemode' (default 0)
stdout_events_enabled=false                                     ; emit events on stdout writes (default false)
killasgroup=true
stopasgroup=true
supervisorctl update
etcd-server-7-12: added process group

备注:
另外两台服务器操作一样,拷贝证书,配置文件,安装管理工具并加入进去就可以了。

~]# supervisorctl status
etcd-server-7-12                 RUNNING   pid 22656, uptime 0:00:35
[root@hdss7-12 etcd]# netstat -luntp|grep etcd
tcp        0      0 10.4.7.12:2379          0.0.0.0:*               LISTEN      22657/./etcd        
tcp        0      0 127.0.0.1:2379          0.0.0.0:*               LISTEN      22657/./etcd        
tcp        0      0 10.4.7.12:2380          0.0.0.0:*               LISTEN      22657/./etcd 

验证集群是否正常:

etcd]# ./etcdctl member list
988139385f78284: name=etcd-server-7-22 peerURLs=https://10.4.7.22:2380 clientURLs=http://127.0.0.1:2379,https://10.4.7.22:2379 isLeader=false
5a0ef2a004fc4349: name=etcd-server-7-21 peerURLs=https://10.4.7.21:2380 clientURLs=http://127.0.0.1:2379,https://10.4.7.21:2379 isLeader=false
f4a0cb0a765574a8: name=etcd-server-7-12 peerURLs=https://10.4.7.12:2380 clientURLs=http://127.0.0.1:2379,https://10.4.7.12:2379 isLeader=true
etcd]# ./etcdctl cluster-health
member 988139385f78284 is healthy: got healthy result from http://127.0.0.1:2379
member 5a0ef2a004fc4349 is healthy: got healthy result from http://127.0.0.1:2379
member f4a0cb0a765574a8 is healthy: got healthy result from http://127.0.0.1:2379
cluster is healthy

kubernetes 基础-安装部署etcd集群

标签:ntp   tar   sig   serial   tde   star   config   ges   rsa   

原文地址:https://www.cnblogs.com/Mongol-J/p/11996935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!