第6周 處理非結構化資料的利器Mongodb
阿新 • • 發佈:2018-12-30
mongodb:面向文件的nosql
mongodb官網:http://www.mongodb.org/ 10gen官網:http://www.mongodb.com/ 面向文件的儲存引擎,可以方便的支援非結構化資料 全面的索引支援,可以在任意屬性上建立索引 資料庫本身內建的複製與高可用 資料庫本身支援的自動分片叢集 豐富的基於文件的查詢功能 原子化的資料操作 非結構化資料 不能確定表的列結構的資料 例子:調查表 集合 集合就是一組文件 文件類似於關係資料庫裡的行 集合類似於關係資料庫裡的表 集合是無模式的,即集合中的文件可以五花八門,無需固定結構 資料庫是由多個集合組成mongodb的安裝:
# tar zxvf mongodb-linux-i686-2.0.9.tgz通過配置檔案來啟動Mongodb
[[email protected] bin]# cat mongodb.conf logpath=/nosql/mongodb/mongodb/log/mongodb.log logappend=true #日誌檔案自動累加,而不是覆蓋 dbpath=/nosql/mongodb/mongodb/data/ pidfilepath=/nosql/mongodb/mongodb/log/mongodb.pid fork=true #加了fork,就會丟後臺執行 [[email protected] bin]# ./mongod -f /nosql/mongodb/mongodb/bin/mongodb.conf [[email protected] bin]# forked process: 4004 all output going to: /nosql/mongodb/mongodb/log/mongodb.log [[email protected] bin]# pstree -p | grep mongo |-mongod(4004)-+-{mongod}(4005) | |-{mongod}(4006) | |-{mongod}(4007) | |-{mongod}(4008) | |-{mongod}(4009) | |-{mongod}(4010) | `-{mongod}(4011)測試javascript:
[[email protected] bin]# ./mongo MongoDB shell version: 2.0.9 connecting to: test > 40/5 8 > x=200 200 > db.foo.save({a:1}); > db.foo.find(); { "_id" : ObjectId("52b815edda39a9573226cb88"), "a" : 1 } ##_id用於唯一標示文件,類似oracle裡的rowid > exit ##objectid是id的預設產生辦法 bye [[email protected] bin]#常用命令 :
如果想檢視當前連線在哪個資料庫下面,可以直接輸入db 檢視使用者列表db.system.users.find(); 檢視所有使用者show users; 檢視所有資料庫show dbs; 檢視所有集合show collections; 刪除當前的資料庫db.dropDatabase(); 刪除collection db.集合名.drop(); 想知道mongodb執行哪些命令,可以直接輸入help; 想知道當前資料庫支援哪些方法db.help(); 想知道當前集合支援哪些方法db.集合名.help();MongoDb web 使用者介面
在比MongoDB服務的埠多1000的埠上,你可以訪問到MondoDB的web使用者介面。
如:如果你的MongoDB執行埠使用預設的27017,你可以在埠號為28017訪問web使用者介面。
http://192.168.253.128:28017/