Linux安装MongoDB3.2.1
谈不上安装,解压即可,绿色环保!
安装包下载地址:http://www.mongodb.org/downloads
- 解压缩
1 |
[root@xxf soft]# tar -zxvf mongodb-linux-x86_64-rhel55-3.2.1.gz |
- 创建MongoDB软件HOME目录
1 |
[root@xxf soft]# mkdir -p /usr/local/mongodb |
- 将解压缩后的软件移至MongoDB的HOME目录下
1 |
[root@xxf soft]# mv mongodb-linux-x86_64-rhel55-3.2.1 /usr/local/mongodb/ |
- 创建数据库目录
1 |
[root@xxf ~]# mkdir -p /data/db |
- 编辑环境变量
1 |
[root@xxf ~]# vi .bash_profile |
export PATH=/usr/local/mongodb/mongodb-linux-x86_64-rhel55-3.2.1/bin:$PATH
1 |
[root@xxf ~]# . .bash_profile |
- 启动MongoDB服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@xxf ~]# mongod 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] MongoDB starting : pid=4243 port=27017 dbpath=/data/db 64-bit host=xxf 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] db version v3.2.1 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] allocator: tcmalloc 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] modules: none 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] build environment: 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] distmod: rhel55 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] distarch: x86_64 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] target_arch: x86_64 2016-01-09T11:09:16.678+0800 I CONTROL [initandlisten] options: {} 2016-01-09T11:09:16.705+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-01-09T11:09:18.195+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2016-01-09T11:09:18.195+0800 I CONTROL [initandlisten] 2016-01-09T11:09:18.200+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data' 2016-01-09T11:09:18.201+0800 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker 2016-01-09T11:09:18.211+0800 I NETWORK [initandlisten] waiting for connections on port 27017 |
- MongoDB shell
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@xxf ~]# mongo MongoDB shell version: 3.2.1 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user Server has startup warnings: 2016-01-09T10:14:01.854+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2016-01-09T10:14:01.854+0800 I CONTROL [initandlisten] > |
默认情况下,会连接到test数据库,不过我们会发现,登录后有个警告,意思是用root用户来登录,不推荐这么干。
解决办法:再建立一个用户用来安装。