一、部署consul
使用yum方式部署consul
yum install -y yum-utils
yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
yum -y install consul
执行以下命令获取uuid密钥并记录下来
uuidgen
编辑consul配置文件
vi /etc/consul.d/consul.hcl
bash
data_dir = "/opt/consul"
log_level = "error"
client_addr = "0.0.0.0"
ui_config{
enabled = true
}
ports = {
grpc = -1
https = -1
dns = -1
grpc_tls = -1
serf_wan = -1
}
peering {
enabled = false
}
connect {
enabled = false
}
server = true
advertise_addr = "10.1.60.118" #指定consul得主机地址
bootstrap_expect=1
acl = {
enabled = true
default_policy = "deny"
enable_token_persistence = true
tokens {
initial_management = "5f0efcc4-860a-4d7e-a397-3b06998f3aa7" #配置为以上步骤获取的uuid
agent = "5f0efcc4-860a-4d7e-a397-3b06998f3aa7" #配置为以上步骤获取的uuid
}
}
启动consul服务
mkdir /opt/consul
chown -R consul:consul /opt/consul
sed -i 's/Type=notify/Type=exec/g' /usr/lib/systemd/system/consul.service
systemctl daemon-reload
systemctl enable consul
systemctl restart consul
关于consul的部署也可以参考:https://github.com/starsliao/TenSunS/blob/main/docs/Consul%E9%83%A8%E7%BD%B2%E8%AF%B4%E6%98%8E.md
二、部署consulmanage
部署需要用到docker和docker-compose,需要提前安装
部署docker参考:部署docker-ce_docker-ce 配置_Apex Predator的博客-CSDN博客
部署docker-compose参考: docker-compose部署_Apex Predator的博客-CSDN博客
从github上的tensuns项目下载consulmanage部署脚本
地址:https://github.com/starsliao/TenSunS/blob/main/install/docker-compose/tensuns_install_only.sh
脚本如下
执行脚本
sh consulmanagement_install.sh
根据脚本的提示编辑yaml文件
vi /opt/tensuns/docker-compose.yaml
bash
version: '3.6'
services:
flask-consul:
image: swr.cn-south-1.myhuaweicloud.com/starsl.cn/flask-consul:latest
container_name: flask-consul
hostname: flask-consul
restart: always
volumes:
- /usr/share/zoneinfo/PRC:/etc/localtime
environment:
consul_token: 5f0efcc4-860a-4d7e-a397-3b06998f3aa7 #填写之前生成的uuid
consul_url: http://10.1.60.118:8500/v1 #编辑为consulmanage本机的地址路径
admin_passwd: 11111111 #设置consulmanage平台登录的admin密码
log_level: INFO
networks:
- TenSunS
nginx-consul:
image: swr.cn-south-1.myhuaweicloud.com/starsl.cn/nginx-consul:latest
container_name: nginx-consul
hostname: nginx-consul
restart: always
ports:
- "1026:1026"
volumes:
- /usr/share/zoneinfo/PRC:/etc/localtime
depends_on:
- flask-consul
networks:
- TenSunS
networks:
TenSunS:
name: TenSunS
driver: bridge
ipam:
driver: default
启动consulmanage服务
cd /opt/tensuns && docker-compose up -d
访问consulmanage web
至此consulmanage部署完成