SCCC to CSRS
Config
Servers
tommy1 – 27018 – 1st
tommy2 – 27018 – 2nd
tommy3 – 27018 – 3rd
Mongos
server
tommongo
1)
Disable the balancer - tommongo
> login to tommongo server
> connect to mongos
> mongo admin --port 27017
# mongos> sh.getBalancerState()
true
# mongos> sh.stopBalancer() or
# mongos> sh.disableBalancer()
# mongos> sh.getBalancerState()
false
2)
Connect a mongo shell to the first config server - tommy1
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
> Initiate the single member replica set
# rs.initiate( {
_id: "CSRS",
configsvr: true,
version: 1,
members: [ { _id: 0, host: "tommy1:27018" } ]
} )
3)
Restart this first config server as a single member replica set - tommy1
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
# db.shutdownServer()
check the process again
# ps aux | grep mongo
> Make the necessary changes in the
config file
# vi
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
sharding:
clusterRole: configsvr
configsvrMode: sccc
replication:
replSetName: CSRS
net:
port: <port>
storage:
dbPath: <path>
engine: <storageEngine>
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
check the process again
# ps aux | grep mongo
4)
Start the new mongod instances to add to the replica set.
tommy2
– 2nd
login to tommy2 server
check the process
# ps aux | grep mongo
Start another mongo instance with new dbpath
> Make the necessary changes in the
config file
# vi
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
sharding:
clusterRole: configsvr
replication:
replSetName: csReplSet
net:
port: <port>
storage:
dbPath: <path>
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
check the process again
# ps aux | grep mongo
tommy3
– 3rd
login to tommy3 server
check the process
# ps aux | grep mongo
Start another mongo instance with new dbpath
> Make the necessary changes in the
config file
# vi
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
sharding:
clusterRole: configsvr
replication:
replSetName: csReplSet
net:
port: <port>
storage:
dbPath: <path>
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
check the process again
# ps aux | grep mongo
5)
Connect to first config server, add the new mongod instances as non-voting,
priority 0 members
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
# rs.add( { host: tommy2:27018, priority: 0,
votes: 0 } )
# rs.add( { host: tommy3:27018, priority: 0,
votes: 0 } )
6)
Wait till new nodes have completed the initial sync and have reached SECONDARY
state.
To check
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
# rs.status()
7)
Shut down one of the other non-replica set config servers - tommy2 – 2nd
login to tommy2 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
# db.shutdownServer()
check the process again
# ps aux | grep mongo
8)
Reconfigure the replica set - tommy1 – 1st
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
var cfg = rs.conf();
cfg.members[0].priority = 1;
cfg.members[1].priority = 1;
cfg.members[2].priority = 1;
cfg.members[3].priority = 1;
cfg.members[0].votes = 1;
cfg.members[1].votes = 1;
cfg.members[2].votes = 1;
cfg.members[3].votes = 1;
rs.reconfig(cfg);
9)
Step down the first config server - tommy1
– 1st
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
# rs.stepDown(600)
10)
Shut down the first config server - tommy1 – 1st
login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27018
# db.shutdownServer()
check the process again
# ps aux | grep mongo
11)
Restart the first config server in config server replica set (CSRS) mode - tommy1
– 1st
> Make the necessary changes in the
config file
# vi
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
sharding:
clusterRole: configsvr
replication:
replSetName: csReplSet
net:
port: <port>
storage:
dbPath: <path>
engine: <storageEngine>
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f
/data/usr/mongodb_3.2.16/conf/mongod_config.conf
check the process again
# ps aux | grep mongo
12)
Restart mongos instances with updated config files - tommongo – mongos
login to tommongo server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27017
# db.shutdownServer()
check the process again
# ps aux | grep mongo
> Make the necessary changes in the
config file
# vi /data/usr/mongodb_3.2.16/conf/mongos.conf
sharding:
configDB: tommy1:27018,tommy2:27018,tommy3:27018
change
to
sharding:
configDB: csReplSet/tommy1:27018,tommy2:27018,tommy3:27018
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongos -f
/data/usr/mongodb_3.2.16/conf/mongos.conf
check the process again
# ps aux | grep mongo
13)
Verify that the restarted mongos instances are aware of the protocol change- tommongo
– mongos
login to tommongo server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27017
# use config
# db.mongos.find()
- The ping value for the mongos instances
should indicate some time after the restart.
14)
Shut down the remaining non-replica set config server.
15)
Re-enable the balancer- tommongo – mongos
- login to tommongo server
- connect to mongo
# mongo --port 27017
# mongos> sh.getBalancerState()
false
# mongos> sh.startBalancer()
# mongos> sh.getBalancerState()
true
No comments:
Post a Comment