项目数据库为MongoDB,分片DB,每个片为一个复制集,每复制集三台DB,
现在需给其中一个复制集增加一台DB,先把用到的资料贴上来,等有时间了再
整理:
Add Members to a Replica Set
--Production Notes
If
you have a backup or snapshot of an existing member, you can move the
data files (i.e. /data/db or dbpath) to a new system and use them to
quickly initiate a new member. These files must be:
1. clean:
the existing dataset must be from a consistent copy of the database
from a member of the same replica set. See the Backup and Restoration
Strategies document for more information.
http://docs.mongodb.org/manual/administration/backups/
2. recent: the copy must more recent than the oldest operation in the
primary member’s oplog. The new secondary must be able to become current
using operations from the primary’s oplog.
-------------------------------------------------------------------------------------------
Creating a slave from an existing master's disk image
If you can stop write operations to the master for an indefinite
period, you can copy the data files from the master to the new slave,
and then start the slave with --fastsync
.
|
Be careful with --fastsync. If the data is not perfectly in sync, a discrepancy will exist forever. |
--fastsync
is a way to start a slave starting with an
existing master disk image/backup. This option declares that the
adminstrator guarantees the image is correct and completely up to date
with that of the master. If you have a full and complete copy of data
from a master you can use this option to avoid a full synchronization
upon starting the slave.
/////////////////////////////
Would like to get documentation for the --fastsync feature. My hope is
the ability to make raw file system copies to seed slaves, then tell the
slave where to "pick up" reads from the oplog. This would make
deploying slaves much faster than performing a initial sync, especially
when there is a slow connection between master/slave (i.e. across data
centers).
//////////////////////////////
Yes. --fastsync is a way to speed up the sync when you have a recent
copy of all the data and oplog
On Feb 24, 3:06Âpm, tetlika <tetl...@xxxxxxxxx> wrote:
> ah ok
>
> I think i understood: fast resync is used just when we have a copy of
> data - including oplogs - it just tells not to do a full resync
>
> when we dont use fastresync all data will be synced, not depending on
> oplog
>
> On 25 ÑÐÐ, 00:55, sridhar <srid...@xxxxxxxxx> wrote:
>
>
>
>
>
>
>
> > fastsync does not replay all the oplog. It only replays the necessary
> > entries post where your database is at. If your oplog is not big
> > enough and has rolled over, fastsync falls back to a full resync.
>
> > On Feb 24, 2:49Âpm, tetlika <tetl...@xxxxxxxxx> wrote:
>
> > > Hi!
>
> > > According to
> > > thehttp://www.mongodb.org/display/DOCS/Adding+a+New+Set+Member
> > > fastsync is just "replaying" ALL Âoplog on the new slave, so if we
> > > dont have the oplog Âbig enough - we need copy data to the new slave
> > > and run it with the fastsync option?
Creating a slave from an existing slave's disk image
You can just copy the other slave's data file snapshot without any
special options. Note data snapshots should only be taken when a mongod
process is down or in fsync-and-lock state.
Sharded Cluster and Replica Set Considerations
The underlying architecture of sharded clusters
and replica sets
presents several
challenges for creating backups. This section describes how to make
quality backups in environments with these configurations and how to
perform restorations.
Back Up Sharded Clusters
Sharding complicates backup operations, because it is impossible to
create a backup of a single moment in time from a distributed cluster
of systems and processes.
Depending on the size of your data, you can back up the cluster as a
whole or back up each mongod
instance. The following
section describes both procedures.
Back Up the Cluster as a Whole Using mongodump
If your sharded cluster
comprises a small collection of data,
you can connect to a mongos
and issue the
mongodump
command. You can use this approach if the following
is true:
- It’s possible to store the entire backup on one system or on a single
storage device. Consider both backups of entire instances and
incremental dumps of data.
- The state of the database at the beginning of the operation is
not significantly different than the state of the database at the
end of the backup. If the backup operation cannot capture a backup,
this is not a viable option.
- The backup can run and complete without affecting the performance of
the cluster.
Note
If you use mongodump
without specifying the a database or
collection, the output will contain both the collection data and the
sharding config metadata from the config servers
.
You cannot use the --oplog
option for
mongodump
when dumping from a mongos
. This option is only
available when running directly against a replica set
member.
Back Up from All Database Instances
If your sharded cluster
is to large for the mongodump
command, then you must back up your data either by creating a snapshot of the cluster
or by creating a binary dump of each database. This section describes both.
In both cases:
- The backups must capture the database in a consistent state.
- The sharded cluster must be consistent in itself.
This procedure describes both approaches:
-
Disable the balancer
process that equalizes the
distribution of data among the shards
. To disable
the balancer, use the sh.stopBalancer()
method in the
mongo
shell, and see the
Disable the Balancer
procedure.
Warning
It is essential that you stop the balancer before creating
backups. If the balancer remains active, your resulting backups
could have duplicate data or miss some data, as chunks
migrate while recording backups.
-
Lock one member of each replica set in shard so that your backups reflect your
entire database system at a single point in time. Lock all shards
in as short of an interval as possible.
To lock or freeze a sharded cluster, you must:
- use the db.fsyncLock()
method in the mongo
shell connected to each shard mongod
instance and
block write operations.
- Shutdown one of the config servers
, to
prevent all metadata changes during the backup process.
-
Use mongodump
to backup one of the config servers
. This backs up the cluster’s metadata. You
only need to back up one config server, as they all have replicas of
the same information.
Issue this command against one of the config server itself or the
mongos
:
-
Back up the replica set members of the shards that you locked. You may back up
shards one at a time or in parallel. For each shard, do one of the
following:
-
Unlock all locked replica set members of each shard using the
db.fsyncUnlock()
method in the mongo
shell.
-
Restore the balancer with the sh.startBalancer()
method
according to the Disable the Balancer
procedure.
Use the following command sequence when connected to the
mongos
with the mongo
shell:
use
config
sh
.
startBalancer
()
Schedule Automated Backups
If you have an automated backup schedule, you can disable all
balancing operations for a period of time. For instance, consider the
following command:
use
config
db
.
settings
.
update
(
{
_id
:
"balancer"
},
{
$set
:
{
activeWindow
:
{
start
:
"6:00"
,
stop
:
"23:00"
}
}
},
true
)
This operation configures the balancer to run between 6:00 am and
11:00pm, server time. Schedule your backup operation to run and
complete
in this time. Ensure that the backup can complete during the
window when the balancer is running and
that the balancer can
effectively balance the collection among the shards in the window
allotted to each.
Restore Sharded Clusters
-
Stop all mongod
and mongos
processes.
-
If shard hostnames have changed, you must manually update the
shards
collection in the Config Database Contents
to use the new
hostnames. Do the following:
-
Start the three config servers
by
issuing commands similar to the following, using values appropriate
to your configuration:
mongod --configsvr --dbpath /data/configdb --port 27018
-
Restore the Config Database Contents
on each config server.
-
Start one mongos
instance.
-
Update the Config Database Contents
collection named shards
to reflect the
new hostnames.
-
Restore the following:
- Data files for each server in each shard
. Because replica
sets provide each production shard, restore all the members of
the replica set or use the other standard approaches for
restoring a replica set from backup.
- Data files for each config server
,
if you have not already done so in the previous step.
-
Restart the all the mongos
instances.
-
Restart all the mongod
instances.
-
Connect to a mongos
instance from a mongo
shell
and run use the db.printShardingStatus()
method to ensure
that the cluster is operational, as follows:
db
.
printShardingStatus
()
show
collections
Restore a Single Shard
Always restore sharded clusters
as a whole. When you restore a single shard, keep in mind that the
balancer
process might have moved chunks
onto or
off of this shard since the last backup. If that’s the case, you must
manually move those chunks, as described in this procedure.
- Restore the shard.
- For all chunks that migrated away from this shard, you need not do
anything. You do not need to delete these documents from the shard
because the chunks are automatically filtered out from queries by
mongos
.
- For chunks that migrated to this shard since the last backup,
you must manually recover the chunks. To determine what chunks have
moved, view the changelog
collection in the Config Database Contents
.
Replica Sets
In most cases, backing up data stored in a replica set
is
similar to backing up data stored in a single instance. It’s possible to
lock a single secondary
or slave
database and then
create a backup from that instance. When you unlock the database, the secondary or
slave will catch up with the primary
or master
. You may also
chose to deploy a dedicated hidden member
for backup purposes.
If you have a sharded cluster
where each shard
is itself a replica
set, you can use this method to create a backup of the entire cluster
without disrupting the operation of the node. In these situations you
should still turn off the balancer when you create backups.
For any cluster, using a non-primary/non-master node to create backups is
particularly advantageous in that the backup operation does not
affect the performance of the primary or master. Replication
itself provides some measure of redundancy. Nevertheless, keeping
point-in time backups of your cluster to provide for disaster recovery
and as an additional layer of protection is crucial.
分享到:
相关推荐
6. **1台mongodb服务器(mongodb、activeMQ)**:提供非关系型数据库服务及消息队列服务。 7. **1台trade服务器**:专门处理交易逻辑和服务。 所有服务器均采用CentOS 6.5操作系统。 #### 二、web服务器配置 Web...
这样,即使主节点出现故障,系统也能自动切换到其他副本节点,确保服务连续性。 8. **分片**: 如果数据量巨大,可以考虑使用分片技术将数据分布在多个服务器上,以实现水平扩展和负载均衡。公寓访客管理系统随着...
## Tom的Koa服务器 引擎 node >=6.2.0 开发者 npm run dev 线上 make builds 测试 npm install test 注意 您需要定义本地测试mongodb才能运行摩卡测试。 请参阅./test/mongodb.conf获取更多详细信息 您需要安装...
1. **节点服务器**:Node.js服务器是利用Node.js的http模块创建的,可以处理HTTP请求并返回响应。在这个项目中,“node-server-zxt”扮演了这一角色,为zhongxiaotuan.com提供服务。 2. **启动本地服务器**:“yarn...
1. **分布式存储**:NoSQL数据库通常采用分布式架构,能够轻松扩展到多台服务器,以处理PB级别的数据。 2. **灵活的数据模型**:不同于RDBMS的固定表格结构,NoSQL允许使用键值对、文档、列族和图形等多种数据模型,...
通过学习和参与这个项目,你可以深入了解Node.js的异步I/O模型、Express框架的使用、数据库操作(如MongoDB或MySQL)、路由设计、模板引擎(如Pug或EJS)、以及如何组织一个全栈JavaScript项目。此外,还会涉及到...
- **可伸缩性**:支持非常庞大的数据量,并能够实现水平扩展,即通过增加更多的服务器节点来提升处理能力。 - **存储效率**:相比传统数据库,NoSQL数据库在存储空间的使用上更为高效。 - **开发友好性**:NoSQL...
1. 高扩展性:NOSQL数据库设计时考虑了水平扩展,可以轻松地通过添加更多服务器来提高处理能力,这在面对大量并发请求时尤其有用。 2. 数据模型灵活:NOSQL数据库通常支持多种数据模型,如键值对、文档型、列族和...
开发一个移动应用涉及到前端和后端开发,可能需要的技术包括Android和iOS平台的开发语言(如Java、Kotlin、Swift或Objective-C)、服务器端编程语言(如Python、Node.js、Java)、数据库管理(如MySQL、MongoDB)...
"节点server.js"表明项目使用了Node.js作为后端服务器。Node.js是一个基于Chrome V8引擎的JavaScript运行环境,它允许开发者使用JavaScript来编写服务器端代码。"server.js"通常是Node.js应用的入口文件,包含了启动...
这可能涉及到API接口设计和使用,如RESTful API,用于存储和检索数据的后台数据库可能是MySQL、MongoDB或其他NoSQL数据库。 4. **支付功能集成**:轻客洗衣小程序可能集成了微信支付,用户下单后可以直接在小程序内...
5. **多样化存储引擎**:针对不同的业务场景,企业可以选择不同的数据库引擎,如MySQL、OceanBase、Oracle、PostgreSQL、MongoDB等,以满足TP(事务处理)和AP(分析处理)的需求。例如,对于文档类型的数据,可以...
为了实现这些功能,OHM可能采用了现代前端框架(如React或Vue.js)来构建用户界面,利用Express.js作为后端服务器,数据库可能采用MongoDB或MySQL来存储用户信息和项目数据。同时,系统可能还利用云服务(如AWS或...
二手家具回收租赁出售平台设计是一项综合性的IT项目,旨在创建一个线上市场,让人们能够便捷地进行二手家具的买卖和租赁。平台的核心理念是C2B2C模式,即消费者(Customer)将二手家具卖给平台(Business),平台...