关闭终端(SSH)时Mongodb崩溃

时间:2018-03-16 11:24:30

标签: java database mongodb crash application-shutdown

我不熟悉编程。

我之前的开发人员( + )有一个活跃的正在运行的项目(移动应用,显示围绕用户的对象)。

与此同时,新开发人员使用 + 从零开发同一个项目。所以他们不熟悉旧项目。

旧项目在很长一段时间(接近9个月)都运行良好,但几天前,在移动应用程序中,对象列表是空的。此外,当我尝试登录管理面板时,它说:

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)}}]

当我输入错误的凭据给管理面板时,它告诉我“用户名或密码错误”,所以它正在工作,这就是为什么我虽然这是mongodb的问题,而不是后端。

所以我已经使用Mac上的终端成功连接到实例( SSH )。

数据库在哪里? Root中有2个文件夹(这是实例的主目录吗?):

 - backend folder
 - backups folder

数据库是:/backend_folder/data/db

我是如何推出数据库的? 终端:

cd backend_folder

cd data/db

然后: mongod(或sudo mongod) - 这没关系,下面是同一个问题:

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

然后:

export LC_ALL=C

然后:

mongod

之后它再次运行(对象显示在应用程序中,我成功登录管理面板)。

问题是,关闭终端后它再次无法运行(应用程序中的对象列表为空,登录管理面板后出现相同的错误)。

那么您如何看待,我该怎么做才能解决这个问题?关闭终端后,mongodb如何仍然有效?非常感谢你!

以下是成功命令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**

另外,我在旧文档中找到了这个东西:

# SpringBoot

CMD mongod --fork --logpath /log/mongodb.log& amp;& \     cd project_backend&& \     mvn clean spring-boot:运行

1 个答案:

答案 0 :(得分:0)

那就是:

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