Skip to content

Instantly share code, notes, and snippets.

@nickvoronin
Last active October 12, 2018 11:13
Show Gist options
  • Save nickvoronin/cb0ccd763d0976a110e23e24afa0d02c to your computer and use it in GitHub Desktop.
Save nickvoronin/cb0ccd763d0976a110e23e24afa0d02c to your computer and use it in GitHub Desktop.

Revisions

  1. nickvoronin revised this gist Oct 12, 2018. 1 changed file with 27 additions and 1 deletion.
    28 changes: 27 additions & 1 deletion mongodb hints
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,30 @@ sudo rm -r /var/lib/mongodb
    Normally, with apt command, you can launch autoremove with all mongoDB packages :
    sudo apt-get autoremove mongodb-*

    https://askubuntu.com/questions/990727/error-removing-broken-mongo-server-package
    https://askubuntu.com/questions/990727/error-removing-broken-mongo-server-package

    ###
    https://stackoverflow.com/questions/37014186/running-mongodb-on-ubuntu-16-04-lts

    # use sudo for all the following steps
    create a service script (in this example the name of the service is Mongodb)

    nano /lib/systemd/system/mongodb.service
    File content should be

    [Unit]
    Description=MongoDB Database Service
    Wants=network.target
    After=network.target

    [Service]
    ExecStart=/usr/bin/mongod --config /etc/mongod.conf
    ExecReload=/bin/kill -HUP $MAINPID
    Restart=always
    User=mongodb
    Group=mongodb
    StandardOutput=syslog
    StandardError=syslog

    [Install]
    WantedBy=multi-user.target
  2. nickvoronin revised this gist Sep 1, 2018. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions mongodb hints
    Original file line number Diff line number Diff line change
    @@ -5,12 +5,15 @@ locate -b '\mongo'
    # Start
    sudo service mongod start

    # Check status
    systemctl status mongodb.service

    # On start error
    # Failed to start mongod.service: Unit mongod.service not found.
    sudo systemctl unmask mongodb

    # Check status
    systemctl status mongodb.service
    # Add to autorun
    systemctl enable mongod.service

    # change dbPath
    /etc/mongod.conf
  3. nickvoronin revised this gist Aug 17, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions mongodb hints
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,9 @@
    which mongo
    locate -b '\mongo'

    # Start
    sudo service mongod start

    # On start error
    # Failed to start mongod.service: Unit mongod.service not found.
    sudo systemctl unmask mongodb
  4. nickvoronin revised this gist Aug 17, 2018. No changes.
  5. nickvoronin revised this gist Aug 17, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions mongodb hints
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,10 @@
    which mongo
    locate -b '\mongo'

    # On start error
    # Failed to start mongod.service: Unit mongod.service not found.
    sudo systemctl unmask mongodb

    # Check status
    systemctl status mongodb.service

  6. nickvoronin revised this gist Aug 17, 2018. 1 changed file with 14 additions and 6 deletions.
    20 changes: 14 additions & 6 deletions mongodb hints
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,25 @@
    # Locate
    which mongo
    systemctl status mongodb.service
    locate -b '\mongo'

    If you run ps -xa | grep mongod and you don't see a --dbpath which explicitly tells mongod to look at that
    parameter for the db location and you don't have a dbpath in your mongodb.conf, then the default location
    will be: /data/db/ and you should look there.
    # Check status
    systemctl status mongodb.service

    # change dbPath
    /etc/mongod.conf
    mongod --config /etc/mongod.conf

    If you run ps -xa | grep mongod and you don't see a --dbpath which explicitly tells mongod to look at that
    parameter for the db location and you don't have a dbpath in your mongodb.conf, then the default location
    will be: /data/db/ and you should look there.

    # Remove
    sudo service mongod stop
    sudo apt-get purge mongodb-org*
    sudo rm -r /var/log/mongodb
    sudo rm -r /var/lib/mongodb
    # OR
    Normally, with apt command, you can launch autoremove with all mongoDB packages :
    sudo apt-get autoremove mongodb-*

    sudo apt-get -f install

    https://askubuntu.com/questions/990727/error-removing-broken-mongo-server-package
  7. nickvoronin renamed this gist Aug 16, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  8. nickvoronin revised this gist Aug 16, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion mongodb
    Original file line number Diff line number Diff line change
    @@ -6,4 +6,12 @@ If you run ps -xa | grep mongod and you don't see a --dbpath which explicitly te
    parameter for the db location and you don't have a dbpath in your mongodb.conf, then the default location
    will be: /data/db/ and you should look there.

    mongod --config /etc/mongod.conf - force config
    /etc/mongod.conf
    mongod --config /etc/mongod.conf

    Normally, with apt command, you can launch autoremove with all mongoDB packages :
    sudo apt-get autoremove mongodb-*

    sudo apt-get -f install

    https://askubuntu.com/questions/990727/error-removing-broken-mongo-server-package
  9. nickvoronin revised this gist Aug 16, 2018. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion mongodb
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,6 @@ locate -b '\mongo'

    If you run ps -xa | grep mongod and you don't see a --dbpath which explicitly tells mongod to look at that
    parameter for the db location and you don't have a dbpath in your mongodb.conf, then the default location
    will be: /data/db/ and you should look there.
    will be: /data/db/ and you should look there.

    mongod --config /etc/mongod.conf - force config
  10. nickvoronin created this gist Aug 16, 2018.
    7 changes: 7 additions & 0 deletions mongodb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    which mongo
    systemctl status mongodb.service
    locate -b '\mongo'

    If you run ps -xa | grep mongod and you don't see a --dbpath which explicitly tells mongod to look at that
    parameter for the db location and you don't have a dbpath in your mongodb.conf, then the default location
    will be: /data/db/ and you should look there.