2016-10-19 MongoDB 3.2.5安裝
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的儋州網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
1 準(zhǔn)備安裝介質(zhì)
安裝介質(zhì)下載:
mongodb的安裝方式,我通常使用二進(jìn)制包的方式,內(nèi)網(wǎng)不能配置連接外網(wǎng)的yum源;
官方建議的mongodb下載地址為: Downloads.mongodb.org
但實(shí)際上,這個(gè)地址,很難找到下載表,正常下載,通??梢杂孟旅娴南螺d地址選擇下載:
我這里下載的是: 3.2.5 版本對(duì)應(yīng)的 mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8.tgz
如果將整個(gè)mongodb安裝過程已經(jīng)編寫了腳本,可以獲取安裝腳本,用腳本執(zhí)行安裝;
如果手動(dòng)安裝,則可跳過此步;
手工安裝mongodb的腳步的執(zhí)行過程,一般如下:
mkdir -p /root/{software,scripts}
wget -q http://ptmaster.test.cn/files/init/mongodb_install.sh -O /root/scripts/mongodb_install.sh
cd /root/scripts
./mongodb_install.sh -p 27117
2 添加mongodb用戶和環(huán)境變量,修改系統(tǒng)參數(shù)
groupadd mongodb
useradd -g mongodb mongodb
創(chuàng)建mongodb腳本目錄
mkdir -p /home/mongodb/scripts/
修改目錄權(quán)限:
chown -R mongodb:mongodb /home/mongodb/scripts/
在 /etc/profile 中添加 mongodb 用戶的環(huán)境變量:
# MongoDB Environment Variables
export PATH=$PATH:$HOME/bin:/usr/local/mongodb/bin:/home/mongodb/scripts/
是上面的變量生效:
source /etc/profile
實(shí)際操作過程如下:
[root@yq-mapp-otadb248 etc]# id mongodb id: mongodb: No such user [root@yq-mapp-otadb248 etc]# [root@yq-mapp-otadb248 etc]# [root@yq-mapp-otadb248 etc]# groupadd mongodb useradd -g mongodb mongodb[root@yq-mapp-otadb248 etc]# useradd -g mongodb mongodb [root@yq-mapp-otadb248 etc]# [root@yq-mapp-otadb248 etc]# [root@yq-mapp-otadb248 etc]# id mongodb uid=801(mongodb) gid=801(mongodb) groups=801(mongodb) [root@yq-mapp-otadb248 etc]#
mongodb要求hugepage設(shè)置為禁用,soft limit設(shè)置足夠大,可以在一開始修改,也可以到后面修改;
cat /etc/security/limits.d/90-nproc.conf
修改這個(gè)文件中下列的值
* soft nproc 2048
確保: soft nproc 的值至少是 soft nofile 值的一半;
修改后,退出當(dāng)前用戶,重新進(jìn)入一下,設(shè)置就可以生效了;
禁用 hugepage 的值:
# echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
# echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
備注:上面兩個(gè)警告,現(xiàn)在不修改也不影響安裝過程,后面會(huì)提示。
3. 安裝mongodb軟件
上傳并解壓軟件:
cd /usr/local
rz mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8.tgz
tar -zxvf mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8.tgz
ln -sv mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 /usr/local/mongodb
修改文件權(quán)限:
chown -R mongodb:mongodb mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8
chown -R mongodb:mongodb /usr/local/mongodb
實(shí)際操作過程如下:
[root@yq-mapp-otadb248 src]# rz rz waiting to receive. Starting zmodem transfer. Press Ctrl+C to cancel. Transferring mongodb-linux-x86_64-rhel62-3.2.5.tar.gz... 100% 66999 KB 16749 KB/sec 00:00:04 0 Errors [root@yq-mapp-otadb248 src]# ll total 277792 -rw-r--r-- 1 root root 68607629 Oct 19 11:53 mongodb-linux-x86_64-rhel62-3.2.5.tar.gz -rw-r--r-- 1 root root 215848960 Apr 19 2016 mongodb-linux-x86_64-rhel62-v3.2-latest [root@yq-mapp-otadb248 src]# [root@yq-mapp-otadb248 src]# tar -zxvf mongodb-linux-x86_64-rhel62-3.2.5.tar.gz mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/ mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongooplog mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongod mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongo mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongofiles mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/bsondump mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongorestore mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongos mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongoexport mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongodump mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongoimport mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongotop mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongostat mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/bin/mongoperf mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/GNU-AGPL-3.0 mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/MPL-2 mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/README mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8/THIRD-PARTY-NOTICES [root@yq-mapp-otadb248 src]# [root@yq-mapp-otadb248 src]# ll total 277796 drwxr-xr-x 3 root root 4096 Oct 19 11:54 mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 -rw-r--r-- 1 root root 68607629 Oct 19 11:53 mongodb-linux-x86_64-rhel62-3.2.5.tar.gz -rw-r--r-- 1 root root 215848960 Apr 19 2016 mongodb-linux-x86_64-rhel62-v3.2-latest [root@yq-mapp-otadb248 src]# [root@yq-mapp-otadb248 src]# mv mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 ../ [root@yq-mapp-otadb248 src]# cd .. [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# ln -sv mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 /usr/local/mongodb `/usr/local/mongodb' -> `mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8' [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# chown -R mongodb:mongodb mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 [root@yq-mapp-otadb248 local]# chown -R mongodb:mongodb /usr/local/mongodb [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# ll total 52 drwxr-xr-x. 2 root root 4096 Apr 24 2014 bin drwxr-xr-x. 2 root root 4096 Sep 23 2011 etc drwxr-xr-x. 2 root root 4096 Sep 23 2011 games drwxr-xr-x. 2 root root 4096 Sep 23 2011 include drwxr-xr-x. 2 root root 4096 Sep 23 2011 lib drwxr-xr-x. 3 root root 4096 Apr 25 2014 lib64 drwxr-xr-x. 2 root root 4096 Sep 23 2011 libexec lrwxrwxrwx 1 root root 25 Mar 6 2015 logstash -> /usr/local/logstash-1.4.2 drwxrwxr-x 8 logstash logstash 4096 Jun 24 2014 logstash-1.4.2 lrwxrwxrwx 1 mongodb mongodb 45 Oct 19 11:59 mongodb -> mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 drwxr-xr-x 3 mongodb mongodb 4096 Oct 19 11:54 mongodb-linux-x86_64-rhel62-3.2.5-20-g07e21d8 lrwxrwxrwx 1 root root 39 Apr 23 2014 MySQL -> /usr/local/mysql-5.5.19-linux2.6-x86_64 drwxr-xr-x 12 root mysql 4096 Apr 23 2014 mysql-5.5.19-linux2.6-x86_64 drwxr-xr-x. 2 root root 4096 Sep 23 2011 sbin drwxr-xr-x. 6 root root 4096 Apr 25 2014 share drwxr-xr-x. 2 root root 4096 Oct 19 11:54 src [root@yq-mapp-otadb248 local]#
4 創(chuàng)建mongodb實(shí)例所需的目錄和配置文件
創(chuàng)建mongodb實(shí)例所需目錄:
mkdir -p /data/mongo_27117/{db,log,tmp}
創(chuàng)建mongodb實(shí)例配置文件所需目錄和文件:
mkdir -p /etc/mongodb
touch /etc/mongodb/mongo_27117.conf
根據(jù)需要配置mongodb的啟動(dòng)參數(shù),我的啟動(dòng)參數(shù)配置內(nèi)容如下:
vim /etc/mongodb/mongo_27117.conf
dbpath=/data/mongo_27117/db logpath=/data/mongo_27117/log/mongo_27117.log pidfilepath = /data/mongo_27117/tmp/mongo_27117.pid storageEngine = wiredTiger wiredTigerCacheSizeGB = 2 syncdelay = 30 wiredTigerCollectionBlockCompressor = zlib port=27117 auth = true directoryperdb = true oplogSize=2048 logappend=true fork=true #rest=true journal = true journalCommitInterval = 50 slowms = 200
修改目錄、文件的權(quán)限和屬組:
chown -R mongodb:mongodb /data/mongo_27117/
chown -R mongodb:mongodb /etc/mongodb
確認(rèn)目錄和配置文件都已經(jīng)準(zhǔn)備完畢:
ls -l /data/mongo_27117/
ls -l /etc/mongodb
cat /etc/mongodb/mongo_27117.conf
該步驟實(shí)際操作過程如下:
[root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# mkdir -p /data/mongo_27117/{db,log,tmp} [root@yq-mapp-otadb248 local]# mkdir -p /etc/mongodb [root@yq
-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# vim /etc/mongodb/mongo_27117.conf dbpath=/data/mongo_27117/db logpath=/data/mongo_27117/log/mongo_27117.log pidfilepath = /data/mongo_27117/tmp/mongo_27117.pid storageEngine = wiredTiger wiredTigerCacheSizeGB = 2 syncdelay = 30 wiredTigerCollectionBlockCompressor = zlib port=27117 auth = true directoryperdb = true oplogSize=2048 logappend=true fork=true #rest=true journal = true journalCommitInterval = 50 slowms = 200 ~ [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# chown -R mongodb:mongodb /data/mongo_27117/ [root@yq-mapp-otadb248 local]# chown -R mongodb:mongodb /etc/mongodb [root@yq-mapp-otadb248 local]# ls -l /data/mongo_27117/ total 12 drwxr-xr-x 2 mongodb mongodb 4096 Oct 19 12:02 db drwxr-xr-x 2 mongodb mongodb 4096 Oct 19 12:02 log drwxr-xr-x 2 mongodb mongodb 4096 Oct 19 12:02 tmp [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# ls -l /etc/mongodb total 4 -rw-r--r-- 1 mongodb mongodb 392 Oct 19 12:05 mongo_27117.conf [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# cat /etc/mongodb/mongo_27117.conf dbpath=/data/mongo_27117/db logpath=/data/mongo_27117/log/mongo_27117.log pidfilepath = /data/mongo_27117/tmp/mongo_27117.pid storageEngine = wiredTiger wiredTigerCacheSizeGB = 2 syncdelay = 30 wiredTigerCollectionBlockCompressor = zlib port=27117 auth = true directoryperdb = true oplogSize=2048 logappend=true fork=true #rest=true journal = true journalCommitInterval = 50 slowms = 200
5. 啟動(dòng)mongodb實(shí)例,修改管理員密碼
使用下面的命令啟動(dòng)mongodb服務(wù):
/usr/local/mongodb/bin/mongod --config /etc/mongodb/mongo_27117.conf
確認(rèn)密碼,mongodb的管理員密碼,可以根據(jù)各自的規(guī)則設(shè)置:
echo $MONGODB_ROOT_PASS
mongodb_020248_Pass
修改管理員密碼,注意 mongodb 3.2要對(duì)admin授予三個(gè)角色,這點(diǎn)與之前的版本不同:
/usr/local/mongodb/bin/mongo --port=27117
db.createUser({user:'useradmin',pwd:'mongodb_020248_Pass',roles:[ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] })
db.auth("useradmin","mongodb_020248_Pass")
db.system.users.find();
生成密碼后,使用新用戶和密碼登陸mongo,確認(rèn)狀態(tài):
/usr/local/mongodb/bin/mongo --port=27117 -u useradmin -p mongodb_020248_Pass --authenticationDatabase admin
該步驟操作過程如下;
[root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# ps -ef|grep mongo root 32295 30115 0 12:12 pts/0 00:00:00 grep mongo [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# /usr/local/mongodb/bin/mongod --config /etc/mongodb/mongo_27117.conf about to fork child process, waiting until server is ready for connections. forked process: 32321 child process started successfully, parent exiting [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# ps -ef|grep mongo root 32321 1 1 12:12 ? 00:00:00 /usr/local/mongodb/bin/mongod --config /etc/mongodb/mongo_27117.conf root 32359 30115 0 12:13 pts/0 00:00:00 grep mongo [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# /usr/local/mongodb/bin/mongo --port=27117 MongoDB shell version: 3.2.5-20-g07e21d8 connecting to: 127.0.0.1:27117/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 > > use admin; switched to db admin > db.system.users.find(); Error: error: { "ok" : 0, "errmsg" : "not authorized on admin to execute command { find: \"system.users\", filter: {} }", "code" : 13 } > > db.createUser({user:'useradmin',pwd:'mongodb_020248_@JJMatch',roles:[ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] }) Successfully added user: { "user" : "useradmin", "roles" : [ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] } > > db.system.users.find(); Error: error: { "ok" : 0, "errmsg" : "not authorized on admin to execute command { find: \"system.users\", filter: {} }", "code" : 13 } > > db.auth("useradmin","mongodb_020248_@JJMatch") 1 > > db.system.users.find(); { "_id" : "admin.useradmin", "user" : "useradmin", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "6hLx/d97hS+yfoN47QTmXQ==", "storedKey" : "B0PqwVs3GFKIHQyyQ6mBp1MA370=", "serverKey" : "xK53AKKAvFcdn5rsEtij5QB9RtU=" } }, "roles" : [ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] } > [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# /usr/local/mongodb/bin/mongo --port=27117 -u useradmin -p mongodb_020248_@JJMatch --authenticationDatabase admin MongoDB shell version: 3.2.5-20-g07e21d8 connecting to: 127.0.0.1:27117/test Server has startup warnings: 2016-10-19T12:12:59.096+0800 I CONTROL [initandlisten] 2016-10-19T12:12:59.096+0800 I CONTROL [initandlisten] ** WARNING: The server was started without specifying a --bind_ip 2016-10-19T12:12:59.096+0800 I CONTROL [initandlisten] ** and listens for connections on all available network interfaces. 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 2048 processes, 8192 files. Number of processes should be at least 4096 : 0.5 times number of files. 2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] > > use admin; switched to db admin > > db.system.users.find(); { "_id" : "admin.useradmin", "user" : "useradmin", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "6hLx/d97hS+yfoN47QTmXQ==", "storedKey" : "B0PqwVs3GFKIHQyyQ6mBp1MA370=", "serverKey" : "xK53AKKAvFCdn5rsEtij5QB9RtU=" } }, "roles" : [ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] } > >
6. 創(chuàng)建應(yīng)用所需的業(yè)務(wù)賬號(hào)
創(chuàng)建一個(gè) admin / admin 用戶,具有可以自行創(chuàng)建用戶和數(shù)據(jù)庫(kù)的權(quán)限,密碼業(yè)務(wù)自己再修改:
db.createUser({user:'admin',pwd:'admin',roles:[{role:'userAdminAnyDatabase',db:'admin'},{role:'dbAdminAnyDatabase',db:'admin'}]})
驗(yàn)證業(yè)務(wù)賬號(hào)登陸:
/usr/local/mongodb/bin/mongo --port=27117 -u admin -p admin --authenticationDatabase admin
該步驟,實(shí)際操作過程如下:
> > db.system.users.find().pretty() { "_id" : "admin.useradmin", "user" : "useradmin", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "6hLx/d97hS+yfoN47QTmXQ==", "storedKey" : "B0PqwVs3GFKIHQyyQ6mBp1MA370=", "serverKey" : "xK53AKKAvFCdn5rsEtij5QB9RtU=" } }, "roles" : [ { "role" : "clusterAdmin", "db" : "admin" }, { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] } { "_id" : "admin.admin", "user" : "admin", "db" : "admin", "credentials" : { "SCRAM-SHA-1" : { "iterationCount" : 10000, "salt" : "snlJe16a2PX3dSwxnOsfAw==", "storedKey" : "VOoX1e7F0tOme6YuR+iyMLuEWK8=", "serverKey" : "aSlpI7TzlyJ5Ccbd8GoptNB8khk=" } }, "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" }, { "role" : "dbAdminAnyDatabase", "db" : "admin" } ] } > > ^C bye [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# [root@yq-mapp-otadb248 local]# /usr/local/mongodb/bin/mongo --port=27117 -u admin -p admin --authenticationDatabase admin MongoDB shell version: 3.2.5-20-g07e21d8 connecting to: 127.0.0.1:27117/test > > show dbs admin 0.000GB local 0.000GB > >
7. 啟動(dòng)時(shí)的報(bào)警處理
在mongodb啟動(dòng)過程中,有時(shí)會(huì)提示一些警告,其中常見的兩類警告處理過程如下:
警告1:
提示:
2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 2048 processes, 8192 files. Number of processes should be at least 4096 : 0.5 times number of files.
參考: http://blog.csdn.net/kk185800961/article/details/45613267
處理方式,根據(jù)提示,將 processes 值,由現(xiàn)在的 2048,修改為4096,甚至更高的值。
ps -ef|grep mongod
cat /proc/32321/limits
cat /etc/security/limits.d/90-nproc.conf
vim /etc/security/limits.d/90-nproc.conf
該步驟實(shí)際操作過程如下:
[root@yq-mapp-otadb248 limits.d]# [root@yq-mapp-otadb248 limits.d]# cat /etc/security/limits.d/90-nproc.conf # 20160621 limit?? #* soft nproc 51200 #* hard nproc 51200 * soft nproc 2048 * hard
nproc 16384 * soft nofile 8192 * hard nofile 8192 * soft stack 8192 * hard stack 8192 * soft memlock unlimited * hard memlock unlimited [root@yq-mapp-otadb248 limits.d]# vim /etc/security/limits.d/90-nproc.conf # 20160621 #* soft nproc 51200 #* hard nproc 51200 * soft nproc 8192 * hard nproc 16384 [root@yq-mapp-otadb248 ~]# [root@yq-mapp-otadb248 ~]# ulimt -a -bash: ulimt: command not found [root@yq-mapp-otadb248 ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 30422 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 8192 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 8192 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
警告2:
2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten]
2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-10-19T12:12:59.097+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
確認(rèn):
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
處理:
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
該步驟,實(shí)際操作過程如下:
[root@yq-mapp-otadb248 limits.d]# cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never [root@yq-mapp-otadb248 limits.d]# cat /sys/kernel/mm/transparent_hugepage/defrag [always] madvise never [root@yq-mapp-otadb248 limits.d]# [root@yq-mapp-otadb248 limits.d]# echo "never" > /sys/kernel/mm/transparent_hugepage/enabled [root@yq-mapp-otadb248 limits.d]# echo "never" > /sys/kernel/mm/transparent_hugepage/defrag [root@yq-mapp-otadb248 limits.d]# [root@yq-mapp-otadb248 limits.d]# cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] [root@yq-mapp-otadb248 limits.d]# cat /sys/kernel/mm/transparent_hugepage/defrag always madvise [never] [root@yq-mapp-otadb248 limits.d]# [root@yq-mapp-otadb248 limits.d]#
8 創(chuàng)建mongodb實(shí)例管理腳本
為了方便對(duì)mongodb實(shí)例的啟動(dòng)和停止,可以先創(chuàng)建mongodb的啟動(dòng)腳本,停止腳本,然后在 /etc/init.d/ 目錄下創(chuàng)建一個(gè)服務(wù)腳本,這樣就可以用 service 進(jìn)行實(shí)例管理了。
腳本1:?jiǎn)?dòng)腳本:
vim /home/mongodb/scripts/mongodb_start.sh
#!/bin/sh # the scripts is used to start mongodb instance with port 27117. # created by zhaofx on 20161019. echo -n "Starting MongoDB port 27117 ... " /usr/local/mongodb/bin/mongod --config /etc/mongodb/mongo_27117.conf &
腳本二:停止腳本:
vim /home/mongodb/scripts/mongodb_stop.sh
#!/bin/bash # the scripts is used to stop mongodb instance with port 27117. # created by zhaofx on 20161019. echo -n "Stopping MongoDB port 27117" pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`; if [ "${pid}" != "" ]; then kill -2 ${pid}; fi
腳本三:服務(wù)腳本:
vim /etc/init.d/mongodb
#! /bin/sh # the scripts is used to mange mongodb service with linux service type. # created by zhaofx on 20161019. PATH=/usr/local/mongodb/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=mongodb start(){ /home/mongodb/scripts/mongodb_start.sh } stop(){ /home/mongodb/scripts/mongodb_stop.sh } test -x $DAEMON || exit 0 set -e case "$1" in start) start ;; stop) stop ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop}" >&2 exit 1 ;; esac exit 0
修改腳本的屬組,添加執(zhí)行權(quán)限:
chown -R mongodb:mongodb /home/mongodb/scripts/ chown mongodb:mongodb /etc/init.d/mongodb chmod +x /home/mongodb/scripts/mongodb_start.sh chmod +x /home/mongodb/scripts/mongodb_stop.sh chmod +x /etc/init.d/mongodb
最后執(zhí)行服務(wù)啟動(dòng)和停止mongodb實(shí)例的過程為:
[root@yq-mapp-otadb248 ~]# [root@yq-mapp-otadb248 ~]# service mongodb stop Stopping MongoDB port 27117 [root@yq-mapp-otadb248 ~]# [root@yq-mapp-otadb248 ~]# [root@yq-mapp-otadb248 ~]# [root@yq-mapp-otadb248 ~]# service mongodb start Starting MongoDB port 27117 ... [root@yq-mapp-otadb248 ~] about to fork child process, waiting until server is ready for connections. forked process: 36088 child process started successfully, parent exiting [root@yq-mapp-otadb248 ~]#
mongodb 3.2.5安裝過程詳細(xì)記錄- END
文章標(biāo)題:mongodb3.2.5安裝過程詳細(xì)記錄
文章地址:http://www.rwnh.cn/article24/gdgcje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷型網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、做網(wǎng)站、網(wǎng)站設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)