ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 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 } ````