第三步:安裝mongodb3.0
添加key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
添加deb源
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
備註:其中lsb_release 是一個查看系統發行版本的命令 -sc 是指查看codeName
可以在系統上運行lsb_release -sc 如果爲utopic,則需將”$(lsb_release -sc)” 替換成trusty 因爲目前http://repo.mongodb.org/apt/ubuntu 中沒有utopic,可以訪問http://repo.mongodb.org/apt/ubuntu查看就知道了
執行安裝
sudo apt-get update
sudo apt-get install -y mongodb-org
基本使用命令及參數
- 啓動
方式一:sudo service mongod start
方式二:
mongod --config /etc/mongod.conf --dbpath youdbpath --port 27017 --storageEngine wiredTiger
具體啓動的參數詳細見http://docs.mongodb.org/manual/reference/program/mongod/
- 配置文件及參數
配置文件在 /etc/mongod.conf
具體參數詳見:
http://docs.mongodb.org/manual/reference/configuration-options/