feat: replace mongo database openIM_v3 to openim_v3

pull/1799/head
Xinwei Xiong (cubxxw) 2 years ago
parent fa55c44113
commit ccfbccd345

@ -52,7 +52,7 @@ mongo:
# Default MongoDB database name # Default MongoDB database name
# Maximum connection pool size # Maximum connection pool size
address: [ 172.28.0.1:37017 ] address: [ 172.28.0.1:37017 ]
database: openIM_v3 database: openim_v3
username: root username: root
password: openIM123 password: openIM123
maxPoolSize: 100 maxPoolSize: 100

@ -97,8 +97,8 @@ MONGO_ADDRESS=172.28.0.2
MONGO_PASSWORD=openIM123 MONGO_PASSWORD=openIM123
# Name of the database in MongoDB to be used. # Name of the database in MongoDB to be used.
# Default: MONGO_DATABASE=openIM_v3 # Default: MONGO_DATABASE=openim_v3
MONGO_DATABASE=openIM_v3 MONGO_DATABASE=openim_v3
# ----- Redis Configuration ----- # ----- Redis Configuration -----
# Address or hostname for the Redis service. # Address or hostname for the Redis service.

@ -115,7 +115,7 @@ MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME}
MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD} MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD}
# Specifies the database name to be used within MongoDB. # Specifies the database name to be used within MongoDB.
# Default: MONGO_DATABASE=openIM_v3 # Default: MONGO_DATABASE=openim_v3
MONGO_DATABASE=${MONGO_DATABASE} MONGO_DATABASE=${MONGO_DATABASE}
# ----- Redis Configuration ----- # ----- Redis Configuration -----

@ -27,7 +27,7 @@ services:
- wiredTigerCacheSizeGB=1 - wiredTigerCacheSizeGB=1
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root} - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-openIM123} - MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD:-openIM123}
- MONGO_INITDB_DATABASE=${MONGO_DATABASE:-openIM_v3} - MONGO_INITDB_DATABASE=${MONGO_DATABASE:-openim_v3}
- MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME:-openIM} # Non-root username - MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME:-openIM} # Non-root username
- MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password - MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password
restart: always restart: always
@ -87,6 +87,7 @@ services:
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@<your_host>:9093 - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@<your_host>:9093
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094 - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094} - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
# - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094} # Mac Deployment
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
networks: networks:

@ -45,86 +45,165 @@ Homebrew is an essential package manager for macOS. Install it using:
git config --global user.email "your.email@example.com" git config --global user.email "your.email@example.com"
``` ```
### Forking and Cloning the Repository ### Setting Up the Devcontainer
To optimize and add logic to your instructions, particularly regarding deploying on a Mac, you can modify them as follows: `Devcontainers` provide a Docker-based isolated development environment.
1. **Fork the OpenIM Repository**: Fork the OpenIM repository on GitHub to your account. Read [README.md](https://github.com/openimsdk/open-im-server/tree/main/.devcontainer) in the `.devcontainer` directory of the project to learn more about the devcontainer.
2. **Clone Your Fork to Your Local Machine**: To set it up:
Open your terminal and execute the following commands:
```sh 1. Install Docker Desktop for Mac from [Docker Hub](https://docs.docker.com/desktop/install/mac-install/).
# Clone the repository 2. Install Visual Studio Code and the Remote - Containers extension.
git clone https://github.com/<your-username>/open-im-server.git 3. Open the cloned OpenIM repository in VS Code.
4. VS Code will prompt to reopen the project in a container. Accept this to set up the environment automatically.
# Set Docker bridging network mode for Mac ### Installing Go and Dependencies
export DOCKER_BRIDGE_SUBNET=127.0.0.0/16
# Set OpenIM IP Use Homebrew to install Go:
export OPENIM_IP=<your-ip>
# Initialize configuration ```sh
make init brew install go
```
# Start components using Docker Ensure the version of Go is compatible with the version required by OpenIM (refer to the main documentation for version requirements).
docker compose up -d
# Start OpenIM Server ### Additional Tools
make start
```
3. **Additional Steps for Mac Deployment**: Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation.
If you are deploying on a Mac and wish to use the chat feature, you need to modify the `docker-compose` file. Specifically, you'll need to uncomment the sections related to `openim-chat` and `mysql`.
Here's how to do it: ## Mac Deployment openim-chat and openim-server
- Open the `docker-compose.yml` file in a text editor. To integrate the Chinese document into an English document for Linux deployment, we will first translate the content and then adapt it to suit the Linux environment. Here's how the translated and adapted content might look:
- Find the sections for `openim-chat` and `mysql`.
- Remove the comment marks (`#`) at the beginning of the lines in these sections to enable them.
- Save the file after making these changes.
4. **Update and Restart Services**: ### Ensure a Clean Environment
After modifying the `docker-compose` file, you need to update and restart the services to apply these changes. Run the following command in your terminal:
```sh - It's recommended to execute in a new directory.
# Update and restart services - Run `ps -ef | grep openim` to ensure no OpenIM processes are running.
docker compose up -d - Run `ps -ef | grep chat` to check for absence of chat-related processes.
- Execute `docker ps` to verify there are no related containers running.
# Check openim-chat start ### Source Code Deployment
docker compose logs openim-chat
```
This command will re-read the `docker-compose.yml` file, apply the new configuration, and restart the necessary containers. #### Deploying openim-server
Remember, replacing `<your-username>` and `<your-ip>` with your actual GitHub username and desired IP address for OpenIM is crucial. These steps should streamline the setup process, particularly for Mac users wishing to use the chat feature. Source code deployment is slightly more complex because Docker's networking on Linux differs from Mac.
### Setting Up the Devcontainer ```bash
git clone https://github.com/openimsdk/open-im-server
cd open-im-server
`Devcontainers` provide a Docker-based isolated development environment. export OPENIM_IP="Your IP" # If it's a cloud server, setting might not be needed
make init # Generates configuration files
```
Read [README.md](https://github.com/openimsdk/open-im-server/tree/main/.devcontainer) in the `.devcontainer` directory of the project to learn more about the devcontainer. Before deploying openim-server, modify the Kafka logic in the docker-compose.yml file. Replace:
To set it up: ```yaml
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://${DOCKER_BRIDGE_GATEWAY:-172.28.0.1}:${KAFKA_PORT:-19094}
```
1. Install Docker Desktop for Mac from [Docker Hub](https://docs.docker.com/desktop/install/mac-install/). With:
2. Install Visual Studio Code and the Remote - Containers extension.
3. Open the cloned OpenIM repository in VS Code.
4. VS Code will prompt to reopen the project in a container. Accept this to set up the environment automatically.
### Installing Go and Dependencies ```yaml
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,EXTERNAL://127.0.0.1:${KAFKA_PORT:-19094}
```
Use Homebrew to install Go: Then start the service:
```sh ```bash
brew install go docker compose up -d
``` ```
Ensure the version of Go is compatible with the version required by OpenIM (refer to the main documentation for version requirements). Before starting the openim-server source, set `config/config.yaml` by replacing all instances of `172.28.0.1` with `127.0.0.1`:
### Additional Tools ```bash
vim config/config.yaml -c "%s/172\.28\.0\.1/127.0.0.1/g" -c "wq"
```
Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation. Then start openim-server:
```bash
make start
```
To check the startup:
```bash
make check
```
<aside>
🚧 To avoid mishaps, it's best to wait five minutes before running `make check` again.
</aside>
#### Deploying openim-chat
There are several ways to deploy openim-chat, either by source code or using Docker.
Navigate back to the parent directory:
```bash
cd ..
```
First, let's look at deploying chat from source:
```bash
git clone https://github.com/openimsdk/chat
cd chat
make init # Generates configuration files
```
If openim-chat has not deployed MySQL, you will need to deploy it. Note that the official Docker Hub for MySQL does not support architectures like ARM, so you can use the newer version of the open-source edition:
```bash
docker run -d \
--name mysql \
-p 13306:3306 \
-p 3306:33060 \
-v "$(pwd)/components/mysql/data:/var/lib/mysql" \
-v "/etc/localtime:/etc/localtime" \
-e MYSQL_ROOT_PASSWORD="openIM123" \
--restart always \
mariadb:10.6
```
Before starting the source code of openim-chat, set `config/config.yaml` by replacing all instances of `172.28.0.1` with `127.0.0.1`:
```bash
vim config/config.yaml -c "%s/172\.28\.0\.1/127.0.0.1/g" -c "wq"
```
Then start openim-chat from source:
```bash
make start
```
To check, ensure the following four processes start successfully:
```bash
➜ chat git:(main) ✗ ps -ef | grep chat
# [Output showing four running chat processes]
```
Access the web interface: http://ip:11001
### Docker Deployment
Refer to https://github.com/openimsdk/openim-docker for Docker deployment instructions, which can be followed similarly on Linux.
```bash
git clone https://github.com/openimsdk/openim-docker
cd openim-docker
export OPENIM_IP="Your IP"
make init
docker compose up -d
docker compose logs -f openim-server
docker compose logs -f openim-chat
```
## GitHub Development Workflow ## GitHub Development Workflow

@ -146,7 +146,7 @@ func Test_BatchInsertChat2DB(t *testing.T) {
func GetDB() *commonMsgDatabase { func GetDB() *commonMsgDatabase {
config.Config.Mongo.Address = []string{"203.56.175.233:37017"} config.Config.Mongo.Address = []string{"203.56.175.233:37017"}
// config.Config.Mongo.Timeout = 60 // config.Config.Mongo.Timeout = 60
config.Config.Mongo.Database = "openIM_v3" config.Config.Mongo.Database = "openim_v3"
// config.Config.Mongo.Source = "admin" // config.Config.Mongo.Source = "admin"
config.Config.Mongo.Username = "root" config.Config.Mongo.Username = "root"
config.Config.Mongo.Password = "openIM123" config.Config.Mongo.Password = "openIM123"

@ -34,7 +34,7 @@ docker run -d \
-e wiredTigerCacheSizeGB=1 \ -e wiredTigerCacheSizeGB=1 \
-e MONGO_INITDB_ROOT_USERNAME=${OPENIM_USER} \ -e MONGO_INITDB_ROOT_USERNAME=${OPENIM_USER} \
-e MONGO_INITDB_ROOT_PASSWORD=${PASSWORD} \ -e MONGO_INITDB_ROOT_PASSWORD=${PASSWORD} \
-e MONGO_INITDB_DATABASE=openIM \ -e MONGO_INITDB_DATABASE=openim_v3 \
-e MONGO_OPENIM_USERNAME=${OPENIM_USER} \ -e MONGO_OPENIM_USERNAME=${OPENIM_USER} \
-e MONGO_OPENIM_PASSWORD=${PASSWORD} \ -e MONGO_OPENIM_PASSWORD=${PASSWORD} \
--restart always \ --restart always \

@ -52,7 +52,7 @@ def "OPENIM_USER" "root"
readonly PASSWORD=${PASSWORD:-'openIM123'} readonly PASSWORD=${PASSWORD:-'openIM123'}
# 设置统一的数据库名称,方便管理 # 设置统一的数据库名称,方便管理
def "DATABASE_NAME" "openIM_v3" def "DATABASE_NAME" "openim_v3"
# Linux系统 openim 用户 # Linux系统 openim 用户
def "LINUX_USERNAME" "openim" def "LINUX_USERNAME" "openim"

@ -31,7 +31,7 @@ var (
usernameV3 = "root" usernameV3 = "root"
passwordV3 = "openIM123" passwordV3 = "openIM123"
addrV3 = "127.0.0.1:13306" addrV3 = "127.0.0.1:13306"
databaseV3 = "openIM_v3" databaseV3 = "openim_v3"
) )
``` ```

@ -38,7 +38,7 @@ func main() {
usernameV3 = "root" // v3版本mysql用户名 usernameV3 = "root" // v3版本mysql用户名
passwordV3 = "openIM123" // v3版本mysql密码 passwordV3 = "openIM123" // v3版本mysql密码
addrV3 = "127.0.0.1:13306" // v3版本mysql地址 addrV3 = "127.0.0.1:13306" // v3版本mysql地址
databaseV3 = "openIM_v3" // v3版本mysql数据库名字 databaseV3 = "openim_v3" // v3版本mysql数据库名字
) )
var concurrency = 1 // 并发数量 var concurrency = 1 // 并发数量

@ -44,7 +44,7 @@ const (
UsernameV3 = "root" UsernameV3 = "root"
PasswordV3 = "openIM123" PasswordV3 = "openIM123"
IpV3 = "43.134.63.160:13306" IpV3 = "43.134.63.160:13306"
DatabaseV3 = "openIM_v3" DatabaseV3 = "openim_v3"
) )
// V3 chat. // V3 chat.

@ -38,7 +38,7 @@ func Cmd() {
usernameV3 = "root" usernameV3 = "root"
passwordV3 = "openIM123" passwordV3 = "openIM123"
addrV3 = "203.56.175.233:13306" addrV3 = "203.56.175.233:13306"
databaseV3 = "openIM_v3" databaseV3 = "openim_v3"
) )
log.SetFlags(log.LstdFlags | log.Llongfile) log.SetFlags(log.LstdFlags | log.Llongfile)
dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2) dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2)

Loading…
Cancel
Save