Failed to obtain address information for hostname mynode1: Name or service not known

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Evils798/article/details/51455246
启动mongodb的时候报以下错,意思是获取不到地址对应的主机名,这一般与HOSTS有关

Failed to obtain address information for hostname mynode1: Name or service not known

2016-05-19T15:18:53.339+0800 I CONTROL  [initandlisten] MongoDB starting : pid=16871 port=27017 dbpath=/data/db 64-bit host=mdb
2016-05-19T15:18:53.340+0800 I CONTROL  [initandlisten] db version v3.2.3
2016-05-19T15:18:53.340+0800 I CONTROL  [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-05-19T15:18:53.340+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-05-19T15:18:53.340+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2016-05-19T15:18:53.340+0800 I CONTROL  [initandlisten] modules: none
2016-05-19T15:18:53.856+0800 I CONTROL  [initandlisten] 2016-05-19T15:18:53.856+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-05-19T15:18:53.856+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-05-19T15:18:53.856+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-05-19T15:18:53.856+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-05-19T15:18:53.856+0800 I CONTROL  [initandlisten] 
2016-05-19T15:18:53.859+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-05-19T15:18:53.860+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-05-19T15:18:53.860+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-05-19T15:18:53.918+0800 W NETWORK  [HostnameCanonicalizationWorker] Failed to obtain address information for hostname mynode1: Name or service not known

首先检查hosts文件,看是否有服务器IP地址对应的主机名

[root@w ~]# more /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

发现没有地址对应的主机名,手动添加以下条目

192.168.10.10  mdb

再次重新启动mongodb,错误消失,看来mongodb启动需要解析hosts,这点与oracle RAC 有点类似,Mark一下
# nohup ./mongod > mongo.out &
# tail -50 mongo.out
2016-05-19T16:56:24.685+0800 I CONTROL  [initandlisten] MongoDB starting : pid=22471 port=27017 dbpath=/data/db 64-bit host=mdb
2016-05-19T16:56:24.686+0800 I CONTROL  [initandlisten] db version v3.2.3
2016-05-19T16:56:24.686+0800 I CONTROL  [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-05-19T16:56:24.686+0800 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-05-19T16:56:24.686+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2016-05-19T16:56:24.686+0800 I CONTROL  [initandlisten] modules: none
2016-05-19T16:56:25.176+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-05-19T16:56:25.176+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-05-19T16:56:25.176+0800 I CONTROL  [initandlisten] 
2016-05-19T16:56:25.176+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-05-19T16:56:25.176+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-05-19T16:56:25.176+0800 I CONTROL  [initandlisten] 
2016-05-19T16:56:25.179+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2016-05-19T16:56:25.180+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-05-19T16:56:25.180+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页