call to replace anchor tags contains '/admin' in href

Mogodb_setup

https://stackoverflow.com/questions/48318487/error-while-upgrading-mongodb-from-3-2-to-3-6

* mean not mandatory

Step:1  Importing the Public Key

MongoDB is already included in Ubuntu package repositories, but the official MongoDB repository provides most up-to-date version and is the recommended way of installing the software. Ubuntu ensures the authenticity of software packages by verifying that they are signed with GPG keys, so we first have to import they key for the official MongoDB repository. Use Any One Command

*~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927

~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Use this one

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

 

Step:2 Create source list file MongoDB Installed MongoDB

We have to add the MongoDB repository details so APT will know where to download the packages from.

~$ echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

In effect, tee duplicates its input, routing it to multiple outputs at once.

 

Step 3 - Install MongoDB

~$ sudo apt-get update

~$ sudo apt-get install -y mongodb-server

~$ sudo apt-get install -y mongodb-org

~$ sudo apt-get install -y mongodb-clients

Now, we have to create a new MongoDB systemd service file in the '/lib/systemd/system' directory. Go to that directory and create the new MongoDB service file 'mongod.service' with vim/vi editor.

Step 4 :- Create a file name mongod.service

~$ cd /lib/systemd/system/

~$ vim mongod.service

Paste script below:

[Unit]

Description=High-performance, schema-free document-oriented database

After=network.target

Documentation=https://docs.mongodb.org/manual

[Service]

User=mongodb

Group=mongodb

ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]

WantedBy=multi-user.target

Save the file and exit.

:wq!

Now update the systemd service with the command below:

~$ sudo apt-get update && sudo apt-get upgrade

Start MongoDB and add it as a service to be started at boot time:

~$ systemctl daemon-reload

~$ sudo service mongod start

~$ systemctl enable mongod

Now check that MongoDB has been started on port 27017 with the netstat command.

~$ netstat -plntu

{  *Step 5 :- Create username and password

      If you want to give password then use these step:-

         Configure MongoDB username and password

~$ Mongo

> LC_ALL=0 -  to remove all localized settings

> use admin

> *db.createUser({user:"admin", pwd:"admin123", roles:[{role:"root", db:"admin"}]})

> exit

~$ vim /lib/systemd/system/mongod.service

        On the 'ExecStart' line 9, add the new option '--auth'.

        ExecStart=/usr/bin/mongod --quiet --auth --config /etc/mongod.conf

Then,

  • ~$ sudo systemctl daemon-reload
  • ~$ sudo systemctl restart mongod
  • ~$ mongo -u admin -p admin123 --authenticationDatabase admin

(Syntax of Command

  • ~$ mongo -u <username> -p <password> --authenticationDatabase <dbname>)
  • >show dbs    

Step 6 :-

~$ sudo systemctl status mongod

If you find that service is not active then:-

~$ sudo rm /var/lib/mongodb/mongod.lock

~$ ps -ef | grep mongo

If you find some error then kill the process by using -> kill -9 <mongo’s ID>

~$ sudo service mongod start

~$ sudo service mongod status

Step 7:- Go to Virtual Machine

Now got to Azure portal ---> then go to networking and add ports on both machine with alternative ips….

Then run command ~$ mongo <ip or second machne>

Replication Step:-

1 Step:- Go to /etc/mongod.conf file.

 Changes:- #net:

      #port: 27017

      #bindIp: 127.0.0.1

      replication:

           replSetName:  <any name>

~$ sudo service mongod restart

2 Step:- Check the log as well - tail -f /var/log/mongod/mongod.conf

             If this is fine then check process - ps -ef | grep mongo

 If you find some error then kill the process by using - kill -9 mongo

~$ sudo service mongod start

~$ sudo service mongod status

3 Step:- ~$ mongo

 >  use admin*

 > rs.initiate()

4 Step:- Now copy the all /etc/mongod.conf file of primary mongodb. Then paste this on second     mongodb

Commands of Mongodb

> show dbs

> use <database name>

> show collections

> db.startup_log.count()  - (to count the status)

> db.startup_log.find()      - (to find the data)

> db.startup_log.findOne() -  (to show first db)

> db.auth("username", "password");

> db.getCollectionNames();

Create Backup

mongodump -d db_name /backup/path/

How to stop Mongodb

~$ sudo  apt-get remove --purge mongodb

~$ sudo apt-get remove --auto-remove mongodb

~$ sudo service mongod stop

~$ sudo apt-get remove mongodb*

~$ sudo rm -R /var/log/mongodb

~$ sudo rm -R /var/lib/mongo

/*sudo rm /var/lib/mongodb/mongod.lock
sudo mongod --dbpath /var/lib/mongodb/ --repair
sudo mongod --dbpath /var/lib/mongodb/ --journal

echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/defrag fi if test -f ... [Unit] Description="Disab*/

How to upgrade mongodb

  • ~$  sudo service mongod stop
  • ~$  *sudo cp /etc/mongod.conf /etc/mymongo.conf(not mandatory)
  • ~$  sudo apt-get purge mongodb-org*
  • ~$  sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
  • ~$  echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
  • ~$ sudo apt-get install -y mongodb-org=3.2.19 mongodb-org-server=3.2.19 mongodb-org-shell=3.2.19 mongodb-org-mongos=3.2.19 mongodb-org-tools=3.2.19
  • ~$  sudo service mongod start
  • ~$ sudo apt-get update && sudo apt-get upgrade
  • ~$  mongod --version

How to create mongo dump

require('./app/node_modules/ms-movedatabase').dumpStoreDatabase('573db3149f0d58741f0cc63b_trial344', 'devhippo', (err, response)=> {

})



require('./app/node_modules/ms-movedatabase').restoreStoreDatabase('573db3149f0d58741f0cc63b_trial344', 'devhippo', (err, response)=> {

})