Thursday, November 24, 2016

MongoDB - Enable auditing on replica set



# Setup directory for replication set testing
# hostname: database.dbaglobe.com
mkdir -p /home/donghua/LAB6/{r0,r1,r2}

# Setup replset with 3 replicas with auditing enable to JSON File
mongod --dbpath /home/donghua/LAB6/r0 --logpath /home/donghua/LAB6/r0/mongo.log --port 3310 --replSet TO_BE_SECURED --fork --auditDestination file --auditFormat JSON --auditPath /home/donghua/LAB6/r0/auditLog.json
mongod --dbpath /home/donghua/LAB6/r1 --logpath /home/donghua/LAB6/r1/mongo.log --port 3311 --replSet TO_BE_SECURED --fork --auditDestination file --auditFormat JSON --auditPath /home/donghua/LAB6/r1/auditLog.json
mongod --dbpath /home/donghua/LAB6/r2 --logpath /home/donghua/LAB6/r2/mongo.log --port 3312 --replSet TO_BE_SECURED --fork --auditDestination file --auditFormat JSON --auditPath /home/donghua/LAB6/r2/auditLog.json

mongo --port 3310 --eval "rs.initiate({_id: 'TO_BE_SECURED',members: [{ _id: 1, host: 'database.dbaglobe.com:3310' },{ _id: 2, host: 'database.dbaglobe.com:3311' },{ _id: 3, host: 'database.dbaglobe.com:3312' }]})"
mongo --port 3310 --eval "rs.status()"

# Shutdown and clean up
mongod --dbpath /home/donghua/LAB6/r0 --shutdown
mongod --dbpath /home/donghua/LAB6/r1 --shutdown
mongod --dbpath /home/donghua/LAB6/r2 --shutdown
rm -rf /home/donghua/LAB6

No comments:

Post a Comment