Home Database Mysql Tutorial 【MongoDB】在windows平台下mongodb的分片集群(六)

【MongoDB】在windows平台下mongodb的分片集群(六)

Jun 07, 2016 pm 04:10 PM
mongodb windows Fragmentation

在本篇博客中我们主要讨论下博客的管理。由于已经在前面五篇中写了详细的实例,因此这里就不再举例说明。 一、监控 分片集群是整个体系中比较复杂的一块,因此更应该需要监控。 主要命令: serverstatus和currentOp() 二、手动分区 手动分区意思就是手动对线

在本篇博客中我们主要讨论下博客的管理。由于已经在前面五篇中写了详细的实例,因此这里就不再举例说明。

一、监控

分片集群是整个体系中比较复杂的一块,因此更应该需要监控。

主要命令: serverstatus和currentOp()

二、手动分区

手动分区意思就是手动对线上分片集群的块进行拆分和迁移。一般而言,一个分片写的越多,它越大。 movechunk命令在这种情况下同样有帮助

三、增加一个分片

sh.addShard("computername:port")

使用这种方式增加容量,要注意向新分片迁移数据所花费的时间。预计迁移速度是每分钟100~200M。最好在索引和工作集达到现有计划添加新分片。

四、删除分片

在一些很少见的情况下,你可能想删除一个分片,可以通过命令removeshard命令进行删除。一旦分片被清空,你还要确认将要删除的分片不是数据库的主分片,可以通过命令config.databases集合进行查询;

db.databases.find()

五、集合去分片

虽然可以删除一个分片,但是没有正式的路径去掉集合的分片。做法就是先用mongodump命令导出数据然后再用mongorestore来恢复数据。

六、备份分片集合

要备份分片集群,就是需要配置数据以及每个分片数据的副本;一种方式是利用monodump命令来导出数据。另一方式就是从每个分片的一个成员里复制数据文件,再从另一台服务器中复制数据文件。

无论那种方式,要确认再备份系统的时候没有块处在移动过程中。

停止均衡器:use config; db.setting.update({_id:"balancer"},{$set:{stopped:true},true})

备份之前重新确认: use config, db.locks.find({"_id":"balancer"})

备份之后别忘了启动均衡器

sh.setBalancerState()

sh.isBalancerRunning()

七、故障转移和恢复

分片成员故障,自动会转移到其他副本集一员。如果有不正常的表现,可以利用重启mongos进行进行重置

配置服务器故障:一个分片集群一般有三台配置服务器,如果有两台发生故障,那么剩余的配置服务器变为只读状态,所有的拆分和均衡操作都会停止。这个对集群的读写没有影响,当三条配置服务器恢复后,均衡器就会它停止的地方那个重新开始工作

mongos故障:如果mongos进程发生故障,一般重启应用服务器;

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Use Composer to solve the dilemma of recommendation systems: andres-montanez/recommendations-bundle Use Composer to solve the dilemma of recommendation systems: andres-montanez/recommendations-bundle Apr 18, 2025 am 11:48 AM

When developing an e-commerce website, I encountered a difficult problem: how to provide users with personalized product recommendations. Initially, I tried some simple recommendation algorithms, but the results were not ideal, and user satisfaction was also affected. In order to improve the accuracy and efficiency of the recommendation system, I decided to adopt a more professional solution. Finally, I installed andres-montanez/recommendations-bundle through Composer, which not only solved my problem, but also greatly improved the performance of the recommendation system. You can learn composer through the following address:

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

What is the CentOS MongoDB backup strategy? What is the CentOS MongoDB backup strategy? Apr 14, 2025 pm 04:51 PM

Detailed explanation of MongoDB efficient backup strategy under CentOS system This article will introduce in detail the various strategies for implementing MongoDB backup on CentOS system to ensure data security and business continuity. We will cover manual backups, timed backups, automated script backups, and backup methods in Docker container environments, and provide best practices for backup file management. Manual backup: Use the mongodump command to perform manual full backup, for example: mongodump-hlocalhost:27017-u username-p password-d database name-o/backup directory This command will export the data and metadata of the specified database to the specified backup directory.

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

How to solve complex BelongsToThrough relationship problem in Laravel? Use Composer! How to solve complex BelongsToThrough relationship problem in Laravel? Use Composer! Apr 17, 2025 pm 09:54 PM

In Laravel development, dealing with complex model relationships has always been a challenge, especially when it comes to multi-level BelongsToThrough relationships. Recently, I encountered this problem in a project dealing with a multi-level model relationship, where traditional HasManyThrough relationships fail to meet the needs, resulting in data queries becoming complex and inefficient. After some exploration, I found the library staudenmeir/belongs-to-through, which easily installed and solved my troubles through Composer.

How to choose a database for GitLab on CentOS How to choose a database for GitLab on CentOS Apr 14, 2025 pm 04:48 PM

GitLab Database Deployment Guide on CentOS System Selecting the right database is a key step in successfully deploying GitLab. GitLab is compatible with a variety of databases, including MySQL, PostgreSQL, and MongoDB. This article will explain in detail how to select and configure these databases. Database selection recommendation MySQL: a widely used relational database management system (RDBMS), with stable performance and suitable for most GitLab deployment scenarios. PostgreSQL: Powerful open source RDBMS, supports complex queries and advanced features, suitable for handling large data sets. MongoDB: Popular NoSQL database, good at handling sea

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

See all articles