mongodb迁移
A机器上有mongodb服务,A机器要废,于是迁至B。 简单起见,依然是在A上ps auxwww|grep mongo找到正在运行的进程: /home/admin/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongod -f /home/admin/mongodb/mongodb.conf 于是把/home/admin/mongodb/ 拷到B下。
A机器上有mongodb服务,A机器要废,于是迁至B。
简单起见,依然是在A上ps auxwww|grep mongo找到正在运行的进程:
/home/admin/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongod -f /home/admin/mongodb/mongodb.conf
于是把/home/admin/mongodb/ 拷到B下。
在b 中执行上述命令,把mongo起来了。
下面是数据的恢复。
一、看mongodb.conf中auth=true,可见A中是设了权限的,否则应用代码无法使用,于是在B中也设一下:
/home/admin/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongo进入mongshell
use stats;
db.addUser('webuser','123456');
二、数据导出导入
从A中dump数据:/home/admin/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongodump -d stats -o stat_dump -uwebuser -pxxxxxx
把上述stat_dump目录scp至B.
在b中导入:
~/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongorestore -d stats /home/admin/stat_dump/*
其他的都没问题,可是user_behavior这个collection报错:
Tue May 20 11:45:35 going into namespace [stats.user_behavior]
Tue May 20 11:45:35 Assertion failure b.empty() src/mongo/db/json.cpp 645
没明白原因,于是把这个user_behavior数据从stat_dump下删除了,导入。即把别的collection先导进去了,然后再单独处理它。
单独处理它就用export/import的方式了。
先在A上/home/admin/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongoexport -d stats -c user_behavior -o ub -uwebuser -pxxxxxxx
再把ub这个文件scp到B上。
~/mongodb/mongodb-linux-x86_64-2.2.0/bin/mongoimport -d stats -c user_behavior ub
这样这个collection也成功了。
应用代码调一下,可以显示了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The best way to move legacy C++ applications to the cloud: Re-platform: Move the application code to a cloud-native platform (such as Kubernetes) and leverage cloud services. Cloudization: Deploy applications on cloud platforms and utilize cloud services without code refactoring.

.NET 4.0 is used to create a variety of applications and it provides application developers with rich features including: object-oriented programming, flexibility, powerful architecture, cloud computing integration, performance optimization, extensive libraries, security, Scalability, data access, and mobile development support.

According to news on August 3, according to Huawei’s official introduction, Huawei’s July Service Day has officially started, from August 3 to August 4. It is understood that Huawei’s service days are from the first consecutive Friday to Sunday of each month (if the weekend spans the month, it will be postponed to the next weekend). Huawei users who visit the store during the event can enjoy six exclusive benefits including free film stickers and free labor costs for repairs. Specifically: Huawei mobile phones: free film, cleaning, maintenance, and system upgrade services. Huawei tablets, laptops, wearables, earphones of designated models, and smart glasses: free appearance cleaning and maintenance services. In addition, during the event, users are not required to go to the store for equipment repairs. Pay labor fees and go to the store to purchase Huawei brand accessories, extended service packages, and personalized film products: enjoy a 10% discount on the recommended retail price. The repaired equipment cannot be repaired on the same day.

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

According to news from this site on July 16, Xiaomi has launched its Thanksgiving Season event today, providing preferential replacement and maintenance services for mobile phones, laptops, air conditioners, washing machines, range hoods and other accessories. The content of the activities organized by this site is as follows: The event time is from 10:00 on July 16, 2024 to 24:00 on July 25, 2024. Mobile phone battery replacement can be enjoyed at 20% off for 80 models, with official quality and original accessories. 12 models can enjoy a 20% discount on mobile phone back cover replacement starting from 79.2 yuan. Mobile phone back cover replacement, official accessories, starting from 68 yuan. It should be noted that after users place an order for the back cover replacement service on Xiaomi Mall, the color can be selected at the store. , the specific inventory is subject to the actual situation of the store. If the selected color is out of stock, there may be a delivery delay. Replace your laptop battery with a new one and enjoy 20% off on 14 models of laptops

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

MongoDB and relational database: In-depth comparison This article will explore in-depth the differences between NoSQL database MongoDB and traditional relational databases (such as MySQL and SQLServer). Relational databases use table structures of rows and columns to organize data, while MongoDB uses flexible document-oriented models to better suit the needs of modern applications. Mainly differentiates data structures: Relational databases use predefined schema tables to store data, and relationships between tables are established through primary keys and foreign keys; MongoDB uses JSON-like BSON documents to store them in a collection, and each document structure can be independently changed to achieve pattern-free design. Architectural design: Relational databases need to pre-defined fixed schema; MongoDB supports
