1, download the decompression installation
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.4.tgz
Tar zxvf mongodb-linux-x86_64-rhel62-3.0.4.tgz
MV Mongodb-linux-x86_64-rhel62-3.0.4/usr/local/mongodb
2, create a directory
Mkdir-p/data/mongodb/27017/data/
Mkdir-p/data/mongodb/27017/log/
3. Create configuration file/data/mongodb/27017/mongodb_27017.conf
DBPath =/data/mongodb/27017/data #指定数据目录
Directoryperdb = True #每个数据库保存到独立的目录
Port = 27017 #设定端口
BIND_IP = localhost,192.168.189.129 #端口绑定
Rest = False #Rest接口关闭
Fork = True #守护进程方式运行
Logappend = True #日志生成追加或者覆盖, true for append
LogPath =/data/mongodb/27017/log/mongodb_27017.log #指定日志路径
Replset = Birdman #定义一个副本集
Journal = True #开启日志功能 to reduce the recovery time of a single machine failure by saving the operation log
Oplogsize = #相当于为mysql Binlog, MB, set to 5% of the hard drive
Nohttpinterface = True #关闭管理接口
CPU = True #显示CPU和IO的利用率
Auth = True #启用验证
4, Start MongoDB
/usr/local/mongodb/bin/mongod-f/data/mongodb/27017/mongodb_27017.conf
5. Set Administrator Privileges
Use admin
Db.createuser (
{
User: "AppAdmin",
PWD: "Password",
Roles
[
{role: "ReadWrite", db: "Config"},
"Clusteradmin"
]
})
http://docs.mongodb.org/manual/reference/method/db.createUser/#create-user-with-roles
There is no admin library in version 3, use admin is required
You can also create a database user for the specified database, with only the database owner and Administrator account permissions
6. View Boot Configuration
Use admin
Db.runcommand ({getcmdlineopts:1})
7, close the service
Use admin
Db.shutdownserver ();
8, Dynamic Modification configuration
Use admin
Db.admincommand ({setparameter:1,loglevel:4})
9. View database Status
Db.stats ()
10. View server Status
Db.serverstatus ()
Precautions:
1, start MongoDB Best use non-root user
2, need to connect to localhost 27017 port to verify Db.auth (' admin ', ' 123qwe ') ####/usr/local/mongodb/bin/mongo 127.0.0.1:27017
This article is from the "I am a Little bird" blog, please make sure to keep this source http://2242558.blog.51cto.com/2232558/1674095
Mongod installation Configuration