The previously deployed single node mode now needs to be scaled to multiple servers. Here we use two servers as an example to explain how to scale.Assume there are two servers with the following information:
Name
Internal IP
External IP
Description
node1(1001)
192.168.1.10
221.123.68.10
Master node (originally deployed single node)
node2(1002)
192.168.1.20
221.123.68.20
New node to be added
node1 is the originally deployed single node, now we want to scale to two servers, node2 is the newly added node.
The following file contents are set with assumed server IPs, just replace the corresponding IPs with your own.
2. Create docker-compose.yml File in Installation Directory
Content as follows (note to replace corresponding IPs with your own):
Copy
version: '3.7'services: wukongim: # WuKongIM service image: registry.cn-shanghai.aliyuncs.com/wukongim/wukongim:v2 environment: - "WK_MODE=release" # release mode - "WK_CLUSTER_NODEID=1002" # - "WK_TOKENAUTHON=true" # Enable token authentication, strongly recommended for production - "WK_EXTERNAL_IP=221.123.68.20" # Server external IP - "WK_EXTERNAL_WSADDR=ws://221.123.68.10:15200" # WebSocket address for web clients, note this is node1's external IP - "WK_EXTERNAL_TCPADDR=221.123.68.10:15100" # TCP address for app clients, note this is node1's external IP - "WK_CLUSTER_APIURL=http://192.168.1.20:5001" # Node internal communication API URL, replace IP with actual node2 internal IP - "WK_CLUSTER_SERVERADDR=192.168.1.20:11110" # Node internal communication request address - "WK_CLUSTER_SEED=1001@192.168.1.10:11110" # Seed node, any node in original cluster can be seed node, here use node1 as seed - "WK_TRACE_PROMETHEUSAPIURL=http://192.168.1.10:9090" # Prometheus monitoring address, node1's internal address healthcheck: test: "wget -q -Y off -O /dev/null http://localhost:5001/health > /dev/null 2>&1" interval: 10s timeout: 10s retries: 3 restart: always volumes: - ./wukongim_data:/root/wukongim # Mount data to physical machine directory ports: - 11110:11110 # Distributed node communication port - 5001:5001 # Internal API communication port - 5100:5100 # TCP port - 5200:5200 # WebSocket port - 5300:5300 # Management port
Adjust node1’s Original docker-compose.yml Configuration
Add the following content under the wukongim1 service:
Copy
wukongim1: ... environment: - "WK_EXTERNAL_WSADDR=ws://221.123.68.10:15200" # WebSocket address for web clients, using load balancer address - "WK_EXTERNAL_TCPADDR=221.123.68.10:15100" # TCP address for app clients, using load balancer address - "WK_CLUSTER_APIURL=http://192.168.1.10:5001" # Node internal API URL, replace IP with actual node1 internal IP - "WK_CLUSTER_SERVERADDR=192.168.1.10:11110" # Node internal communication request address ...
Nodes originally deployed using multi-node deployment can expand cluster size by adding nodes. This document describes how to expand cluster size by adding nodes.Assume the newly added node information is as follows:
2. Create docker-compose.yml File in Installation Directory
Copy
version: '3.7'services: wukongim: # WuKongIM service image: registry.cn-shanghai.aliyuncs.com/wukongim/wukongim:v2 environment: - "WK_CLUSTER_NODEID=1004" # - "WK_TOKENAUTHON=true" # Enable token authentication, strongly recommended for production - "WK_CLUSTER_APIURL=http://10.206.0.6:5001" # Node internal communication API URL, replace IP with actual node4 internal IP - "WK_CLUSTER_SERVERADDR=10.206.0.6:11110" # Node internal communication request address - "WK_EXTERNAL_WSADDR=ws://119.45.229.172:15200" # WebSocket address for web clients - "WK_EXTERNAL_TCPADDR=119.45.229.172:15100" # TCP address for app clients - "WK_TRACE_PROMETHEUSAPIURL=http://10.206.0.13:9090" # Monitoring address - "WK_CLUSTER_SEED=1001@10.206.0.13:11110" # Seed node, any node in original cluster can be seed node, here use node1 as seed healthcheck: test: "wget -q -Y off -O /dev/null http://localhost:5001/health > /dev/null 2>&1" interval: 10s timeout: 10s retries: 3 restart: always volumes: - ./wukongim_data:/root/wukongim # Mount data to physical machine directory ports: - 11110:11110 # Distributed node communication port - 5001:5001 # Internal API communication port - 5100:5100 # TCP port - 5200:5200 # WebSocket port - 5300:5300 # Management port - 5172:5172 # Demo port