Jen

Mongo DB - RepliSet Mode 懶人設定筆記

之前分享的 Mongo DB Sharding 心得筆記 (一) 提到每個 Shard 可以是個 RepliSet,以避免台主機掛掉之後,資料就救不回來的情況發生。簡單做個筆記。
 [more] 
【RepliSet 設定】
假設我們要以 3 個 Mongod 來做 1 個 RepliSet,我們會用以下指令來啟動 3 Mongod:
mongod --dbpath "C:\MongoDB\Database\Set1" --port 10001 --replSet fpgSet
mongod --dbpath "C:\MongoDB\Database\Set2" --port 10002 --replSet fpgSet
mongod --dbpath "C:\MongoDB\Database\Set3" --port 10003 --replSet fpgSet
然後用 mongo 指令,連上任意 1 個節點,設定 Config ,
config = { _id: "fpgSet", members: [
... { _id:0, host:"localhost:10001" },
... { _id:1, host:"localhost:10002" },
... { _id:2, host:"localhost:10003" }
... ]}

rs.initiate(config);
這些資訊都會存在 database 中預設的 local 這個 collection 中,如果設定失敗,要先確定是否有切到 local 這個 collection。
使用 rs.isMaster() 查看目前 ReplSet 的 Member 跟 master 是哪個節點。
如果用 shell 連上 Slave 的節點,預設是不能做查詢,下 rs.slaveOk() 指令 或 rs.slaveOk=true ,即可查詢。
_id是流水號,請注意,如果有個成員被移除的話,該 _id 就不能再被使用。
參考1

【新增、移除 RepliSet 的成員】
要新增一個成員也是很簡單,需要注意的是新成員的資料必須是空的或是從其他成員複製過來的資料,啟動新的 mongod 並給他一個 RepliSet 的名稱:
mongod --replSet fpgSet --host localhost --port 10004 --dbpath "c:\MongoDB\Database\Set4"
 
新增成員:
rs.add("localhost:10004")
移除現有的成員:
rs.remove("localhost:10004")
1.舊的成員重新加入?
2.快速增加新的成員,可以拿現有的成員資料,重新複製新的成員加到 RepliSet。
要「乾淨」並且是「最近的」的資料檔案。
參考1參考2 

【重新設定 RepliSet 的成員】
使用參考1  : 當一個成員 down 掉時。
使用參考2  : 當成員 up。

5 意見:

  匿名

2013年3月8日 下午2:01

You could experience natural disasters like cyclone, tornadoes, earthquakes, and fire.
Unlike popular beliefs video games have how to use them which enable it to even be considered as being a learning tool.
You could also do your very own version connected with makeovers and allow a celebrity a whole different start looking.


Here is my weblog please click the up coming article
Also see my website :: kostenlos spiele spielen

  匿名

2013年3月10日 上午3:16

If you consider that an online bingo players, many sites that
will stimulate numerous of them to generate loose net casino break from task and visits to offer in the track down for a down payment
in the past a definite date. You will eventually run into the Download
Location menu with two options: Wii System Menu and SD Card.
However, make sure that your phone is equipped with a powerful processor to enable deeper
searches and devise a strategy to give a challenging game of chess.


Feel free to visit my weblog: www.gaydate-online.co.uk

  匿名

2013年3月30日 下午1:30

I am sure this piece of writing has touched all the internet users, its really really pleasant article on building
up new weblog.

my page :: Http://Www.performancenotes.com/index.Php/member/153059

  匿名

2013年3月31日 上午5:09

I leave a comment when I appreciate a article
on a blog or if I have something to add to the discussion.
Usually it is caused by the passion displayed in the article
I read. And after this post "Mongo DB - RepliSet Mode 懶人設定筆記".
I was moved enough to drop a leave a responsea response ;
-) I actually do have a few questions for you if you do not mind.
Could it be only me or do a few of the remarks look like left by brain dead visitors?
:-P And, if you are writing on additional places,
I'd like to keep up with you. Could you list the complete urls of all your communal pages like your Facebook page, twitter feed, or linkedin profile?

My web blog ... casino bonus blog

  匿名

2013年4月9日 上午6:41

In the four tournaments since his first of the season, he.
Port forwarding lets you specify which ports the game needs to
perform at it's best. We carry R4 SDHC, DSTT, R4i SDHC, Acekard 2i, EZFlash Vi, M3i Zero, and now the i - Edge.

My web site; kostenlos spielen