1、下载consul安装包
官网地址:Install | Consul | HashiCorp Developer
2:解压到指定目录
unzip consul_1.6.1_linux_amd64.zip -d /soft/consul
3:查看是否安装成功
[root@localhost ~]# cd /soft/consul
[root@localhost consul]# ./consul version
Consul v1.6.1
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)
[root@localhost consul]#
4:启动consul
./consul agent -dev -ui -node=consul-dev -client=192.168.6.10
5:配置consul 开机启动后关机重启
注意:第一次修改要增加可执行权限(chmod +x /etc/rc.d/rc.local)
[root@localhost consul]# vim /etc/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
# 配置consul 开机启动
nohup /soft/consul/consul agent -dev -ui -node=consul-dev -client=192.168.6.10 -log-level=info > /soft/consul/log/consul.log 2>&1 &
[root@localhost consul]#
6:效果演示
http://192.168.6.10:8500/ui/dc1/services
7:错误演示:
下载错误的安装包
发现报 :-bash: ./consul: cannot execute binary file 异常
[root@localhost consul]# ./consul
-bash: ./consul: cannot execute binary file
原因:
我的Linux 版本是x86_64 ,所以应该用AMD64版本的包