Friday, June 29, 2018

MongoDB Fresh Installation with Security - Linux


MongoDB Installation – Linux

Prerequisites

To Switch User to mongod – Changes to be made

# vi /etc/passwd/
only for the mongod user - have to change the home path and /bin/false to /bin/bash
/var/lib/mongo:/bin/false
to
/home/mongod:/bin/bash

Or
# usermod -d /home/mongod mongod
# usermod --shell /bin/bash  mongod
Then
# mkdir -p /home/mongod
# cp .bash_profile .bashrc /home/mongod/
# chown -R mongod:mongod /home/mongod/

Create necessary directories

# mkdir /data/usr/conf
# mkdir /data/usr/logs/
# mkdir -p /var/run/mongodb/
# chown mongod:mongod /var/run/mongodb/
# chmod 775 /var/run/mongodb/
# chmod -R 775 /data/usr

Copy the Latest copy of binaries

# dzdo su - mongod
# cp /tmp/mongodb-linux-x86_64-rhel62-3.6.5.tgz /data/usr
# tar -zxvf  mongodb-linux-x86_64-rhel62-3.6.5.tgz

Create Softlink

# ln -s mongodb-linux-x86_64-rhel62-3.6.5 mongodb

Create Config File:

# vi /data/usr/conf/mongod.conf

net:
  port: 27017
  bindIpAll: true
processManagement:
  pidFilePath: /var/run/mongodb/mongod.pid
  fork: true
#security:
#  authorization: enabled
storage:
  dbPath: /data/mongodb
systemLog:
  destination: file
  logAppend: true
  logRotate: rename
  path: /data/usr/logs/mongod.log

# :wq!

Create Init.d scripts – to run mongod as a service

# touch /etc/init.d/mongod
# copy the script to the file mongod

File Paths as per Standards

Config File Path: /data/usr/conf/mongod.conf
Log File Path: /data/usr/logs/mongod.log
Binary File Path: /data/usr/mongodb/bin/mongod

Start the Service

# dzdo service mongod start

Security:

Create root user for DBAs

# use admin
db.createUser(
  {
    user: "dba_mongo",
    pwd: "xxxxx",
    roles: [ { role: "root", db: "admin" } ]
  }
)

Enable the security options in config file

net:
  port: 27017
  bindIpAll: true
processManagement:
  pidFilePath: /var/run/mongodb/mongod.pid
  fork: true
security:
  authorization: enabled
storage:
  dbPath: /data/mongodb
systemLog:
  destination: file
  logAppend: true
  logRotate: rename
  path: /data/usr/logs/mongod.log

Restart the server

# dzdo service mongod restart

Login to mongo console

# /data/usr/mongodb/bin/mongo --port 27017 -u "dba_mongo" -p "xxxxx" --authenticationDatabase "admin"

# mongo --port 27017 -u dba_mongo -p xxxxxx --authenticationDatabase admin

Creating App Users

# use admin
db.createUser(
  {
    user: "app_mongo",
    pwd: "xxxx",
    roles: [{role:"dbAdminAnyDatabase",db: "admin"},{role:"readWriteAnyDatabase", db: "admin"}]
  }
)

Login to mongo console as App User

# mongo --port 27017 -u app_mongo -p xxxx --authenticationDatabase admin


Thursday, June 28, 2018

Downgrade MongoDB - Enterprise to Community Edition


MongoDB Enterprise to Community Edition  - Implementation

Overview:

Shards 1(rs_0)

tommy1:27019 - Primary
tommy2:27019 - Secondary
tommy3:27019 - Secondary

Shards 2(rs_1)

tommy4:27019 - Primary
tommy5:27019 - Secondary
tommy6:27019 - Secondary

Shards 3(rs_3)

tommy7:27019 - Primary
tommy8:27019 - Secondary
tommy9:27019 - Secondary

ConfigDB:

tommy10:27018
tommy11:27018
tommy12:27018

Mongos:

tommy13:27017

Version : 3.0.5

Cluster size : 56.3GB

Implementation Plan:

1) Login as mongod user

Sudo -u mongod -i
Password

Note: just for reference

Existing path in Prod server bin - /var/lib/mongodb-mms-automation/mongodb-linux-x86_64-3.0.5-ent/bin/
Existing path in Prod server config - /data/automation-mongod.conf

Generic Path for bin - /usr/mongodb_3.0.5/bin/
Generic Path for config - /usr/mongodb_3.0.5/conf/

2) Create necessary directories in all the servers

# mkdir -p /usr/mongodb_3.0.5/bin/
# chmod 775 /usr/mongodb_3.0.5/bin/

# mkdir /usr/mongodb_3.0.5/conf/
# chmod 775 /usr/mongodb_3.0.5/conf/

3) Copy the New Binaries to all the servers in bin folder from - tommy13

Path - /usr/mongodb_3.0.5/bin/

Log in to tommy13 – run the below command in all the servers
# scp /tmp/mongodb-linux-x86_64-3.0.5.tgz [user account]@[hostname]:/tmp/

Then log in to each server, run the commands – ( have to run this in all servers)

# cd /tmp
# tar -zxvf mongodb-linux-x86_64-3.0.5.tgz
# cp -R /tmp/mongodb-linux-x86_64-3.0.5/* /usr/mongodb_3.0.5/

4) Copy the existing configuration files to the new path

Path - /usr/mongodb_3.0.5/conf/

For tommy13 - mongos
cp /var/lib/mongodb-mms-automation/workspace/mongos-cluster_mongos_0.conf /usr/mongodb_3.0.5/conf/

For tommy10 - config
cp /data/cluster_config_10/automation-mongod.conf /usr/mongodb_3.0.5/conf/
For tommy11 - config
cp /data/cluster_config_11/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy12 - config
cp /data/cluster_config_12/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy1 - primary
cp /data/cluster_rs_0_2/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy2 - secondary
cp /data/cluster_rs_0_1/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy3 - secondary
cp /data/cluster_rs_0_3/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy4 - primary
cp /data/cluster_rs_0_4/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy5 - secondary
cp /data/cluster_rs_1_4/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy6 - seconday
cp /data/cluster_rs_1_5/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy7 - primary
cp /data/cluster_rs_2_8/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy8 - secondary
cp /data/cluster_rs_2_7/automation-mongod.conf /usr/mongodb_3.0.5/conf/

For tommy9 secondary
cp /data/cluster_rs_2_9/automation-mongod.conf /usr/mongodb_3.0.5/conf/

5) Rename the config file names

tommy13 - mongos
# mv /usr/mongodb_3.0.5/conf/mongos-cluster_mongos_0.conf /usr/mongodb_3.0.5/conf/mongos.conf

tommy1, tommy2, tommy3, tommy4, 
tommy5, tommy6, tommy7, tommy8,
tommy9 - mongod
# mv /usr/mongodb_3.0.5/conf/automation-mongod.conf /usr/mongodb_3.0.5/conf/mongod.conf

tommy10, tommy11, tommy12 - config
# mv /usr/mongodb_3.0.5/conf/automation-mongod.conf /usr/mongodb_3.0.5/conf/mongod_config.conf

6) Open all config files in all servers and delete the first 2 lines which is hashed (#)

tommy13 - mongos
# vi /usr/mongodb_3.0.5/conf/mongos.conf

tommy1, tommy2, tommy3, tommy4, 
tommy5, tommy6, tommy7, tommy8,
tommy9 - mongod
# vi /usr/mongodb_3.0.5/conf/mongod.conf

tommy10, tommy11, tommy12 - config
# vi /usr/mongodb_3.0.5/conf/mongod_config.conf

6) Disable the balancer

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

7) Downgrade secondary members of the replica set in each shard 1

1st secondary

login to tommy2 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

2nd secondary

login to tommy3 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

8) Step down the primary in shard 1.

login to tommy1 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
Step down the primary
# rs.stepDown()
when the server become secondary
# use admin
# db.shutdownServer()
start the server with the new binaries and new config file
# /var/lib/mongodb/mongodb_3.0.5/bin/mongod -f /var/lib/mongodb/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

9) Downgrade secondary members of the replica set in each shard 2

1st secondary

login to tommy5 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

2nd secondary

login to tommy6 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

10) Step down the primary in shard 2.

login to tommy4 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
Step down the primary
# rs.stepDown()
when the server become secondary
# use admin
# db.shutdownServer()
start the server with the new binaries and new config file
# /var/lib/mongodb/mongodb_3.0.5/bin/mongod -f /var/lib/mongodb/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

11) Downgrade secondary members of the replica set in each shard 3

1st secondary

login to tommy8 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

2nd secondary

login to tommy9 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

12) Step down the primary in shard 3.

login to tommy7 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27019
Step down the primary
# rs.stepDown()
when the server become secondary
# use admin
# db.shutdownServer()
start the server with the new binaries and new config file
# /var/lib/mongodb/mongodb_3.0.5/bin/mongod -f /var/lib/mongodb/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

13) Downgrade the SCCC config servers in reverse order

> Reverse order based on the configDB option in mongos config file
configDB: tommy10:27018, tommy11:27018, tommy12:27018
> Downgrade Config3, followed by config2 and then config1 so
> Downgrade tommy12, followed by tommy11 and then tommy10

tommy12

login to tommy12 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27018
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod_config.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

tommy11

login to tommy11 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27018
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

tommy10

login to tommy10 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27018
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongod -f /usr/mongodb_3.0.5/conf/mongod.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()

14) Downgrade the mongos instances.

login to tommy13 server
check the process
# ps aux | grep mongo
Remove MongoDB automation agent
# sudo rpm -e mongodb-mms-automation-agent-manager
connect to mongo
# mongo admin --port 27017
# db.shutdownServer()
start the server with the new binaries and new config file
# /usr/mongodb_3.0.5/bin/mongos -f /usr/mongodb_3.0.5/conf/mongos.conf
connect to mongo and wait for the member to recover to SECONDARY state before downgrading the next secondary - to check
# rs.status()


15) Re-enable the balancer.

- Once the downgrade of sharded cluster components is complete, re-enable the balancer.
- login to tommy13 server
- connect to mongo
# mongo --port 27017
# mongos> sh.getBalancerState()
false
# mongos> sh.startBalancer()
# mongos> sh.getBalancerState()
true

Note: This implementation is done before the migration of Config Server from SCCC to ReplicaSet


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