V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xmge
V2EX  ›  程序员

5步完成 etcd 单机集群部署

  •  
  •   xmge · 2019-11-26 18:14:14 +08:00 · 3226 次点击
    这是一个创建于 1584 天前的主题,其中的信息可能已经有所发展或是发生改变。

    一、下载 etcd

    相关版本在: https://github.com/etcd-io/etcd/releases/

    这里以 ubuntu x64 举例:

    wget https://github.com/etcd-io/etcd/releases/download/v3.4.0-rc.3/etcd-v3.4.0-rc.3-linux-amd64.tar.gz
    

    二、创建如下目录结构

    image

    三、新增三个配置文件

    etcd1/etcd.conf 配置文件:

    name: etcd-1
    data-dir: /home/xmge/show/etcd_cluster/etcd1/data   // 需要指定自己目录下的位置
    listen-client-urls: http://0.0.0.0:2379
    advertise-client-urls: http://127.0.0.1:2379
    listen-peer-urls: http://0.0.0.0:2380
    initial-advertise-peer-urls: http://127.0.0.1:2380
    initial-cluster: etcd-1=http://127.0.0.1:2380,etcd-2=http://127.0.0.1:2480,etcd-3=http://127.0.0.1:2580
    initial-cluster-token: etcd-cluster-my
    initial-cluster-state: new
    

    etcd2/etcd.conf 配置文件:

    name: etcd-2
    data-dir: /home/xmge/show/etcd_cluster/etcd2/data   // 需要指定自己目录下的位置
    listen-client-urls: http://0.0.0.0:2479
    advertise-client-urls: http://127.0.0.1:2479
    listen-peer-urls: http://0.0.0.0:2480
    initial-advertise-peer-urls: http://127.0.0.1:2480
    initial-cluster: etcd-1=http://127.0.0.1:2380,etcd-2=http://127.0.0.1:2480,etcd-3=http://127.0.0.1:2580
    initial-cluster-token: etcd-cluster-my
    initial-cluster-state: new
    

    etcd3/etcd.conf 配置文件:

    name: etcd-3
    data-dir: /home/xmge/show/etcd_cluster/etcd3/data   // 需要指定自己目录下的位置
    listen-client-urls: http://0.0.0.0:2579
    advertise-client-urls: http://127.0.0.1:2579
    listen-peer-urls: http://0.0.0.0:2580
    initial-advertise-peer-urls: http://127.0.0.1:2580
    initial-cluster: etcd-1=http://127.0.0.1:2380,etcd-2=http://127.0.0.1:2480,etcd-3=http://127.0.0.1:2580
    initial-cluster-token: etcd-cluster-my
    initial-cluster-state: new
    
    

    四、新增启动脚本 start.sh 并启动

    #!/bin/bash
    
    CRTDIR=$(pwd)
    servers=("etcd1" "etcd2" "etcd3")
    
    
    for server in ${servers[@]}
    do
            cd ${CRTDIR}/$server
            nohup ./etcd --config-file=etcd.conf &
            echo $?
    done
    

    启动集群

    chmod +x start.sh
    ./start.sh
    

    五、检验集群是否启动成功

    image

    5 条回复    2019-11-27 08:53:52 +08:00
    chennqqi
        1
    chennqqi  
       2019-11-26 19:02:50 +08:00
    一步搞定 yum installl.或者 docker run...
    zunceng
        2
    zunceng  
       2019-11-26 19:27:17 +08:00
    装好了 k8s web UI 按一下 或者 helm install 了解一下
    xmge
        3
    xmge  
    OP
       2019-11-27 08:47:06 +08:00
    @zunceng 哈哈哈,ok
    xmge
        4
    xmge  
    OP
       2019-11-27 08:53:38 +08:00
    @chennqqi 看到啦,,
    xmge
        5
    xmge  
    OP
       2019-11-27 08:53:52 +08:00
    果然可以抛砖引玉。。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1040 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 19:19 · PVG 03:19 · LAX 12:19 · JFK 15:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.