【发布时间】:2018-03-16 11:24:29
【问题描述】:
我不熟悉编程。
我有一个来自我以前的开发者 (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)}}]
当我在管理面板中输入错误的凭据时,它告诉我“用户名或密码错误”,所以它可以工作,这就是为什么我认为这是 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:run
【问题讨论】:
标签: java mongodb .net mysql java database mongodb crash application-shutdown