mongodb 4.2鍗曟満閮ㄧ讲
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mongodb 4.2鍗曟満閮ㄧ讲相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/use' title='use'>use
https logrotate blog 閰嶇疆鏂囦欢 download oplog font 绠$悊1.涓嬭浇鐩稿簲鐨勭増鏈?/span>
https://www.mongodb.com/download-center/community
鎴戣繖閲屼笅杞界殑鏄痬ongodb-linux-x86_64-rhel70-4.2.9.tgz
---------------------------------------瀹夎閮ㄧ讲---------------------------------------
1.鍒涘缓瀹夎鐩綍
192.168.1.169:28001瀵瑰簲鐨勫畨瑁呯洰褰?/span>
[root@test services]# mkdir -p /usr/local/services
[root@test services]# mkdir -p /home/middle/mongodb/data
[root@test services]# mkdir -p /home/middle/mongodb/log
[root@test services]# mkdir -p /home/middle/mongodb/key
[root@test services]# mkdir -p /home/middle/mongodb/conf
[root@test services]# mkdir -p /home/middle/mongodb/run
2.瀹夎鏁版嵁搴?/span>
192.168.1.169:28001 瀹夎
[root@test]# cd /soft
[root@test soft]# tar -xvf mongodb-linux-x86_64-rhel70-4.2.9.tgz
[root@test soft]# mv mongodb-linux-x86_64-rhel70-4.2.9 /usr/local/services/mongodb
3.浜х敓绉橀挜楠岃瘉
鍦ㄥ叾涓竴涓満鍣ㄤ笂鍒涘缓绉橀挜鏂囦欢,鎴戣繖閲屾槸鍦?92.168.1.169:29001
[root@test key]# cd /home/middle/mongodb/key
[root@test key]# openssl rand -base64 741 >>keyfile
[root@test key]# chmod 700 keyfile
4.鐢熸垚鏃ュ織鏂囦欢
192.168.1.169:28001
[root@test key]#echo>/home/middle/mongodb/log/mongodb.log
5.鍒涘缓閰嶇疆鏂囦欢mongo.cnf
##涓昏妭鐐圭殑閰嶇疆鍙傛暟
vi /home/middle/mongodb/conf/mongo.cnf
port=28001
fork=true
dbpath=/home/middle/mongodb/data
logpath=/home/middle/mongodb/log/mongodb.log
pidfilepath=/home/middle/mongodb/run/28001.pid
logappend=true
##shardsvr=true ##鍒涘缓鍓湰闆嗘墠闇€瑕?/span>
##replSet=repltest ##鍒涘缓鍓湰闆嗘墠闇€瑕?/span>
bind_ip=192.168.1.169,127.0.0.1
oplogSize=10000
logRotate=reopen
##auth=true
杩欓噷keyFile鍜宎uth鍏堟敞閲?鍥犱负绛夐儴缃插畬鍒濆鍖栧畬闆嗙兢鍚庡啀鍚敤
6.鍚姩
涓昏妭鐐瑰惎鍔?
192.168.1.169:28001
[root@test key]# /usr/local/services/mongodb/bin/mongod -f /home/middle/mongodb/conf/mongo.cnf
7.鍒涘缓绠$悊鍛樼敤鎴?/span>
鍦ㄤ富鑺傜偣涓?鎴戣繖閲屾槸鑺傜偣1)涓婂垱寤虹鐞嗗憳璐﹀彿test
[root@localhost bin]# /usr/local/services/mongodb/bin/mongo 192.168.1.169:28001
use admin
db.createUser({user:"yeemiao",pwd:"yeemiao123",roles:["root"]}); --鍒涘缓鐢ㄦ埛
db.auth("yeemiao","yeemiao123"); --璁剧疆鐢ㄦ埛鐧婚檰鏉冮檺锛屽瘑鐮佷竴瀹氳鍜屽垱寤虹敤鎴锋椂杈撳叆鐨勫瘑鐮佺浉鍚?/span>
show users; --鏌ョ湅鍒涘缓鐨勭敤鎴?/span>
8.閲嶅惎mongodb鐒跺悗鍚敤璁よ瘉鍙傛暟
鍋滄帀mongodb
/usr/local/services/mongodb/bin/mongo localhost:28001
use admin
db.auth("yeemiao","yeemiao123");
db.shutdownServer()
淇敼閰嶇疆鏂囦欢,灏嗕箣鍓嶆敞閲婄殑涓よ,鍚敤
auth = true
鍐嶆鍚姩
/usr/local/services/mongodb/bin/mongod -f /home/middle/mongodb/conf/mongo.cnf
9.鍐嶆鍚姩鍚庡垱寤烘櫘閫氳处鍙?骞跺啓鍏ヨ褰?/span>
[root@test key]#/usr/local/services/mongodb/bin/mongo 192.168.1.169:28001
> use admin
switched to db admin
> db.auth("yeemiao","yeemiao123");
>use mgdb_zhibo
>db.createUser({user:鈥榯hreedev鈥?pwd:鈥榯hreedev123鈥?roles:[{role:鈥榙bOwner鈥?db:鈥榤gdb_zhibo鈥榼]})
10.鍔犲叆鑷姩閲嶅惎鏈嶅姟
鍙傝€?/span>
http://blog.chinaunix.net/uid-77311-id-5791282.html
-- The End --
以上是关于mongodb 4.2鍗曟満閮ㄧ讲的主要内容,如果未能解决你的问题,请参考以下文章