Git Product home page Git Product logo

mongodb-devops's Introduction

mongodb-devops

Setup Vagrant

cd mongodb-devops
vagrant init centos/7
vagrant up
vagrant ssh

Steps on Centos virtual box

sudo yum install git lsof -y
git clone https://github.com/laimison/mongodb-devops.git
cd mongodb-devops
alias pull='git pull origin master'
pull

sudo cp mongodb-org-4.0.repo /etc/yum.repos.d/
sudo yum install -y mongodb-org-4.0.6
sudo setenforce 0
sudo service mongod start
mongo

sudo mkdir -p /data/1/log /data/2/log /data/3/log
sudo mkdir -p /data/1/db /data/2/db /data/3/db
sudo mkdir -p /data/1/config /data/2/config /data/3/config
sudo mkdir -p /data/1/pid /data/2/pid /data/3/pid

sudo cp mongod-1.conf /data/1/config/mongod.conf
sudo cp mongod-2.conf /data/2/config/mongod.conf
sudo cp mongod-3.conf /data/3/config/mongod.conf

sudo mongod -f /data/1/config/mongod.conf --replSet myset

mongo --port 27001
rsconf={ _id:"myset", members: [ { _id: 0,host:"localhost:27001"}]}
rs.initiate(rsconf)

db.test.insert({"Test": 1})
db.test.find()
rs.status()

sudo mongod -f /data/2/config/mongod.conf --replSet myset
sudo mongod -f /data/3/config/mongod.conf --replSet myset

sudo lsof -n -i -P | grep LISTEN | grep 2700

mongo --port 27001

rsconf={ _id:"myset", protocolVersion: 1, members: [ { _id: 0, host:"localhost:27001" }, { _id: 1, host:"localhost:27002" }, { _id: 2, host:"localhost:27003"}]}
rs.reconfig(rsconf)
rs.status()
db.isMaster()

mongo --port 27002
rs.slaveOk()

mongo --port 27003
rs.slaveOk()
db.test.find()

mongo --port 27001
db.test.insert({"Test2": 2})

mongo --port 27002
db.test.find()

Create admin user

mongo < delete_admin.js
mongo < list_users.js
mongo < create_admin.js
mongo < list_users.js
mongo -u mongoadmin -p mongoadmin
mongo < admin_user_exists.js

Consider different roles

For super user, use 'root'

To disable anonymous authentication

mongodb-devops's People

Contributors

laimison avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.