Fail to start mongodb on centos - linux

I'm trying to install mongodb on my centos server. after downloading and unziping the file I used the command rpm -ivh mongodb-org-server-4.0.5-1.el6.x86_64.rpm to install mongodb, then mkdir -p /var/lib/mongo and mkdir -p /var/log/mongodb to create the MongoDB data and log directories. I did chown -R mongod:mongod <directory> to set the owner and group of these directories to mongod. I modified the path : export PATH=<mongodb-install-directory>/bin:$PATH
but when I want to start mongo it fails Starting mongod: [FAILED]
it is the stack trace in mongodb log file:
2019-01-13T10:45:13.807+0330 F - [initandlisten] Fatal assertion 28520 knownError: 28: No space left on device at src/mongo/db/storage/kv/kv_storage_ gine.cpp 128
2019-01-13T10:45:13.807+0330 F - [initandlisten]
***aborting after fassert() failure
2019-01-13T10:45:13.949+0330 F - [initandlisten] Got signal: 6 (Aborted
0x7fc4b8b36b11 0x7fc4b8b35d29 0x7fc4b8b3620d 0x7fc4b4fb3710 0x7fc4b4c42925 0x c4b4c44105 0x7fc4b715570b 0x7fc4b73a42a5 0x7fc4b73a6d40 0x7fc4b720c066 0x7fc4b ffa7a 0x7fc4b70d7f90 0x7fc4b71c1466 0x7fc4b7156fb9 0x7fc4b4c2ed1d 0x7fc4b71bf5
----- BEGIN BACKTRACE -----
{"backtrace":[{"b":"7FC4B6741000","o":"23F5B11","s":"_ZN5mongo15printStackTrac RSo"},{"b":"7FC4B6741000","o":"23F4D29"},{"b":"7FC4B6741000","o":"23F520D"},{" :"7FC4B4FA4000","o":"F710"},{"b":"7FC4B4C10000","o":"32925","s":"gsignal"},{"b "7FC4B4C10000","o":"34105","s":"abort"},{"b":"7FC4B6741000","o":"A1470B","s":" N5mongo42fassertFailedWithStatusNoTraceWithLocationEiRKNS_6StatusEPKcj"},{"b": FC4B6741000","o":"C632A5","s":"_ZN5mongo15KVStorageEngine11loadCatalogEPNS_16O rationContextE"},{"b":"7FC4B6741000","
can any one knows why it doesn't start successfully?
It doesn't know the use command either when I want to make a database.

Why are you using version mongodb-org-server-4.0.5-1.el6.x86_64?
I recently installed mongodb on a shared centos server from godaddy. I used this version of mongodb: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.5.tgz.
Remove all the files and folders from your first attempt, and try the version above. Hope it helps!
Edit:
SOLUTION by kometen
Does the file /tmp/mongodb-27017.sock exist? If so try to delete it, ie. 'sudo rm /tmp/mongodb-27017.sock'.

Related

No passwd entry for user 'mssql' sqlsrv on Linux

I use the mcr.microsoft.com/mssql/server:2017 docker container to run a mssql server. I tried to change the collation like this:
echo "SQL_Latin1_General_CP1_CI_AS" | /opt/mssql/bin/mssql-conf set-collation
Unfortunately I get this error:
No passwd entry for user 'mssql'
How is it possible to fix this error?
I created a new user with useradd mssql, but now I get this error if I run the command:
sqlservr: Unable to open /var/opt/mssql/.system/instance_id: File: pal.cpp:566 [Status: 0xC0000022 Access Denied errno = 0xD(13) Permission denied]
/opt/mssql/bin/sqlservr: PAL initialization failed. Error: 101
It looks the latest mcr.microsoft.com/mssql/server fix such issue, if you insist on the old, next could be the procedure to fix all user/permission issue:
cake#cake:~/20211012$ docker run --rm -it mcr.microsoft.com/mssql/server:2017-latest /bin/bash
SQL Server 2019 will run as non-root by default.
This container is running as user root.
To learn more visit https://go.microsoft.com/fwlink/?linkid=2099216.
root#4fd0bdf1d21c:/# useradd mssql
root#4fd0bdf1d21c:/# mkdir -p /var/opt/mssql
root#4fd0bdf1d21c:/# chmod -R 777 /var/opt/mssql
root#4fd0bdf1d21c:/# echo "SQL_Latin1_General_CP1_CI_AS" | /opt/mssql/bin/mssql-conf set-collation
Enter the collation: Configuring SQL Server...
The SQL Server End-User License Agreement (EULA) must be accepted before SQL
Server can start. The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746388.
You can accept the EULA by specifying the --accept-eula command line option,
setting the ACCEPT_EULA environment variable, or using the mssql-conf tool.

Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect) when connecting to Azure SQL database from Python running in OpenShift

Only when trying to connect to my Azure DB from Python 3.7 running in
a OpenShift container (FROM rhel7:latest) I see the following error:
sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('IM004', "[IM004][unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect)
I tried the exact same code in Docker on my MAC, Windows and a RHEL7 Virtualbox running the RHEL7 base container - it always works! The problem is only in my container running in OpenShift!
I checked that I can telnet to my Azure DB server in 1433 from Openshift.
I enabled the ODBC logs as well but there is no more information than the above error.
What else should I check?
Here is how I set up the MSODBC driver in my Dockerfile:
RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo && \
yum remove unixODBC-utf16 unixODBC-utf16-devel && \
ACCEPT_EULA=Y yum install -y msodbcsql17 && \
yum install -y unixODBC-devel
And here is the code that throws the error:
inside modules.database:
pyodbc_connstring_safe = 'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER='+config.settings["DB_HOST"]+\
';PORT=1433;DATABASE='+config.settings["DB_NAME"]+';UID='+config.usernames["database"]+\
';PWD={};MARS_Connection=Yes'
if config.settings["debug"]:
print("Using DB connection string: {}".format(pyodbc_connstring_safe.format("SAFE_DB_PASS")))
pyodbc_connstring = pyodbc_connstring_safe.format(config.passwords["database"])
Base = declarative_base()
quoted = urllib.parse.quote_plus(pyodbc_connstring)
def get_engine():
return create_engine('mssql+pyodbc:///?odbc_connect={}'.format(quoted), echo=config.settings["debug"], pool_pre_ping=True)
Inside my flask app (the error gets thrown in the call to 'has_table'):
#app.route("/baselinedb", methods=["POST"])
def create_db():
from modules.database import Base
engine = database.get_engine()
if not engine.dialect.has_table(engine, database.get_db_object_name("BaselineDefinition"), schema = 'dbo'):
Base.metadata.create_all(engine)
db.session.commit()
return "OK"
As I mentioned in the beginning, the same Dockerfile gives me a working Container in Docker either locally on Mac or Windows or inside a RHEL7 VM.
Thanks for having a look!
unixODBC is trying to find the odbc.ini in the current users home directory. It's trying to do this by looking up the user in /etc/passwd. Since Openshift is using a project specific UID which does not exist in /etc/passwd the user lookup will not work and the connection will fail.
To resolve this add the following to the dockerfile
ADD entrypoint.sh .
RUN chmod 766 /etc/passwd
..
..
ENTRYPOINT entrypoint.sh
And the following in the entrypoint script
export $(id)
echo "default:x:$uid:0:user for openshift:/tmp:/bin/bash" >> /etc/passwd
python3.7 app.py
The above will insert the current user to /etc/passwd during startup of the container.
An alternative and probably better approach might be to use nss_wrapper:
https://cwrap.org/nss_wrapper.html
I encountered the same problem while using django on Windows.
After upgrading the 'SQL Server 2017 client' to the latest client resolves my issue.
Use below link to download latest patch:
https://www.microsoft.com/en-us/download/details.aspx?id=56567

can't initialize MongoDB

when I try to initialize a MongoDB project , it says " 2018-07-28T21:54:34.391+0530 F CONTROL [main] Failed global initialization: BadValue: dbPath requires an absolute file path with Windows services".
If someone knows what is the reason for that, please let me know...
my command is :
C:\"Program Files"\MongoDB\Server\4.0\bin>mongod --directoryperdb --dbpath C:\"Program Files"\MongoDB\Server\4.0\data\db --logpath C:\"Program Files"\MongoDB\Server\4.0\log\mongo.log --logappend --install
when I try to initialize it returns an error like below...
2018-07-28T21:54:34.391+0530 F CONTROL [main] Failed global initialization: BadValue: dbPath requires an absolute file path with Windows services
my dbpath -> C:\Program Files\MongoDB\Server\4.0\data\db
my logpath -> C:\Program Files\MongoDB\Server\4.0\log\mongo.log
Have you installed the mongodb? If you haven't done the install, download the mongodb from the link and install it:
https://www.mongodb.com/dr/fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-4.0.0-signed.msi/download
Create the database folder from command prompt
mkdir c:\mongodb\data\db
Create a folder for the log files.
mkdir c:\mongodb\logs
Create a folder for the config files
mkdir c:\mongodb\config
Create a file called mongodb.cfg with the following contents under the config folder c:\mongodb\config.
port=27017
dbpath=C:\mongodb\data\db\
logpath=C:\mongodb\logs\mongod.log
maxConns=100
Start the mongod (for a manual startup. To automate the startup, use step 6 instead)
"C:\Program Files\MongoDB\Server\4.0\bin\mongod" --directoryperdb --config "C:\mongodb\config\mongodb.cfg" --fork
Alternatively define the service
"C:\Program Files\MongoDB\Server\4.0\bin\mongod" --directoryperdb --config "C:\mongodb\config\mongodb.cfg" --install --serviceName "MongoDB"
net start MongoDB
Now your database in localhost with the port 27017 is running. You can create or use the database in node.js or in your favorite programming language.

start-stop-daemon: failed to start `/usr/bin/mongod'

I have an alpine machine on my virtual machine and I want to install mongodb. I added the package for mongodb using "apk add mongodb". I started mongo daemon using command mongod in one terminal. Then opened another terminal with mongo shell using mongo --disableJavaScriptJIT. I tried adding files and reading them from the database and that worked fine. But when I do sudo service mongodb restart I got the following output.
* Caching service dependencies ... [ ok ]
* Starting mongodb ...
* start-stop-daemon: failed to start `/usr/bin/mongod' [ !! ]
* ERROR: mongodb failed to start
The first thing you should do is to read the log file. I think that you’ll read here that mongodb doesn’t have rights to access some files. When you started it manually, you haven’t run it as user mongodb, have you…?
If this hypothesis is right, then the solution is to fix owner (and group) of the /var/lib/mongodb (recursively).

Puppet Dashboard permissions: Permission denied - /var/lib/puppet/reports/

I'm setting up the Puppet Dashboard for the first time. I have it running with the passenger module in Apache.
sudo rake RAILS_ENV=production reports:import
When I run this command, the tasks appear in the dashboard as failed.
630 new failed tasks
The details for each failure look something like this:
Importing report 201212270754.yaml at 2012-12-27 09:21 UTC
Permission denied - /var/lib/puppet/reports/rb-db1/201212270754.yaml
Backtrace
/usr/share/puppet-dashboard/app/models/report.rb:86:in `read'
/usr/share/puppet-dashboard/app/models/report.rb:86:in `create_from_yaml_file'
The report files were owned by puppet:puppet with a 640 permission by default.
I ran chmod a+rw on the reports directory, but I still get the same errors.
Any ideas on what I might be doing wrong here?
If you are running the puppet-dashboard server as root instead of as the puppet-dashboard user, you will see this error. My system is using /usr/share/puppet-dashboard/script/server on centos 6.4 using the puppet-dashboard-1.2.23-1.el6.noarch rpm from puppetlabs.
[root#hadoop01 puppet-dashboard]# cat /etc/sysconfig/puppet-dashboard
#
# path to where you installed puppet dashboard
#
DASHBOARD_HOME=/usr/share/puppet-dashboard
#DASHBOARD_USER=puppet-dashboard
DASHBOARD_USER=root
DASHBOARD_RUBY=/usr/bin/ruby
DASHBOARD_ENVIRONMENT=production
DASHBOARD_IFACE=0.0.0.0
DASHBOARD_PORT=3000
edit the file like above and then run the command
/etc/init.d/puppet-dashboard restart && /etc/init.d/puppet-dashboard-workers restart
my puppet-dashboard version is 1.2.23

Resources