Friday, June 8, 2018

Upgrade Storage Engine - mmapv1 to wiredtiger - Implementation


mmapv1 to wiredTiger

Overview:

Shard1
tommy1 – Pri - 27019
tommy2 - Sec - 27019
tommy3 – Sec - 27019

Shard2
tommy4 - Pri - 27019
tommy5 - Sec - 27019
tommy6 - Sec - 27019

Config
tommy7 - 27018
tommy8 - 27018
tommy9 - 27018

Mongos
tommy10 – 27017

Create data directory in all the servers except mongos - tommy10
For tommy1, tommy2, tommy3, tommy4, tommy5, tommy6

# mkdir -p /data/usr/mongod_data
# chmod 775 /data/usr/mongod_data

For tommy7, tommy8, tommy9

# mkdir -p /data/usr/mongod_config_data
# chmod 775 /data/usr/mongod_config_data

Change each shard ( Replica Set ) to WiredTiger

Shard1

tommy2 – 1st Sec

login to tommy2 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
check the process again
# ps aux | grep mongo
Delete the existing data directory
# cd /data
# rm -rf emeatest_rs_0_11
Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod.conf
# Change the dbpath from /data/emeatest_rs_0_11 to /data/usr/mongod_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before upgrading the next secondary - to check
# mongo admin --port 27019
# rs.status()

tommy3 – 2nd Sec

login to tommy3 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
check the process again
# ps aux | grep mongo
Delete the existing data directory
# cd /data
# rm -rf emeatest_rs_0_12
Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod.conf
# Change the dbpath from /data/emeatest_rs_0_12 to /data/usr/mongod_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before upgrading the next secondary - to check
# mongo admin --port 27019
# rs.status() 

tommy1 – Pri

login to tommy1 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27019
Step down the primary
# rs.stepDown()
when the server become secondary
# use admin
# db.shutdownServer()
check the process again
# ps aux | grep mongo
Delete the existing data directory
# cd /data
# rm -rf emeatest_rs_0_13
Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod.conf
# Change the dbpath from /data/emeatest_rs_0_13 to /data/usr/mongod_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state - to check
# mongo admin --port 27019
# rs.status() 

Shard2

tommy5 – 1st Sec

login to tommy5 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
check the process again
# ps aux | grep mongo
Delete the existing data directory
# cd /data
# rm -rf emeatest_rs_1_16
Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod.conf
# Change the dbpath from /data/emeatest_rs_1_16 to /data/usr/mongod_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before upgrading the next secondary - to check
# mongo admin --port 27019
# rs.status()

tommy6 – 2nd Sec

login to tommy6 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
check the process again
# ps aux | grep mongo
Delete the existing data directory
# cd /data
# rm -rf /data/emeatest_rs_1_14
Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod.conf
# Change the dbpath from /data/emeatest_rs_1_14 to /data/usr/mongod_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before upgrading the next secondary - to check
# mongo admin --port 27019
# rs.status()

tommy4 - Pri

login to tommy4 server
check the process
# ps aux | grep mongo
connect to mongo
# mongo admin --port 27019
Step down the primary
# rs.stepDown()
when the server become secondary
# use admin
# db.shutdownServer()
check the process again
# ps aux | grep mongo
Delete the existing data directory
# cd /data
# rm -rf emeatest_rs_1_15
Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod.conf
# Change the dbpath from /data/emeatest_rs_1_15 to /data/usr/mongod_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# wq!
Start the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state - to check
# mongo admin --port 27019
# rs.status()

Config Servers:

1) Disable the balancer

> login to tommy10 server
> connect to mongos
> mongo admin --port 27017
# mongos> sh.getBalancerState()
true
# mongos> sh.stopBalancer() or
# mongos> sh.disableBalancer()
# mongos> sh.getBalancerState()
false

2) Shut down the third config server tommy7

login to tommy7 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

3) Export the data of the second config server tommy8

login to tommy8 server
check the process
# ps aux | grep mongo
# mongodump –port 27018 --out /data/usr/mongodump-03-10-17

4) For the second config server, create a new data directory tommy8

# We have already created a data directory,
/data/usr/mongod_config_data

5) Stop the second config server tommy8

login to tommy8 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

6) Start the second config server mongod with the WiredTiger storage engine option tommy8

Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod_config.conf
# Change the dbpath from /data/emeatest_config_18 to /data/usr/mongod_config_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# 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
To check the storage engine
connect to mongo
# mongo admin --port 27018
# db.serverStatus().storageEngine

7) Upload the exported data to the second config server tommy8

login to tommy8 server
check the process
# ps aux | grep mongo
# mongorestore –port 27018 /data/usr/mongodump-03-10-17

8) Shut down the second config server tommy8

login to tommy8 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

9) Restart the third config server -  tommy7  - without wiredTiger

login to tommy7 server
check the process
# ps aux | grep mongo
Restart the server
# /data/usr/mongodb_3.2.16/bin/mongod -f /data/usr/mongodb_3.2.16/conf/mongod_config.conf
check the process
# ps aux | grep mongo

10) Export the data of the third config server - tommy7 

login to tommy7 server
check the process
# ps aux | grep mongo
# mongodump –port 27018 --out /data/usr/mongodump-03-10-17

11) For the third config server, create a new data directory - tommy7 

# We have already created a data directory,
/data/usr/mongod_config_data

12) Stop the third config server - tommy7 

login to tommy7 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

13) Start the third config server with the WiredTiger storage engine - tommy7 

Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod_config.conf
# Change the dbpath from /data/emeatest_config_19 to /data/usr/mongod_config_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# 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
To check the storage engine
connect to mongo
# mongo admin --port 27018
# db.serverStatus().storageEngine

14) Upload the exported data to the third config server - tommy7 

login to tommy7 server
check the process
# ps aux | grep mongo
# mongorestore --port 27018 /data/usr/mongodump-03-10-17

15) Export data of the first config server - tommy9

login to tommy9 server
check the process
# ps aux | grep mongo
# mongodump --port 27018 --out /data/usr/mongodump-03-10-17

16) For the first config server, create a new data directory - tommy9

# We have already created a data directory,
/data/usr/mongod_config_data

17) Stop the first config server - tommy9

login to tommy9 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

18) Start the first config server with the WiredTiger storage engine - tommy9

Config file changes
# vi /data/usr/mongodb_3.2.16/conf/mongod_config.conf
# Change the dbpath from /data/emeatest_config_17 to /data/usr/mongod_config_data
Remove the storage.engine field in the config file
# storage.engine: mmapv1 – remove this
# 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
To check the storage engine
connect to mongo
# mongo admin --port 27018
# db.serverStatus().storageEngine

19) Upload the exported data to the first config server - tommy9

login to tommy9 server
check the process
# ps aux | grep mongo
# mongorestore --port 27018 /data/usr/mongodump-03-10-17

20) Restart the second config server - tommy8

login to tommy8 server
check the process
# ps aux | grep mongo
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

21) Re-enable the balancer - tommy10

- login to tommy10 server
- connect to mongo
# mongo --port 27017
# mongos> sh.getBalancerState()
false
# mongos> sh.startBalancer()
# mongos> sh.getBalancerState()
true


1 comment: