In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
I feel a little confused recently. I don't know what to do. I went to work today to look at my monitoring data. I wonder if I can write the data into this non-relational database in mongodb for the sake of reading and writing speed. Here is how to learn mongodb:
1. Installation:
Download: 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
Edit the.bash_profile file, add the path to MongoDB, and refresh the file [root@saltstack mongodb]# vim .bash_profileMONGO_BIN=/usr/local/mongodb/bin
export PATH=$PATH:$MONGO_BIN
[root@saltstack mongodb]# source /root/.bash_profile
2. To facilitate management, configuration files and startup scripts are given:
(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)Create database file directory:
mkdir /opt/mongodata
(3)Set up the startup server script:
[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
Start test after installation:
[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
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.