Cluster Deployment Instructions
Cluster Deployment Instructions
open-im-server
supports cluster deployment. The following are the steps for cluster deployment:
Modify the addresses in
kafka
,minio
,mongodb
,etcd(discovery.yml)
, andredis
, configuring them to the correct component addresses. Ensure that all ports of the connected components are accessible.Modify the
registerIP
of eachrpc
component to the IP address accessible by the server whereetcd
is deployed, and ensure that all ports are accessible. If you need to enableprometheus
, also ensure that theprometheus.port
of each component is accessible.The machine deploying
prometheus
needs to modify thetargets
inprometheus.yml
.You can modify the number of each component in
open-im-server/start-config.yml
.Modify the port that
kafka
broadcasts to the host. If deploying usingdocker-compose.yml
inopen-im-server
, change theEXTERNAL
inservice.kafka.environment.KAFKA_CFG_ADVERTISED_LISTENERS
to the address accessing thekafka
component.For example:
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://192.168.2.36:19094
.If deploying
redis
in cluster mode, setclusterMode
inredis.yml
totrue
.If you deploy multiple
api
orWebSocket
listening ports, you can usenginx
to easily implement load balancing. The configuration reference is as follows:# nginx.conf
events {
worker_connections 1024;
}
http {
upstream websocket_cluster {
server 192.168.2.10:10101; # WebSocket address
server 192.168.2.11:10001;
}
upstream api_cluster {
server 192.168.2.10:10102; # API address
server 192.168.2.11:10002;
}
# WebSocket
server {
listen 10001;
server_name _;
location / {
proxy_pass http://websocket_cluster;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# API
server {
listen 10002;
server_name _;
location / {
proxy_pass http://api_cluster;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}If you decide to start
nginx
usingdocker
, you can refer to the following command (Linux system):docker run --name nginx -p 10001:10001 -p 10002:10002 -v $(pwd)/nginx-config:/etc/nginx/conf.d -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf -d nginx
If using a different system, adjust the mounted directories accordingly.
Start the services.
Common Issues/Notes
When deploying on multiple machines, ensure clock synchronization for the services to run properly. For example, the issuance of
tokens
allows each machine's clock to have a time difference within5s
.Component ports are inaccessible: Check whether the component starts normally via the loopback address. If the loopback address is accessible, then check if firewall rules are blocking access.