You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/tools/data-conversion
Xinwei Xiong 088b143300
Update README.md (#1265)
9 months ago
..
chat feat(release-v3.4): Enhanced Build, Deployment, and Configuration Management for Optimized Performance and Automation (#1255) 9 months ago
openim feat(release-v3.4): Enhanced Build, Deployment, and Configuration Management for Optimized Performance and Automation (#1255) 9 months ago
utils fix: single chat unread status change. (#1171) 9 months ago
README.md Update README.md (#1265) 9 months ago
go.mod feat(release-v3.4): Enhanced Build, Deployment, and Configuration Management for Optimized Performance and Automation (#1255) 9 months ago
go.sum chore(deps): bump golang.org/x/net in /tools/data-conversion (#1187) 9 months ago

README.md

OpenIM V2 至 V3 数据迁移指南

该指南提供了从 OpenIM V2 迁移至 V3 的详细步骤。请确保在开始迁移过程之前,熟悉所有步骤,并按照指南准确执行。

1. 数据备份

在开始数据迁移之前,强烈建议备份所有相关的数据以防止任何可能的数据丢失。

2. 迁移 OpenIM MySQL 数据

  • 位置: open-im-server/v3/tools/data-conversion/openim/mysql.go
  • 配置 mysql.go 文件中的数据库信息。
  • 手动创建 V3 版本的数据库,并确保字符集为 utf8mb4
// V2 数据库配置
var (
    usernameV2 = "root"
    passwordV2 = "openIM"
    addrV2     = "127.0.0.1:13306"
    databaseV2 = "openIM_v2"
)

// V3 数据库配置
var (
    usernameV3 = "root"
    passwordV3 = "openIM123"
    addrV3     = "127.0.0.1:13306"
    databaseV3 = "openIM_v3"
)

执行数据迁移命令:

make build BINS="conversion-mysql"

启动的二进制在 _output/bin/tools

3. 转换聊天消息(可选)

  • 只支持转换存储在 Kafka 中的消息。
  • 位置: open-im-server/v3/tools/data-conversion/openim/msg.go
  • 配置 msg.go 文件中的消息和服务器信息。
var (
	topic       = "ws2ms_chat"      // V2 版本 Kafka 主题
	kafkaAddr   = "127.0.0.1:9092"  // V2 版本 Kafka 地址
	rpcAddr     = "127.0.0.1:10130" // V3 版本 RPC 地址
	adminUserID = "openIM123456"    // V3 版本管理员用户ID
	concurrency = 4                 // 并发数量
)

执行数据迁移命令:

make build BINS="conversion-msg"

4. 转换业务服务器数据

  • 只支持转换存储在 Kafka 中的消息。
  • 位置: open-im-server/v3/tools/data-conversion/chat/chat.go
  • 需要手动创建 V3 版本的数据库,并确保字符集为 utf8mb4
  • 配置 main.go 文件中的数据库信息。
// V2 数据库配置
var (
	usernameV2 = "root"
	passwordV2 = "openIM"
	addrV2     = "127.0.0.1:13306"
	databaseV2 = "admin_chat"
)

// V3 数据库配置
var (
	usernameV3 = "root"
	passwordV3 = "openIM123"
	addrV3     = "127.0.0.1:13306"
	databaseV3 = "openim_enterprise"
)

执行数据迁移命令:

make build BINS="conversion-chat"