鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

创建配置文件

  1. 在Node1节点,节点命名为etcd01,IP地址为10.208.71.111,创建配置文件为“/usr/local/etcd/conf.yml”,文件内容请根据实际情况修改。
    1. 创建配置文件。
      1
      vim /usr/local/etcd/conf.yml
      
    2. “i”进入编辑模式,在文件中添加以下内容。
      name: etcd01
      data-dir: /usr/local/etcd/data
      initial-advertise-peer-urls: http://10.208.71.111:2380
      listen-peer-urls: http://10.208.71.111:2380
      listen-client-urls: http://10.208.71.111:2379,http://127.0.0.1:2379
      advertise-client-urls: http://10.208.71.111:2379
      initial-cluster-token: etcd-cluster
      initial-cluster: etcd01=http://10.208.71.111:2380,etcd02=http://10.208.107.205:2380,etcd03=http://10.208.72.182:2380
      initial-cluster-state: new
    3. “Esc”键,输入:wq!,按“Enter”保存并退出编辑。
  2. 在Node2节点,节点命名为etcd02,IP地址为10.208.107.205,创建配置文件为“/usr/local/etcd/conf.yml”,文件内容请根据实际情况修改。
    1. 创建配置文件。
      1
      vim /usr/local/etcd/conf.yml
      
    2. “i”进入编辑模式,在文件中添加以下内容。
      name: etcd02
      data-dir: /usr/local/etcd/data
      initial-advertise-peer-urls: http://10.208.107.205:2380
      listen-peer-urls: http://10.208.107.205:2380
      listen-client-urls: http://10.208.107.205:2379,http://127.0.0.1:2379
      advertise-client-urls: http://10.208.107.205:2379
      initial-cluster-token: etcd-cluster
      initial-cluster: etcd01=http://10.208.71.111:2380,etcd02=http://10.208.107.205:2380,etcd03=http://10.208.72.182:2380
      initial-cluster-state: new
    3. “Esc”键,输入:wq!,按“Enter”保存并退出编辑。
  3. 在Node3节点,节点命名为etcd03,IP地址为10.208.72.182,创建配置文件为“/usr/local/etcd/conf.yml”,文件内容请根据实际情况修改。
    1. 创建配置文件。
      1
      vim /usr/local/etcd/conf.yml
      
    2. “i”进入编辑模式,在文件中添加以下内容。
      name: etcd03
      data-dir: /usr/local/etcd/data
      initial-advertise-peer-urls: http://10.208.72.182:2380
      listen-peer-urls: http://10.208.72.182:2380
      listen-client-urls: http://10.208.72.182:2379,http://127.0.0.1:2379
      advertise-client-urls: http://10.208.72.182:2379
      initial-cluster-token: etcd-cluster
      initial-cluster: etcd01=http://10.208.71.111:2380,etcd02=http://10.208.107.205:2380,etcd03=http://10.208.72.182:2380
      initial-cluster-state: new
    3. “Esc”键,输入:wq!,按“Enter”保存并退出编辑。

配置文件中的相关参数解释如下:

  • name:当前etcd节点名称。
  • data-dir:数据存储目录。
  • initial-advertise-peer-urls:集群的其他节点通过该地址与当前节点通信。
  • listen-peer-urls:当前节点通过该地址监测集群其他节点发送的信息。
  • listen-client-urls:当前节点通过该地址监测客户端发送的信息。
  • advertise-client-urls:客户端通过该地址与当前节点通信。
  • initial-cluster-token:用于区分不同的集群,同一集群的所有节点配置相同的值。
  • initial-cluster:当前集群的所有节点信息,当前节点根据此信息与其他节点取得联系。
  • initial-cluster-state:本次是否为新建集群,有两个取值:new和existing。