Skip to content

Instantly share code, notes, and snippets.

@drakemccabe
Last active July 18, 2016 17:41
Show Gist options
  • Save drakemccabe/17b680e8d347375363c5009e605005a3 to your computer and use it in GitHub Desktop.
Save drakemccabe/17b680e8d347375363c5009e605005a3 to your computer and use it in GitHub Desktop.
Installing MongoDB on CentOs and Syncing with a Drupal DB. NOT a step by step list, just helpful commands.
# Download + install mongodb (centOs)
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Create a /etc/yum.repos.d/mongodb-org-3.2.repo file
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
sudo yum install -y mongodb-org
# Installed packages
mongodb-org.x86_64 3.2.8-1.amzn1 @mongodb-org-3.2
mongodb-org-mongos.x86_64 3.2.8-1.amzn1 @mongodb-org-3.2
mongodb-org-server.x86_64 3.2.8-1.amzn1 @mongodb-org-3.2
mongodb-org-shell.x86_64 3.2.8-1.amzn1 @mongodb-org-3.2
mongodb-org-tools.x86_64 3.2.8-1.amzn1 @mongodb-org-3.2
# storage dir
sudo mkdir /data/db
# Download Mongo PHP driver
http://php.net/manual/en/mongo.installation.php
install from source
# Disable SELINUX
/usr/sbin/setsebool -P httpd_can_network_connect 1
# start server
sudo mongod --auth --port 27017 --dbpath /data/db
# start server in background
sudo service mongod start
# if lock
sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --repair
# storage
/var/lib/mongo
# mongod.conf
/etc/mongod.conf
# check mongo is running
sudo netstat -tulpn | grep 'mongo'
# mongo enter shell and authenticate
mongo
use admin
db.auth("user", "password")
# console functions
db.getUsers()
db.find()
db.removeUser(user)
# Using with Drupal
# donwload mongosync
drush dl mongosync && drush pm-enable mongosync
# Create admin user and create DB
use admin
db.createUser( { user: "usrname", pwd: "password", roles: [ { role: "root", db: "admin" } ] } )
# Add extension in php.ini
extension=mongo.so
sudo service httpd restart
# Setup in /admin/config/mongosync
host: localhost:27017
database: dbname
user: admin user
password: admin pw
add node(s) to sync list
# Resouces
https://devops.profitbricks.com/tutorials/install-mongodb-on-centos-7/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment