最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Mongodb 刪除添加分片與非分片表維護(hù)

 更新時間:2016年01月15日 09:10:01   作者:aqszhuaihuai  
MongoDB 是一個介于關(guān)系數(shù)據(jù)庫和非關(guān)系數(shù)據(jù)庫之間的產(chǎn)品,是非關(guān)系數(shù)據(jù)庫當(dāng)中功能最豐富,最像關(guān)系數(shù)據(jù)庫的。通過本文給大家介紹Mongodb 刪除添加分片與非分片表維護(hù)的相關(guān)知識,對此文感興趣的朋友一起學(xué)習(xí)吧

MongoDB 是一個基于分布式文件存儲的數(shù)據(jù)庫。由 C++ 語言編寫。旨在為 WEB 應(yīng)用提供可擴(kuò)展的高性能數(shù)據(jù)存儲解決方案。

MongoDB 是一個介于關(guān)系數(shù)據(jù)庫和非關(guān)系數(shù)據(jù)庫之間的產(chǎn)品,是非關(guān)系數(shù)據(jù)庫當(dāng)中功能最豐富,最像關(guān)系數(shù)據(jù)庫的。

一、如何移除分片

1、確認(rèn)balancer已經(jīng)開啟

mongos> sh.getBalancerState()
true

2、移除分片

注:在admin db下執(zhí)行命令。

mongos> use admin
switched to db admin
mongos> db.runCommand( { removeShard: "shard3" } )
{
"msg" : "draining started successfully",
"state" : "started",
"shard" : "shard3",
"ok" : 1
}

3、檢查遷移的狀態(tài)

同樣執(zhí)行

mongos> use admin
switched to db admin
mongos> db.runCommand( { removeShard: "shard3" } )
{
"msg" : "draining ongoing",
"state" : "ongoing",
"remaining" : {
"chunks" : NumberLong(3),
"dbs" : NumberLong(0)
},
"ok" : 1
}

remaining中的chunks表示還有多少數(shù)據(jù)塊未遷移。

4、移除未分片數(shù)據(jù)

In a cluster, a database with unsharded collections stores those collections only on a single shard.
That shard becomes the primary shard for that database. (Different databases in a cluster can have different primary shards.)
WARNING
Do not perform this procedure until you have finished draining the shard.
1)To determine if the shard you are removing is the primary shard for any of the cluster's databases, issue one of the following methods:
sh.status()
db.printShardingStatus()
In the resulting document, the databases field lists each database and its primary shard.
For example, the following database field shows that the products database uses mongodb0 as the primary shard:
{ "_id" : "products", "partitioned" : true, "primary" : "mongodb0" }
2)To move a database to another shard, use the movePrimary command. For example, to migrate all remaining unsharded data from mongodb0 to mongodb1,
issue the following command:
use admin
db.runCommand( { movePrimary: "products", to: "mongodb1" }) --products為db name
This command does not return until MongoDB completes moving all data, which may take a long time.
The response from this command will resemble the following:
{ "primary" : "mongodb1", "ok" : 1 }
If you use the movePrimary command to move un-sharded collections, you must either restart all mongos instances,
or use the flushRouterConfig command on all mongos instances before writing any data to the cluster.
This action notifies the mongos of the new shard for the database.
If you do not update the mongos instances' metadata cache after using movePrimary, the mongos may not write data to the correct shard.
To recover, you must manually intervene.

根據(jù)上面所說,遷移非分片表 時 最好停機(jī),在運(yùn)行db.runCommand( { movePrimary: "products", to: "mongodb1" }) 命令完成之后,刷新所有mongos后(所有mongos上運(yùn)行db.runCommand("flushRouterConfig")),再對外提供服務(wù)。當(dāng)然也可以重新啟動所有mongos實(shí)例 。

5、完成遷移

mongos> use admin
switched to db admin
mongos> db.runCommand( { removeShard: "shard3" } )
{
"msg" : "removeshard completed successfully",
"state" : "completed",
"shard" : "shard3",
"ok" : 1
}

如果state為 completed,表示已完成遷移。

二、添加分片

1、首先確認(rèn)balancer已經(jīng)開啟

mongos> sh.getBalancerState()
true

2、執(zhí)行添加分片的命令

如果出現(xiàn)以下錯誤,刪除目標(biāo)shard3上的test1數(shù)據(jù)庫,再次執(zhí)行命令

mongos> sh.addShard("shard3/192.168.137.138:27019")
{
"ok" : 0,
"errmsg" : "can't add shard shard3/192.168.137.138:27019 because a local database 'test1' exists in another shard1:shard1/192.168.137.111:27017,192.168.137.75:27017"
}
mongos> sh.addShard("shard3/192.168.137.138:27019")
{ "shardAdded" : "shard3", "ok" : 1 }

最后運(yùn)行sh.status()命令確認(rèn)遷移是否成功,可能會花比較長的時間。

以上內(nèi)容是給大家介紹了Mongodb 刪除添加分片與非分片表維護(hù)的全部敘述,希望對大家有所幫助。

相關(guān)文章

  • MongoDB快速入門筆記(二)之MongoDB的概念及簡單操作

    MongoDB快速入門筆記(二)之MongoDB的概念及簡單操作

    MongoDB是面向集合的文檔式數(shù)據(jù)庫,不像關(guān)系數(shù)據(jù)庫那樣,有表,列、行,mongoDB數(shù)據(jù)庫則是由一系列的文檔組成。接下來通過本文給大家介紹MongoDB的概念及簡單操作,一起看看吧
    2016-06-06
  • MongoDB學(xué)習(xí)筆記之MapReduce使用示例

    MongoDB學(xué)習(xí)筆記之MapReduce使用示例

    這篇文章主要介紹了MongoDB學(xué)習(xí)筆記之MapReduce使用示例,本文直接給出實(shí)例代碼,需要的朋友可以參考下
    2015-07-07
  • MongoDB快速入門及其SpringBoot實(shí)戰(zhàn)教程

    MongoDB快速入門及其SpringBoot實(shí)戰(zhàn)教程

    MongoDB是一個開源、高性能、無模式的文檔型數(shù)據(jù)庫,當(dāng)初的設(shè)計(jì)就是用于簡化開發(fā)和方便擴(kuò)展,是NoSQL數(shù)據(jù)庫產(chǎn)品中的一種,它支持的數(shù)據(jù)結(jié)構(gòu)非常松散,是一種類似于JSON的格式叫BSON,本文介紹MongoDB快速入門及其SpringBoot實(shí)戰(zhàn),感興趣的朋友一起看看吧
    2023-12-12
  • 使用命令方式安裝MongoDB指南(Windows、Linux)

    使用命令方式安裝MongoDB指南(Windows、Linux)

    這篇文章主要介紹了使用命令方式安裝MongoDB指南,本文分別介紹Windows、Linux下使用命令的方式安裝mongodb,需要的朋友可以參考下
    2015-04-04
  • MongoDB數(shù)據(jù)庫安裝部署及警告優(yōu)化

    MongoDB數(shù)據(jù)庫安裝部署及警告優(yōu)化

    大家好,本篇文章主要講的是MongoDB數(shù)據(jù)庫安裝部署及警告優(yōu)化,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • NoSQL反模式 - 文檔數(shù)據(jù)庫篇

    NoSQL反模式 - 文檔數(shù)據(jù)庫篇

    我們設(shè)計(jì)關(guān)系數(shù)據(jù)庫Schema的都有一套完整的方案,而NoSQL卻沒有這些。半年前筆者讀了本《SQL反模式》的書,覺得非常好。就開始留意,對于NoSQL是否也有反模式?好的反模式可以在我們設(shè)計(jì)Schema告訴哪里是陷阱和懸崖。
    2014-08-08
  • CentOS 7下用yum快速安裝MongoDB的方法教程

    CentOS 7下用yum快速安裝MongoDB的方法教程

    MongoDB 是一個基于分布式文件存儲的數(shù)據(jù)庫。由 C++ 語言編寫。旨在為 WEB 應(yīng)用提供可擴(kuò)展的高性能數(shù)據(jù)存儲解決方案。本文介紹了CentOS 7系統(tǒng)下用yum快速安裝MongoDB的方法教程,文中通過一步步的步驟介紹的很詳細(xì),有需要的朋友們可以參考借鑒。
    2016-12-12
  • Mongodb讀數(shù)據(jù)操作

    Mongodb讀數(shù)據(jù)操作

    今天小編就為大家分享一篇關(guān)于Mongodb讀數(shù)據(jù)操作,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • mongodb replica set 配置高性能多服務(wù)器詳解

    mongodb replica set 配置高性能多服務(wù)器詳解

    mongodb的多服務(wù)器配置,以前寫過一篇文章,是master-slave模式的,master-slave模式,不能自動實(shí)現(xiàn)故障轉(zhuǎn)移和恢復(fù)。所以推薦大家使用mongodb的replica set,來實(shí)現(xiàn)多服務(wù)器的高性能。
    2014-07-07
  • MongoDB4.28開啟權(quán)限認(rèn)證配置用戶密碼登錄功能

    MongoDB4.28開啟權(quán)限認(rèn)證配置用戶密碼登錄功能

    這篇文章主要介紹了MongoDB4.28開啟權(quán)限認(rèn)證配置用戶名和密碼認(rèn)證登錄,本文分步驟給大家介紹開啟認(rèn)證登錄的方法,需要的朋友可以參考下
    2022-01-01

最新評論

花莲县| 甘孜| 湖州市| 诏安县| 怀安县| 洛阳市| 陇川县| 苏尼特左旗| 顺昌县| 张家界市| 怀柔区| 建平县| 遂川县| 济宁市| 马尔康县| 榕江县| 台湾省| 陇川县| 阿拉尔市| 吉木萨尔县| 阳泉市| 新田县| 威海市| 沙洋县| 秭归县| 虹口区| 化德县| 黄石市| 舞钢市| 辽中县| 长武县| 荣昌县| 泉州市| 三江| 楚雄市| 丹寨县| 缙云县| 尼勒克县| 翁牛特旗| 嘉黎县| 芮城县|