I'm trying to reinstall mongodb with apt-get install.
But it make error.
chown: invalid group: ‘mongodb:mongodb’
dpkg: error processing package mongodb-server (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb:
mongodb depends on mongodb-server (>= 1:2.4.1-2); however:
Package mongodb-server is not configured yet.
dpkg: error processing package mongodb (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Processing triggers for systemd (215-17+deb8u7) ...
Errors were encountered while processing:
mongodb-server
mongodb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I'm using next command but not work.
apt-get --reinstall install mongodb
and
sudo apt-get purge mongodb mongodb-clients mongodb-server mongodb-dev
sudo apt-get autoremove
and install mongodb but it also don't work.
When i install mongodb first,
I use install.sh to install.
#!/bin/bash
if [ $(id -u) != 0 ]; then
exec sudo -- "$0" "$#"
exit
fi
echo "Creating mongodb user"
adduser --firstuid 100 --ingroup nogroup --shell /etc/false --disabled-password --gecos "" --no-create-home mongodb
echo "Installing mongo to /opt/mongo..."
tar xfz mongo.tar.gz -C /opt --owner mongodb
echo "Creating runtime directories under /var"
install -o mongodb -g nogroup -d /var/log/mongodb/
install -o mongodb -g nogroup -d /var/lib/mongodb/
echo "Installing config scripts"
install mongod /etc/init.d
install mongodb.conf /etc
echo "Setting mongod to start on boot"
update-rc.d mongod defaults
echo "Starting mongod"
/etc/init.d/mongod start
echo "done."
How to uninstall mongodb?
Related
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!
I am trying to build a mongo 4.4 image based on the official image Dockerfile but I am running into an issue with systemctl not found. The image itself has a line to remove it after setup, but not sure where it came from. Any ideas?
Setting up mongodb-org-database-tools-extra (4.4.0) ...
Setting up librtmp1:amd64 (2.4+20151223.gitfa8646d.1-1) ...
Setting up libkrb5support0:amd64 (1.16-2ubuntu0.1) ...
Setting up krb5-locales (1.16-2ubuntu0.1) ...
Setting up libkeyutils1:amd64 (1.5.9-9.2ubuntu2) ...
Setting up libk5crypto3:amd64 (1.16-2ubuntu0.1) ...
Setting up libkrb5-3:amd64 (1.16-2ubuntu0.1) ...
Setting up libgssapi-krb5-2:amd64 (1.16-2ubuntu0.1) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.10) ...
Setting up mongodb-database-tools (100.1.1) ...
Setting up mongodb-org-mongos (4.4.0) ...
Setting up mongodb-org-tools (4.4.0) ...
Setting up mongodb-org-server (4.4.0) ...
/var/lib/dpkg/info/mongodb-org-server.postinst: 43: /var/lib/dpkg/info/mongodb-org-server.postinst: systemctl: not found
dpkg: error processing package mongodb-org-server (--configure):
installed mongodb-org-server package post-installation script subprocess returned error exit status 127
Setting up mongodb-org-shell (4.4.0) ...
dpkg: dependency problems prevent configuration of mongodb-org:
mongodb-org depends on mongodb-org-server; however:
Package mongodb-org-server is not configured yet.
dpkg: error processing package mongodb-org (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Errors were encountered while processing:
mongodb-org-server
mongodb-org
[91mE: Sub-process /usr/bin/dpkg returned an error code (1)
[0mThe command '/bin/sh -c set -x && export DEBIAN_FRONTEND=noninteractive && apt-get update && echo "mongodb-org hold" | dpkg --set-selections && echo "mongodb-org-server hold" | dpkg --set-selections && echo "mongodb-org-shell hold" | dpkg --set-selections && echo "mongodb-org-mongos hold" | dpkg --set-selections && echo "mongodb-org-tools hold" | dpkg --set-selections && apt-get install -y ${MONGO_PACKAGE}=$MONGO_VERSION ${MONGO_PACKAGE}-server=$MONGO_VERSION ${MONGO_PACKAGE}-shell=$MONGO_VERSION ${MONGO_PACKAGE}-mongos=$MONGO_VERSION ${MONGO_PACKAGE}-tools=$MONGO_VERSION && rm -f /usr/local/bin/systemctl && rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/mongodb && mv /etc/mongod.conf /etc/mongod.conf.orig' returned a non-zero code: 100
To be precise
RUN ln -s /bin/echo /bin/systemctl
RUN apt-get -qqy install mongodb-org
FL3SH answer works but to convey the meaning more effectively you can create a symbolic link from /bin/systemctl to /bin/true.
/bin/true is a command wich always return 0 (the truthy value of the shell) so it does not fail. It's a standard way to indicate that you want to return true. See this SO post also
The command you need to add in the Dockerfile is:
RUN ln -s /bin/true /usr/local/bin/systemctl
or
RUN ln -s /bin/true /bin/systemctl
The effect is that you trick the post-install script by calling /bin/true instead of /bin/systemctl
You can find the same trick into the official mongodb Dockerfile 4.4 line 91 that haytham linked in his description.
/bin/echo works as well as /bin/true because echo returns 0 as well. You can try it by doing
echo "test"
echo $?
And you'll see 0 as the result of the second echo.
echo ln to /bin/systemctl solves the issue.
I want to install MongoDB in my AWS Cloud9 server. So I followed the instruction as the Cloud9 community page says, but the command to run the MongoDB server in c9 command line i.e.,
$ *./mongod* returns ./mongod: line 1: mongod: command not found.
help me to fix this.
I've tried searching about it on YouTube but it didn't work.
$ *sudo yum install -y mongodb-org*
Loaded plugins: priorities, update-motd, upgrade-helper
1062 packages excluded due to repository priority protections
No package mongodb-org available.
Error: Nothing to do
$ mkdir data
$ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$#"' > mongod
$ chmod a+x mongod
$ ./mongod
./mongod: line 1: mongod: command not found
We can start mongodb by running the mongod script on your project root:
command :- ./mongod
From the error given below, it is apparent that the mongo repo wasn't configured in your yum package manager.
vocstartsoft:~ $ sudo yum install -y mongodb-org
Loaded plugins: priorities, update-motd, upgrade-helper 1062 packages excluded due to repository priority protections No package mongodb-org available. Error: Nothing to do
Create /etc/yum.repos.d/mongodb-org-4.0.repo and write the following in it.
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Or add the repo directly from the .repo file,
yum-config-manager --add-repo https://repo.mongodb.org/yum/amazon/mongodb-org.repo
Then run,
sudo yum install -y mongodb-org
Reference
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Either try this: sudo apt install mongodb-clients
Or consider the below process:
ubuntu:~/environment $ At the terminal you’ll see this.
Enter touch mongodb-org-3.6.repo into the terminal
Now open the mongodb-org-3.6.repo file in your code editor (select it from the left-hand file menu) and paste the following into it then save the file:
[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
* Now run the following in your terminal:
sudo mv mongodb-org-3.6.repo /etc/yum.repos.d
sudo yum install -y mongodb-org
If the second code does not work try:
sudo apt install mongodb-clients
Close the mongodb-org-3.6.repo file and press Close tab when prompted
Change directories back into root ~ by entering cd into the terminal then enter the following commands:
“ubuntu:~ $ “ - Terminal should look like this.
sudo mkdir -p /data/db
echo 'mongod --dbpath=data --nojournal' > mongod
chmod a+x mongod
Now test mongod with ./mongod
Remember, you must first enter cd to change directories into root ~ before running ./mongod
Don't forget to shut down ./mongod with ctrl + c each time you're done working
-if this error pops up while using command mongod
exception in initAndListen: IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db, terminating
Then use the code:
sudo chmod -R go+w /data/db
Reference
from my node scripts I need to execute mongoimport via the exec function from child_process. When it comes to the CI tests in the docker image I run into a problem:
/bin/sh: 1: mongoimport: not found
Now I inserted the installation of mongodb in the drone.yml file:
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
- echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 main" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
- apt-get update
- apt-get install -d -y mongodb-org-tools
But still mongoimport isn't found. I even added the root / to the PATH variable or made a
find / -name "mongoimport"
Nothing.
Has anyone an idea, how to get mongoimport working in the docker image?
Thank you.
PS.: Here's the output from apt-get:
$ apt-get install -d -y mongodb-org-tools
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
mongodb-org-tools
0 upgraded, 1 newly installed, 0 to remove and 102 not upgraded.
Need to get 31.4 MB of archives.
After this operation, 135 MB of additional disk space will be used.
Get:1 http://repo.mongodb.org/apt/debian/ jessie/mongodb-org/3.2/main mongodb-org-tools amd64 3.2.14 [31.4 MB]
Fetched 31.4 MB in 1s (28.2 MB/s)
Download complete and in download only mode
Solved: I tried to install the wrong package.
- apt-get install -d -y mongodb-org-tools
It must be
- apt-get install -y mongodb-org
Then automatically the mongodb-org-tools are installed together with some other packages. Now mongoimport can be used
$ find / -name "mongoimport" -ls > out.txt
$ cat out.txt
2038 10588 -rwxr-xr-x 1 root root 10839312 Jun 13 22:30 /usr/bin/mongoimport
I installed mongo DB by using docs of mongo DB. But when I tried this command in ubuntu terminal, I got this error:
Command used:
sudo mongod
Error:
*********************************************************************
ERROR: dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
How can I fix this error?
Run this command to create a directory -
sudo mkdir /data/db
and then run
sudo mongod
If you installed mongo as a service (for example, using the following docs: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/), simply execute:
sudo service mongod start
Otherwise, if you simply wish to try mongo without any specific configuration, you can supply a directory for the db files by executing:
mongod --dbpath /path/to/db &
Simple Mongo Setup on AWS Unbuntu 14.0 - By Hrushikesh Kulkarni
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update sudo apt-get install -y mongodb-org sudo apt-get install php5 sudo apt-get install apache2 sudo apt-get install libsasl2-dev sudo apt-get install php-pear php5-dev sudo pecl install mongo
Add Below Stuff in /etc/php5/apache2/php.ini
extension_dir = "/usr/lib/php5/20121212" extension=mongo.so sudo service apache2 restart
Create php File in /var/www/html Run file in browser and find Extension "Mongo"
If you have created Test123 folder then
Run following command to restart the mongodb service
sudo service mongodb restart
Then change the db for the mongodb
Use following command
sudo mongod --dbpath Test123
Here Test123 is directory that you have created on specific location.