【Mongodb】 replica set 兩種新增節點方法的日誌分析
這篇文章算是《replica set 新增和刪除節點》的點綴,本來沒打算檢視新增節點的第二種方法,即複製其他節點的資料檔案到新的節點,本著“入微”的原則,對兩種方法做一下對比,具體新增節點的過程和前面介紹的一樣,只是在啟動mongod服務之前要複製資料檔案到本機。
下面是空庫新增到一個replica set中的日誌記錄:
####連線primary庫
Tue Nov 1 14:22:57 [initandlisten] connection accepted from 10.250.7.220:54235 #2
Tue Nov 1 14:22:57 [initandlisten] connection accepted from 10.250.7.220:54236 #3
Tue Nov 1 14:22:57 [initandlisten] connection accepted from 10.250.7.220:54237 #4
Tue Nov 1 14:22:57 [rsStart] trying to contact 10.250.7.220:27018
Tue Nov 1 14:22:57 [rsStart] trying to contact 10.250.7.220:27019
Tue Nov 1 14:22:57 [rsStart] trying to contact 10.250.7.220:27020
####從primary庫複製replica set的配置資訊,並儲存到本地 -dbpath 指定的檔案目錄####
Tue Nov 1 14:22:57 [rsStart] replSet got config version 2 from a remote, saving locally
Tue Nov 1 14:22:57 [rsStart] replSet info saving a newer config version to local.system.replset
Tue Nov 1 14:22:57 [FileAllocator] allocating new datafile /opt/mongodata/r1/local.ns, filling with zeroes...
Tue Nov 1 14:22:57 [FileAllocator] creating directory /opt/mongodata/r1/_tmp
Tue Nov 1 14:22:57 [FileAllocator] done allocating datafile /opt/mongodata/r1/local.ns, size: 16MB, took 0.118 secs
Tue Nov 1 14:22:57 [FileAllocator] allocating new datafile /opt/mongodata/r1/local.0, filling with zeroes...
Tue Nov 1 14:23:01 [FileAllocator] done allocating datafile /opt/mongodata/r1/local.0, size: 64MB, took 3.807 secs
Tue Nov 1 14:23:01 [FileAllocator] allocating new datafile /opt/mongodata/r1/local.1, filling with zeroes...
Tue Nov 1 14:23:02 [rsStart] replSet saveConfigLocally done
Tue Nov 1 14:23:02 [FileAllocator] done allocating datafile /opt/mongodata/r1/local.1, size: 128MB, took 1.068 secs
Tue Nov 1 14:23:02 [rsStart] replSet STARTUP2
Tue Nov 1 14:23:02 [rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
Tue Nov 1 14:23:02 [rsSync] ******
####建立oplog 日誌檔案####
Tue Nov 1 14:23:02 [rsSync] creating replication oplog of size: 944MB...
Tue Nov 1 14:23:02 [FileAllocator] allocating new datafile /opt/mongodata/r1/local.2, filling with zeroes...
Tue Nov 1 14:23:04 [rsHealthPoll] replSet info member 10.250.7.220:27018 is up
Tue Nov 1 14:23:04 [rsHealthPoll] replSet member 10.250.7.220:27018 is now in state SECONDARY
Tue Nov 1 14:23:04 [rsHealthPoll] replSet info member 10.250.7.220:27019 is up
Tue Nov 1 14:23:04 [rsHealthPoll] replSet member 10.250.7.220:27019 is now in state SECONDARY
Tue Nov 1 14:23:04 [rsHealthPoll] replSet info member 10.250.7.220:27020 is up
Tue Nov 1 14:23:04 [rsHealthPoll] replSet member 10.250.7.220:27020 is now in state PRIMARY
Tue Nov 1 14:23:49 [FileAllocator] done allocating datafile /opt/mongodata/r1/local.2, size: 1024MB, took 46.28 secs
Tue Nov 1 14:23:50 [rsSync] ******
####應用主庫的日誌,複製資料檔案####
Tue Nov 1 14:23:50 [rsSync] replSet initial sync pending
Tue Nov 1 14:23:50 [rsSync] replSet syncing to: 10.250.7.220:27020
Tue Nov 1 14:23:50 [rsSync] build index local.me { _id: 1 }
Tue Nov 1 14:23:50 [rsSync] build index done 0 records 0.003 secs
Tue Nov 1 14:23:50 [rsSync] replSet initial sync drop all databases
Tue Nov 1 14:23:50 [rsSync] dropAllDatabasesExceptLocal 1
Tue Nov 1 14:23:50 [rsSync] replSet initial sync clone all databases
Tue Nov 1 14:23:50 [rsSync] replSet initial sync cloning db: test
Tue Nov 1 14:23:50 [FileAllocator] allocating new datafile /opt/mongodata/r1/test.ns, filling with zeroes...
Tue Nov 1 14:23:51 [FileAllocator] done allocating datafile /opt/mongodata/r1/test.ns, size: 16MB, took 0.8 secs
Tue Nov 1 14:23:51 [FileAllocator] allocating new datafile /opt/mongodata/r1/test.0, filling with zeroes...
Tue Nov 1 14:23:55 [FileAllocator] done allocating datafile /opt/mongodata/r1/test.0, size: 64MB, took 3.643 secs
Tue Nov 1 14:23:55 [FileAllocator] allocating new datafile /opt/mongodata/r1/test.1, filling with zeroes...
Tue Nov 1 14:23:55 [rsSync] build index test.yql { _id: 1 }
Tue Nov 1 14:23:56 [rsSync] build index done 1 records 0.006 secs
Tue Nov 1 14:23:56 [rsSync] replSet initial sync query minValid
Tue Nov 1 14:23:56 [rsSync] replSet initial oplog application from 10.250.7.220:27020 starting at Nov 1 14:14:05:1 to Nov 1 14:14:05:1
Tue Nov 1 14:23:57 [rsSync] replSet initial sync finishing up
Tue Nov 1 14:23:57 [rsSync] replSet set minValid=4eaf8e2d:1
Tue Nov 1 14:23:57 [rsSync] build index local.replset.minvalid { _id: 1 }
Tue Nov 1 14:23:57 [rsSync] build index done 0 records 0.023 secs
Tue Nov 1 14:23:57 [rsSync] replSet initial sync done
Tue Nov 1 14:23:58 [rsSync] replSet syncing to: 10.250.7.220:27020
Tue Nov 1 14:23:58 [rsSync] replSet SECONDARY
Tue Nov 1 14:24:02 [FileAllocator] done allocating datafile /opt/mongodata/r1/test.1, size: 128MB, took 7.428 secs
Tue Nov 1 14:24:16 [clientcursormon] mem (MB) res:16 virt:2848 mapped:1312
Tue Nov 1 14:24:42 [initandlisten] connection accepted from 127.0.0.1:21141 #5
Tue Nov 1 14:29:16 [clientcursormon] mem (MB) res:16 virt:2849 mapped:1312
Tue Nov 1 14:34:16 [clientcursormon] mem (MB) res:16 virt:2913 mapped:1312
Tue Nov 1 14:39:16 [clientcursormon] mem (MB) res:16 virt:2913 mapped:1312
===下面是刪除節點以後的日誌==
Tue Nov 1 14:39:28 [conn2] end connection 10.250.7.220:54235
Tue Nov 1 14:39:29 [rsMgr] replset msgReceivedNewConfig version: version: 3
Tue Nov 1 14:39:29 [rsMgr] replSet info saving a newer config version to local.system.replset
Tue Nov 1 14:39:29 [rsMgr] replSet saveConfigLocally done
Tue Nov 1 14:39:29 [rsMgr] replSet error self not present in the repl set configuration:
Tue Nov 1 14:39:29 [rsMgr] { _id: "myset", version: 3, members: [ { _id: 0, host: "10.250.7.220:27018" }, { _id: 1, host: "10.250.7.220:27019" }, { _id: 2, host: "10.
250.7.220:27020" } ] }
-------------------------------------------------------------------------
這是複製replica set myset 中其他節點的資料檔案!(記住是資料檔案,一定不要mongod.lock ,每個mongod程式都需要自己的資料目錄,如果你要執行3個mongod的例項,那麼就需要3個獨自的目錄。mongod啟動的時候會在資料目錄建立一個mongod.lock檔案,阻止其他程式使用此目錄.)
####連線primary庫,這一點和上面一種方法一樣。
Tue Nov 1 15:53:24 [initandlisten] connection accepted from 10.250.7.220:54761 #2
Tue Nov 1 15:53:28 [initandlisten] connection accepted from 10.250.7.220:54763 #3
Tue Nov 1 15:53:28 [initandlisten] connection accepted from 10.250.7.220:54764 #4
Tue Nov 1 15:53:34 [clientcursormon] mem (MB) res:31 virt:2606 mapped:1232
Tue Nov 1 15:53:34 [rsStart] trying to contact 10.250.7.220:27018
Tue Nov 1 15:53:34 [rsStart] trying to contact 10.250.7.220:27019
Tue Nov 1 15:53:34 [rsStart] trying to contact 10.250.7.220:27020
####複製配置檔案,並儲存。這一點和上面一種方法一樣。
Tue Nov 1 15:53:34 [rsStart] replSet got config version 6 from a remote, saving locally
Tue Nov 1 15:53:34 [rsStart] replSet info saving a newer config version to local.system.replset
Tue Nov 1 15:53:34 [rsStart] replSet saveConfigLocally done
Tue Nov 1 15:53:34 [rsStart] replSet STARTUP2
Tue Nov 1 15:53:34 [rsMgr] replSet total number of votes is even - add arbiter or give one member an extra vote
Tue Nov 1 15:53:34 [rsSync] replSet SECONDARY
Tue Nov 1 15:53:34 [rsHealthPoll] replSet info member 10.250.7.220:27018 is up
Tue Nov 1 15:53:34 [rsHealthPoll] replSet member 10.250.7.220:27018 is now in state SECONDARY
Tue Nov 1 15:53:34 [rsHealthPoll] replSet info member 10.250.7.220:27019 is up
Tue Nov 1 15:53:34 [rsHealthPoll] replSet member 10.250.7.220:27019 is now in state SECONDARY
Tue Nov 1 15:53:34 [rsHealthPoll] replSet info member 10.250.7.220:27020 is up
Tue Nov 1 15:53:34 [rsHealthPoll] replSet member 10.250.7.220:27020 is now in state PRIMARY
Tue Nov 1 15:53:34 [rsMgr] replSet can't see a majority, will not try to elect self
Tue Nov 1 15:53:38 [rsSync] replSet syncing to: 10.250.7.220:27020
從上面的日誌來看,整個第二種方法初始化的速度比較快。當然考慮複製資料檔案的時間,在大量資料的時候,才能看到哪一個比較好!
Note:學習mongodb 的時候注意檢視輸出日誌。從裡面能看到很多重要的資訊。如果對mongodb 進行監控的話,也要對輸出日誌進行分析!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22664653/viewspace-710057/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【Mongodb】 replica set 新增和刪除節點。MongoDB
- 【Mongodb】如何建立mongodb的replica setMongoDB
- mongodb 3.0 replica set 配置MongoDB
- [MONGODB]: WHEN ARBITER REQUIRED FOR REPLICA SETMongoDBUI
- 【Mongodb】 Replica set 的讀寫分離MongoDB
- MongoDB Replica Set 副本集實踐MongoDB
- MongoDB搭建Replica Set複製集MongoDB
- 【Mongodb】Replica Set 的選舉策略之三MongoDB
- 【Mongodb】 Replica set 的 選舉策略之二MongoDB
- 【Mongodb】 Replica set 的選舉策略之一MongoDB
- mongodb replica set 和 nodejs中使用mongoose連線replicaMongoDBNodeJS
- docker 下部署mongodb Replica Set 叢集DockerMongoDB
- SQL SERVER日誌清除的兩種方法(轉)SQLServer
- mongodb複製集(replica set)搭建及管理MongoDB
- 【MongoDB】高可用方案之副本集(Replica Set)MongoDB
- alert日誌中的兩種ORA錯誤分析
- 節點2線上日誌生成歸檔日誌在節點1上的初步分析
- RAC各節點時間同步的兩種方法
- mongodb 日誌分析工具mtoolsMongoDB
- MongoDB 日誌分析工具 mtoolsMongoDB
- mongodb副本集新增刪除節點MongoDB
- MongoDB副本集replica set (二)--副本集環境搭建MongoDB
- mongodb叢集shard_replica的搭建方法MongoDB
- MongoDB系列-解決面試中可能遇到的MongoDB複製集(replica set)問題MongoDB面試
- 小丸子學MongoDB系列之——部署Replica Set+Sharded ClusterMongoDB
- 新增redo日誌的時候,錯誤新增了一個節點的redo,怎麼辦?
- 兩種Java容器類List和Set分析Java
- mongodb叢集節點故障的切換方法MongoDB
- RAC節點日誌目錄是必要的!
- tomcat日誌集中採集、分析與展示的幾種方法Tomcat
- 教你兩種新增網路印表機的方法
- Apache Camel日誌四種方法Apache
- 多種分割WebServer日誌的方法(轉)WebServer
- mongodb replica sets 測試MongoDB
- 日誌分析-apache日誌分析Apache
- MongoDB資料庫的兩種正確停庫方法MongoDB資料庫
- 做實驗驗證MongoDB分頁的兩種方法MongoDB
- mongodb常用的兩種group方法,以及對結果排序MongoDB排序