Mongodb 关闭终端 (SSH) 时崩溃
Mongodb crashing when closing Terminal (SSH)
我不熟悉编程。
我有一个活跃的 运行ning 项目(移动应用程序,显示对象,围绕它的用户)来自我以前的开发者(java + mongodb)。
与此同时,新开发人员正在使用 .net + mysql 从零开始开发同一个项目。所以他们对旧项目不熟悉。
旧项目在很长一段时间内(将近 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)}}]
当我向管理面板输入错误的凭据时,它告诉我 "wrong username or password",所以它正在工作,这就是为什么我认为这是 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 && \
cd project_backend && \
mvn clean spring-boot:运行
就是这样:
sudo mongod --fork --logpath /var/log/mongod.log
我不熟悉编程。
我有一个活跃的 运行ning 项目(移动应用程序,显示对象,围绕它的用户)来自我以前的开发者(java + mongodb)。
与此同时,新开发人员正在使用 .net + mysql 从零开始开发同一个项目。所以他们对旧项目不熟悉。
旧项目在很长一段时间内(将近 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)}}]
当我向管理面板输入错误的凭据时,它告诉我 "wrong username or password",所以它正在工作,这就是为什么我认为这是 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 && \ cd project_backend && \ mvn clean spring-boot:运行
就是这样:
sudo mongod --fork --logpath /var/log/mongod.log