docker环境安装mongoDB实现平滑迁移实战

docker环境安装mongoDB实现平滑迁移实战

  • 一、备份原始数据(从别的服务器备份到当前服务器)
  • 二、数据迁移
  • 三、迁移过程日志打印
  • 四、验证迁移数据准确性

一、备份原始数据(从别的服务器备份到当前服务器)

使用mongodump工具对原始mongoDB进行全量备份,在备份期间,确保没有新的数据写入,否则这部分数据迁移不到。


docker exec -it 12b9d0ccf6c5 mongodump -h xxx.xxx.xx.xx -u admin -p 123456 -o /data

二、数据迁移

使用mongorestore 工具 将备份的数据文件下载入新的mongDB容器即可:

docker exec -it 502a471acc14 mongorestore -h localhost -u madmin -p 123456 /data

三、迁移过程日志打印

2024-10-16T09:36:03.599+0000    WARNING: On some systems, a password provided directly using --password may be visible to system status programs such as `ps` that may be invoked by other users. Consider omitting the password to provide it via stdin, or using the --config option to specify a configuration file with the password.
2024-10-16T09:36:03.610+0000    preparing collections to restore from
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/.bash_history", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with subdirectory "db/.mongodb", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/WiredTiger", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/WiredTiger.lock", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/WiredTiger.turtle", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/WiredTiger.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/WiredTigerHS.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/_mdb_catalog.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/collection-0--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/collection-2--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/collection-4--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/collection-7--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with subdirectory "db/diagnostic.data", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/index-1--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/index-3--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/index-5--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/index-6--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/index-8--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/index-9--833647413404653651.wt", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with subdirectory "db/journal", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/mongod.lock", skipping...
2024-10-16T09:36:03.610+0000    don't know what to do with file "/data/db/sizeStorer.wt", skipping...
2024-10-16T09:36:03.612+0000    reading metadata for admin.crawler_data from /data/admin/crawler_data.metadata.json
2024-10-16T09:36:03.612+0000    reading metadata for admin.crawler_data_title from /data/admin/crawler_data_title.metadata.json
2024-10-16T09:36:03.612+0000    reading metadata for admin.sequence from /data/admin/sequence.metadata.json
2024-10-16T09:36:03.643+0000    restoring admin.crawler_data from /data/admin/crawler_data.bson
2024-10-16T09:36:03.649+0000    restoring admin.crawler_data_title from /data/admin/crawler_data_title.bson
2024-10-16T09:36:03.659+0000    restoring db.storage from /data/db/storage.bson
2024-10-16T09:36:03.660+0000    finished restoring admin.crawler_data_title (76 documents, 0 failures)
2024-10-16T09:36:03.669+0000    finished restoring db.storage (1 document, 0 failures)
2024-10-16T09:36:03.669+0000    restoring admin.sequence from /data/admin/sequence.bson
2024-10-16T09:36:03.680+0000    finished restoring admin.sequence (1 document, 0 failures)
2024-10-16T09:36:06.610+0000    [........................]  admin.crawler_data  176MB/12.1GB  (1.4%)
2024-10-16T09:36:09.611+0000    [........................]  admin.crawler_data  432MB/12.1GB  (3.5%)
2024-10-16T09:36:12.610+0000    [#.......................]  admin.crawler_data  690MB/12.1GB  (5.6%)
2024-10-16T09:36:15.610+0000    [#.......................]  admin.crawler_data  983MB/12.1GB  (7.9%)
2024-10-16T09:36:18.610+0000    [##......................]  admin.crawler_data  1.25GB/12.1GB  (10.3%)
2024-10-16T09:36:21.610+0000    [###.....................]  admin.crawler_data  1.53GB/12.1GB  (12.6%)
2024-10-16T09:36:24.610+0000    [###.....................]  admin.crawler_data  1.70GB/12.1GB  (14.0%)
2024-10-16T09:36:27.611+0000    [###.....................]  admin.crawler_data  1.89GB/12.1GB  (15.6%)
2024-10-16T09:36:30.610+0000    [####....................]  admin.crawler_data  2.13GB/12.1GB  (17.6%)
2024-10-16T09:36:33.610+0000    [####....................]  admin.crawler_data  2.44GB/12.1GB  (20.1%)
2024-10-16T09:36:36.610+0000    [#####...................]  admin.crawler_data  2.65GB/12.1GB  (21.9%)
2024-10-16T09:36:39.610+0000    [#####...................]  admin.crawler_data  2.92GB/12.1GB  (24.1%)
2024-10-16T09:36:42.610+0000    [######..................]  admin.crawler_data  3.17GB/12.1GB  (26.1%)
2024-10-16T09:36:45.610+0000    [######..................]  admin.crawler_data  3.42GB/12.1GB  (28.2%)
2024-10-16T09:36:48.610+0000    [#######.................]  admin.crawler_data  3.70GB/12.1GB  (30.5%)
2024-10-16T09:36:51.610+0000    [#######.................]  admin.crawler_data  3.96GB/12.1GB  (32.6%)
2024-10-16T09:36:54.610+0000    [########................]  admin.crawler_data  4.20GB/12.1GB  (34.6%)
2024-10-16T09:36:57.610+0000    [########................]  admin.crawler_data  4.46GB/12.1GB  (36.8%)
2024-10-16T09:37:00.610+0000    [#########...............]  admin.crawler_data  4.68GB/12.1GB  (38.6%)
2024-10-16T09:37:03.610+0000    [#########...............]  admin.crawler_data  4.92GB/12.1GB  (40.5%)
2024-10-16T09:37:06.610+0000    [##########..............]  admin.crawler_data  5.17GB/12.1GB  (42.7%)
2024-10-16T09:37:09.610+0000    [##########..............]  admin.crawler_data  5.38GB/12.1GB  (44.3%)
2024-10-16T09:37:12.610+0000    [###########.............]  admin.crawler_data  5.62GB/12.1GB  (46.4%)
2024-10-16T09:37:15.610+0000    [###########.............]  admin.crawler_data  5.86GB/12.1GB  (48.3%)
2024-10-16T09:37:18.611+0000    [############............]  admin.crawler_data  6.07GB/12.1GB  (50.1%)
2024-10-16T09:37:21.610+0000    [############............]  admin.crawler_data  6.32GB/12.1GB  (52.1%)
2024-10-16T09:37:24.610+0000    [############............]  admin.crawler_data  6.49GB/12.1GB  (53.5%)
2024-10-16T09:37:27.610+0000    [#############...........]  admin.crawler_data  6.66GB/12.1GB  (54.9%)
2024-10-16T09:37:30.610+0000    [#############...........]  admin.crawler_data  6.82GB/12.1GB  (56.2%)
2024-10-16T09:37:33.610+0000    [#############...........]  admin.crawler_data  6.95GB/12.1GB  (57.3%)
2024-10-16T09:37:36.611+0000    [##############..........]  admin.crawler_data  7.10GB/12.1GB  (58.5%)
2024-10-16T09:37:39.610+0000    [##############..........]  admin.crawler_data  7.25GB/12.1GB  (59.8%)
2024-10-16T09:37:42.610+0000    [##############..........]  admin.crawler_data  7.37GB/12.1GB  (60.7%)
2024-10-16T09:37:45.610+0000    [##############..........]  admin.crawler_data  7.55GB/12.1GB  (62.2%)
2024-10-16T09:37:48.610+0000    [###############.........]  admin.crawler_data  7.82GB/12.1GB  (64.5%)
2024-10-16T09:37:51.610+0000    [###############.........]  admin.crawler_data  7.95GB/12.1GB  (65.5%)
2024-10-16T09:37:54.610+0000    [################........]  admin.crawler_data  8.16GB/12.1GB  (67.3%)
2024-10-16T09:37:57.610+0000    [################........]  admin.crawler_data  8.44GB/12.1GB  (69.6%)
2024-10-16T09:38:00.610+0000    [#################.......]  admin.crawler_data  8.60GB/12.1GB  (70.9%)
2024-10-16T09:38:03.610+0000    [#################.......]  admin.crawler_data  8.81GB/12.1GB  (72.7%)
2024-10-16T09:38:06.610+0000    [#################.......]  admin.crawler_data  9.01GB/12.1GB  (74.3%)
2024-10-16T09:38:09.610+0000    [##################......]  admin.crawler_data  9.23GB/12.1GB  (76.1%)
2024-10-16T09:38:12.610+0000    [##################......]  admin.crawler_data  9.44GB/12.1GB  (77.8%)
2024-10-16T09:38:15.610+0000    [###################.....]  admin.crawler_data  9.65GB/12.1GB  (79.6%)
2024-10-16T09:38:18.610+0000    [###################.....]  admin.crawler_data  9.79GB/12.1GB  (80.7%)
2024-10-16T09:38:21.610+0000    [###################.....]  admin.crawler_data  9.91GB/12.1GB  (81.7%)
2024-10-16T09:38:24.610+0000    [###################.....]  admin.crawler_data  10.0GB/12.1GB  (82.8%)
2024-10-16T09:38:27.610+0000    [####################....]  admin.crawler_data  10.2GB/12.1GB  (84.4%)
2024-10-16T09:38:30.610+0000    [####################....]  admin.crawler_data  10.4GB/12.1GB  (85.7%)
2024-10-16T09:38:33.610+0000    [####################....]  admin.crawler_data  10.5GB/12.1GB  (86.7%)
2024-10-16T09:38:36.610+0000    [#####################...]  admin.crawler_data  10.7GB/12.1GB  (88.2%)
2024-10-16T09:38:39.610+0000    [#####################...]  admin.crawler_data  10.8GB/12.1GB  (89.5%)
2024-10-16T09:38:42.610+0000    [#####################...]  admin.crawler_data  11.0GB/12.1GB  (90.5%)
2024-10-16T09:38:45.610+0000    [######################..]  admin.crawler_data  11.1GB/12.1GB  (91.7%)
2024-10-16T09:38:48.610+0000    [######################..]  admin.crawler_data  11.3GB/12.1GB  (93.0%)
2024-10-16T09:38:51.610+0000    [######################..]  admin.crawler_data  11.4GB/12.1GB  (94.0%)
2024-10-16T09:38:54.610+0000    [######################..]  admin.crawler_data  11.5GB/12.1GB  (94.9%)
2024-10-16T09:38:57.610+0000    [#######################.]  admin.crawler_data  11.6GB/12.1GB  (95.9%)
2024-10-16T09:39:00.610+0000    [#######################.]  admin.crawler_data  11.8GB/12.1GB  (96.9%)
2024-10-16T09:39:03.611+0000    [#######################.]  admin.crawler_data  11.9GB/12.1GB  (97.8%)
2024-10-16T09:39:06.610+0000    [#######################.]  admin.crawler_data  12.1GB/12.1GB  (99.4%)
2024-10-16T09:39:08.107+0000    [########################]  admin.crawler_data  12.1GB/12.1GB  (100.0%)
2024-10-16T09:39:08.107+0000    finished restoring admin.crawler_data (12791925 documents, 0 failures)
2024-10-16T09:39:08.107+0000    restoring users from /data/admin/system.users.bson
2024-10-16T09:39:08.143+0000    no indexes to restore for collection admin.crawler_data
2024-10-16T09:39:08.143+0000    no indexes to restore for collection admin.crawler_data_title
2024-10-16T09:39:08.143+0000    no indexes to restore for collection admin.sequence
2024-10-16T09:39:08.144+0000    12792003 document(s) restored successfully. 0 document(s) failed to restore.

到这里数据就迁移到新的容器成功了。

四、验证迁移数据准确性

迁移后验证数据一致性,在两个新旧mongDB环境分别查询集合下的数据量统计,看是否一致,如果一致,则迁移成功。

db.crawler_data.countDocuments();
db.crawler_data_title.countDocuments();

在这里插入图片描述

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/56489.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java发送请求实现QPS限制

业务场景 在开发中,当有业务需求需要调用第三方服务实现功能,但是服务接口有QPS限制,所以我们需要在发送请求时限制发送频率防止请求失败。 实现方法 使用 Java Semaphore 类来实现控制请求QPS QPS限制 Component public class QPSControll…

MySQL 8.4修改user的host属性值

MySQL 8.4修改user的host属性值 update mysql.user set host localhost where user mysql用户名; MySQL 8.4修改初始化后的默认密码-CSDN博客文章浏览阅读804次,点赞6次,收藏11次。先下载mysql的zip压缩包:MySQL :: Download MySQL Communi…

STL-string

STL的六大组件&#xff1a; string // string constructor #include <iostream> #include <string> using namespace std; int main() {// 构造std::string s0("Initial string");std::string s1; //nullptrstd::string s2("A character sequenc…

【在Linux世界中追寻伟大的One Piece】Jsoncpp|序列化

目录 1 -> Jsoncpp 1.1 -> 特性 1.2 -> 安装 2 -> 序列化 3 -> 反序列化 4 -> Json::Value 1 -> Jsoncpp Jsoncpp是一个用于处理JSON数据的C库。它提供了将JSON数据序列化为字符串以及从字符串反序列化为C数据结构的功能。Jsoncpp是开源的&#xf…

RHCSA复习题

第一~七章 1.创建以下目录和文件结构&#xff0c;并将/yasuo目录拷贝4份到/目录下。 [rootlocalhost ~]# mkdir /yasuo [rootlocalhost ~]# mkdir /yasuo/dir1 [rootlocalhost ~]# cd /yasuo/dir1 [rootlocalhost dir1]# touch hostname hostname02 passwd ssh_config sshd [r…

F5-TTS开源项目详解:非自回归语音合成技术革新与应用场景

在现代科技的推动下&#xff0c;语音合成技术取得了长足的进步。随着越来越多的场景开始依赖语音交互&#xff0c;如何高效、自然地生成语音成为了行业的一个重要课题。今天我们要讨论的是一个在语音合成领域备受瞩目的开源项目——F5-TTS。它不仅采用了非自回归架构&#xff0…

Arduino配置ESP32环境

Arduino配置ESP32环境 引言一、IDE下载教程操作取巧方法 二、社区安装包三、官方手动安装 引言 最近入手了一款ESP32-C3的开发板&#xff0c;想继续沿用现有Arduino IDE&#xff0c;网上看了很多方法&#xff0c;大致分了三类&#xff1a;IDE下载、社区安装包、github手动配置…

南京邮电大学电工电子A实验十一(数据选择器及逻辑电路的动态测试)

文章目录 一、实验报告预览二、Word版本报告下载 一、实验报告预览 二、Word版本报告下载 点我

2.Java--入门程序

一、开发Java程序 步骤&#xff1a; 1.编写代码 其中第一行的HelloWorld叫类名&#xff0c;下面的框架叫main()方法&#xff0c; 类名要和文件名一致&#xff0c; 2.编译代码 用Javac进行编译&#xff0c;将编写的代码保存之后&#xff0c;打开WindowsR输入cmd 用cd文件夹…

rom定制系列------小米6x_澎湃os1.0.28安卓13定制固件修改 刷写过程与界面预览

&#x1f49d;&#x1f49d;&#x1f49d; 在接待很多定制化系统过程中。小米6x机型为很多工作室客户使用。但官方低版本固件无法适应新应用的使用。有些第三方固件却可以完美解决。此固件是客户分享的卡刷固件。需要修改为可以批量刷写的线刷固件。去除一些内置应用。需要自带…

Spring使用注解进行依赖注入

一、原则 不要把选择留给Spring 二、Autowired&#xff08;Spring注解&#xff09; 流程图&#xff1a; Spring依赖注入-Autowired 截图&#xff1a; 三、Resource&#xff08;JDK注解&#xff09; 流程图&#xff1a; Spring依赖注入-Resource 截图&#xff1a;

Docker-Harbor概述及构建

文章目录 一、Docker Harbor概述1.Harbor的特性2.Harbor的构成 二、搭建本地私有仓库三、部署 Docker-Harbor 服务四、在其他客户端上传镜像五、维护管理Harbor 一、Docker Harbor概述 Harbor 是 VMware 公司开源的企业级 Docker Registry 项目&#xff0c;其目标是帮助用户迅…

LLM - 使用 Neo4j 可视化 GraphRAG 构建的 知识图谱(KG) 教程

欢迎关注我的CSDN&#xff1a;https://spike.blog.csdn.net/ 本文地址&#xff1a;https://spike.blog.csdn.net/article/details/142938982 免责声明&#xff1a;本文来源于个人知识与公开资料&#xff0c;仅用于学术交流&#xff0c;欢迎讨论&#xff0c;不支持转载。 Neo4j …

向日葵下载教程以及三款远程控制工具推荐!!!

向日葵远程控制下载教程&#xff01;&#xff01; 亲爱的朋友们&#xff0c;如果你对远程控制软件有所需求&#xff0c;那么向日葵绝对是一个不错的选择。现在我将带你走一遍向日葵的下载流程。 1. 打开你的浏览器&#xff0c;输入“向日葵官方网站”&#xff0c;进入官方网站…

线性回归逻辑回归-笔记

一、线性回归&#xff08;Linear Regression&#xff09; 1. 定义 线性回归是一种用于回归问题的算法&#xff0c;旨在找到输入特征与输出值之间的线性关系。它试图通过拟合一条直线来最小化预测值与真实值之间的误差。 2. 模型表示 线性回归模型假设目标变量&#xff08;输…

【黑苹果】记录MacOS升级Sonoma的过程

【黑苹果】记录MacOS升级Sonoma的过程 一、硬件二、提前说明三、准备OC四、选择驱动五、选择ACPI六、下载内核扩展七、其他问题 一、硬件 设备是神舟zx6-ct5da 具体参照下图 二、提前说明 本机器已经安装过 macOS Monterey 12.6&#xff0c;这次是升级到 macOS Sonoma 14。 …

测试教程分享

前几年在腾讯课堂上发布了不少课程&#xff0c;后来腾讯课堂改革&#xff0c;要收会员费&#xff0c;课程还要抽提程&#xff0c;这么下来就相当于白干了。就放弃了在上面发课程&#xff0c;再后来腾讯课堂就关闭了&#xff0c;以前发布的视频就没有地方发了&#xff0c;于是我…

火车头采集器易优cms采集发布模块下载

火车头采集器发布数据到易优cms&#xff08;Eyoucms&#xff09;的详细流程&#xff1a; 1. 火车头采集器易优cms&#xff08;Eyoucms&#xff09;发布模块下载地址&#xff1a; 火车头Eyoucms发布模块插件下载-CSDN 2. 在火车头导入下载的易优cms采集发布模块&#xff1b; …

uniapp学习(003-2 vue3学习 Part.2)

零基础入门uniapp Vue3组合式API版本到咸虾米壁纸项目实战&#xff0c;开发打包微信小程序、抖音小程序、H5、安卓APP客户端等 总时长 23:40:00 共116P 此文章包含第15p-第p20的内容 文章目录 事件监听以及组件内置事件处理自定义模板快速创建uniapp条件渲染 v-if和v-elsev-e…

一分钟带你认清Java抽象类

abstrat——抽象&#xff0c;抽象类真的有像它的名字一样那么抽象吗&#xff1f;其实不然&#xff0c;它只是一个比较特殊的类别&#xff0c;我们只需要简单地认清它的作用就行&#xff0c;一起来看看吧~ 抽象类的概念 首先我们要明确一个事情&#xff1a;在面向对象的概念中&…