## consul 部署配置
官网下在 consul https://www.consul.io/downloads.html,并创建文件夹、用户 `consul`
useradd -s /sbin/nologin consul
#useradd -s consul
chown consul:consul /app/consul/consul/data/
### 添加 service 文件
```
$ vi /etc/systemd/system/consul.service
[Unit]
Description=Consul agent server
Documentation=https://www.consul.io/
Requires=network-online.target
After=network-online.target
[Service]
EnvironmentFile=-/etc/sysconfig/consul
Environment=GOMAXPROCS=4
Restart=on-failure
User=consul
LimitNOFILE=65536
ExecStart=/app/consul/consul/consul agent -config-file /etc/consul/consul.json
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
```
### 创 配置文件
```
172.16.16.142 server
$ vi /etc/consul/consul.json
{
"datacenter": "fd", // 数据中心名称
"data_dir": "/app/consul/consul/data", // Server 节点数据目录
"log_level": "INFO", // 日志级别
"node_name": "n01", // 当前节点名称
"server": true, // 是否为 Server 模式,false 为 Client 模式
"ui": true, // 是否开启 UI 访问
"bootstrap_expect": 1, // 启动时期望的就绪节点,1 代表启动为 bootstrap 模式,等待其他节点加入
"bind_addr": "0.0.0.0", // 绑定的 IP,如网卡存在多IP,需制定明细IP
"client_addr": "0.0.0.0", // 同时作为 Client 接受请求的绑定 IP,可用来访问UI的IP,如网卡存在多IP,需制定明细IP
"retry_join": ["172.16.16.143","172.16.16.144"], // 尝试加入的其他节点
"retry_interval": "3s", // 每次尝试间隔
"raft_protocol": 3, // Raft 协议版本
"enable_debug": false, // 是否开启 Debug 模式
"rejoin_after_leave": true, // 允许重新加入集群
"enable_syslog": false // 是否开启 syslog
}
172.16.16.143 server
$ vi /etc/consul/consul.json
{
"datacenter": "fd",
"data_dir": "/app/consul/consul/data",
"log_level": "INFO",
"node_name": "n02",
"server": true,
"ui": true,
"bootstrap_expect": 1,
"bind_addr": "0.0.0.0",
"client_addr": "0.0.0.0",
"retry_join": ["172.16.16.142","172.16.16.144"],
"retry_interval": "3s",
"raft_protocol": 3,
"enable_debug": false,
"rejoin_after_leave": true,
"enable_syslog": false
}
172.16.16.144 server
$ vi /etc/consul/consul.json
{
"datacenter": "fd",
"data_dir": "/app/consul/consul/data",
"log_level": "INFO",
"node_name": "n03",
"server": true,
"ui": true,
"bootstrap_expect": 2,
"bind_addr": "0.0.0.0",
"client_addr": "0.0.0.0",
"retry_join": ["172.16.16.142","172.16.16.143"],
"retry_interval": "3s",
"raft_protocol": 3,
"enable_debug": false,
"rejoin_after_leave": true,
"enable_syslog": false
}
172.16.16.145 client
$ vi /etc/consul/consul.json
{
"datacenter": "fd",
"data_dir": "/app/consul/consul/data",
"log_level": "INFO",
"node_name": "n04",
"server": false,
"ui": true,
"bootstrap_expect": 0,
"bind_addr": "0.0.0.0",
"client_addr": "0.0.0.0",
"retry_join": ["172.16.16.142","172.16.16.143","172.16.16.144"],
"retry_interval": "3s",
"raft_protocol": 3,
"enable_debug": false,
"rejoin_after_leave": true,
"enable_syslog": false
}
```
### 启动并加入开机自启动
```
$ systemctl daemon-reload
$ systemctl start consul
$ systemctl enable consul
./consul members -http-addr=192.168.50.173:8500 #查看节点信息
./consul info -http-addr=192.168.50.173:8500 #查看具体信息
./consul members -wan -http-addr=192.168.50.173:8500 #查看多DC的节点信息
```
### 默认端口说明
ports This is a nested object that allows setting the bind ports for the following keys:
```
dns - The DNS server, -1 to disable. Default 8600.
http - The HTTP API, -1 to disable. Default 8500.
https - The HTTPS API, -1 to disable. Default -1 (disabled).
serf_lan - The Serf LAN port. Default 8301.
serf_wan - The Serf WAN port. Default 8302.
server - Server RPC address. Default 8300.
```
### 多数据中心配置
确定每个DC中确定一台server节点为与其他DC通讯,在配置里添加
```
"advertise_addr": "192.168.50.173", //用于集群之间的通信
```
加入其他DC到本DC中
```
./consul join -http-addr=192.168.50.173:8500 -wan 192.168.10.44 #在配有advertise_addr的server节点上运行
```
````
###win配置启动服务
###安装powershell插件
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
#运行This will download the latest NSSM
choco install -y nssm
nssm install Consul C:\app\consul\consul\consul.exe agent -config-dir C:\app\etc\consul --ui-dir C:\app\ui
具体consul.json 配置代码如下
````
````
{
"datacenter": "fd",
"data_dir": "C:\\app\\consul\\consul\\data\\",
"log_level": "INFO",
"node_name": "fdwvweb-16-180",
"server": false,
"ui_dir": "C:\\app\\ui\\",
"bootstrap_expect": 0,
"bind_addr": "172.16.16.180",
"client_addr": "172.16.16.180",
"retry_join": ["172.16.16.100","172.16.16.101","172.16.16.102"],
"retry_interval": "3s",
"raft_protocol": 3,
"enable_debug": false,
"rejoin_after_leave": true,
"enable_syslog": false
}
````
- 第一章:Centos快捷操作
- EPEL 存储库
- 第二章:系统命令
- 第三章:Consul搭建配置
- consul-客户端配置win
- 第四章:Mongodb3.20搭建配置
- 1、mongodb-bak
- 第五章:Centos 7搭建Gitlab服务器
- yum-install
- 第六章:Mysql5.6主从搭建
- 第七张:Vmware-exsi6.5
- 第八章:Jumpserver 堡垒机
- 第九章:OCS Inventory NG-CMDB”
- 第十章:zabbix监控部署
- 第十一章:ELK快速搭建
- 第十二章:docker安装
- 第十三章:rabbitmq集群安装
- 第十四章:Nginx相关配置
- 1、Nginx禁止访问某个目录或某个后缀文件
- 2、Nginx-GeoIP部署
- 3、Nginx的lua-nginx-module模块
- 4、lua-resty-redis
- 5、nginx删除不安全的请求头
- 6、Nginx支持HTTPS并且支持反爬虫
- 7、nginx配置location总结及rewrite规则写法
- 7、nginx安装和监控
- 第十五章:racktables资产管理
- 第十六章:缓存服务安装
- memcache
- 第十七章:自动化管理
- ansible-playbook
- ansible-playbook-firewalld
- 第十八章:redis集群部署
- 第十九章:yapi配置ldap
- yapi
- 第二十章:winlogbeat
- win配置winlogbeat
