ITPub博客

首页 > 数据库 > NoSQL > mongodb 3.2.0.4安装

mongodb 3.2.0.4安装

原创 NoSQL 作者:orclwujian 时间:2016-04-07 14:19:42 0 删除 编辑
下载地址
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.4.tgz
解压
[root@trcloud-wujian-test02 disk]# tar -xf mongodb-linux-x86_64-3.2.4.tgz 
[root@trcloud-wujian-test02 disk]# ls
lost+found  mongodb-linux-x86_64-3.2.4  mongodb-linux-x86_64-3.2.4.tgz
将mongodb目录名改成mongodb
[root@trcloud-wujian-test02 disk]# mv mongodb-linux-x86_64-3.2.4 mongodb
[root@trcloud-wujian-test02 disk]# ls
lost+found  mongodb  mongodb-linux-x86_64-3.2.4.tgz
[root@trcloud-wujian-test02 disk]# cd mongodb
创建数据目录、日志目录和日志文件
[root@trcloud-wujian-test02 mongodb]# mkdir data
[root@trcloud-wujian-test02 mongodb]# mkdir log
[root@trcloud-wujian-test02 mongodb]# cd log/
[root@trcloud-wujian-test02 log]# touch mongodb.log
[root@trcloud-wujian-test02 log]# cd ../bin

启动mongodb服务
[root@trcloud-wujian-test02 bin]# ./mongod --dbpath=/disk/mongodb/data/
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] MongoDB starting : pid=20221 port=27017 dbpath=/disk/mongodb/data/ 64-bit host=trcloud-wujian-test02.novalocal
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] db version v3.2.4
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] modules: none
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] build environment:
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten]     distarch: x86_64
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2016-04-07T13:23:18.234+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/disk/mongodb/data/" } }
2016-04-07T13:23:18.257+0800 I -        [initandlisten] Detected data files in /disk/mongodb/data/ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-04-07T13:23:18.257+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=1G,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),
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] 
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] 
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] 
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-04-07T13:23:20.954+0800 I CONTROL  [initandlisten] 
2016-04-07T13:23:20.955+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/disk/mongodb/data/diagnostic.data'
2016-04-07T13:23:20.955+0800 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-04-07T13:23:20.955+0800 I NETWORK  [initandlisten] waiting for connections on port 27017
2016-04-07T13:23:20.978+0800 W NETWORK  [HostnameCanonicalizationWorker] Failed to obtain address information for hostname trcloud-wujian-test02.novalocal: Name or service not known
^C2016-04-07T13:23:36.013+0800 I CONTROL  [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2016-04-07T13:23:36.013+0800 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2016-04-07T13:23:36.015+0800 I CONTROL  [signalProcessingThread] now exiting
2016-04-07T13:23:36.015+0800 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2016-04-07T13:23:36.015+0800 I NETWORK  [signalProcessingThread] closing listening socket: 5
2016-04-07T13:23:36.015+0800 I NETWORK  [signalProcessingThread] closing listening socket: 6
2016-04-07T13:23:36.015+0800 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2016-04-07T13:23:36.015+0800 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...
2016-04-07T13:23:36.015+0800 I NETWORK  [signalProcessingThread] shutdown: going to close sockets...
2016-04-07T13:23:36.015+0800 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2016-04-07T13:23:36.146+0800 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2016-04-07T13:23:36.147+0800 I CONTROL  [signalProcessingThread] dbexit:  rc: 0
标红处有3个警告和一处错误
错误是无法找到 trcloud-wujian-test02.novalocal主机
解决
方法是在/etc/hosts文件中加一条这个主机名的映射
127.0.0.1  trcloud-wujian-test02.novalocal

几处警告的解决方法是
[root@trcloud-wujian-test02 bin]# echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
[root@trcloud-wujian-test02 bin]# echo "never" > /sys/kernel/mm/transparent_hugepage/defrag

再次启动服务
[root@trcloud-wujian-test02 bin]# ./mongod --dbpath=/disk/mongodb/data/
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] MongoDB starting : pid=20260 port=27017 dbpath=/disk/mongodb/data/ 64-bit host=trcloud-wujian-test02.novalocal
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] db version v3.2.4
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] git version: e2ee9ffcf9f5a94fad76802e28cc978718bb7a30
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] modules: none
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] build environment:
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten]     distarch: x86_64
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2016-04-07T13:24:42.989+0800 I CONTROL  [initandlisten] options: { storage: { dbPath: "/disk/mongodb/data/" } }
2016-04-07T13:24:43.011+0800 E NETWORK  [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
2016-04-07T13:24:43.011+0800 E NETWORK  [initandlisten]   addr already in use
2016-04-07T13:24:43.011+0800 E STORAGE  [initandlisten] Failed to set up sockets during startup.
2016-04-07T13:24:43.011+0800 I CONTROL  [initandlisten] dbexit:  rc: 48
成功
设置mongodb日志
[root@trcloud-wujian-test02 bin]# ./mongod --logpath=/disk/mongodb/log/mongodb.log
2016-04-07T13:40:45.695+0800 I CONTROL  [main] log file "/disk/mongodb/log/mongodb.log" exists; moved to "/disk/mongodb/log/mongodb.log.2016-04-07T05-40-45".

进入交互界面
[root@trcloud-wujian-test02 bin]# ./mongo
MongoDB shell version: 3.2.4
connecting to: test
2016-04-07T13:27:48.214+0800 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:35315 #2 (1 connection now open)
Server has startup warnings: 
2016-04-07T13:24:18.194+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-04-07T13:24:18.194+0800 I CONTROL  [initandlisten] 
>

将mongodb设置开机启动
 ./mongod ----dbpath=/disk/mongodb/data/ --logpath=/disk/mongodb/log/mongodb.log语句放入到/etc/rc.local文件中





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29989552/viewspace-2076786/,如需转载,请注明出处,否则将追究法律责任。

下一篇: mysql查询日志
请登录后发表评论 登录
全部评论

注册时间:2014-10-29

  • 博文量
    95
  • 访问量
    206890