1.系統(tǒng)版本
創(chuàng)新互聯(lián)公司自2013年起,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)、做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元撫遠(yuǎn)做網(wǎng)站,已為上家服務(wù),為撫遠(yuǎn)各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575 [root@test2 ~]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m2.下載MongoDB 到/usr/loca/
[root@test2 ~]# cd /usr/local/cd /usr/local/ [root@test2 ~]# cd /usr/local/wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.7.tgz3.解壓并創(chuàng)建數(shù)據(jù)庫的存儲(chǔ)及日志目錄:
[root@test2 local]# tar -zxvf mongodb-linux-x86_64-rhel62-3.0.7.tgz [root@test2 local]# mkdir -p mogodb/{data,logs} [root@test2 local]# cd mogodb/ [root@test2 mogodb]# ls bin data GNU-AGPL-3.0 logs README THIRD-PARTY-NOTICES [root@test2 mogodb]# cd logs/ [root@test2 logs]# touch mongodb.log4.建立配置文件
[root@test2 mogodb]# vi /usr/local/mongodb/bin/mongodb.conf dbpath=/usr/local/mongodb/data logpath=/usr/local/mongodb/logs/mongodb.log port=27017 fork=true nohttpinterface=true5.啟動(dòng)MongoDB
[root@test2 mongodb]# /usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf about to fork child process, waiting until server is ready for connections. forked process: 1449 child process started successfully, parent exiting6.設(shè)置開機(jī)自啟動(dòng)MongoDB
[root@test2 mongodb]# echo "/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf" >> /etc/rc.local /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf7.測(cè)試:
(1)進(jìn)入Mongodb的shell模式:
[root@test2 ~]# /usr/local/mongodb/bin/mongo MongoDB shell version: 3.0.7 connecting to: test Server has startup warnings: 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2015-11-11T18:26:02.022+0800 I CONTROL [initandlisten] >(2)查看數(shù)據(jù)庫列表
> show dbsshow dbs local 0.078GB(3)查看數(shù)據(jù)庫版本
> db.version();db.version(); 3.0.7(4)關(guān)閉數(shù)據(jù)庫
[root@test2 bin]# /usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/bin/mongodb.conf 2015-11-11T18:36:01.404+0800 I CONTROL log file "/usr/local/mongodb/logs/mongodb.log" exists; moved to "/usr/local/mongodb/logs/mongodb.log.2015-11-11T10-36-01". killing process with pid: 1449或使用kill
[root@test2 ~]# ps -ef |grep mongo root 1505 1 0 18:37 ? 00:00:03 /usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf root 1544 1324 0 18:45 pts/2 00:00:00 grep mongo [root@test2 ~]# kill 1505 注意:這個(gè)地方不能使用kill -9 pid,這樣會(huì)導(dǎo)致數(shù)據(jù)丟失,同時(shí)mongodb還可能會(huì)報(bào)錯(cuò)。
如果使用kill -9 pid的方式關(guān)閉mongodb,并且mongodb不能正常啟動(dòng),則需刪除mongod.lock文件
[root@test2 bin]# kill rm -rf /usr/local/mongodb/data/mongod.lock
[root@test2 bin]# /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
本文借鑒 “doiido” 博客,http://doiido.blog.51cto.com/5503054/1562541
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章標(biāo)題:Centos6.5下搭建Mongodb服務(wù)-創(chuàng)新互聯(lián)
鏈接分享:http://www.rwnh.cn/article22/hsjjc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、品牌網(wǎng)站制作、服務(wù)器托管、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站建設(shè)
聲明:本網(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)
猜你還喜歡下面的內(nèi)容