# 迁移 MongoDB

将您的 MongoDB 实例升级至新版本并迁移 Talend Dictionary Service、Talend Data Stewardship 和 Talend Data Preparation 的数据。

## 迁移 Talend Dictionary Service 的 MongoDB

按照以下步骤将先前 MongoDB 升级到 MongoDB 7，并为 Talend Dictionary Service 迁移数据。有关兼容版本的更多信息，请参阅[兼容数据库](https://help.qlik.com/talend/en-US/installation-guide-windows/8.0/compatible-databases)。

### 开始之前

* 您下载了 MongoDB 7。

### 步骤

1. 停止先前版本 Talend Data Preparation、Talend Data Stewardship 和 Talend 和组件服务器，但保持 MongoDB 运行。
2. 打开命令提示符。
3. 通过运行以下命令之一备份 MongoDB Talend Dictionary Service 数据。

   Linux 系统：
   ```
   <mongo_path>/bin ./mongodump -h <source_mongodb_host>:<source_mongo_port> -u <mongo_dqDict_username> -p <mongo_dqDict_password> -d <mongo_dqDict_database> -o <dqDict_backup_location>
   ```

   Windows 系统：
   ```
   <mongo_path>/bin>mongodump -h <source_mongodb_host>:<source_mongo_port> -u <mongo_dqDict_username> -p <mongo_dqDict_password> -d <mongo_dqDict_database> -o <dqDict_backup_location>
   ```

   例如：mongodump -h localhost:27017 -d dqdict -u dqdict-user -p duser -o dump\
4. 停止 MongoDB 实例。
5. 卸载之前的 MongoDB。
6. 安装新的 MongoDB 版本。有关 MongoDB 安装的更多信息，请参阅 [MongoDB 文档](https://www.mongodb.com/docs/manual/installation/)。
7. 启动新的 MongoDB 版本。
8. 通过运行以下命令之一恢复 MongoDB 备份。

   Linux 系统：
   ```
   <mongo_path>/bin ./mongorestore -h <mongo_host>:<mongo_port> -u <mongo_dqDict_username> -p <mongo_dqDict_password> -d <mongo_dqDict_database> <dqDict_backup_location>
   ```

   Windows 系统：
   ```
   <mongo_path>/bin>mongorestore -h <mongo_host>:<mongo_port> -u <mongo_dqDict_username> -p <mongo_dqDict_password> -d <mongo_dqDict_database> <dqDict_backup_location>
   ```

   例如：mongorestore -h localhost:27017 -u dqdict-user -p duser -d dqdict dump\

### 下一步做什么

迁移 Talend Data Stewardship 和 Talend Data Preparation 的数据。

## 迁移 Talend Data Stewardship 的 MongoDB

按照以下步骤将先前 MongoDB 升级到 MongoDB 7，并为 Talend Data Stewardship 迁移数据。有关兼容版本的更多信息，请参阅[兼容数据库](https://help.qlik.com/talend/en-US/installation-guide-windows/8.0/compatible-databases)。

### 开始之前

* 如果您已安装和使用 Talend Dictionary Service 来创建自定义语义类型或更新预定义语义类型，您必须在迁移 Talend Data Stewardship MongoDB 之前迁移 Talend Dictionary Service MongoDB。有关更多信息，请参阅[迁移 Talend Dictionary Service 的 MongoDB](https://help.qlik.com/talend/zh-CN/migration-upgrade-guide/8.0/migrating-mongodb#migrating_mongodb_for_talend_dictionary_service "按照以下步骤将先前 MongoDB 升级到 MongoDB 7，并为 Talend Dictionary Service 迁移数据。有关兼容版本的更多信息，请参阅兼容数据库。")。

### 步骤

1. 停止先前版本的 Talend Data Stewardship，但让 MongoDB 保持运行。
2. 通过运行以下命令之一备份 MongoDB。

   Linux 系统：
   ```
   <mongo_path>/bin ./mongodump -h <source_mongodb_host>:<source_mongo_port> -u <mongo_tds_username> -p <mongo_tds_password> -d <mongo_tds_database> -o <backup_location>
   ```

   Windows 系统：
   ```
   <mongo_path>/bin>mongodump -h <source_mongodb_host>:<source_mongo_port> -u <mongo_tds_username> -p <mongo_tds_password> -d <mongo_tds_database> -o <backup_location>
   ```

   例如：mongodump -h localhost:27017 -u tdsuser -p tds -d tds -o dump\
3. 停止 MongoDB 实例。
4. 卸载之前的 MongoDB。
5. 安装 MongoDB 7。有关 MongoDB 安装的更多信息，请参阅 [MongoDB 文档](https://www.mongodb.com/docs/manual/installation/)。
6. 启动新的 MongoDB 版本。
7. 通过运行以下命令之一恢复 MongoDB 备份。

   Linux 系统：
   ```
   <mongo_path>/bin ./mongorestore -h <mongo_host>:<mongo_port> -u <mongo_tds_username> -p <mongo_tds_password> -d <mongo_tds_database> <backup_location>
   ```

   Windows 系统：
   ```
   <mongo_path>/bin>mongorestore -h <mongo_host>:<mongo_port> -u <mongo_tds_username> -p <mongo_tds_password> -d <mongo_tds_database> <backup_location>
   ```

   例如：./mongorestore -h localhost:27017 -u tdsuser -p tds -d tds -o dump\
8. 开始 Talend Data Stewardship.

## 迁移 Talend Data Preparation 的 MongoDB

按照以下步骤将先前 MongoDB 升级到 MongoDB 8，并为 Talend Data Preparation 迁移数据。有关兼容版本的更多信息，请参阅[兼容数据库](https://help.qlik.com/talend/en-US/installation-guide-windows/8.0/compatible-databases)。

### 开始之前

* 如果您已安装和使用 Talend Dictionary Service 来创建自定义语义类型或更新预定义语义类型，您必须在迁移 Talend Data Preparation MongoDB 之前迁移 Talend Dictionary Service MongoDB。有关更多信息，请参阅[迁移 Talend Dictionary Service 的 MongoDB](https://help.qlik.com/talend/zh-CN/migration-upgrade-guide/8.0/migrating-mongodb#migrating_mongodb_for_talend_dictionary_service "按照以下步骤将先前 MongoDB 升级到 MongoDB 7，并为 Talend Dictionary Service 迁移数据。有关兼容版本的更多信息，请参阅兼容数据库。")。

### 步骤

1. 停止先前版本 Talend Data Preparation 和 Talend 组件服务器，但保持 MongoDB 运行。
2. 打开命令提示符。
3. 通过运行以下命令之一备份 MongoDB Talend Data Preparation 数据。

   Linux 系统：
   ```
   <mongo_path>/bin ./mongodump -h <source_mongodb_host>:<source_mongo_port> -u <mongo_tdp_username> -p <mongo_tdp_password> -d <mongo_tdp_database> -o <tdp_backup_location>
   ```

   Windows 系统：
   ```
   <mongo_path>/bin>mongodump -h <source_mongodb_host>:<source_mongo_port> -u <mongo_tdp_username> -p <mongo_tdp_password> -d <mongo_tdp_database> -o <tdp_backup_location>
   ```

   例如：mongodump -h localhost:27017 -u tdpuser -p tdp -d tdp -o dump\
4. 复制 /data 文件夹并将其粘贴到另一个存储库中作为备份。您不应该修改此文件夹。
5. 停止 MongoDB 实例。
6. 卸载之前的 MongoDB。
7. 安装 MongoDB 8。有关 MongoDB 安装的更多信息，请参阅 [MongoDB 文档](https://www.mongodb.com/docs/manual/installation/)。
8. 启动新的 MongoDB 版本。
9. 通过运行以下命令之一恢复 MongoDB 备份。

   Linux 系统：
   ```
   <mongo_path>/bin ./mongorestore -h <mongo_host>:<mongo_port> -u <mongo_tdp_username> -p <mongo_tdp_password> -d <mongo_tdp_database> <tdp_backup_location>
   ```

   Windows 系统：
   ```
   <mongo_path>/bin>mongorestore -h <mongo_host>:<mongo_port> -u <mongo_tdp_username> -p <mongo_tdp_password> -d <mongo_tdp_database> <tdp_backup_location>
   ```

   例如：./mongorestore -h localhost:27017 -u tdpuser -p tdp -d tdp -o dump\
10. 验证 /data 文件夹。如果您移动了它，则需要恢复它。
11. 启动 Talend Data Preparation 以及 Talend Component Server。