You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# OpenIMServer Source Code Cluster Deployment Guide on the Same Internal Network
9
9
10
-
This guide uses machines A and B (with internal IPs `IP_A` and `IP_B`) as an example. They are located in the same LAN environment, used for deploying the clustered IM Server and Nginx.
11
-
Assuming you have already deployed Redis cluster, MongoDB sharded cluster, Kafka cluster, and Etcd cluster at the following addresses:
This guide uses machines A and B (with internal IPs `IP_A` and `IP_B`) as examples. They are located in the same internal network and are used to deploy clustered OpenIMServer and Nginx.
11
+
Assume that you have already deployed a Redis cluster, MongoDB sharded cluster, Kafka cluster, and Etcd cluster with the following addresses:
These components should be deployed on three or more nodes to ensure high availability and load balancing.
17
+
It is recommended to deploy these components on three or more nodes to ensure high availability and load balancing.
18
18
19
-
Additionally, MinIO's internal access address is configured as`your_minio_internal_address`, and the external access address is `your_minio_external_address`.
20
-
Machines A and B, as well as the component clusters, have internal network connectivity. Both machines A and B also have public IPs.
19
+
In addition, MinIOis configured with`your_minio_internal_address` for internal access and `your_minio_external_address` for external access.
20
+
Machines A and B, as well as the component clusters, must be reachable over the internal network, and both A and B must have public IPs.
21
21
22
22
### Table of Contents
23
23
24
24
1.[Prerequisites](#prerequisites)
25
-
2.[Clone Repository](#1-clone-repository)
25
+
2.[Clone the Repository](#1-clone-the-repository)
26
26
3.[Modify Configuration](#2-modify-configuration)
27
27
4.[Configure Nginx](#3-configure-nginx)
28
-
5.[Set Up DNS](#4-set-up-dns)
28
+
5.[Configure DNS](#4-configure-dns)
29
29
6.[Start Services](#5-start-services)
30
30
31
31
### Prerequisites
32
32
33
-
Ensure the following components are properly deployed and running:
33
+
Ensure that the following components are already deployed and running correctly:
34
34
35
-
-**Redis Cluster**
36
-
-**MongoDB Sharded Cluster**
37
-
-**Kafka Cluster**
38
-
-**Etcd Cluster**
39
-
-**MinIO Service**
35
+
-**Redis cluster**
36
+
-**MongoDB sharded cluster**
37
+
-**Kafka cluster**
38
+
-**Etcd cluster**
39
+
-**MinIO service**
40
40
41
-
### 1. Clone Repository
41
+
> This document only covers deploying two OpenIMServer business nodes and Nginx. It does not include the deployment of the Redis / MongoDB / Kafka / Etcd clusters themselves. If you currently only have two empty machines, complete those external component clusters first before continuing.
42
42
43
-
On both machines (A and B), run the following commands to clone the `open-im-server` repository:
43
+
### 1. Clone the Repository
44
+
45
+
Run the following commands on both machines (A and B) to clone the OpenIMServer repository and switch to the latest official release tag marked with the green **Latest** badge on GitHub Releases:
> Here, `latest` means the latest official release marked with the green **Latest** badge on GitHub Releases. It does not include alpha, beta, rc, or other pre-releases. It is recommended that both machines use the same stable tag. If you need a fixed version such as `v3.8.3-patch.12`, run `git checkout v3.8.3-patch.12` on both machines.
56
+
50
57
### 2. Modify Configuration
51
58
52
-
On both machines A and B, modify the configuration files as follows to ensure all components are correctly connected. All address fields use the inline list format `address: [addr1, addr2, addr3]`.
59
+
On machines A and B, modify the configuration files as follows so that all components connect correctly. All address fields use the single-line list format `address: [addr1, addr2, addr3]`.
53
60
54
61
#### 2.1 Kafka Configuration
55
62
56
-
Edit the `open-im-server/config/kafka.yml`file, setting the `address` field to the Kafka cluster address list:
63
+
Edit `open-im-server/config/kafka.yml`and set the `address` field to the Kafka cluster address list:
57
64
58
65
```yaml
59
66
address: [kafkaAddr1, kafkaAddr2, kafkaAddr3]
60
67
```
61
68
62
69
#### 2.2 MinIO Configuration
63
70
64
-
Edit the `open-im-server/config/minio.yml` file, setting `internalAddress` and `externalAddress`:
71
+
Edit `open-im-server/config/minio.yml` and set `internalAddress` and `externalAddress`:
Edit the `open-im-server/config/mongodb.yml` file, setting the `address` field to the MongoDB cluster address list:
80
+
Edit `open-im-server/config/mongodb.yml` and set the `address` field to the MongoDB cluster address list:
74
81
75
82
```yaml
76
83
address: [mongoAddr1, mongoAddr2, mongoAddr3]
77
84
```
78
85
79
86
#### 2.4 Etcd Configuration
80
87
81
-
Edit the `open-im-server/config/discovery.yml` file, setting the `etcd.address` field to the Etcd cluster address list:
88
+
Edit `open-im-server/config/discovery.yml` and set `etcd.address` to the Etcd cluster address list:
82
89
83
90
```yaml
84
91
etcd:
@@ -87,7 +94,7 @@ etcd:
87
94
88
95
#### 2.5 Redis Configuration
89
96
90
-
Edit the `open-im-server/config/redis.yml` file, setting the `address` field to the Redis cluster address list and enabling cluster mode:
97
+
Edit `open-im-server/config/redis.yml`, set `address` to the Redis cluster address list, and enable cluster mode:
91
98
92
99
```yaml
93
100
address: [redisAddr1, redisAddr2, redisAddr3]
@@ -96,9 +103,9 @@ clusterMode: true
96
103
97
104
### 3. Configure Nginx
98
105
99
-
Deploy `nginx` on both machines A and B using the following configuration. Make sure to replace with your actual domain name, SSL certificate path, and SSL key path.
106
+
Deploy `nginx` on machines A and B using the following configuration. Make sure to replace it with your actual domain, SSL certificate path, and SSL private key path.
100
107
101
-
> 🚀 **Tip**: Make sure to replace with your actual domain name, SSL certificate path, and SSL key.
108
+
> 🚀 **Tip**: Be sure to replace the example domain, SSL certificate path, and SSL key path with your actual values.
102
109
103
110
```nginx
104
111
events {
@@ -113,7 +120,7 @@ http {
113
120
}
114
121
115
122
upstream im_api {
116
-
# IM API server addresses — specify multiple based on your deployment
123
+
# OpenIMServer API addresses; add more upstreams if needed
117
124
server IP_A:10002;
118
125
server IP_B:10002;
119
126
}
@@ -123,9 +130,9 @@ http {
123
130
server_name yourhost.com; # Replace with your domain
124
131
125
132
ssl_certificate /usr/local/nginx/conf/ssl/your_host_bundle.pem; # Replace with your certificate path
126
-
ssl_certificate_key /usr/local/nginx/conf/ssl/your_host.key; # Replace with your certificate key path
133
+
ssl_certificate_key /usr/local/nginx/conf/ssl/your_host.key; # Replace with your private key path
127
134
128
-
location ^~/api/ {
135
+
location ^~/api/ {
129
136
proxy_http_version 1.1;
130
137
proxy_set_header Upgrade $http_upgrade;
131
138
proxy_set_header Connection "Upgrade";
@@ -145,7 +152,7 @@ http {
145
152
}
146
153
}
147
154
148
-
# Optional: HTTP to HTTPS redirect
155
+
# Optional: redirect HTTP to HTTPS
149
156
server {
150
157
listen 80;
151
158
server_name yourhost.com; # Replace with your domain
@@ -155,23 +162,32 @@ http {
155
162
}
156
163
```
157
164
158
-
Add this configuration to your `nginx` config file and reload to apply:
165
+
Add this configuration to the Nginx configuration file and reload it to apply the changes:
159
166
160
-
### 4. Set Up DNS
167
+
### 4. Configure DNS
161
168
162
169
Point your domain `yourhost.com` to the public IP addresses of machines A and B.
163
170
164
171
### 5. Start Services
165
172
166
-
On both machines (A and B), run the following commands in the `open-im-server` directory to build and start the services:
173
+
Run the following commands in the `open-im-server` directory on both machines (A and B) to build and start the services:
167
174
168
-
For users in China, it is recommended to set a Go proxy:
175
+
For users in Mainland China, setting a Go proxy is recommended:
169
176
```
170
177
$ go env -w GO111MODULE=on
171
178
$ go env -w GOPROXY=https://goproxy.cn,direct
172
179
```
173
180
174
181
#### 5.1 Build
182
+
183
+
Before the first execution on each machine, it is recommended to run:
184
+
185
+
```bash
186
+
bash bootstrap.sh
187
+
```
188
+
189
+
This step installs `mage`. If `mage` is already installed on your machine, you can skip it.
190
+
175
191
```bash
176
192
mage
177
193
```
@@ -183,8 +199,8 @@ mage start
183
199
```
184
200
185
201
186
-
## **FAQ / Important Notes**
202
+
## **FAQ / Notes**
187
203
188
-
1. When deploying `Kafka`, you need to modify the Kafka advertised port. If using the `docker-compose.yml` from `open-im-server`, modify `service.kafka.environment.KAFKA_CFG_ADVERTISED_LISTENERS` where `EXTERNAL` should be set to the address for accessing the Kafka component. For other deployment methods, modify accordingly.
2. Multi-machine deployments require clock synchronization across machines for services to run correctly. For example, the `token` signing process allows a maximum clock skew of `5 seconds` between machines.
204
+
1. When deploying `kafka`, you need to modify the Kafka advertised port. If you use `docker-compose.yml` from `open-im-server`, change the `EXTERNAL` listener in `service.kafka.environment.KAFKA_CFG_ADVERTISED_LISTENERS` to the address used to access the `kafka` component. If you use another deployment method, adjust it accordingly.
205
+
For example: `KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://192.168.2.36:19094`.
206
+
2. In multi-machine deployment, the clocks of all machines must stay synchronized, or services may fail. For example, token issuing only tolerates clock drift within `5s`.
Copy file name to clipboardExpand all lines: i18n/en/docusaurus-plugin-content-docs-guides/current/gettingStarted/dockerCompose.md
+43-15Lines changed: 43 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,32 @@ title: 'Docker Deployment'
3
3
sidebar_position: 2
4
4
5
5
---
6
-
## 1. Prerequisites 🌍
7
-
For server hardware, software, operating system, and component requirements, please refer to [this document](./env-comp).
6
+
## 1. Environment Preparation 🌍
7
+
For server hardware, software, operating system, and dependent components, please refer to [this document](./env-comp).
8
8
9
-
## 2. Deploy IMServer
9
+
## 2. Deploy OpenIMServer
10
10
### 2.1 Clone the Repository 🗂️
11
11
12
+
Use the latest official release tag marked with the green **Latest** badge on the GitHub Releases page. Do not sort tags manually, and do not use pre-release versions such as alpha or rc.
> Here, `latest` means the latest official release marked with the green **Latest** badge on GitHub Releases. It does not include alpha, beta, rc, or other pre-releases. `main` is the development branch and should not be used directly in production.
23
+
24
+
### 2.2 Configuration Changes 🔧
17
25
18
-
- Edit the `.env`file to configure the MinIO external IP for sending images, videos, and files. Replace `your-server-ip` with your server's public IP address:
26
+
- Edit `.env`and configure the MinIO external IP to support image and file sending. Replace `your-server-ip` with your server's public IP.
@@ -31,6 +37,11 @@ git clone https://github.com/openimsdk/openim-docker && cd openim-docker
31
37
docker compose up -d
32
38
```
33
39
40
+
> The first run pulls large images and may take some time. After startup, wait `30-60s` before running health checks or API verification.
41
+
42
+
> This document assumes a **clean environment**. If the machine already has containers with the same names such as `mongo`, `redis`, `kafka`, `etcd`, `minio`, `openim-server`, or `openim-chat`, `docker compose up -d` will fail because of `container_name` conflicts. In that case, stop and remove those containers first, or reuse the existing components after adjusting configuration.
43
+
44
+
> If startup shows warnings such as missing `ETCD_USERNAME`, `ETCD_PASSWORD`, `KAFKA_USERNAME`, or `KAFKA_PASSWORD`, and you have not enabled authentication for those components, these warnings can usually be ignored.
34
45
35
46
- Stop services:
36
47
@@ -44,17 +55,34 @@ docker compose down
44
55
docker logs -f openim-server
45
56
```
46
57
47
-
## 3. Quick Verification ⚡
58
+
### 2.4 Monitoring & Alerting (Optional)
59
+
60
+
If you also want to start `Prometheus`, `Alertmanager`, `Grafana`, and `node-exporter`, run:
61
+
62
+
```bash
63
+
docker compose --profile m up -d
64
+
```
65
+
66
+
Default ports follow the current `.env`. Common values are:
67
+
68
+
-`19090`: Prometheus
69
+
-`19093`: Alertmanager
70
+
-`13000`: Grafana
71
+
-`19100`: node-exporter
72
+
73
+
## 3. Quick Experience ⚡
48
74
49
-
To quickly test the core capabilities of OpenIMSDK and verify your deployment, refer to [Quick Verification](./quickTestServer).
75
+
To quickly experience core OpenIMSDK capabilities and verify whether OpenIMServer / ChatServer deployment is working, refer to [Quick Verification](./quickTestServer).
50
76
77
+
> Additional note for the current project layout: if you deploy from the two source repositories `open-im-server` and `chat`, `open-im-server/docker-compose.yml` is mainly used for dependency components, and ChatServer still needs to be started with `mage start` in the `chat` directory. See [Source Code Deployment](./imSourceCodeDeployment).
51
78
52
79
## 4. FAQ
53
80
54
-
### Troubleshooting Unhealthy Status
55
-
1. Run `docker exec -it openim-server mage check` and verify if it has been running for more than one minute.
56
-
2. Run `docker logs -f openim-server` to view logs.
81
+
### Troubleshooting `unhealthy`
82
+
1. Run `docker exec -it openim-server mage check` and confirm whether the state lasts longer than one minute.
83
+
2. Run `docker logs -f openim-server` to inspect logs.
84
+
3. If `openim-chat` briefly reports `connect: connection refused` during startup, wait `30-60s` and check again. This is usually a startup ordering issue while `openim-server` is still becoming ready.
57
85
58
-
### Modifying Configuration
59
-
Editing configuration files inside the `config` directory within the container has no effect!
60
-
You must use environment variables to modify configuration. Refer to the [Environment Variable Configuration Guide](https://github.com/openimsdk/openim-docker/issues/136).
86
+
### Configuration Changes
87
+
Editing files under the container `config` directory does not work.
88
+
Configuration changes must be made through environment variables. See the [environment variable guide](https://github.com/openimsdk/openim-docker/issues/136).
Applies to the OpenIMServer and ChatServer deployment documents under `docs/guides/gettingStarted`.
17
9
10
+
---
18
11
19
-
20
-
## 🌐 Software
21
-
| Software | Details |
22
-
| --- | --- |
23
-
|**Golang**| v1.21 or higher, [Installation Guide](https://go.dev/learn/)|
24
-
|**Docker**| v24.0.5 or higher, [Installation Guide](https://www.docker.com/get-started/)|
25
-
|**Git**| v2.17.1 or higher, [Installation Guide](https://git-scm.com/downloads)|
26
-
27
-
## 💾 Component Requirements
28
-
29
-
| Component | Recommended Version |
30
-
| --- | --- |
31
-
|**MongoDB**| v7.0 |
32
-
|**Redis**| v7.0.0 |
33
-
|**Etcd**| v3.5.13 |
34
-
|**Kafka**| v3.5.1 |
35
-
|**MinIO**| RELEASE.2024-01-11T07-46-16Z |
12
+
## 1. Terminology
13
+
14
+
-**OpenIMSDK**: The overall project name, including OpenIMClientSDK and OpenIMServer.
15
+
-**OpenIMClientSDK**: The client SDK.
16
+
-**OpenIMServer**: The IM core server.
17
+
-**ChatServer**: The business extension server. This documentation no longer uses `Chat` as a standalone product name.
18
+
-**APP Administrator**: The backend management role that calls management APIs such as `10009`.
19
+
-**APP Business Server**: The application-side server that calls business extension APIs such as `10008`.
20
+
21
+
## 2. Version and Branch Strategy
22
+
23
+
-`main`: The development branch for unreleased changes in continuous integration. It is not recommended for production.
24
+
-`vX.Y.Z...`: Stable release version naming.
25
+
- For production, prefer the latest official release marked with the green **Latest** badge on the GitHub Releases page.
26
+
- If you need reproducible troubleshooting, rollback, or multi-environment consistency, pin an explicit stable release tag.
27
+
28
+
## 3. Environment Requirements
29
+
30
+
| Item | Details | Notes |
31
+
| --- | --- | --- |
32
+
| Operating system | Linux | Officially uses `ubuntu 22.04`; `Debian 13` has also been verified to work |
33
+
| Hardware resources | 8 CPU cores, 16 GB RAM, 10 Mbps bandwidth, 1 TB disk | Estimated for 100k registered users, 10% daily online ratio, 50k-member large groups, and 600 messages per second; requires a public IP |
34
+
| CPU architecture |`x86_64`| ARM requires separate verification |
35
+
| Golang |`v1.22.7` or higher |[Installation reference](https://go.dev/learn/)|
36
+
| Docker |`v24.0.5` or higher | Must include `compose` support |
37
+
| Git |`v2.17.1` or higher |[Installation reference](https://git-scm.com/downloads)|
38
+
39
+
## 4. External Component Requirements
40
+
41
+
| Component | Recommended Version | Supported Modes in OpenIMServer | ChatServer Access Mode | Cloud Support / Notes |
42
+
| --- | --- | --- | --- | --- |
43
+
| MongoDB |`v7.0`|`standalone`, `replicaSet`|`address` or `uri`| Supported; for replica sets, `uri` is preferred |
44
+
| Redis |`v7.0.0`|`standalone`, `cluster`, `sentinel`|`standalone`, `clusterMode`| Supported; `sentinel` is explicitly supported only in OpenIMServer config |
45
+
| Etcd |`v3.5.13`| Single node, multi-node cluster | Multi-address access | No managed cloud support |
46
+
| Kafka |`v3.5.1`| Single node, distributed cluster | Not directly used by ChatServer | Supported; required topics must be created in advance |
47
+
| MinIO |`RELEASE.2024-01-11T07-46-16Z`| Single node | Not directly used by ChatServer | Can be replaced with S3-compatible storage such as `COS`, `OSS`, `Kodo`, or `AWS S3`|
0 commit comments