国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Linux服務器 > 正文

Linux下安裝MongoDB的實現步驟

2024-09-05 23:04:17
字體:
來源:轉載
供稿:網友

Linux下安裝MongoDB的實現步驟

  Mongo DB 是目前在IT行業非常流行的一種非關系型數據庫(NoSql),其靈活的數據存儲方式備受當前IT從業人員的青睞。Mongo DB很好的實現了面向對象的思想(OO思想),在Mongo DB中 每一條記錄都是一個Document對象。Mongo DB最大的優勢在于所有的數據持久操作都無需開發人員手動編寫SQL語句,直接調用方法就可以輕松的實現CRUD操作。本文介紹了如何快速安裝mongodb供大家參考。

一、安裝配置mongodb

Step 1: 設置系統環境及確保缺省端口27107可用

###當前環境# cat /etc/issueRed Hat Enterprise Linux Server release 6.5 (Santiago)# vi /etc/selinux/configSELINUX=disabled

Step 2: 下載安裝文件

下載地址: https://www.mongodb.org/downloads. 或者直接在命令提示符下使用curl命令下載curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz

Step 3: 解壓下載的文件

# pwd/usr/local/src# tar -xvf mongodb-linux-x86_64-rhel62-3.0.6.gz ###注,本文直接從網站下載,所以文件為.gz

Step 4: 復制解壓文件到運行目錄

# mkdir -p /var/lib/mongodb# cp -R -n /usr/local/src/mongodb-linux-x86_64-rhel62-3.0.6/. /var/lib/mongodb/

Step 5: 設置環境變量

e.g. export PATH=<mongodb-install-directory>/bin:$PATH# vi ~/.bash_profile  export PATH=/var/lib/mongodb/bin:$PATH# source ~/.bash_profile

Step 6: 創建數據目錄

# mkdir -p /data/mongodata

二、啟動及驗證mongodb

###啟動mongo# mongod --dbpath /data/mongodata###以下內容為啟動后輸出的相關信息2015-10-28T10:03:33.100+0800 I JOURNAL [initandlisten] journal dir=/data/mongodata/journal2015-10-28T10:03:33.101+0800 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed2015-10-28T10:03:33.264+0800 I JOURNAL [initandlisten] preallocateIsFaster=true 2.182015-10-28T10:03:33.398+0800 I JOURNAL [durability] Durability thread started2015-10-28T10:03:33.398+0800 I JOURNAL [journal writer] Journal writer thread started2015-10-28T10:03:33.401+0800 I CONTROL [initandlisten] MongoDB starting : pid=10191 port=27017 dbpath=/data/mongodata 64-bit host=java_22015-10-28T10:03:33.401+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2015-10-28T10:03:33.401+0800 I CONTROL [initandlisten] 2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] 2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] **    We suggest setting it to 'never'2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] 2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] **    We suggest setting it to 'never'2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] 2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] db version v3.0.62015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f22015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] build info: Linux ip-10-67-194-123 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 BOOST_LIB_VERSION=1_492015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] allocator: tcmalloc2015-10-28T10:03:33.402+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/mongodata" } }2015-10-28T10:03:33.404+0800 I INDEX  [initandlisten] allocating new ns file /data/mongodata/local.ns, filling with zeroes...2015-10-28T10:03:33.491+0800 I STORAGE [FileAllocator] allocating new datafile /data/mongodata/local.0, filling with zeroes...2015-10-28T10:03:33.491+0800 I STORAGE [FileAllocator] creating directory /data/mongodata/_tmp2015-10-28T10:03:33.497+0800 I STORAGE [FileAllocator] done allocating datafile /data/mongodata/local.0, size: 64MB, took 0.001 secs2015-10-28T10:03:33.511+0800 I NETWORK [initandlisten] waiting for connections on port 27017###停止mongo,直接使用ctrl + c^C2015-10-28T10:09:21.510+0800 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends2015-10-28T10:09:21.511+0800 I CONTROL [signalProcessingThread] now exiting2015-10-28T10:09:21.511+0800 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...2015-10-28T10:09:21.511+0800 I NETWORK [signalProcessingThread] closing listening socket: 52015-10-28T10:09:21.511+0800 I NETWORK [signalProcessingThread] closing listening socket: 62015-10-28T10:09:21.511+0800 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock2015-10-28T10:09:21.511+0800 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog...2015-10-28T10:09:21.511+0800 I NETWORK [signalProcessingThread] shutdown: going to close sockets...2015-10-28T10:09:21.512+0800 I STORAGE [signalProcessingThread] shutdown: waiting for fs preallocator...2015-10-28T10:09:21.512+0800 I STORAGE [signalProcessingThread] shutdown: final commit...2015-10-28T10:09:21.512+0800 I JOURNAL [signalProcessingThread] journalCleanup...2015-10-28T10:09:21.512+0800 I JOURNAL [signalProcessingThread] removeJournalFiles2015-10-28T10:09:21.515+0800 I JOURNAL [signalProcessingThread] Terminating durability thread ...2015-10-28T10:09:21.615+0800 I JOURNAL [journal writer] Journal writer thread stopped2015-10-28T10:09:21.615+0800 I JOURNAL [durability] Durability thread stopped2015-10-28T10:09:21.615+0800 I STORAGE [signalProcessingThread] shutdown: closing all files...2015-10-28T10:09:21.618+0800 I STORAGE [signalProcessingThread] closeAllFiles() finished2015-10-28T10:09:21.618+0800 I STORAGE [signalProcessingThread] shutdown: removing fs lock...2015-10-28T10:09:21.618+0800 I CONTROL [signalProcessingThread] dbexit: rc: 0###修復啟動過程中的兩個警告,關于使用root用戶啟動mongo的警告先忽略# echo "never" > /sys/kernel/mm/transparent_hugepage/enabled# echo "never" > /sys/kernel/mm/transparent_hugepage/defrag###再次重啟,后置于后臺進程,# mongod --dbpath /data/mongodata &###查看啟動后的進程# ps -ef|grep mongo |grep -v greproot   11115 27956 0 10:11 pts/2  00:00:00 mongod --dbpath /data/mongodata# lsof -i:27017COMMAND  PID USER  FD  TYPE  DEVICE SIZE/OFF NODE NAMEmongod 11115 root  5u IPv4 50567119   0t0 TCP *:27017 (LISTEN)###使用mongo連接到mongod# mongoMongoDB shell version: 3.0.6connecting to: test2015-10-28T10:14:30.685+0800 I NETWORK [initandlisten] connection accepted from 127.0.0.1:53907 #1 (1 connection now open)Server has startup warnings: 2015-10-28T10:11:49.217+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.2015-10-28T10:11:49.217+0800 I CONTROL [initandlisten] > help    db.help()          help on db methods    db.mycoll.help()       help on collection methods    sh.help()          sharding helpers    rs.help()          replica set helpers    help admin          administrative help    help connect         connecting to a db help    help keys          key shortcuts    help misc          misc things to know    help mr           mapreduce    show dbs           show database names    show collections       show collections in current database    show users          show users in current database    show profile         show most recent system.profile entries with time >= 1ms    show logs          show the accessible logger names    show log [name]       prints out the last segment of log in memory, 'global' is default    use <db_name>        set current database    db.foo.find()        list objects in collection foo    db.foo.find( { a : 1 } )   list objects in foo where a == 1    it              result of the last line evaluated; use to further iterate    DBQuery.shellBatchSize = x  set default number of items to display on shell    exit             quit the mongo shell> db.getCollection("version");test.version> exitbye

三、mongodb相關工具

###在安裝文件下有README,描述了常用的mongodb相關命令行工具# more /usr/local/mongodb/README MongoDB READMEWelcome to MongoDB!COMPONENTS bin/mongod - The database process. bin/mongos - Sharding controller. bin/mongo - The database shell (uses interactive javascript).UTILITIES bin/mongodump     - MongoDB dump tool - for backups, snapshots, etc.. bin/mongorestore   - MongoDB restore a dump bin/mongoexport    - Export a single collection to test (JSON, CSV) bin/mongoimport    - Import from JSON or CSV bin/mongofiles    - Utility for putting and getting files from MongoDB GridFS bin/mongostat     - Show performance statisticsRUNNING For command line options invoke:  $ ./mongod --help To run a single server database:  $ mkdir /data/db  $ ./mongod  $  $ # The mongo javascript shell connects to localhost and test database by default:  $ ./mongo   > helpDRIVERS Client drivers for most programming languages are available at mongodb.org. Use the  shell ("mongo") for administrative tasks.###獲取單個命令用法# <command> --help# mongod --help|moreOptions:General options: -h [ --help ]        show this usage information --version          show version information# mongod --versiondb version v3.0.6git version: 1ef45a23a4c5e3480ac919b28afcba3c615488f2 

如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东丰县| 巴林右旗| 澳门| 阿尔山市| 阿克苏市| 封丘县| 三江| 方城县| 株洲县| 伊川县| 娄底市| 台州市| 沁水县| 太仓市| 鹿泉市| 来宾市| 淅川县| 临夏县| 阳江市| 金阳县| 临洮县| 嘉定区| 休宁县| 清新县| 颍上县| 福州市| 友谊县| 哈尔滨市| 鄂托克前旗| 界首市| 商南县| 宝鸡市| 波密县| 洪雅县| 当涂县| 平凉市| 屏边| 布尔津县| 青冈县| 禄劝| 双辽市|