diff --git a/config/templates/config.yaml.template b/config/templates/config.yaml.template index 9954a8863..f22e26589 100644 --- a/config/templates/config.yaml.template +++ b/config/templates/config.yaml.template @@ -52,7 +52,7 @@ mongo: # Default MongoDB database name # Maximum connection pool size address: [ 172.28.0.1:37017 ] - database: openIM_v3 + database: openim_v3 username: root password: openIM123 maxPoolSize: 100 diff --git a/config/templates/env.template b/config/templates/env.template index a606704c5..cdd0bac6c 100644 --- a/config/templates/env.template +++ b/config/templates/env.template @@ -97,8 +97,8 @@ MONGO_ADDRESS=172.28.0.2 MONGO_PASSWORD=openIM123 # Name of the database in MongoDB to be used. -# Default: MONGO_DATABASE=openIM_v3 -MONGO_DATABASE=openIM_v3 +# Default: MONGO_DATABASE=openim_v3 +MONGO_DATABASE=openim_v3 # ----- Redis Configuration ----- # Address or hostname for the Redis service. diff --git a/deployments/templates/env-template.yaml b/deployments/templates/env-template.yaml index cbe900c19..9b21c8c65 100644 --- a/deployments/templates/env-template.yaml +++ b/deployments/templates/env-template.yaml @@ -115,7 +115,7 @@ MONGO_OPENIM_USERNAME=${MONGO_OPENIM_USERNAME} MONGO_OPENIM_PASSWORD=${MONGO_OPENIM_PASSWORD} # Specifies the database name to be used within MongoDB. -# Default: MONGO_DATABASE=openIM_v3 +# Default: MONGO_DATABASE=openim_v3 MONGO_DATABASE=${MONGO_DATABASE} # ----- Redis Configuration ----- diff --git a/docker-compose.yml b/docker-compose.yml index 6d0f3c25a..6e9bd7de7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: - wiredTigerCacheSizeGB=1 - MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME:-root} - 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_PASSWORD=${MONGO_OPENIM_PASSWORD:-openIM123456} # Non-root password restart: always @@ -87,6 +87,7 @@ services: - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=0@:9093 - 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://127.0.0.1:${KAFKA_PORT:-19094} # Mac Deployment - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER networks: diff --git a/docs/contrib/mac-developer-deployment-guide.md b/docs/contrib/mac-developer-deployment-guide.md index 69e4e7503..db67d7722 100644 --- a/docs/contrib/mac-developer-deployment-guide.md +++ b/docs/contrib/mac-developer-deployment-guide.md @@ -45,86 +45,165 @@ Homebrew is an essential package manager for macOS. Install it using: 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**: - Open your terminal and execute the following commands: +To set it up: - ```sh - # Clone the repository - git clone https://github.com//open-im-server.git +1. Install Docker Desktop for Mac from [Docker Hub](https://docs.docker.com/desktop/install/mac-install/). +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. - # Set Docker bridging network mode for Mac - export DOCKER_BRIDGE_SUBNET=127.0.0.0/16 +### Installing Go and Dependencies - # Set OpenIM IP - export OPENIM_IP= +Use Homebrew to install Go: - # Initialize configuration - make init +```sh +brew install go +``` - # Start components using Docker - 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). - # Start OpenIM Server - make start - ``` +### Additional Tools -3. **Additional Steps for Mac Deployment**: - 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`. +Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation. - Here's how to do it: +## Mac Deployment openim-chat and openim-server - - Open the `docker-compose.yml` file in a text editor. - - 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. +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: -4. **Update and Restart Services**: - 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: +### Ensure a Clean Environment - ```sh - # Update and restart services - docker compose up -d +- It's recommended to execute in a new directory. +- Run `ps -ef | grep openim` to ensure no OpenIM processes are running. +- 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 - docker compose logs openim-chat - ``` +### Source Code Deployment - This command will re-read the `docker-compose.yml` file, apply the new configuration, and restart the necessary containers. +#### Deploying openim-server -Remember, replacing `` and `` 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/). -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. +With: -### 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 -brew install go +```bash +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 +``` + + + +#### 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 diff --git a/pkg/common/db/controller/msg_test.go b/pkg/common/db/controller/msg_test.go index cfb969b3e..70c055bf3 100644 --- a/pkg/common/db/controller/msg_test.go +++ b/pkg/common/db/controller/msg_test.go @@ -146,7 +146,7 @@ func Test_BatchInsertChat2DB(t *testing.T) { func GetDB() *commonMsgDatabase { config.Config.Mongo.Address = []string{"203.56.175.233:37017"} // 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.Username = "root" config.Config.Mongo.Password = "openIM123" diff --git a/scripts/install/dependency.sh b/scripts/install/dependency.sh index 78995bcf9..32f255ee5 100755 --- a/scripts/install/dependency.sh +++ b/scripts/install/dependency.sh @@ -34,7 +34,7 @@ docker run -d \ -e wiredTigerCacheSizeGB=1 \ -e MONGO_INITDB_ROOT_USERNAME=${OPENIM_USER} \ -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_PASSWORD=${PASSWORD} \ --restart always \ diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh index 41a70c64d..7f2979673 100755 --- a/scripts/install/environment.sh +++ b/scripts/install/environment.sh @@ -52,7 +52,7 @@ def "OPENIM_USER" "root" readonly PASSWORD=${PASSWORD:-'openIM123'} # 设置统一的数据库名称,方便管理 -def "DATABASE_NAME" "openIM_v3" +def "DATABASE_NAME" "openim_v3" # Linux系统 openim 用户 def "LINUX_USERNAME" "openim" diff --git a/tools/data-conversion/README.md b/tools/data-conversion/README.md index 22126e4d8..71387af7f 100644 --- a/tools/data-conversion/README.md +++ b/tools/data-conversion/README.md @@ -31,7 +31,7 @@ var ( usernameV3 = "root" passwordV3 = "openIM123" addrV3 = "127.0.0.1:13306" - databaseV3 = "openIM_v3" + databaseV3 = "openim_v3" ) ``` diff --git a/tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go b/tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go index 8992e12c4..8a951e16f 100644 --- a/tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go +++ b/tools/data-conversion/openim/cmd/conversion-mysql/conversion-mysql.go @@ -38,7 +38,7 @@ func main() { usernameV3 = "root" // v3版本mysql用户名 passwordV3 = "openIM123" // v3版本mysql密码 addrV3 = "127.0.0.1:13306" // v3版本mysql地址 - databaseV3 = "openIM_v3" // v3版本mysql数据库名字 + databaseV3 = "openim_v3" // v3版本mysql数据库名字 ) var concurrency = 1 // 并发数量 diff --git a/tools/data-conversion/openim/common/config.go b/tools/data-conversion/openim/common/config.go index e2bd14a05..e993038d1 100644 --- a/tools/data-conversion/openim/common/config.go +++ b/tools/data-conversion/openim/common/config.go @@ -44,7 +44,7 @@ const ( UsernameV3 = "root" PasswordV3 = "openIM123" IpV3 = "43.134.63.160:13306" - DatabaseV3 = "openIM_v3" + DatabaseV3 = "openim_v3" ) // V3 chat. diff --git a/tools/data-conversion/openim/mysql/cmd.go b/tools/data-conversion/openim/mysql/cmd.go index f5a23facb..ab3857fba 100644 --- a/tools/data-conversion/openim/mysql/cmd.go +++ b/tools/data-conversion/openim/mysql/cmd.go @@ -38,7 +38,7 @@ func Cmd() { usernameV3 = "root" passwordV3 = "openIM123" addrV3 = "203.56.175.233:13306" - databaseV3 = "openIM_v3" + databaseV3 = "openim_v3" ) log.SetFlags(log.LstdFlags | log.Llongfile) dsnV2 := fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4&parseTime=True&loc=Local", usernameV2, passwordV2, addrV2, databaseV2)