[ Spring ] Install Consul on Ubuntu24
Add GPG Key
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
Add Repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Install
sudo apt update && sudo apt install consul
Check Version
which consul
consul version
Enable Fire Wall
sudo ufw allow ssh
sudo ufw enable
for i in 8300/tcp 8301/tcp 8302/tcp 8400/tcp 8500/tcp 8600/tcp
do sudo ufw allow $i
done
sudo ufw status
Configure and Restart Consul Service
sudo systemctl stop consul
save the generated key
consul keygen
sudo nano /etc/consul.d/consul.hcl
datacenter = "my-dc-1"
data_dir = "/opt/consul"
client_addr = "0.0.0.0"
domain = "consul"
ui = true
server = true
advertise_addr = "127.0.0.1"
bootstrap_expect=1
encrypt = "2I2x0tUjCO6uCpU4S6GQNSSJJkEwKBSjQhU6CB+jdLE="
sudo consul validate /etc/consul.d/
sudo systemctl stop consul
sudo systemctl start consul
sudo systemctl status consul
Test Service
do this after at least one client connected to this server
consul members
consul operator raft list-peers
consul kv put consul/configuration/test_db testkv
consul kv get consul/configuration/test_db
dig @127.0.0.1 -p 8600 consul.service.consul
Visit UI Console
http://localhost:8500
原文地址:https://blog.csdn.net/u013718730/article/details/145155161
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!