centOS下mongodb的安装
来源:互联网 发布:dnf制裁秒淘宝能解么 编辑:程序博客网 时间:2024/05/01 10:49
###############centOS下mongodb的安装#########
mongodb作为非关系型数据库NoSQL数据库的一种,并且是属于免安装类型。
mongodb安装说明:32的安装db空间有限,最大支持2G多,并且性能低于64bit。64bit系统db存储没有限制!
mongodb安装需要磁盘大小为15G以上,如果只是测试可以使用--smallfiles参数最小安装!
1:准备安装包:
可以到官网下载:https://www.mongodb.org/
包括各种:dbservers / drivers / docs
2:我准备的安装包[mongodb-linux-x86_64-3.0.3.gz]:
[root@localhost install-files]# lltotal 115412-rw-r--r--. 1 root root 40231021 Oct 17 11:45 mongodb-linux-x86_64-3.0.3.gz-rw-r--r--. 1 root root 18596528 Oct 12 22:42 MySQL-client-5.6.27-1.el6.x86_64.rpm-rw-r--r--. 1 root root 3392620 Oct 12 22:42 MySQL-devel-5.6.27-1.el6.x86_64.rpm-rw-r--r--. 1 root root 55950588 Oct 12 22:42 MySQL-server-5.6.27-1.el6.x86_64.rpm
3:免安装,解压即可使用:
[root@localhost install-files]# tar zxvf mongodb-linux-x86_64-3.0.3.gz
mongodb-linux-x86_64-3.0.3/READMEmongodb-linux-x86_64-3.0.3/THIRD-PARTY-NOTICESmongodb-linux-x86_64-3.0.3/GNU-AGPL-3.0mongodb-linux-x86_64-3.0.3/bin/mongodumpmongodb-linux-x86_64-3.0.3/bin/mongorestoremongodb-linux-x86_64-3.0.3/bin/mongoexportmongodb-linux-x86_64-3.0.3/bin/mongoimportmongodb-linux-x86_64-3.0.3/bin/mongostatmongodb-linux-x86_64-3.0.3/bin/mongotopmongodb-linux-x86_64-3.0.3/bin/bsondumpmongodb-linux-x86_64-3.0.3/bin/mongofilesmongodb-linux-x86_64-3.0.3/bin/mongooplogmongodb-linux-x86_64-3.0.3/bin/mongoperfmongodb-linux-x86_64-3.0.3/bin/mongodmongodb-linux-x86_64-3.0.3/bin/mongosmongodb-linux-x86_64-3.0.3/bin/mongo
4:查看免安装目录下的文件结构:
[root@localhost install-files]# lltotal 115412drwxr-xr-x. 3 root root 74 Oct 17 11:46 mongodb-linux-x86_64-3.0.3-rw-r--r--. 1 root root 40231021 Oct 17 11:45 mongodb-linux-x86_64-3.0.3.gz-rw-r--r--. 1 root root 18596528 Oct 12 22:42 MySQL-client-5.6.27-1.el6.x86_64.rpm-rw-r--r--. 1 root root 3392620 Oct 12 22:42 MySQL-devel-5.6.27-1.el6.x86_64.rpm-rw-r--r--. 1 root root 55950588 Oct 12 22:42 MySQL-server-5.6.27-1.el6.x86_64.rpm
[root@localhost install-files]# cd mongodb-linux-x86_64-3.0.3[root@localhost mongodb-linux-x86_64-3.0.3]# lltotal 68drwxr-xr-x. 2 root root 4096 Oct 17 11:47 bin-rw-r--r--. 1 1046 1046 34520 May 12 05:35 GNU-AGPL-3.0-rw-r--r--. 1 1046 1046 1359 May 12 05:35 README-rw-r--r--. 1 1046 1046 22660 May 12 05:35 THIRD-PARTY-NOTICES
[root@localhost mongodb-linux-x86_64-3.0.3]# cd bin/[root@localhost bin]# lltotal 116340-rwxr-xr-x. 1 1046 1046 4305912 May 12 05:35 bsondump-rwxr-xr-x. 1 1046 1046 11694552 May 12 05:43 mongo-rwxr-xr-x. 1 1046 1046 22349960 May 12 05:43 mongod-rwxr-xr-x. 1 1046 1046 6199144 May 12 05:35 mongodump-rwxr-xr-x. 1 1046 1046 6001840 May 12 05:35 mongoexport-rwxr-xr-x. 1 1046 1046 5956232 May 12 05:35 mongofiles-rwxr-xr-x. 1 1046 1046 6211952 May 12 05:35 mongoimport-rwxr-xr-x. 1 1046 1046 5686856 May 12 05:35 mongooplog-rwxr-xr-x. 1 1046 1046 22129448 May 12 05:43 mongoperf-rwxr-xr-x. 1 1046 1046 6332464 May 12 05:35 mongorestore-rwxr-xr-x. 1 1046 1046 10552760 May 12 05:43 mongos-rwxr-xr-x. 1 1046 1046 5909928 May 12 05:35 mongostat-rwxr-xr-x. 1 1046 1046 5769944 May 12 05:35 mongotop
解压即可使用!
注:参数最后备注附件:
5:mongod为启动mongodb,可以直接./mongod,默认启动需要配置db的路径为/data/db,没有路径则失败,请手动创建!
5:mongod为启动mongodb,可以直接./mongod,默认启动需要配置db的路径为/data/db,没有路径则失败,请手动创建!
[root@localhost bin]# ./mongod2015-10-17T11:52:52.338+0800 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating2015-10-17T11:52:52.338+0800 I CONTROL [initandlisten] dbexit: rc: 100
[root@localhost bin]# mkdir /data[root@localhost bin]# mkdir /data/db
安装留足空间最小大概15G空间,不然报错:Error:Insufficient free space for journal files
解决:注可以使用--smallfiles参数最小安装
默认:启动mongodb:
[root@localhost bin]# ./mongod --smallfiles
或
[root@localhost bin]# ./mongod
非最小安装启动:
[root@localhost bin]# ./mongod2015-10-17T12:03:34.488+0800 I STORAGE [initandlisten]………………2015-10-17T12:03:41.407+0800 I NETWORK [initandlisten] waiting for connections on port 270176:查看默认安装文件结构:
[root@localhost bin]# cd /data/db/[root@localhost db]# lltotal 81932drwxr-xr-x. 2 root root 17 Oct 17 12:03 journal-rw-------. 1 root root 67108864 Oct 17 12:03 local.0-rw-------. 1 root root 16777216 Oct 17 12:03 local.ns-rwxr-xr-x. 1 root root 5 Oct 17 12:03 mongod.lock-rw-r--r--. 1 root root 69 Oct 17 11:59 storage.bson
7:默认关闭关闭mongodb:
[root@localhost bin]# pwd/home/install-files/mongodb-linux-x86_64-3.0.3/bin[root@localhost bin]# ./mongod --shutdownkilling process with pid: 2107注:默认安装缺点:数据库目录不能指定,log日志不能保存查看.
8:自定义配置文件安装mongodb:
查看mongodb的启动参数:
[root@localhost bin]# ./mongod --help或[root@localhost bin]# ./mongod --help | more
-f 参数 使用配置文件控制mongodb的启动:
操作:在mongodb免安装目录下创建/conf/mongodb.conf来配置启动参数:
[root@localhost mongodb-linux-x86_64-3.0.3]# pwd/home/install-files/mongodb-linux-x86_64-3.0.3[root@localhost mongodb-linux-x86_64-3.0.3]# mkdir conf[root@localhost mongodb-linux-x86_64-3.0.3]# lltotal 68drwxr-xr-x. 2 root root 4096 Oct 17 12:27 bindrwxr-xr-x. 2 root root 25 Oct 17 12:25 conf-rw-r--r--. 1 1046 1046 34520 May 12 05:35 GNU-AGPL-3.0-rw-r--r--. 1 1046 1046 1359 May 12 05:35 README-rw-r--r--. 1 1046 1046 22660 May 12 05:35 THIRD-PARTY-NOTICES[root@localhost mongodb-linux-x86_64-3.0.3]# cd conf/[root@localhost mongodb-linux-x86_64-3.0.3]# vim mongodb.conf[root@localhost mongodb-linux-x86_64-3.0.3]# cat mongodb.conf
配置文件信息:
#日志路径logpath=../log/mongodb.log#启动日志不追加,太过庞大logappend=false#设置mongodb的db路径dbpath=/home/mongodb/data/db#后台驻留(守护)进程服务运行fork=true
注:日志路径和mongodb的路径需要自己创建,否则报错:
创建日志目录:
[root@localhost mongodb-linux-x86_64-3.0.3]# mkdir log[root@localhost mongodb-linux-x86_64-3.0.3]# lltotal 68drwxr-xr-x. 2 root root 4096 Oct 17 12:27 bindrwxr-xr-x. 2 root root 25 Oct 17 12:25 conf-rw-r--r--. 1 1046 1046 34520 May 12 05:35 GNU-AGPL-3.0drwxr-xr-x. 2 root root 6 Oct 17 12:29 log-rw-r--r--. 1 1046 1046 1359 May 12 05:35 README-rw-r--r--. 1 1046 1046 22660 May 12 05:35 THIRD-PARTY-NOTICES
创建mongodb数据db路径:
[root@localhost home]# mkdir mongodbroot@localhost home]# cd mongodb/[root@localhost mongodb]# mkdir data[root@localhost mongodb]# cd data/[root@localhost data]# mkdir db[root@localhost data]# cd db/[root@localhost db]# pwd/home/mongodb/data/db
删除默认安装的mongodb数据,释放空间:
[root@localhost mongodb-linux-x86_64-3.0.3]# cd /[root@localhost /]# lsbin boot data dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var[root@localhost /]# rm -rf data/[root@localhost /]# lsbin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
使用-f参数:配置文件控制mongodb的启动,空间不足继续加参数:--smallfiles
[root@localhost mongodb-linux-x86_64-3.0.3]# cd bin/[root@localhost bin]# lsbsondump mongo mongod mongodump mongoexport mongofiles mongoimport mongooplog mongoperf mongorestore mongos mongostat mongotop[root@localhost bin]# pwd/home/install-files/mongodb-linux-x86_64-3.0.3/bin
使用自定义配置文件启动mongodb:
[root@localhost bin]# ./mongod -f ../conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.forked process: 4327child process started successfully, parent exiting
查看是否用守护进程服务启动:
[root@localhost bin]# ps -ef | grep mongodbroot 4327 1 0 12:38 ? 00:00:00 ./mongod -f ../conf/mongodb.confroot 4340 2122 0 12:41 pts/1 00:00:00 grep --color=auto mongodb
查看自定义的mongodb数据文件:
[root@localhost bin]# cd /home/mongodb/data/db/[root@localhost db]# lltotal 81932drwxr-xr-x. 2 root root 17 Oct 17 12:38 journal-rw-------. 1 root root 67108864 Oct 17 12:38 local.0-rw-------. 1 root root 16777216 Oct 17 12:38 local.ns-rwxr-xr-x. 1 root root 5 Oct 17 12:38 mongod.lock-rw-r--r--. 1 root root 69 Oct 17 12:38 storage.bsondrwxr-xr-x. 2 root root 6 Oct 17 12:38 _tmp
注:--smallfiles启动,无storage.bson文件.
查看自定义的日志文件:
[root@localhost db]# cd /home/install-files/mongodb-linux-x86_64-3.0.3/log/[root@localhost log]# lsmongodb.log[root@localhost log]# cat mongodb.log 2015-10-17T12:38:58.575+0800 I STORAGE [initandlisten] ………………2015-10-17T12:38:58.979+0800 I NETWORK [initandlisten] waiting for connections on port 27017
默认启动端口为:27017
登陆测试:
[root@CentOS-Slave1 bin]# telnet localhost 27017Trying ::1...telnet: connect to address ::1: Connection refusedTrying 127.0.0.1...Connected to localhost.Escape character is '^]'.^]telnet> quitConnection closed.
登陆日志:
[root@CentOS-Slave1 log]# tail -f mongodb.log………………………2015-10-18T10:24:10.877+0800 I NETWORK [conn27] AssertionException handling request, closing client connection: 17133 SSL handshake requested, SSL feature not available in this build2015-10-18T10:24:12.627+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:56321 #28 (1 connection now open)2015-10-18T10:24:16.956+0800 I NETWORK [conn28] end connection 127.0.0.1:56321 (0 connections now open)
注:日志会自动备份:
[root@CentOS-Slave1 sbin]# cd /home/install-files/mongodb-linux-x86_64-3.0.3/log/[root@CentOS-Slave1 log]# lsmongodb.log mongodb.log.2015-10-17T08-35-18 mongodb.log.2015-10-18T01-31-48
[root@CentOS-Slave1 log]# tail -f mongodb.log………………………2015-10-18T10:24:10.877+0800 I NETWORK [conn27] AssertionException handling request, closing client connection: 17133 SSL handshake requested, SSL feature not available in this build2015-10-18T10:24:12.627+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:56321 #28 (1 connection now open)2015-10-18T10:24:16.956+0800 I NETWORK [conn28] end connection 127.0.0.1:56321 (0 connections now open)
打开浏览器console:
[root@CentOS-Slave1 conf]# pwd/home/install-files/mongodb-linux-x86_64-3.0.3/conf[root@CentOS-Slave1 conf]# vim mongodb.conf [root@CentOS-Slave1 conf]# cat mongodb.conf
#日志路径logpath=../log/mongodb.log#启动日志不追加,太过庞大logappend=false#设置mongodb的db路径dbpath=/home/mongodb/data/db#后台驻留进程服务运行fork=true#配置浏览器可以通过28017端口访问mongodbrest=true
配置后,重新启动,先关闭再启动:
关闭自定义配置文件的mongodb:
关闭自定义配置文件的mongodb:
[root@CentOS-Slave1 bin]# ./mongod --shutdown --dbpath=/home/mongodb/data/db/killing process with pid: 5891
浏览器登录端口默认28017:
访问url:http://192.168.10.56:28017/
访问url:http://192.168.10.56:28017/
使用客户端登陆mongodb:
[root@CentOS-Slave1 bin]# ./mongo --port 27017
MongoDB shell version: 3.0.3connecting to: 127.0.0.1:27017/testServer has startup warnings: 2015-10-18T09:31:48.114+0800 I CONTROL ** WARNING: --rest is specified without --httpinterface,2015-10-18T09:31:48.114+0800 I CONTROL ** enabling http interface2015-10-18T09:31:48.159+0800 I STORAGE [initandlisten] 2015-10-18T09:31:48.159+0800 I STORAGE [initandlisten] ** WARNING: Readahead for /home/mongodb/data/db is set to 4096KB2015-10-18T09:31:48.159+0800 I STORAGE [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less2015-10-18T09:31:48.159+0800 I STORAGE [initandlisten] ** http://dochub.mongodb.org/core/readahead2015-10-18T09:31:48.940+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2015-10-18T09:31:48.940+0800 I CONTROL [initandlisten] 2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] 2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] 2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'2015-10-18T09:31:48.941+0800 I CONTROL [initandlisten] > show dbslocal 0.078GB> show users>
备注附件:
mongodb数据db目录文件:
[root@CentOS-Slave1 db]# pwd/home/mongodb/data/db[root@CentOS-Slave1 db]# lltotal 81932drwxr-xr-x. 2 root root 17 Oct 18 09:31 journal-rw-------. 1 root root 67108864 Oct 18 09:31 local.0-rw-------. 1 root root 16777216 Oct 18 09:31 local.ns-rwxr-xr-x. 1 root root 5 Oct 18 09:31 mongod.lock-rw-r--r--. 1 root root 69 Oct 17 12:38 storage.bson
journal :事务日志目录(j._0 日志文件从0编号,可循环重用)mongod.lock :记录当前的mongod的进程号_tmp :临时数据文件local.0 :数据库文件,按序号递增,大小也倍增(64M—128M—256M—512M—1G—最大2G)local.ns :记录集合命名空间和索引命名空间
mongodb指令文件:
[root@CentOS-Slave1 bin]# pwd/home/install-files/mongodb-linux-x86_64-3.0.3/bin[root@CentOS-Slave1 bin]# lltotal 116340-rwxr-xr-x. 1 1046 1046 4305912 May 12 05:35 bsondump-rwxr-xr-x. 1 1046 1046 11694552 May 12 05:43 mongo-rwxr-xr-x. 1 1046 1046 22349960 May 12 05:43 mongod-rwxr-xr-x. 1 1046 1046 6199144 May 12 05:35 mongodump-rwxr-xr-x. 1 1046 1046 6001840 May 12 05:35 mongoexport-rwxr-xr-x. 1 1046 1046 5956232 May 12 05:35 mongofiles-rwxr-xr-x. 1 1046 1046 6211952 May 12 05:35 mongoimport-rwxr-xr-x. 1 1046 1046 5686856 May 12 05:35 mongooplog-rwxr-xr-x. 1 1046 1046 22129448 May 12 05:43 mongoperf-rwxr-xr-x. 1 1046 1046 6332464 May 12 05:35 mongorestore-rwxr-xr-x. 1 1046 1046 10552760 May 12 05:43 mongos-rwxr-xr-x. 1 1046 1046 5909928 May 12 05:35 mongostat-rwxr-xr-x. 1 1046 1046 5769944 May 12 05:35 mongotop[root@CentOS-Slave1 bin]#
mongo 客户端程序,连接MongoDB mongod 服务端程序,启动MongoDB mongodump 备份程序 mongoexport 数据导出程序 mongofiles GridFS工具,内建的分布式文件系统 mongoimport 数据导入程序 mongorestore 数据恢复程序 mongos 数据分片程序,支持数据的横向扩展 mongostat 监视程序
0 0
- centOS下mongodb的安装
- CentOS的下安装MongoDB
- CentOS下安装MongoDB
- CentOs下MongoDB安装
- CentOS下安装mongodb
- MONGODB在CENTOS下的安装
- centos 6.5下mongodb的安装
- MongoDB centos下的安装和启动
- CentOS环境下安装MongoDB
- CentOS下源码安装mongodb
- CentOS 7下安装MongoDB
- 在centos下安装mongodb
- CentOS 下 mongodb 安装步骤
- centos 7 下安装 mongodb
- centos用yum安装mongodb及 32位linux(centos)下mongoDB的安装
- centos用yum安装mongodb及 32位linux(centos)下mongoDB的安装
- 32位linux(centos)下mongoDB的安装
- Centos下 Mongodb 的安装及远程连接
- 安装Genymotion期间遇到的问题
- 面向对象原则小总结
- velocity freemarker比较
- Android内存优化
- leetcode系列(35)Roman to Integer & Integer to Roman
- centOS下mongodb的安装
- Javassist介绍
- web服务器是如何工作的
- 第7讲 项目1----求正差值
- 【opencv】之直方图的应用
- deep learning lecture
- 写这些东西目的在于温故而知新
- Android性能优化典范第2季
- OpenCV—图像分割中的分水岭算法原理与应用