【问题标题】:How do you restart MongoDB server and closing the terminal on Cloud 9如何在 Cloud 9 上重新启动 MongoDB 服务器并关闭终端
【发布时间】:2018-06-06 03:00:58
【问题描述】:

我正在开发其中我使用 MongoDB 作为我的数据库,我使用以下命令安装在云 9 上的终端上。

$ sudo apt-get install -y mongodb-org 
$ mkdir data
$ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"' > mongod
$ chmod a+x mongod 
$ ./mongod

这很好,完成后我关闭了终端。然后我回到它,我只是输入:$ ./mongod 以运行程序,但它给了我以下错误:

2017-12-24T07:02:40.787+0000 ** WARNING: --rest is specified without --httpinterface,
2017-12-24T07:02:40.787+0000 **          enabling http interface
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
2017-12-24T07:02:40.790+0000 [initandlisten] MongoDB starting : pid=15545 port=27017 dbpath=data 64-bit host=traorefly-real-5786569
2017-12-24T07:02:40.790+0000 [initandlisten] db version v2.6.12
2017-12-24T07:02:40.790+0000 [initandlisten] git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a
2017-12-24T07:02:40.790+0000 [initandlisten] build info: Linux build5.ny.cbi.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2017-12-24T07:02:40.790+0000 [initandlisten] allocator: tcmalloc
2017-12-24T07:02:40.790+0000 [initandlisten] options: { net: { bindIp: "0.0.0.0", http: { RESTInterfaceEnabled: true, enabled: true } }, storage: { dbPath: "data", journal: { enabled: false } } }
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR:   addr already in use
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
2017-12-24T07:02:40.811+0000 [initandlisten] ERROR:   addr already in use
2017-12-24T07:02:40.814+0000 [initandlisten] now exiting
2017-12-24T07:02:40.814+0000 [initandlisten] dbexit: 
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: going to close listening sockets...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: going to flush diaglog...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: going to close sockets...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: waiting for fs preallocator...
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: closing all files...
2017-12-24T07:02:40.814+0000 [initandlisten] closeAllFiles() finished
2017-12-24T07:02:40.814+0000 [initandlisten] shutdown: removing fs lock...
2017-12-24T07:02:40.814+0000 [initandlisten] dbexit: really exiting now

有人说删除数据文件中创建的*mongod.lock 然后使用--repair 然后运行它,但它仍然不起作用。

【问题讨论】:

    标签: mongodb nosql cloud9


    【解决方案1】:

    您正在启动一个 mongod 实例,而一个实例已经在后台运行。您可以使用ps -A 查找mongod 进程,然后使用kill <process id> 杀死该实例。

    如果端口被任何其他进程阻塞,您可以通过以下方式找到:lsof -i :27017

    COMMAND   PID   USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
    mongod  30284 ubuntu    5u  IPv4 447749095      0t0  TCP *:27017 (LISTEN)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      相关资源
      最近更新 更多