MongoDB單機開啟oplog
修改引數檔案
[mongo@cjc-db-01 conf]$ vi mongodb.conf
###新增
replSet = cjcMongodb
重啟mongodb
停
> use admin; switched to db admin > db.shutdownServer();
啟
[mongo@cjc-db-01 ~]$ cd /mongodb/27017/conf/ [mongo@cjc-db-01 conf]$ mongod -f mongodb.conf
查詢
[mongo@cjc-db-01 conf]$ mongo --port 27017 > show dbs; 2023-02-08T17:15:54.317+0800 E QUERY [js] Error: listDatabases failed:{ "ok" : 0, "errmsg" : "not master and slaveOk=false", "code" : 13435, "codeName" : "NotMasterNoSlaveOk" } : _getErrorWithCode@src/mongo/shell/utils.js:25:13 Mongo.prototype.getDBs@src/mongo/shell/mongo.js:151:1 shellHelper.show@src/mongo/shell/utils.js:882:13 shellHelper@src/mongo/shell/utils.js:766:15 @(shellhelp2):1:1
初始化
> rs.initiate(); { "info2" : "no configuration specified. Using a default configuration for the set", "me" : "cjc-db-01:27017", "ok" : 1 }
再次查詢
cjcMongodb:SECONDARY> show dbs; admin 0.000GB cjcdb 0.000GB config 0.000GB local 0.000GB
cjcMongodb:PRIMARY> use local switched to db local
cjcMongodb:PRIMARY> show tables; oplog.rs replset.election replset.minvalid replset.oplogTruncateAfterPoint startup_log system.replset system.rollback.id
Oplog 儲存在 local 庫的 oplog.rs 集合裡面
cjcMongodb:PRIMARY> db.oplog.rs.find(); { "ts" : Timestamp(1675847798, 1), "h" : NumberLong("-4142341003137703290"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2023-02-08T09:16:38.168Z"), "o" : { "msg" : "initiating set" } } { "ts" : Timestamp(1675847798, 3), "t" : NumberLong(1), "h" : NumberLong("-8128858175787158320"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2023-02-08T09:16:38.174Z"), "o" : { "msg" : "new primary" } } { "ts" : Timestamp(1675847798, 4), "t" : NumberLong(1), "h" : NumberLong("2262279575084486449"), "v" : 2, "op" : "c", "ns" : "config.$cmd", "ui" : UUID("e1b444f6-20e3-4695-8ddb-45011cde7906"), "wall" : ISODate("2023-02-08T09:16:38.191Z"), "o" : { "create" : "image_collection", "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "config.image_collection" } } } { "ts" : Timestamp(1675847798, 5), "t" : NumberLong(1), "h" : NumberLong("-7259636297367536820"), "v" : 2, "op" : "c", "ns" : "config.$cmd", "ui" : UUID("4286a448-9182-44a6-b1fc-7ab1b0e79f1d"), "wall" : ISODate("2023-02-08T09:16:38.206Z"), "o" : { "create" : "transactions", "idIndex" : { "v" : 2, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "config.transactions" } } } ...... { "ts" : Timestamp(1675847938, 1), "t" : NumberLong(1), "h" : NumberLong("-2455973444836006621"), "v" : 2, "op" : "n", "ns" : "", "wall" : ISODate("2023-02-08T09:18:58.251Z"), "o" : { "msg" : "periodic noop" } } ...... cjcMongodb:PRIMARY> cjcMongodb:PRIMARY>
檢視Oplog狀態
cjcMongodb:PRIMARY> rs.printReplicationInfo() configured oplog size: 2654.523241996765MB log length start to end: 550secs (0.15hrs) oplog first event time: Wed Feb 08 2023 17:16:38 GMT+0800 (CST) oplog last event time: Wed Feb 08 2023 17:25:48 GMT+0800 (CST) now: Wed Feb 08 2023 17:25:51 GMT+0800 (CST)
###chenjuchao 20230208###
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2934443/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MongoDB更改oplog大小MongoDB
- MongoDB oplog詳解MongoDB
- mongodb修改oplog大小MongoDB
- MongoDB 如何保證 oplog 順序?MongoDB
- Mongodb 複製的紐帶–OplogMongoDB
- mongodb線上調整Oplog Size的值MongoDB
- MongoDB Oplog中的欄位介紹MongoDB
- MongoDB journal 與 oplog,究竟誰先寫入?MongoDB
- Mongodb 啟動關閉指令碼並設定開機自動啟動MongodbMongoDB指令碼
- mongodb 基於oplog的時間點恢復MongoDB
- MongoDB案例分享:如何使用oplog恢復資料MongoDB
- MongoDB如何查oplog.rs集合裡的操作日誌MongoDB
- linux下開機自動開啟單機oracleLinuxOracle
- Mongodb開啟與關閉MongoDB
- MongoDB Primary 為何持續出現 oplog 全表掃描?MongoDB
- mongodb使用備份後的oplog做時間點恢復MongoDB
- mongodb異機做時間點恢復(基於時間範圍查詢匯出oplog)MongoDB
- mongodb3.03開啟認證MongoDB
- 怎樣開啟mongodb服務端?MongoDB服務端
- 怎樣開啟mongodb資料庫MongoDB資料庫
- Homestead 開啟mongodb正確姿勢MongoDB
- mongodb啟動MongoDB
- 剖析後OpLog訂閱MongoDB的資料變更就沒那麼難了MongoDB
- mongodb服務無法開啟怎麼辦MongoDB
- mongodb 啟動故障MongoDB
- mongodb單機從3.2升級到4.0.4升級MongoDB
- 華碩主機板開啟vt怎麼操作 華碩主機板開啟vt虛擬化最簡單步驟
- MongoDB 簡單上手MongoDB
- 虛擬機器或真機除錯React Native, 開啟開發者選單虛擬機除錯React Native
- 單機Linux下搭建MongoDB副本集-三節點LinuxMongoDB
- Oracle之 服務啟動&停止指令碼與開機自啟動(單例項)Oracle指令碼單例
- nginx開機啟動Nginx
- oracle開機啟動Oracle
- MongoDB配置與啟動MongoDB
- mongodb 啟動報錯MongoDB
- KVM虛機開機自啟和取消自啟動
- 初探Nacos(一)-- 單機模式啟動模式
- MongoDB單點故障分析MongoDB