zoukankan      html  css  js  c++  java
  • mongodb的副本集方法

    方法名描述
    rs.initiate()  
    rs.addArb()  
    rs.help()  
    rs.printReplicationInfo() 查看到副本集操作日志
    rs.remove() 减少副本集节点
    rs.freeze() “冻结”mongodb实例
    rs.status() 查看副本集状态
    db.printSlaveReplicationInfo 查看复制集的同步状态
    rs.add() 增加副本集节点
    rs.stepDown() 将当前主库“降级”
    rs.slaveOk()  
    rs.conf()  
    rs.syncFrom()  
    rs.reconfig()

    glc-test:PRIMARY> rs.help()
            rs.status()                                { replSetGetStatus : 1 } checks repl set status
            rs.initiate()                              { replSetInitiate : null } initiates set with default settings
            rs.initiate(cfg)                           { replSetInitiate : cfg } initiates set with configuration cfg
            rs.conf()                                  get the current configuration object from local.system.replset
            rs.reconfig(cfg)                           updates the configuration of a running replica set with cfg (disconnects)
            rs.add(hostportstr)                        add a new member to the set with default attributes (disconnects)
            rs.add(membercfgobj)                       add a new member to the set with extra attributes (disconnects)
            rs.addArb(hostportstr)                     add a new member which is arbiterOnly:true (disconnects)
            rs.stepDown([stepdownSecs, catchUpSecs])   step down as primary (disconnects)
            rs.syncFrom(hostportstr)                   make a secondary sync from the given member
            rs.freeze(secs)                            make a node ineligible to become primary for the time specified
            rs.remove(hostportstr)                     remove a host from the replica set (disconnects)
            rs.slaveOk()                               allow queries on secondary nodes
    
            rs.printReplicationInfo()                  check oplog size and time range
            rs.printSlaveReplicationInfo()             check replica set members and replication lag
            db.isMaster()                              check who is primary
    
            reconfiguration helpers disconnect from the database so the shell will display
            an error, even if the command succeeds.
    glc-test:PRIMARY> 
    glc-test:PRIMARY> 
    glc-test:PRIMARY>  rs.slaveOk()
    glc-test:PRIMARY> 
    glc-test:PRIMARY> 
    glc-test:PRIMARY> db.isMaster()
    {
            "hosts" : [
                    "c3-dba-glc-db03.bj:28042",
                    "c4-mc-buffer-db41.bj:28042",
                    "c4-using-glc-db05.bj:28042"
            ],
            "setName" : "glc-test",
            "setVersion" : 3,
            "ismaster" : true,
            "secondary" : false,
            "primary" : "c4-mc-buffer-db41.bj:28042",
            "me" : "c4-mc-buffer-db41.bj:28042",
            "electionId" : ObjectId("7fffffff0000000000000071"),
            "lastWrite" : {
                    "opTime" : {
                            "ts" : Timestamp(1604998554, 1),
                            "t" : NumberLong(113)
                    },
                    "lastWriteDate" : ISODate("2020-11-10T08:55:54Z"),
                    "majorityOpTime" : {
                            "ts" : Timestamp(1604998554, 1),
                            "t" : NumberLong(113)
                    },
                    "majorityWriteDate" : ISODate("2020-11-10T08:55:54Z")
            },
            "maxBsonObjectSize" : 16777216,
            "maxMessageSizeBytes" : 48000000,
            "maxWriteBatchSize" : 100000,
            "localTime" : ISODate("2020-11-10T08:55:57.034Z"),
            "logicalSessionTimeoutMinutes" : 30,
            "minWireVersion" : 0,
            "maxWireVersion" : 7,
            "readOnly" : false,
            "ok" : 1,
            "operationTime" : Timestamp(1604998554, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1604998554, 1),
                    "signature" : {
                            "hash" : BinData(0,"ClLo/8FOOXSQJ0zson/tzskvsOI="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> rs.printReplicationInfo()  
    configured oplog size:   16384MB
    log length start to end: 350295secs (97.3hrs)
    oplog first event time:  Fri Nov 06 2020 15:37:49 GMT+0800 (CST)
    oplog last event time:   Tue Nov 10 2020 16:56:04 GMT+0800 (CST)
    now:                     Tue Nov 10 2020 16:56:07 GMT+0800 (CST)
    glc-test:PRIMARY> rs.printSlaveReplicationInfo()
    source: c3-dba-glc-db03.bj:28042
            syncedTo: Tue Nov 10 2020 16:56:04 GMT+0800 (CST)
            0 secs (0 hrs) behind the primary 
    source: c4-using-glc-db05.bj:28042
            syncedTo: Tue Nov 10 2020 16:56:04 GMT+0800 (CST)
            0 secs (0 hrs) behind the primary 
    glc-test:PRIMARY>  rs.conf()  
    {
            "_id" : "glc-test",
            "version" : 3,
            "protocolVersion" : NumberLong(1),
            "writeConcernMajorityJournalDefault" : true,
            "members" : [
                    {
                            "_id" : 0,
                            "host" : "c3-dba-glc-db03.bj:28042",
                            "arbiterOnly" : false,
                            "buildIndexes" : true,
                            "hidden" : false,
                            "priority" : 1,
                            "tags" : {
    
                            },
                            "slaveDelay" : NumberLong(0),
                            "votes" : 1
                    },
                    {
                            "_id" : 1,
                            "host" : "c4-mc-buffer-db41.bj:28042",
                            "arbiterOnly" : false,
                            "buildIndexes" : true,
                            "hidden" : false,
                            "priority" : 1,
                            "tags" : {
    
                            },
                            "slaveDelay" : NumberLong(0),
                            "votes" : 1
                    },
                    {
                            "_id" : 2,
                            "host" : "c4-using-glc-db05.bj:28042",
                            "arbiterOnly" : false,
                            "buildIndexes" : true,
                            "hidden" : false,
                            "priority" : 1,
                            "tags" : {
    
                            },
                            "slaveDelay" : NumberLong(0),
                            "votes" : 1
                    }
            ],
            "settings" : {
                    "chainingAllowed" : true,
                    "heartbeatIntervalMillis" : 2000,
                    "heartbeatTimeoutSecs" : 10,
                    "electionTimeoutMillis" : 10000,
                    "catchUpTimeoutMillis" : -1,
                    "catchUpTakeoverDelayMillis" : 30000,
                    "getLastErrorModes" : {
    
                    },
                    "getLastErrorDefaults" : {
                            "w" : 1,
                            "wtimeout" : 0
                    },
                    "replicaSetId" : ObjectId("5f277b18c13c2cbe19624b2d")
            }
    }
    glc-test:PRIMARY>  rs.status()
    {
            "set" : "glc-test",
            "date" : ISODate("2020-11-10T08:56:26.438Z"),
            "myState" : 1,
            "term" : NumberLong(113),
            "syncingTo" : "",
            "syncSourceHost" : "",
            "syncSourceId" : -1,
            "heartbeatIntervalMillis" : NumberLong(2000),
            "optimes" : {
                    "lastCommittedOpTime" : {
                            "ts" : Timestamp(1604998584, 1),
                            "t" : NumberLong(113)
                    },
                    "readConcernMajorityOpTime" : {
                            "ts" : Timestamp(1604998584, 1),
                            "t" : NumberLong(113)
                    },
                    "appliedOpTime" : {
                            "ts" : Timestamp(1604998584, 1),
                            "t" : NumberLong(113)
                    },
                    "durableOpTime" : {
                            "ts" : Timestamp(1604998584, 1),
                            "t" : NumberLong(113)
                    }
            },
            "lastStableCheckpointTimestamp" : Timestamp(1604998534, 1),
            "electionCandidateMetrics" : {
                    "lastElectionReason" : "stepUpRequestSkipDryRun",
                    "lastElectionDate" : ISODate("2020-10-20T08:13:43.452Z"),
                    "electionTerm" : NumberLong(113),
                    "lastCommittedOpTimeAtElection" : {
                            "ts" : Timestamp(1603181617, 1),
                            "t" : NumberLong(112)
                    },
                    "lastSeenOpTimeAtElection" : {
                            "ts" : Timestamp(1603181617, 1),
                            "t" : NumberLong(112)
                    },
                    "numVotesNeeded" : 2,
                    "priorityAtElection" : 1,
                    "electionTimeoutMillis" : NumberLong(10000),
                    "priorPrimaryMemberId" : 0,
                    "numCatchUpOps" : NumberLong(0),
                    "newTermStartDate" : ISODate("2020-10-20T08:13:43.456Z"),
                    "wMajorityWriteAvailabilityDate" : ISODate("2020-10-20T08:13:43.458Z")
            },
            "electionParticipantMetrics" : {
                    "votedForCandidate" : true,
                    "electionTerm" : NumberLong(112),
                    "lastVoteDate" : ISODate("2020-09-22T06:24:36.196Z"),
                    "electionCandidateMemberId" : 0,
                    "voteReason" : "",
                    "lastAppliedOpTimeAtElection" : {
                            "ts" : Timestamp(1600755874, 1),
                            "t" : NumberLong(111)
                    },
                    "maxAppliedOpTimeInSet" : {
                            "ts" : Timestamp(1600755874, 1),
                            "t" : NumberLong(111)
                    },
                    "priorityAtElection" : 1
            },
            "members" : [
                    {
                            "_id" : 0,
                            "name" : "c3-dba-glc-db03.bj:28042",
                            "health" : 1,
                            "state" : 2,
                            "stateStr" : "SECONDARY",
                            "uptime" : 4243441,
                            "optime" : {
                                    "ts" : Timestamp(1604998584, 1),
                                    "t" : NumberLong(113)
                            },
                            "optimeDurable" : {
                                    "ts" : Timestamp(1604998584, 1),
                                    "t" : NumberLong(113)
                            },
                            "optimeDate" : ISODate("2020-11-10T08:56:24Z"),
                            "optimeDurableDate" : ISODate("2020-11-10T08:56:24Z"),
                            "lastHeartbeat" : ISODate("2020-11-10T08:56:24.572Z"),
                            "lastHeartbeatRecv" : ISODate("2020-11-10T08:56:24.820Z"),
                            "pingMs" : NumberLong(1),
                            "lastHeartbeatMessage" : "",
                            "syncingTo" : "c4-mc-buffer-db41.bj:28042",
                            "syncSourceHost" : "c4-mc-buffer-db41.bj:28042",
                            "syncSourceId" : 1,
                            "infoMessage" : "",
                            "configVersion" : 3
                    },
                    {
                            "_id" : 1,
                            "name" : "c4-mc-buffer-db41.bj:28042",
                            "health" : 1,
                            "state" : 1,
                            "stateStr" : "PRIMARY",
                            "uptime" : 6401661,
                            "optime" : {
                                    "ts" : Timestamp(1604998584, 1),
                                    "t" : NumberLong(113)
                            },
                            "optimeDate" : ISODate("2020-11-10T08:56:24Z"),
                            "syncingTo" : "",
                            "syncSourceHost" : "",
                            "syncSourceId" : -1,
                            "infoMessage" : "",
                            "electionTime" : Timestamp(1603181623, 1),
                            "electionDate" : ISODate("2020-10-20T08:13:43Z"),
                            "configVersion" : 3,
                            "self" : true,
                            "lastHeartbeatMessage" : ""
                    },
                    {
                            "_id" : 2,
                            "name" : "c4-using-glc-db05.bj:28042",
                            "health" : 1,
                            "state" : 2,
                            "stateStr" : "SECONDARY",
                            "uptime" : 4227596,
                            "optime" : {
                                    "ts" : Timestamp(1604998584, 1),
                                    "t" : NumberLong(113)
                            },
                            "optimeDurable" : {
                                    "ts" : Timestamp(1604998584, 1),
                                    "t" : NumberLong(113)
                            },
                            "optimeDate" : ISODate("2020-11-10T08:56:24Z"),
                            "optimeDurableDate" : ISODate("2020-11-10T08:56:24Z"),
                            "lastHeartbeat" : ISODate("2020-11-10T08:56:25.291Z"),
                            "lastHeartbeatRecv" : ISODate("2020-11-10T08:56:25.030Z"),
                            "pingMs" : NumberLong(0),
                            "lastHeartbeatMessage" : "",
                            "syncingTo" : "c4-mc-buffer-db41.bj:28042",
                            "syncSourceHost" : "c4-mc-buffer-db41.bj:28042",
                            "syncSourceId" : 1,
                            "infoMessage" : "",
                            "configVersion" : 3
                    }
            ],
            "ok" : 1,
            "operationTime" : Timestamp(1604998584, 1),
            "$clusterTime" : {
                    "clusterTime" : Timestamp(1604998584, 1),
                    "signature" : {
                            "hash" : BinData(0,"Sx7IW3xyv17MwDyskTFJOOQ8IeU="),
                            "keyId" : NumberLong("6856584343653974019")
                    }
            }
    }
    glc-test:PRIMARY> 

    ##################################

  • 相关阅读:
    ML
    python常用库函数
    ML神器:sklearn的快速使用
    分类算法
    离散型特征编码方式:one-hot与哑变量*
    LR多分类推广
    细品
    特征提取方法: one-hot 和 TF-IDF
    【数据化运营模型】目标客户的预测(响应、分类)模型
    【转】 Python 中,matplotlib绘图无法显示中文的问题
  • 原文地址:https://www.cnblogs.com/igoodful/p/13913316.html
Copyright © 2011-2022 走看看