博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mongodb 初学 意外 连接服务器异常(Connection refused)
阅读量:5325 次
发布时间:2019-06-14

本文共 4038 字,大约阅读时间需要 13 分钟。

啦啦啦

这种情况

root@localhost:/# mongoMongoDB shell version: 3.2.13connecting to: test2017-05-31T07:40:34.548-0700 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused2017-05-31T07:40:34.549-0700 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :connect@src/mongo/shell/mongo.js:229:14@(connect):1:6exception: connect failed

由于直接kill掉的进程,不知道为什么服务再启动时options:{}为空。虽启动时指定-dbpath 参数

mongod -dbpath "/var/lib/mongodb/"

但是这样必须保证服务窗口不能关闭。

使用配置文件方式启动

mongod -f /etc/mongod.conf

这样也必须保证服务窗口不能关闭。

采用守护进程方式启动:Daemon

–fork参数可以将mongodb的服务放在后台运行

root@localhost:/# mongod -fork -f /etc/mongod.conf about to fork child process, waiting until server is ready for connections.forked process: 1163child process started successfully, parent exiting

mongod.log

2017-05-31T07:42:28.242-0700 I CONTROL  [main] ***** SERVER RESTARTED *****2017-05-31T07:42:28.249-0700 I CONTROL  [initandlisten] MongoDB starting : pid=1163 port=27017 dbpath=/var/lib/mongodb 64-bit host=localhost2017-05-31T07:42:28.250-0700 I CONTROL  [initandlisten] db version v3.2.132017-05-31T07:42:28.250-0700 I CONTROL  [initandlisten] git version: 23899209cad60aaafe114f6aea6cb83025ff51bc2017-05-31T07:42:28.251-0700 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 20162017-05-31T07:42:28.251-0700 I CONTROL  [initandlisten] allocator: tcmalloc2017-05-31T07:42:28.251-0700 I CONTROL  [initandlisten] modules: none2017-05-31T07:42:28.251-0700 I CONTROL  [initandlisten] build environment:2017-05-31T07:42:28.252-0700 I CONTROL  [initandlisten]     distmod: ubuntu16042017-05-31T07:42:28.252-0700 I CONTROL  [initandlisten]     distarch: x86_642017-05-31T07:42:28.252-0700 I CONTROL  [initandlisten]     target_arch: x86_642017-05-31T07:42:28.252-0700 I CONTROL  [initandlisten] options: { config: "/etc/mongod.conf", net: { port: 27017 }, processManagement: { fork: true }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }2017-05-31T07:42:28.276-0700 I -        [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.2017-05-31T07:42:28.276-0700 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_min=4,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),2017-05-31T07:42:28.461-0700 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2017-05-31T07:42:28.462-0700 I CONTROL  [initandlisten] 2017-05-31T07:42:28.462-0700 I CONTROL  [initandlisten] 2017-05-31T07:42:28.462-0700 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.2017-05-31T07:42:28.462-0700 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2017-05-31T07:42:28.462-0700 I CONTROL  [initandlisten] 2017-05-31T07:42:28.463-0700 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.2017-05-31T07:42:28.463-0700 I CONTROL  [initandlisten] **        We suggest setting it to 'never'2017-05-31T07:42:28.463-0700 I CONTROL  [initandlisten] 2017-05-31T07:42:28.466-0700 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'2017-05-31T07:42:28.466-0700 I NETWORK  [initandlisten] waiting for connections on port 270172017-05-31T07:42:28.467-0700 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker2017-05-31T07:43:01.201-0700 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:56034 #1 (1 connection now open)

啦啦啦

啦啦啦

转载于:https://www.cnblogs.com/ClassNotFoundException/p/6926215.html

你可能感兴趣的文章
面向对象(多异常的声明与处理)
查看>>
MTK笔记
查看>>
ERROR: duplicate key value violates unique constraint "xxx"
查看>>
激活office 365 的启动文件
查看>>
无法根据中文查找
查看>>
[简讯]phpMyAdmin项目已迁移至GitHub
查看>>
转载 python多重继承C3算法
查看>>
【题解】 bzoj1597: [Usaco2008 Mar]土地购买 (动态规划+斜率优化)
查看>>
css文本溢出显示省略号
查看>>
git安装和简单配置
查看>>
面向对象:反射,双下方法
查看>>
鼠标悬停提示文本消息最简单的做法
查看>>
课后作业-阅读任务-阅读提问-2
查看>>
面向对象设计中private,public,protected的访问控制原则及静态代码块的初始化顺序...
查看>>
fat32转ntfs ,Win7系统提示对于目标文件系统文件过大解决教程
查看>>
Awesome Adb——一份超全超详细的 ADB 用法大全
查看>>
shell cat 合并文件,合并数据库sql文件
查看>>
Android 将drawable下的图片转换成bitmap、Drawable
查看>>
介绍Win7 win8 上Java环境的配置
查看>>
Linux设置环境变量的方法
查看>>