etcd安装及集群配置
来源:互联网 发布:数据分析 培训 上海 编辑:程序博客网 时间:2024/04/27 23:10
1、安装
解压安装包,拷贝etcd、etcdctl到/usr/bin下
#此时可以直接etcd启动,但是不建议这么做,因为没有利用配置文件制定参数,则default.etcd会出现在当前目录下,不好管理且不利于参数管理及集群管理。
#以下两个配置文件可以在别的虚拟机以yum install etcd安装之后在相同的位置得到。
将配置文件etcd.conf拷贝到/etc/etcd下
将配置文件etcd.service拷贝到/usr/lib/systemd/system下
启动:systemctl start etcd
状态:systemctl status etcd
停止:systemctl stop etcd
2、集群--这里只讨论static方式
static静态集群:在确切知道节点情况的时候可采取这种方式,又分为两种方式:
命令行方式,如下:
etcd --name infra0 --initial-advertise-peer-urls http://192.168.75.137:2380 \
--listen-peer-urls http://192.168.75.137:2380 \
--listen-client-urls http://192.168.75.137:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.75.137:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.75.137:2380,infra1=http://192.168.75.138:2380,infra2=http://192.168.75.139:2380 \
--initial-cluster-state new
================================
etcd --name infra1 --initial-advertise-peer-urls http://192.168.75.138:2380 \
--listen-peer-urls http://192.168.75.138:2380 \
--listen-client-urls http://192.168.75.138:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.75.138:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.75.137:2380,infra1=http://192.168.75.138:2380,infra2=http://192.168.75.139:2380 \
--initial-cluster-state new
================================
etcd --name infra2 --initial-advertise-peer-urls http://192.168.75.139:2380 \
--listen-peer-urls http://192.168.75.139:2380 \
--listen-client-urls http://192.168.75.139:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.75.139:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.75.137:2380,infra1=http://192.168.75.138:2380,infra2=http://192.168.75.139:2380 \
--initial-cluster-state new
配置文件方式,如下:
vim /opt/etcd/etcd-v3.1.6-linux-amd64/etcd.conf
ETCD_NAME=etcd00
ETCD_DATA_DIR="/opt/etcd/etcd-v3.1.6-linux-amd64/etcd00"
ETCD_LISTEN_PEER_URLS="http://192.168.75.137:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.75.137:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.75.137:2380"
ETCD_INITIAL_CLUSTER="etcd00=http://192.168.75.137:2380,etcd01=http://192.168.75.138:2380,etcd02=http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.75.137:2379"
vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=EtcdServer
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# setGOMAXPROCS to number of processors
ExecStart=/bin/bash-c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\"\
--data-dir=\"${ETCD_DATA_DIR}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"\
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"\
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\"\
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
================================================
ETCD_NAME=etcd01
ETCD_DATA_DIR="/var/lib/etcd/etcd00"
ETCD_LISTEN_PEER_URLS="http://192.168.75.138:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.75.138:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.75.138:2380"
ETCD_INITIAL_CLUSTER="etcd00=http://192.168.75.137:2380,etcd01=http://192.168.75.138:2380,etcd02=http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.75.138:2379"
vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=EtcdServer
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# setGOMAXPROCS to number of processors
ExecStart=/bin/bash-c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\"\
--data-dir=\"${ETCD_DATA_DIR}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"\
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"\
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\"\
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
============================================
ETCD_NAME=etcd02
ETCD_DATA_DIR="/var/lib/etcd/etcd00"
ETCD_LISTEN_PEER_URLS="http://192.168.75.139:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.75.139:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER="etcd00=http://192.168.75.137:2380,etcd01=http://192.168.75.138:2380,etcd02=http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.75.139:2379"
vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=EtcdServer
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# setGOMAXPROCS to number of processors
ExecStart=/bin/bash-c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\"\
--data-dir=\"${ETCD_DATA_DIR}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"\
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"\
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\"\
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
解压安装包,拷贝etcd、etcdctl到/usr/bin下
#此时可以直接etcd启动,但是不建议这么做,因为没有利用配置文件制定参数,则default.etcd会出现在当前目录下,不好管理且不利于参数管理及集群管理。
#以下两个配置文件可以在别的虚拟机以yum install etcd安装之后在相同的位置得到。
将配置文件etcd.conf拷贝到/etc/etcd下
将配置文件etcd.service拷贝到/usr/lib/systemd/system下
启动:systemctl start etcd
状态:systemctl status etcd
停止:systemctl stop etcd
2、集群--这里只讨论static方式
static静态集群:在确切知道节点情况的时候可采取这种方式,又分为两种方式:
命令行方式,如下:
etcd --name infra0 --initial-advertise-peer-urls http://192.168.75.137:2380 \
--listen-peer-urls http://192.168.75.137:2380 \
--listen-client-urls http://192.168.75.137:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.75.137:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.75.137:2380,infra1=http://192.168.75.138:2380,infra2=http://192.168.75.139:2380 \
--initial-cluster-state new
================================
etcd --name infra1 --initial-advertise-peer-urls http://192.168.75.138:2380 \
--listen-peer-urls http://192.168.75.138:2380 \
--listen-client-urls http://192.168.75.138:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.75.138:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.75.137:2380,infra1=http://192.168.75.138:2380,infra2=http://192.168.75.139:2380 \
--initial-cluster-state new
================================
etcd --name infra2 --initial-advertise-peer-urls http://192.168.75.139:2380 \
--listen-peer-urls http://192.168.75.139:2380 \
--listen-client-urls http://192.168.75.139:2379,http://127.0.0.1:2379 \
--advertise-client-urls http://192.168.75.139:2379 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster infra0=http://192.168.75.137:2380,infra1=http://192.168.75.138:2380,infra2=http://192.168.75.139:2380 \
--initial-cluster-state new
配置文件方式,如下:
vim /opt/etcd/etcd-v3.1.6-linux-amd64/etcd.conf
ETCD_NAME=etcd00
ETCD_DATA_DIR="/opt/etcd/etcd-v3.1.6-linux-amd64/etcd00"
ETCD_LISTEN_PEER_URLS="http://192.168.75.137:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.75.137:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.75.137:2380"
ETCD_INITIAL_CLUSTER="etcd00=http://192.168.75.137:2380,etcd01=http://192.168.75.138:2380,etcd02=http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.75.137:2379"
vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=EtcdServer
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# setGOMAXPROCS to number of processors
ExecStart=/bin/bash-c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\"\
--data-dir=\"${ETCD_DATA_DIR}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"\
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"\
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\"\
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
================================================
ETCD_NAME=etcd01
ETCD_DATA_DIR="/var/lib/etcd/etcd00"
ETCD_LISTEN_PEER_URLS="http://192.168.75.138:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.75.138:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.75.138:2380"
ETCD_INITIAL_CLUSTER="etcd00=http://192.168.75.137:2380,etcd01=http://192.168.75.138:2380,etcd02=http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.75.138:2379"
vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=EtcdServer
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# setGOMAXPROCS to number of processors
ExecStart=/bin/bash-c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\"\
--data-dir=\"${ETCD_DATA_DIR}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"\
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"\
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\"\
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
============================================
ETCD_NAME=etcd02
ETCD_DATA_DIR="/var/lib/etcd/etcd00"
ETCD_LISTEN_PEER_URLS="http://192.168.75.139:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.75.139:2379,http://127.0.0.1:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER="etcd00=http://192.168.75.137:2380,etcd01=http://192.168.75.138:2380,etcd02=http://192.168.75.139:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-00"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.75.139:2379"
vim /usr/lib/systemd/system/etcd.service
[Unit]
Description=EtcdServer
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
WorkingDirectory=/var/lib/etcd/
EnvironmentFile=-/etc/etcd/etcd.conf
User=etcd
# setGOMAXPROCS to number of processors
ExecStart=/bin/bash-c "GOMAXPROCS=$(nproc) /usr/bin/etcd --name=\"${ETCD_NAME}\"\
--data-dir=\"${ETCD_DATA_DIR}\" \
--initial-advertise-peer-urls=\"${ETCD_INITIAL_ADVERTISE_PEER_URLS}\" \
--listen-peer-urls=\"${ETCD_LISTEN_PEER_URLS}\" \
--listen-client-urls=\"${ETCD_LISTEN_CLIENT_URLS}\"\
--advertise-client-urls=\"${ETCD_ADVERTISE_CLIENT_URLS}\"\
--initial-cluster-token=\"${ETCD_INITIAL_CLUSTER_TOKEN}\"\
--initial-cluster=\"${ETCD_INITIAL_CLUSTER}\" \
--initial-cluster-state=\"${ETCD_INITIAL_CLUSTER_STATE}\""
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
以上是常规安装方式,我采取的是解压之后自己指定路径的方式,而并没有将etcd和etcdctl拷贝到bin目录下面,也没有采取默认的相关路径。这样有利于配置文件和数据文件的维护。
0 0
- etcd安装及集群配置
- ETCD集群安装配置及简单应用
- etcd集群安装
- etcd安装配置
- etcd 集群搭建及常用场景分析
- etcd 集群搭建及常用场景分析
- etcd集群启动参数说明及注意事项
- 集群之 -- zookeeper 集群安装及配置
- etcd 安装部署及常见使用场景
- etcd配置
- etcd安装
- skydns+etcd域名服务集群
- etcd集群部署
- etcd集群部署
- etcd服务器集群搭建
- etcd集群搭建步骤
- etcd集群管理
- etcd集群日常维护
- 2017年ACM模板(常用)弱渣整理 四、动态规划
- CMSIS-RTOS2 应用笔记 七 构建RTX5库
- Abbreviation(HackerRank abbr)
- 什么是JS面向对象?
- TextView:图文混排
- etcd安装及集群配置
- mysql中用命令行复制表结构的方法主要有一下几种
- JSONObject、JSONArray
- String中的加号和字符串拼接的理解
- SQL练习+答案(一)
- 面向对象的接口
- webstrom 配置
- Tomcat8 安装配置
- 17年结婚了!