您好,登錄后才能下訂單哦!
近段時間感覺有點迷茫了,不知道該做什么,今天上班看看自己的監(jiān)控數(shù)據(jù),想想能不能為了讀寫速度我把數(shù)據(jù)寫入到mongodb里面這種非關(guān)系型數(shù)據(jù)庫里面呢,下面開始學(xué)習(xí)mongodb:
1、安裝:
下載:wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.3.tgz
[root@saltstack mongodb]
# tar xvfz mongodb-linux-x86_64-2.6.3.tgz -C /usr/local/
[root@saltstack mongodb]# mv mongodb-linux-x86_64-2.6.3 mongodb
編輯.bash_profile文件,加入MongoDB的路徑,然后刷新一下該文件
[root@saltstack mongodb]# vim .bash_profile
MONGO_BIN=
/usr/local/mongodb/bin
export
PATH=$PATH:$MONGO_BIN
[root@saltstack mongodb]# source /root/.bash_profile
2、為了方便管理,給出配置文件和啟動腳本:
(1)[root@saltstack mongodb]# cat /etc/mongod.conf
bind_ip=127.0.0.1
port=27017
fork=true
quiet=false
dbpath=/opt/mongodata
logpath=/opt/log/mongodb/mongod.log
logappend=true
journal=true
auth=true
(2)建立數(shù)據(jù)庫文件目錄:
mkdir /opt/mongodata
(3)設(shè)置啟動服務(wù)器腳本:
[root@saltstack mongodb]# cat /etc/init.d/mongod
#!/bin/bash
config_file=/etc/mongod.conf
lock_file=/opt/mongodata/mongod.lock
bin_file=/usr/local/mongodb/bin/mongod
start(){
pid=`cat "$lock_file" 2>/dev/null`
if [ -z "$pid" ];then
"$bin_file" --config="$config_file"
echo "mongod is start!"
else
echo "mongod is running!"
fi
}
stop(){
pid=`cat "$lock_file" 2>/dev/null`
if [ -z "$lock_file" ];then
echo "mongod is not running!"
else
kill -2 $pid
echo "mongod is stop!"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}"
exit 3
;;
esac
exit 0
安裝之后啟動測試:
[root@saltstack mongodb]# /etc/init.d/mongod start
[root@saltstack mongodb]# mongostat
connected to: 127.0.0.1
insert query update delete getmore command flushes mapped vsize res faults locked db idx miss % qr|qw ar|aw netIn netOut conn time
*0 *0 *0 *0 0 1|0 0 240m 777m 32m 0 xiaoluo:0.0% 0 0|0 0|0 62b 3k 1 06:22:04
*0 *0 *0 *0 0 1|0 0 240m 777m 32m 0 xiaoluo:0.0% 0 0|0 0|0 62b 3k 1 06:22:05
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。