Thursday, November 24, 2016

MongoDB - Enable auditing on replica set

# Setup directory for replication set testing
# hostname:
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: '' },{ _id: 2, host: '' },{ _id: 3, host: '' }]})"
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