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 Size的值MongoDB
- mongodb 基於oplog的時間點恢復MongoDB
- MongoDB案例分享:如何使用oplog恢復資料MongoDB
- mongodb使用備份後的oplog做時間點恢復MongoDB
- mongodb異機做時間點恢復(基於時間範圍查詢匯出oplog)MongoDB
- 剖析後OpLog訂閱MongoDB的資料變更就沒那麼難了MongoDB
- Homestead 開啟mongodb正確姿勢MongoDB
- 怎樣開啟mongodb服務端?MongoDB服務端
- 怎樣開啟mongodb資料庫MongoDB資料庫
- mongodb服務無法開啟怎麼辦MongoDB
- mongodb 啟動故障MongoDB
- mongodb單機從3.2升級到4.0.4升級MongoDB
- 單機Linux下搭建MongoDB副本集-三節點LinuxMongoDB
- MongoDB 簡單上手MongoDB
- MongoDB配置與啟動MongoDB
- 開機啟動
- Go控制Docker啟動MongoDBDockerMongoDB
- 華碩主機板開啟vt怎麼操作 華碩主機板開啟vt虛擬化最簡單步驟
- 開機啟動項
- YashanDB 開機自啟
- C#簡單操作MongoDBC#MongoDB
- MongoDB索引的簡單理解MongoDB索引
- 初探Nacos(一)-- 單機模式啟動模式
- Apache DolphinScheduler如何開啟開機自啟動功能?Apache
- KVM虛機開機自啟和取消自啟動
- mongodb服務在哪裡啟動?MongoDB
- mongoDB當機修復MongoDB
- MongoDB 複製機制MongoDB
- win10快速啟動開啟開機黑屏怎麼辦 win10開啟快速啟動開機黑屏如何解決Win10
- nacos 加入開機啟動
- .Net Core中簡單使用MongoDBMongoDB
- NoSLQ之MongoDB簡單入門MongoDB
- jmeter 單機可以開啟多大多少執行緒?怎麼評估?JMeter執行緒
- 如何安裝MongoDB併成功啟動MongoDB
- mongodb的安裝和啟動方法MongoDB
- mongodb啟動報錯怎麼辦MongoDB