背景:
同一台服务器需要在两个IP(内、外)上各启一个consul server,且不在一个datacenter中,所以其中一个consul必须要修改各项端口,我们暂且称之为"consul-public"。由于consul的二进制文件默认HTTP端口8500,对于consul-public无法使用原有的二级制文件,需要修改consul源码重新进行编译。
Consul修改端口
-
将编辑好的json配置文件放到指定目录下
请看ports部分
“ports”:{
“http” : 9500,
“dns” : 9600,
“serf_lan” : 9301,
“serf_wan” : 9302,
“server” : 9300
}
-
编辑consul-server的启动文件
[Unit]
Description=Consul-public
After=network.target[Service]
EnvironmentFile=/opt/consul-public/etc/systemd/consul.confExecStart=/opt/consul-public/bin/consul agent -config-dir /opt/consul-public/etc/ -config-file /opt/consul-public/etc/consul/config-server.json -bind 10.10.10.10[Install]
WantedBy=multi-user.target