简体   繁体   中英

Mongodb crashing when closing Terminal (SSH)

I'm not familiar with programming.

I have an active running project (mobile app, showing objects, that surround it's users) from my previous devs ( + ).

At the same time, the new devs are developing the same project from zero using + . So they are not familiar with the old project.

The old project was working perfectly during a long time (near 9 months), but a few days ago, in mobile app the list of objects was empty. Also when i was trying to login to the admin panel, it was saying:

Response Status: 500

Cause: org.springframework.dao.DataAccessResourceFailureException

Message: 
Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=STANDALONE, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=STANDALONE, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

When i'm entering wrong credentials to the admin panel, it's telling me "wrong username or password", so it's working, that's why i though it was a problem with mongodb, not back-end.

So i've successfully connected to the instance ( SSH ) using Terminal on my Mac.

Where the database is? There are 2 folders in the Root (that's the home directory of the instance right?):

 - backend folder
 - backups folder

The database is: /backend_folder/data/db

How i've launched the database? Terminal:

cd backend_folder

cd data/db

then: mongod (or sudo mongod ) - it's doesn't matter, the same issue below:

F CONTROL  [main] Failed global initialization: BadValue: Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.

then:

export LC_ALL=C

then:

mongod

After that it's working again (objects are showing in the app, and i successfully can login to the admin panel).

The problem is, that after closing the Terminal it's not working again (objects list in the app is empty, and the same error after login to the admin panel).

So how do you think, what can i do to fix it? How the mongodb can be still active after closing the Terminal? Thank you a lot!

Here is the text, showing in the Terminal after successful command mongod :

2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] MongoDB starting : pid=***** port=***** dbpath=/data/db 64-bit host=ip-***-**-**-***
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] db version v3.2.11
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] git version: *******************
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] OpenSSL version: *************
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] allocator: *******
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] modules: none
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] build environment:
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten]     distmod: ubuntu********
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten]     distarch: x86_64
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2018-03-16T01:57:37.314+0000 I CONTROL  [initandlisten] options: {}
2018-03-16T01:57:37.337+0000 I -        [initandlisten] Detected data files in /data/db created by the '**********' storage engine, so setting the active storage engine to '**********'.
2018-03-16T01:57:37.337+0000 I STORAGE  [initandlisten] **********_open config: create,cache_size=3G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] 
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] 
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-03-16T01:57:37.510+0000 I CONTROL  [initandlisten] 
2018-03-16T01:57:37.513+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-03-16T01:57:37.514+0000 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2018-03-16T01:57:37.514+0000 I NETWORK  [initandlisten] waiting for connections on port *****
2018-03-16T01:57:43.713+0000 I NETWORK  [initandlisten] connection accepted from ***.*.*.*:***** #1 (1 connection now open)
2018-03-16T01:57:43.731+0000 I ACCESS   [conn1] Successfully authenticated as principal admin on **My Project Name**

Also, I found this thing in the old documentation:

# SpringBoot

CMD mongod --fork --logpath /log/mongodb.log && \\ cd project_backend && \\ mvn clean spring-boot:run

而已:

sudo mongod --fork --logpath /var/log/mongod.log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM