Description
Operating system: CentOS 6.X 64-bit
IP Address: 192.168.1.111
Purpose of implementation:
Installing the Configuration MongoDB database
Specific operation: First, turn off SELinux, configure Firewall 1, Vi/etc/selinux/config
#SELINUX =enforcing #注释掉 #selinuxtype=targeted #注释掉SELINUX =disabled #增加setenforce 0 #使配置立即生效
2, Vi/etc/sysconfig/iptables
-A rh-firewall-1-input-m state--state new-m tcp-p TCP--dport 27017-j ACCEPT #允许27017端口通过防火墙/etc/init.d/iptables Rest Art #重启防火墙使配置生效
Ii. installation of MongoDB
Mongodb:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz #目前最新版
Upload mongodb-linux-x86_64-3.0.6.tgz to/usr/local/src directory
CD/USR/LOCAL/SRC #进入软件存放目录tar zxvf mongodb-linux-x86_64-3.0.6.tgz #解压mv mongodb-linux-x86_64-3.0.6/usr/local/ MongoDB #移动解压文件夹到MongoDB安装目录mkdir-P/data/mongodb/mongodb_data/#创建MongoDB数据库存放路径mkdir-P/data/mongodb/mongodb_log /#创建MongoDB数据库日志存放路径 # start Mongodb/usr/local/mongodb/bin/mongod--port 27017--fork--dbpath=/data/mongodb/mongodb_ data/--logpath=/data/mongodb/mongodb_log/mongodb.log--LOGAPPENDNETSTAT-LANP | grep "27017" #查看MongoDB是否启动cd/usr/local/mongodb/bin/./mongo #进入MongoDB数据库控制台use admin #进入admin数据库db. Shutdownserver ( ) #关闭MongoDB数据库exit #退出
Third, set up MongoDB database 1, cd/usr/local/mongodb/#进入MongoDB安装目录
vi/usr/local/mongodb/mongodb.conf #编辑port =27017 #端口号dbpath =/data/mongodb/mongodb_data/#数据库路径logpath =/data/ Mongodb/mongodb_log/mongodb.log #日志输出文件路径pidfilepath =/usr/local/mongodb/mongo.pidfork=true #设置后台运行logappend =true #日志输出方式shardsvr =true#auth=true #开启认证
2, cd/usr/local/mongodb/bin/
chmod +x/etc/rc.d/init.d/mongod #添加脚本执行权限chkconfig mongod on #设置开机启动service mongod start #启动MongoDB
Note: If the Administrator account password is set, use the following command
Account: Root
Password: 123456
/usr/local/mongodb/bin/mongo 127.0.0.1:27017/admin--eval "Db.auth (' root ', ' 123456 ');d b.shutdownserver ()"/usr/ Local/mongodb/bin/mongo 127.0.0.1:27017/admin--eval "Db.auth (' root ', ' 123456 ');d b.stats ()"
3, Vi/etc/profile #添加环境变量, edit, add the following code in the last line
Export path= $PATH:/usr/local/mongodb/binsource/etc/profile #使配置立即生效
4. Testing
MONGO #进入MongoDB控制台show DBS #查看默认数据库use admin #切换到admin数据库exit #退出MongoDB控制台
At this point, the MongoDB database installation configuration is complete.
This article is from the "Youngcheung Technology Road" blog, make sure to keep this source http://youngcheung.blog.51cto.com/10809015/1785783
Linux under Installation configuration MongoDB 3.0.x version database