[wangshumin@CentOSNode2 conf]$ mongo CentOSNode2:22002
MongoDB shell version v3.6.4
connecting to: mongodb://CentOSNode2:22002/test
MongoDB server version: 3.6.4
Server has startup warnings:
2018-05-16T15:27:59.841+0800 I CONTROL [initandlisten]
2018-05-16T15:27:59.841+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-05-16T15:27:59.841+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-05-16T15:27:59.841+0800 I CONTROL [initandlisten]
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten]
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten]
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten]
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 65536 files. Number of processes should be at least 32768 : 0.5 times number of files.
2018-05-16T15:27:59.842+0800 I CONTROL [initandlisten]
> use admin
switched to db admin
> config = {_id:"shard2",members:[
... {_id:0,host:"CentOSNode1:22002"},
... {_id:1,host:"CentOSNode2:22002",arbiterOnly:true},
... {_id:2,host:"CentOSNode3:22002"},]
... }
{
"_id" : "shard2",
"members" : [
{
"_id" : 0,
"host" : "CentOSNode1:22002"
},
{
"_id" : 1,
"host" : "CentOSNode2:22002",
"arbiterOnly" : true
},
{
"_id" : 2,
"host" : "CentOSNode3:22002"
}
]
}
> rs.initiate(config);
{
"ok" : 0,
"errmsg" : "This node, CentOSNode2:22002, with _id 1 is not electable under the new configuration version 1 for replica set shard2",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}
> config = {_id:"shard2",members:[
... {_id:0,host:"CentOSNode1:22002"},
... {_id:1,host:"CentOSNode2:22002"},
... {_id:2,host:"CentOSNode3:22002",arbiterOnly:true},]
... }
{
"_id" : "shard2",
"members" : [
{
"_id" : 0,
"host" : "CentOSNode1:22002"
},
{
"_id" : 1,
"host" : "CentOSNode2:22002"
},
{
"_id" : 2,
"host" : "CentOSNode3:22002",
"arbiterOnly" : true
}
]
}
> rs.initiate(config);
{ "ok" : 1 }
仲裁不能再同一台服务器上换下就可以。