#启动mongod sudo ./mongod --replSet "rs0" #另一个终端运行mongo sudo ./mongo #副本集初始化 rs.initiate() """返回 "info2" : "no configuration specified. Using a default configuration for the set", "me" : "localhost:27017", "ok" : 1, "operationTime" : Timestamp(1599449053, 1), "$clusterTime" : "clusterTime" : Timestamp(1599449053, 1), "signature" : "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) """ #验证初始化副本集的配置 rs.conf() """返回 "_id" : "rs0", "version" : 1, "protocolVersion" : NumberLong(1), "writeConcernMajorityJournalDefault" : true, "members" : [ "_id" : 0, "host" : "localhost:27017", "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("5f55a7dd29ddc8eeb2ffcca8") """ #验证副本集的状态 rs.status() """返回 "set" : "rs0", "date" : ISODate("2020-09-07T03:37:53.317Z"), "myState" : 1, "term" : NumberLong(1), "syncingTo" : "", "syncSourceHost" : "", "syncSourceId" : -1, "heartbeatIntervalMillis" : NumberLong(2000), "optimes" : "lastCommittedOpTime" : "ts" : Timestamp(1599449865, 1), "t" : NumberLong(1) , "readConcernMajorityOpTime" : "ts" : Timestamp(1599449865, 1), "t" : NumberLong(1) , "appliedOpTime" : "ts" : Timestamp(1599449865, 1), "t" : NumberLong(1) , "durableOpTime" : "ts" : Timestamp(1599449865, 1), "t" : NumberLong(1) , "lastStableCheckpointTimestamp" : Timestamp(1599449835, 1), "members" : [ "_id" : 0, "name" : "localhost:27017", "health" : 1, "state" : 1, "stateStr" : "PRIMARY", "uptime" : 920, "optime" : "ts" : Timestamp(1599449865, 1), "t" : NumberLong(1) , "optimeDate" : ISODate("2020-09-07T03:37:45Z"), "syncingTo" : "", "syncSourceHost" : "", "syncSourceId" : -1, "infoMessage" : "", "electionTime" : Timestamp(1599449053, 2), "electionDate" : ISODate("2020-09-07T03:24:13Z"), "configVersion" : 1, "self" : true, "lastHeartbeatMessage" : "" ], "ok" : 1, "operationTime" : Timestamp(1599449865, 1), "$clusterTime" : "clusterTime" : Timestamp(1599449865, 1), "signature" : "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) """ #ES端同步操作 mongo-connector -m localhost:27017 -t localhost:9200 -n runoob.student -d elastic2_doc_manager |