The installation of Mongod in RS cluster is the same as a single machine, but the configuration file is slightly different,
Standalone installation path Linux under MongoDB 3.2.5 installation
The following is the RS cluster configuration file:
Systemlog:
Destination:file
Path:/home/mongodb/log1/mongod.log # #log的路径
Logappend:true
Storage
Journal
Enabled:true
DbPath:/home/mongodb/data # #数据的路径
Directoryperdb:true
Engine:wiredtiger
Wiredtiger:
Engineconfig:
Cachesizegb:6 # #这个值根据自己的机器的内存进行修改
Directoryforindexes:true
Collectionconfig:
Blockcompressor:zlib
Indexconfig:
Prefixcompression:true
Replication
oplogsizemb:10000
Replsetname:luo
Net
port:27018 # #根据自己的需要进行修改
Template of the configuration file I put a copy in the \\10.10.10.1\ShareDoc\User\luozhitao\replica set. Modify the next path and Replsetname.
After starting the Mongod instance on three machines, configure replica set, select any machine
./mongo 10.10.5.248:27018 After landing
> Use admin
Switched to DB admin
> cfg3 = {_id: "Luo", members:[
{_id:0,host: "10.10.7.33:27019", priority:1000},
{_id:1,host: "10.10.5.248:27018", priority:999},
{_id:2,host: "10.10.5.248:27017", priority:800, Arbiteronly:true}
]
}
> Rs.initiate (CFG3)
Press ENTER until it appears
Luo:primary>
Luo:primary> Rs.status ()
{
"Set": "Luo",
"Date": Isodate ("2016-04-26t07:48:53.958z"),
"MyState": 1,
"Term": Numberlong (1),
"Heartbeatintervalmillis": Numberlong (2000),
"Members": [
{
"_id": 0,
"Name": "10.10.7.33:27019",
"Health": 1,
"State": 1,
"Statestr": "PRIMARY",
"Uptime": 753,
"Optime": {
"TS": Timestamp (1461656928, 1),
"T": Numberlong (1)
},
"Optimedate": Isodate ("2016-04-26t07:48:48z"),
"InfoMessage": "Could not find member-sync from",
"Electiontime": Timestamp (1461656927, 1),
"Electiondate": Isodate ("2016-04-26t07:48:47z"),
"ConfigVersion": 1,
"Self": true
},
{
"_id": 1,
"Name": "10.10.5.248:27018",
"Health": 1,
"State": 2,
"Statestr": "Secondary",
"Uptime": 17,
"Optime": {
"TS": Timestamp (1461656928, 1),
"T": Numberlong (1)
},
"Optimedate": Isodate ("2016-04-26t07:48:48z"),
"Lastheartbeat": Isodate ("2016-04-26t07:48:53.377z"),
"Lastheartbeatrecv": Isodate ("2016-04-26t07:48:49.622z"),
"Pingms": Numberlong (1),
"Syncingto": "10.10.7.33:27019",
"ConfigVersion": 1
},
{
"_id": 2,
"Name": "10.10.5.248:27017",
"Health": 1,
"State": 7,
"Statestr": "Arbiter",
"Uptime": 17,
"Lastheartbeat": Isodate ("2016-04-26t07:48:53.377z"),
"Lastheartbeatrecv": Isodate ("2016-04-26t07:48:52.642z"),
"Pingms": Numberlong (0),
"ConfigVersion": 1
}
],
"OK": 1
}
Installation Successful
Linux MongoDB replica set cluster installation