Thursday, October 13, 2016

Opsmanager setup with MongoDB from scratch with CentOS 6.5

MongoDB Installation 

1) vi /etc/yum.repos.d/mongodb-enterprise.repo
[mongodb-enterprise]
name=MongoDB Enterprise Repository
baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/3.2/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

2) Install the MongoDB packages and associated tools.
sudo yum install -y mongodb-enterprise

3) connect to mongo (check  mongo working correctly)

mongo --port 27017

OR

service mongod status (check mongo working correctly)

Opsmanager Installation Steps

1) Create Replicaset for ApplicationDB
2) Install Opsmanager & Configure it
3) Install Automation Agent 
4) Create Replicaset for BlockStore
5) Create Replicaset for OplogStore
6) Create Replicaset for DataNodes
7) Configure backup daemon
8) Add existing replicasets in Opsmanager
9) Backup & Restore steps using Opsmanager


**************** Create Replicaset for ApplicationDB*****************
Create data folders for ApplicationDB
mkdir -p /apps/mongodb/appdb/rs0
mkdir -p /apps/mongodb/appdb/rs1
mkdir -p /apps/mongodb/appdb/rs2

Assign mongod user permission to the folders

chown mongod.mongod /apps/mongodb/appdb/rs0
chown mongod.mongod /apps/mongodb/appdb/rs1
chown mongod.mongod /apps/mongodb/appdb/rs2

Generate the mongodb key file for replication
rm –f  /apps/mongodb/appdb/ mongodb-keyfile
openssl rand -base64 755 > /apps/mongodb/appdb/mongodb-keyfile
chown mongod.mongod /apps/mongodb/appdb/mongodb-keyfile
chmod 600 /apps/mongodb/appdb/mongodb-keyfile

Configuration file for first node
*****************************************************************************
vi /apps/mongodb/appdb/rs0/mongod.config
*****************************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/appdb/rs0/mongod.log

storage:
  dbPath: /apps/mongodb/appdb/rs0
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 30000
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsapp

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

Configuration file for second node
******************************************************************************
vi /apps/mongodb/appdb/rs1/mongod.config
******************************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/appdb/rs1/mongod.log

storage:
  dbPath: /apps/mongodb/appdb/rs1
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 30001
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsapp

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

Configuration file for third node
****************************************************************************
vi /apps/mongodb/appdb/rs2/mongod.config
****************************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/appdb/rs2/mongod.log

storage:
  dbPath: /apps/mongodb/appdb/rs2
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 30002
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsapp

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

Create mongodb process for all three nodes
(Please make sure run this process by using mongod user)
/usr/bin/mongod -f /apps/mongodb/appdb/rs0/mongod.conf
/usr/bin/mongod -f /apps/mongodb/appdb/rs1/mongod.conf
/usr/bin/mongod -f /apps/mongodb/appdb/rs2/mongod.conf

Connect to mongo –port 30000 & initiate replication
mongo --port 30000
use admin
rsconf = {_id: "rsapp",members: [{_id: 0,host: "cignex.mongodb.com:30000"}]}
rs.initiate(rsconf);

Create Super User
db.createUser({user:"admin",pwd:"admin#123",roles:["root"]})
db.auth("admin","admin#123");

db.createUser({user:"mms-automation",pwd:"admin#123",roles:["root"]})
db.createUser({user:"mms-monitoring-agent",pwd:"admin#123",roles:["root"]})

db.createUser({user:"mms-backup-agent",pwd:"admin#123",roles:["root"]})

Add rest of nodes in Replication
rs.add("cignex.mongodb.com:30001");
rs.add("cignex.mongodb.com:30002");

Check your replication status
rs.status()

***************************Opsmanager Installation*************************

Create directory to download rpm file for Opsmanager installation
mkdir -p /apps/mongodb/opsmanager_rpm_package

Download specific version of opsmanager at this location
cd /apps/mongodb/opsmanager_rpm_package

Install wget command if not installed
yum install wget

download rpm package for Opsmanager installation
wget https://downloads.mongodb.com/on-prem-mms/rpm/mongodb-mms-2.0.6.363-1.x86_64.rpm?_ga=1.5032432.2128777169.1475558721

Rename rpm file
Rename "mongodb-mms-2.0.6.363-1.x86_64.rpm?_ga=1.5032432.2128777169.1475558721" to "mongodb-mms-2.0.6.363-1.x86_64.rpm"

Install Opsmanager using rpm file

sudo rpm -ivh mongodb-mms-2.0.6.363-1.x86_64.rpm

By default Opsmanager import data for application db at 27017 port. But I have changed it to replica set configured on 30000 port
change configuration of Opsmanager
vi /opt/mongodb/mms/conf/conf-mms.properties

Replace this property in properties file
mongo.mongoUri=mongodb://admin:admin#123@cignex.mongodb.com:30000,cignex.mongodb.com:30001,cignex.mongodb.com:30002/?replicaSet=rsapp

Start Opsmanager Process
[root@cignex conf]# sudo service mongodb-mms start
Starting pre-flight checks
Successfully finished pre-flight checks

Migrate Ops Manager data
   Running migrations...[  OK  ]
Start Ops Manager server
   Instance 0 starting..........................................[  OK  ]
Starting pre-flight checks
Successfully finished pre-flight checks

Start Backup Daemon...[  OK  ]

**********************Opsmanager Installed Successfully*******************

Start Opsmanager and Open browser and verify it
http://localhost:8080/














Click on Register














Click on “CREATE ACCOUNT”
It will open page and ask for configuration for Webserver

Field
Configuration Value
URL to access Opsmanager
http://cignex.mongodb.com:8080
"From" Email Address
nilap.shah@cignex.com
"Reply To Email Address
nilap.shah@cignex.com
Admin Email Address
nilap.shah@cignex.com
Email Delivery Configuration Method
SMTP Email Server
Transport
smtp
SMTP Server Hostname
smtp.exg6.exghost.com
SMTP Server Port
587
Username
nilap.shah@cignex.com
Password
**********

Next It will open page and ask for configuration for User Authentication
Field
Configuration Value
User Authentication Method
Application Database

For two next pages please press "continue" button.

It will show you below screen for Opsmanager















************************Install Automation Agent************************

Click on "Settings" & "Agents"

Select Appropriate Option for Automation Agent Installation

Select Appropriate OS & Press Continue button



















Automation Agent rpm file download and install.

[root@cignex ~]# curl -OL http://cignex.mongodb.com:8080/download/agent/automation/mongodb-mms-automation-agent-manager-2.5.20.1755-1.x86_64.rpm
[root@cignex ~]# mkdir -p /apps/mongodb/Opsmanager_installation_rpm
[root@cignex ~]# cd /apps/mongodb/Opsmanager_installation_rpm

Run rpm file for installation
sudo rpm -U mongodb-mms-automation-agent-manager-2.5.20.1755-1.x86_64.rpm

Open config file for Automation Agent
sudo vi /etc/mongodb-mms/automation-agent.config

Set following Properties
mmsGroupId=57f6650fe4b0b3cbca694898
mmsApiKey=4b6902b512c8edbf7e63d4194c253c26
mmsBaseUrl=http://cignex.mongodb.com:8080

Start Automation Agent
[root@cignex Opsmanager_installation_rpm]#
sudo service mongodb-mms-automation-agent start
mongodb-mms-automation-agent is starting


**************** Create Replicaset for BlockStore*****************
mkdir -p /apps/mongodb/blockstore/rs0
mkdir -p /apps/mongodb/blockstore/rs1
mkdir -p /apps/mongodb/blockstore/rs2

chown mongod.mongod /apps/mongodb/blockstore/rs0
chown mongod.mongod /apps/mongodb/blockstore/rs1
chown mongod.mongod /apps/mongodb/blockstore/rs2

**************************************************************
vi /apps/mongodb/blockstore/rs0/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/blockstore/rs0/mongod.log

storage:
  dbPath: /apps/mongodb/blockstore/rs0
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 31000
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsblockstore

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

**************************************************************
vi /apps/mongodb/blockstore/rs1/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/blockstore/rs1/mongod.log

storage:
  dbPath: /apps/mongodb/blockstore/rs1
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 31001
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsblockstore

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

**************************************************************
vi /apps/mongodb/blockstore/rs2/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/blockstore/rs2/mongod.log

storage:
  dbPath: /apps/mongodb/blockstore/rs2
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 31002
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsblockstore

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

start blockstore mongod processes
(Please make sure run this process by using mongod user)
/usr/bin/mongod -f /apps/mongodb/blockstore/rs0/mongod.conf
/usr/bin/mongod -f /apps/mongodb/blockstore/rs1/mongod.conf
/usr/bin/mongod -f /apps/mongodb/blockstore/rs2/mongod.conf

connect to mongo port 31000
mongo --port 31000

configure replication for blockstore
use admin
rsconf = {_id: "rsblockstore",members: [{_id: 0,host: "cignex.mongodb.com:31000"}]}
rs.initiate(rsconf);

create admin user for blockstore database
db.createUser({user:"admin",pwd:"admin#123",roles:["root"]})
db.auth("admin","admin#123");

db.createUser({user:"mms-automation",pwd:"admin#123",roles:["root"]})
db.createUser({user:"mms-monitoring-agent",pwd:"admin#123",roles:["root"]})

db.createUser({user:"mms-backup-agent",pwd:"admin#123",roles:["root"]})

Add rest of mongod servers for blockstore
rs.add("cignex.mongodb.com:31001");
rs.add("cignex.mongodb.com:31002");

check replication status
rs.status()

**************** Create Replicaset for OplogStore*****************
mkdir -p /apps/mongodb/oplogstore/rs0
mkdir -p /apps/mongodb/oplogstore/rs1
mkdir -p /apps/mongodb/oplogstore/rs2

chown mongod.mongod /apps/mongodb/oplogstore/rs0
chown mongod.mongod /apps/mongodb/oplogstore/rs1
chown mongod.mongod /apps/mongodb/oplogstore/rs2

**************************************************************
vi /apps/mongodb/oplogstore/rs0/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/oplogstore/rs0/mongod.log

storage:
  dbPath: /apps/mongodb/oplogstore/rs0
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 32000
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsoplogstore

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

**************************************************************
vi /apps/mongodb/oplogstore/rs1/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/oplogstore/rs1/mongod.log

storage:
  dbPath: /apps/mongodb/oplogstore/rs1
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 32001
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsoplogstore

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

**************************************************************
vi /apps/mongodb/oplogstore/rs2/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/oplogstore/rs2/mongod.log

storage:
  dbPath: /apps/mongodb/oplogstore/rs2
  journal:
    enabled: true
  engine: mmapv1

processManagement:
  fork: true

net:
  port: 32002
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsoplogstore

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

start oplogstore mongod processes
(Please make sure run this process by using mongod user)
/usr/bin/mongod -f /apps/mongodb/oplogstore/rs0/mongod.conf
/usr/bin/mongod -f /apps/mongodb/oplogstore/rs1/mongod.conf
/usr/bin/mongod -f /apps/mongodb/oplogstore/rs2/mongod.conf

connect to mongo port 32000
mongo --port 32000

use admin

rsconf = {_id: "rsoplogstore",members: [{_id: 0,host: "cignex.mongodb.com:32000"}]}
rs.initiate(rsconf); 

db.createUser({user:"admin",pwd:"admin#123",roles:["root"]})
db.auth("admin","admin#123");

db.createUser({user:"mms-automation",pwd:"admin#123",roles:["root"]})
db.createUser({user:"mms-monitoring-agent",pwd:"admin#123",roles:["root"]})

db.createUser({user:"mms-backup-agent",pwd:"admin#123",roles:["root"]})

rs.add("cignex.mongodb.com:32001");
rs.add("cignex.mongodb.com:32002");

check replication status
rs.status()

**************** Create Replicaset for Datanodes*****************

mkdir -p /apps/mongodb/datadb/rs0
mkdir -p /apps/mongodb/datadb/rs1
mkdir -p /apps/mongodb/datadb/rs2

chown mongod.mongod /apps/mongodb/datadb/rs0
chown mongod.mongod /apps/mongodb/datadb/rs1
chown mongod.mongod /apps/mongodb/datadb/rs2

**************************************************************
vi /apps/mongodb/datadb/rs0/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/datadb/rs0/mongod.log

storage:
  dbPath: /apps/mongodb/datadb/rs0
  journal:
    enabled: true
  engine: wiredTiger

processManagement:
  fork: true

net:
  port: 33000
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsdatadb

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

**************************************************************
vi /apps/mongodb/datadb/rs1/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/datadb/rs1/mongod.log

storage:
  dbPath: /apps/mongodb/datadb/rs1
  journal:
    enabled: true
  engine: wiredTiger

processManagement:
  fork: true

net:
  port: 33001
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsdatadb

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

**************************************************************
vi /apps/mongodb/datadb/rs2/mongod.conf
**************************************************************
systemLog:
  destination: file
  logAppend: true
  path: /apps/mongodb/datadb/rs2/mongod.log

storage:
  dbPath: /apps/mongodb/datadb/rs2
  journal:
    enabled: true
  engine: wiredTiger

processManagement:
  fork: true

net:
  port: 33002
  bindIp: localhost,cignex.mongodb.com

replication:
  replSetName: rsdatadb

security:
  authorization: enabled
  keyFile: /apps/mongodb/appdb/mongodb-keyfile

start datanodes with mongod processes
(Please make sure run this process by using mongod user)
/usr/bin/mongod -f /apps/mongodb/datadb/rs0/mongod.conf
/usr/bin/mongod -f /apps/mongodb/datadb/rs1/mongod.conf
/usr/bin/mongod -f /apps/mongodb/datadb/rs2/mongod.conf

connect to mongo port 33000
mongo --port 33000

use admin 
rsconf = {_id: "rsdatadb",members: [{_id: 0,host: "cignex.mongodb.com:33000"}]}
rs.initiate(rsconf);

db.createUser({user:"admin",pwd:"admin#123",roles:["root"]})
db.auth("admin","admin#123");

db.createUser({user:"mms-automation",pwd:"admin#123",roles:["root"]})
db.createUser({user:"mms-monitoring-agent",pwd:"admin#123",roles:["root"]})

db.createUser({user:"mms-backup-agent",pwd:"admin#123",roles:["root"]})

rs.add("cignex.mongodb.com:33001");
rs.add("cignex.mongodb.com:33002");

check replication status
rs.status()

***********************Install Backup Daemon*****************************
Creating headdb folder for backup daemon(click "Install Backup Daemon")
mkdir -p /apps/mongodb/headdb
chown mongodb-mms.mongodb-mms /apps/mongodb/headdb
















Set head directory : /apps/mongodb/headdb & click on "SET".















Headdb is configured Now Click on “ENABLE DAEMON” to enable backup process