MongoDB is not installed correctly in Ubuntu 18.04 server - mongodb

Specs: Ubuntu 18.04 Nginx server, Vestacp control panel.
MongoDB was pre-installed in my server, in 3.6.3 version. It was working but I wanted to upgrade it to version 4.4 (current release).
The problem now is that I can't start the mongo service (community edition).
Steps I followed so far:
Stop MongoDB service, Remove packages and remove Data Directories.
sudo service mongod stop
sudo apt-get purge mongodb-org*
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
Trying to install the new version 4.4 the exact steps from the documentation. Below are the commands with an order:
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
sudo apt-get install gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
ps --no-headers -o comm 1
sudo systemctl start mongod
sudo systemctl daemon-reload
sudo systemctl enable mongod
mongo
Errors:
sudo apt-get update
It throws an error:
Skipping acquire of configured file 'nginx/binary-i386/Packages' as repository 'http://nginx.org/packages/mainline/ubuntu bionic InRelease' doesn't support architecture 'i386'
On the step:
sudo apt-get install -y mongodb-org
E: Sub-process /usr/bin/dpkg returned an error code (1)
On the step:
sudo systemctl start mongod
Failed to start mongod.service: Unit mongod.service not found.
Directories:
/var/lib/mongodb
and
/var/log/mongodb
are not auto-created after the installation and I can't find them on the above paths.
The port I am trying to begin the server is the default 27017 and I set the rules to ufw.
I am tried to find a solution from similar posts but nothing. I'm stuck for two days now.
Any thought or help?

The problem was in uninstallation of previous MongoDB version 3.6.3.
The command in terminal...
sudo apt-get purge mongodb-org*
...Doesn't uninstall all the packages correctly.
The correct uninstallation was to type in the command line:
sudo apt list --installed | grep mongo
...In order to see if there are any packages left from MongoDB. I had 2 packages left that "purge mongodb-org*" couldn't delete.
So the correct removing executions are the below:
sudo apt remove mongodb
sudo apt purge mongodb
sudo apt autoremove
After that, the installation of the new MongoDB version 4.4 was successfully completed without errors!

Related

mongodb is not running on my Ubuntu 20.04.3 LTS

I'm trying to follow a MongoDB example for learning matters.
The instructions say that after starting MongoDB I will have a mongodb terminal so I can create a database and make it the active one.
The problem is that I start mongodb but I don't have the application terminal, it runs but at the end I have the ubuntu's terminal.
I followed this https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ to install Mongo:
pip install pymongo
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
I also installed COMPASS, this is running correctly
wget https://downloads.mongodb.com/compass/mongodb-compass_1.26.1_amd64.deb
sudo dpkg -i mongodb-compass_1.26.1_amd64.deb
mongodb-compass
I'm starting Mongo
sudo systemctl start mongod #this do something but takes me back to the terminal prompt.
mongosh #is launching this "MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017"
Definitely I'm doing something wrong but I cannot identify it.
Does anyone have an idea?
Thanks in advance

Is it possible to install postgresql 11 on Ubuntu 14.04?

I'm running on a Ubuntu 14,04 ('trusty') with no possibility to upgrade (a complex website-management platform is dependant upon it), but I'd like to install the latest version of postgresql in parallel... are there any compatibility issues?
Yes, I tried it just now, I followed the guide here: https://gist.github.com/alistairewj/8aaea0261fe4015333ddf8bed5fe91f8
# add postgresql to apt repository
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
# get the signing key and update
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
# install postgresql
sudo apt-get install postgresql-11
# ensure that the server is started by switching to the postgres user
sudo su - postgres
# I didn't do this part since the database was started during install
# and I checked via `psql`
# /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main -l logfile start

Cannot install postgres on Ubuntu (E: Unable to locate package postgresql)

So I'm having this problem where for some reason I can't install any package on my ubuntu system.
I'm currently on Ubuntu 16.10.
terminal install logs
Update:
I've done entered those commands and got this.
after update and apt-cache
What should I do now?
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
After installing the PostgreSQL database server, by default, it creates a user ‘postgres’ with role ‘postgres’. Also creates a system account with the same name ‘postgres’. So to connect to Postgres server, log in to your system as user postgres and connect database.
sudo su - postgres
psql
First do
sudo apt-get update
You should get no errors upon updating. In case you do, then you might have issues with your firewall, or something blocking you from updating repositories. Check the output carefully.
And then search for the correct (exact!) package name using this command:
apt-cache search postgresql
As a last resort you could add external 3rd Party repository as described in this answer. Just remember to use your distribution name instead of "xenial".
It should work.
$ sudo apt-get install postgresql postgresql-client
If you are getting (E: Unable to locate package postgresql-12) while migrating following step may helps you:
sudo apt-get -y install bash-completion wget
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |
sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-12 postgresql-client-12
sudo systemctl status postgresql
ref:install postgres12 in ubuntu-18.04
Following Commands worked for me: sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ lsb_release -cs-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt install postgresql-11 libpq-dev

MongoDB - upgrade from 3.2 to 3.4

I updated with this commands from MongoDB 3.2 to 3.4:
https://medium.com/mongoaudit/how-to-upgrade-mongodb-to-latest-stable- version-9607266834cf:
sudo rm /etc/apt/sources.list.d/mongodb*.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo apt-get install -y mongodb-org shows this lines:
root#accounting:/home/accounting# sudo apt-get install -y mongodb-org
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
»mongodb-org« ist bereits die neuste Version (3.4.17).
Afterwards I started mongo and the following lines are shown:
root#accounting:/home/accounting# mongo
MongoDB shell version: 3.2.17
How can I update MongoDB shell version to 3.4.17?
[SOLVED]
sudo service mongod stop
sudo apt-get purge mongodb-org*
mongod --shutdown

Getting error status:unknown job while starting MongoDB using Ubuntu

I am not able to start MongoDB in my Ubuntu machine. First I follow below steps to install MongoDB in my Ubuntu system.
1->sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
2-> echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
3-> sudo apt-get update
4-> sudo apt-get install -y mongodb-org
5-> service mongod start
While I tried to start the MongoDB I got the following message rather than its starting.
status:unknown job : mongod
I am trying to also remove the mongodb.lock file from /var/lib/mongodb folder but unable to remove here I need to start the MongoDB service.
ok try this one:
sudo apt-get purge mongodb-stable
sudo apt-get install mongodb-stable
(remove the lock file if present in /var/lib/mongodb)
Then edit /etc/init/mongodb.conf removing the line "limit nofile 20000"