- MongoDB Administrator’s Guide
- Cyrus Dasadia
- 276字
- 2021-07-02 15:47:41
How to do it…
- Create a directory /data and untar your downloaded file into this directory so that you now have a /data/mongodb-linux-x86_64-ubuntu1404-3.4.4 directory. All of MongoDB's core binaries are available in the /data/mongodb-linux-x86_64-ubuntu1404-3.4.4/bin directory.
- Create a symbolic link to the versioned file directory for a simpler naming convention and also allowing us to use a generic directory name (for example, in scripts):
ln -s /data/mongodb-linux-x86_64-ubuntu1404-3.4.4/ /data/mongodb
- Create a directory for the database:
mkdir /data/db
- Start the MongoDB server:
/data/mongodb/bin/mongod --dbpath /data/db
- You should see output like this:
2017-05-14T10:07:15.247+0000 I CONTROL [initandlisten] MongoDB starting : pid=3298 port=27017 dbpath=/data/db 64-bit host=vagrant-ubuntu-trusty-64
2017-05-14T10:07:15.247+0000 I CONTROL [initandlisten] db version v3.4.4
2017-05-14T10:07:15.248+0000 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-05-14T10:07:15.248+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2017-05-14T10:07:15.248+0000 I CONTROL [initandlisten] allocator: tcmalloc
2017-05-14T10:07:15.249+0000 I CONTROL [initandlisten] modules: none
2017-05-14T10:07:15.249+0000 I CONTROL [initandlisten] build environment:
2017-05-14T10:07:15.249+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2017-05-14T10:07:15.249+0000 I CONTROL [initandlisten] distarch: x86_64
2017-05-14T10:07:15.250+0000 I CONTROL [initandlisten] target_arch: x86_64
2017-05-14T10:07:15.250+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } }
< -- snip -- >
2017-05-14T10:07:15.313+0000 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.4
2017-05-14T10:07:15.313+0000 I NETWORK [thread1] waiting for connections on port 27017
- You can stop the server by pressing Ctrl + C.
Additionally, for convenience, we can edit the system's PATH variable to include the mongodb binaries directory. This allows us to invoke the mongodb binaries without having to type the entire path. For example, to execute the mongo client, instead of having to type /data/mongodb/bin/mongo every time, we can simply type mongo. This can be done by appending your ~/.bashrc or ~/.zshrc files for bash and zsh respectively, with the following lines:
PATH=/data/mongodb/bin:${PATH}
export PATH
推薦閱讀
- 零基礎PHP學習筆記
- Three.js開發指南:基于WebGL和HTML5在網頁上渲染3D圖形和動畫(原書第3版)
- CentOS 7 Linux Server Cookbook(Second Edition)
- Python 3破冰人工智能:從入門到實戰
- Visual Basic程序設計實驗指導(第4版)
- Unity 5.x By Example
- 自制編程語言
- 程序設計基礎教程:C語言
- Android應用案例開發大全(第二版)
- 移動增值應用開發技術導論
- Python商務數據分析(微課版)
- 監控的藝術:云原生時代的監控框架
- 邊玩邊學Scratch3.0少兒趣味編程
- 創新工場講AI課:從知識到實踐
- Scratch少兒編程高手的7個好習慣