Cannot start mongodb after editing .conf file to add new Ip to bindIp - linux

I have installed mongodb 2.6 in a ubuntu 14.02 server. To allow remote access I added the static Ip to /etc/mongod.conf
bindIp= 127.0.0.1, 192.168.0.150
I edited the file as root user using sudo command.
After this mongodb is not starting as service on boot up. But I can start it using following command :
sudo mongod --dbpath /var/lib/mongodb
As I understand I made some permission problem while editing conf file. I tried a few solutions including changing owner of /etc folder to mongodb as well as current system user. But they are not working. I am a very new user to linux environment. Any help would be much appreciated.
Edit:
Result of ls -l /etc/mongod.conf:
-rw-r--r-- 1 root root 1716 Aug 14 23:32 /etc/mongod.conf
Also the result for the command:
sudo service mongod start
is:
mongod start/running, process 2660.
But if I try to open mongo client with mongo, I get
errno:111 connection refused, connection attempt failed at src/mongo/shell/mongo.js:146

this line should be:
bindIp=[127.0.0.1,192.168.0.150]

Related

Unable to connect to server following phpMyAdmin upgrade from 5.1 to 5.2

Working environment:
OpenSUSE Leap 15.4
MariaDB : mariadb Ver 15.1 Distrib 10.7.7-MariaDB
PHP 8.0.25 (cli) (built: Oct 31 2022 12:00:00) ( NTS )
Based on phpinfo(), PHP ini file is: /etc/php8/cli/php.ini.
phpMyAdmin 5.1 is working well. Installation directory is: /usr/share/phpMyAdmin (default directory created when installing via zypper install phpMyAdmin command).
The "famous" option $cfg['Servers'][$i]['host'] from /etc/phpMyAdmin/config.inc.php file is set to localhost (and it does work!).
I have then upgraded phpMyAdmin version this way:
srv-bla:~ # mv /usr/share/phpMyAdmin /usr/share/phpMyAdmin.old
srv-bla:~ # mkdir /usr/share/phpMyAdmin
srv-bla:~ # wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.tar.gz
srv-bla:~ # tar -xzf phpMyAdmin-5.2.0-all-languages.tar.gz
srv-bla:~ # mv phpMyAdmin-5.2.0-all-languages/* /usr/share/phpMyAdmin/
I then restart daemons and test the connection:
srv-bla:~ # systemctl restart mysqld mariadb apache2
The connection page is showing right. I then enter my credentials and I get stuck with this bloody message:
Impossible to connect to server.
mysqli::real_connect(): (HY000/2002): No such file or directory
I have wandered for a while on numerous webpages. Many of them suggest to modify the config.inc.php file and to set $cfg['Servers'][$i]['host'] option to 127.0.0.1 instead of localhost. Unfortunately, this does not fix the problem for me...
Am I editing the right config.inc.php file? Actually, I can find only one on the server:
srv-bla:~ # updatedb
srv-bla:~ # locate config.inc.php
/etc/phpMyAdmin/config.inc.php
/etc/phpMyAdmin/config.inc.php.rpmnew
/etc/phpMyAdmin/config.inc.php.rpmsave
Apache logs are not friendly either. Access logs returns 200 codes only, which seems normal to me (the phpMyAdmin webpage is served properly). Error logs are empty...
Mysql logs are empty also (/var/log/mysql/mysqld.log).
Or course, I have check that mysqld service (same as mariadb service) is running.
The socket file from MariaDB point of view is:
srv-bla:~ # mariadb -u root -p
Enter password:
MariaDB [(none)]> \s
[...]
UNIX socket: /var/lib/mysql/mysql.sock
[...]
The php.ini file is configured the same way:
srv-bla:~ # cat /etc/php8/cli/php.ini | grep mysqli.default_socket
mysqli.default_socket = /var/lib/mysql/mysql.sock
To me, there is no socket issue...
You were right #Georg Richter!
Solution for me:
The PHP configuration file returned by php -r 'phpinfo();' command in a terminal is /etc/php8/cli/php.ini.
The PHP configuration file returned by the phpinfo() function called with a URL such as http://myserver.fr/phpinfo.php is /etc/php8/apache2/php.ini.
I modified the line mysqli.default_socket = /var/lib/mysql/mysql.sock in this other configuration file and could call again phpMyAdmin with success. Note that emtying the browser cache was necessary!
Thanks for help, and hope this will help others!

Error when install postgresql in linux mint sarah

I want to install postgresql in my computer Linux mint sarah, and I finish procedure installation but when I type psql in my cmd postgres error, like this :
Error when install PostgreSQL
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
how I fixed that ??
thanks
The error states that the psql utility can't find the socket to connect to your database server.
Either you don't have the database service running in the background, or the socket is located elsewhere, or perhaps the pg_hba.conf needs to be fixed.
Step 1: Verify that the database is running
The command may vary depending on your operating system. But on most *ix systems the following would work, it will search for postgres among all running processes
ps -ef | grep postgres
On my system, mac osx, this spits out
501 408 1 0 2Jul15 ?? 0:21.63 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
The last column shows the command used to start the server, and the options.
You can look at all the options available to start the postgres server using the following.
man postgres
From there, you'd see that the options -D and -r are respectively the datadir & the logfilename.
Step 2: If the postgres service is running
Use find to search for the location of the socket, which should be somewhere in the /tmp
sudo find /tmp/ -name .s.PGSQL.5432
If postgres is running and accepting socket connections, the above should tell you the location of the socket. On my machine, it turned out to be:
/tmp/.s.PGSQL.5432
Then, try connecting via psql using this file's location explicitly, eg.
psql -h /tmp/ dbname
Step 3: If the service is running but you don't see a socket
If you can't find the socket, but see that the service is running, Verify that the pg_hba.conf file allows local sockets.
Browse to the datadir and you should find the pg_hba.conf file.
By default, near the bottom of the file you should see the following lines:
# "local" is for Unix domain socket connections only
local all all trust
If you don't see it, you can modify the file, and restart the postgres service.

Bacula bconsole doesn't connect to localhost Centos7

I've recently installed Bacula on Centos7 Cloud HaaS from digital ocean. However, all the tests and steps were done correctly, the problem is when I try to connect to bacula's console using the command:
sudo bconsole
I get Connecting to Director localhost:9101 and nothing happens.
If i try listening:
netstat -ltnp
No outputs are present from the port 9101
After trying debugging using:
bacula-dir -d 100 -c /etc/bacula/bacula-dir.conf
I get the following output:
bacula-dir: dird.c:223-0 Debug level = 100
[root#panel ~]# 14-أكت 11:37 bacula-dir: ERROR TERMINATION at bsys.c:484
bacula-dir is already running. pid=2458
Check file /var/run/bacula-dir.9101.pid
Any clue what to do in order to get the bconole to work?
Resolved.
Database user was not connected to the configuration files.
To fix this login to mysql as root:
mysql -u root -p
Enter your root password, then create a DB user and password for Bacula.
(Assuming you already entered your db password inside "bacula-sd.conf"
Now lets set Bacula to use the Mysql library:
su -c 'alternatives --config libbaccats.so'
This should show you the following:
There are 3 programs which provide ‘libbaccats.so’.
Selection Command
————————————————————————
1 /usr/lib64/libbaccats-mysql.so
2 /usr/lib64/libbaccats-sqlite3.so
*+ 3 /usr/lib64/libbaccats-postgresql.so
Hit 1 and press enter to select MySql.

Cassandra in Docker unable to make directory on mounted volume

When I attempt to start the docker image tobert/cassandra from https://github.com/tobert/cassandra-docker I get the following error. Can anyone explain what this error means?
os.MkdirAll('/data/conf') failed: %!s(MISSING)
The command I am running is:
sudo docker run -v /data/cassandra:/data tobert/cassandra
I have created the directory /data/cassandra in my host os of RH Linux. I have even opened up the permissions all the way to see if it was a permission issue.
drwxrwxrwx. 2 root root 6 Apr 10 12:10 cassandra
Is SELinux enabled? You're doing everything right so something else must be blocking mkdir. Please check your syslog (RHEL <= 6.x) or journalctl (RHEL 7).

Permission denied to read file owned by user

I'm trying to restart (it is running) MongoDB on Ubuntu 14.04 but keep getting failures with this line in the log error getting file /srv/mongodb/keyfile: Permission denied
Here's directory structure
drwxr-xr-x 3 root root 4096 Jan 31 05:54 srv/
drw------- 2 mongodb mongodb 4096 Jan 31 07:07 mongodb/
-rw------- 1 mongodb mongodb 876 Jan 31 07:07 keyfile
The user running mongod is "mongodb", group "mongodb" so it should be available for reading.
If I change permissions on mongodb/ and keyfile to -rw-r--r-- it becomes readable, but mongo claims it's too permissive of course
Going cookoo with this thing already. Any suggestion what's wrong here?
I've had the same problem before, and the solution I found and was not documented had to do with the context. If you are in Linux try:
ls -lahZ
That will display in list, all files, sizes in human readable and Z for contexts, I noticed that the keyFile must have "system_u:object_r:mongod_var_lib_t:s0" context, so it gets fixed with:
chcon system_u:object_r:mongod_var_lib_t:s0 mongodb-keyfile
Hope that helps!!
I got the mongod service working by changing the owner of the key file to mongod
sudo chown mongod:mongod mongodb.key
the mongod process owner is mongod which tries to access the file
In addition to read and write permission for a directory, usually you must have an execute permission as well (more info at http://en.wikipedia.org/wiki/File_system_permissions#Permissions). So, you have to set the following permissions:
chmod 700 /srv/mongodb/
chmod 600 /srv/mongodb/keyfile
Since none of the answers here solved my problem, and I had the same problem exactly, I'll try to post what worked for me.
My solution:
Stop Mongo
Edit mongod.conf and temproraily comment out the attribute keyFile: /path/to/key
Start Mongo
sudo chown mongod </path/to/key>
sudo chmod 400 </path/to/key>
Remove comment from KeyFile attribute in mongod.conf
Restart Mongo
Hope this helps

Resources