如何在Ubuntu上安装MongoDB 3.0.2 WiredTiger

安装mongodb 3.0.2

操作系统是Ubuntu 14.04.1 LTS \n \l

主要步骤如下:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
sudo 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
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start



安装详细步骤如下

root@dbdao-Inspiron-560s:~# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.08FbwQ9cDM --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
gpg: requesting key 7F0CEB10 from hkp server keyserver.ubuntu.com
gpg: key 7F0CEB10: public key "Richard Kreuter <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

root@dbdao-Inspiron-560s:~# 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
deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse


sudo apt-get update
sudo apt-get install -y mongodb-org

 

之后创建wiredTiger使用的存储目录并修改必要的参数

 

 

sudo mkdir -p /m01/mondata
 sudo chown mongodb:mongodb /m01/mondata
 sudo echo "storageEngine = wiredTiger" >> /etc/mongod.conf 

 修改 sudo vi /etc/mongod.conf 

 dbpath=/var/lib/mongodb

 修改为

 dbpath=/m01/mondata





修改/etc/security/limits.conf 加入如下内容 : sudo vi /etc/security/limits.conf

* soft nproc 1024
root soft nproc unlimited

* soft nofile 64000 # 加入的内容
* hard nofile 64000 # 加入的内容

修改/etc/rc.local 如下sudo vi /etc/rc.local


touch /var/lock/subsys/local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then # ↑加入的内容
 echo never > /sys/kernel/mm/transparent_hugepage/enabled # │
fi # │
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then # │
 echo never > /sys/kernel/mm/transparent_hugepage/defrag # │
fi 


修改 /etc/init/mongod.conf , 加入 sudo vi /etc/init/mongod.conf

在pre-start script 这一行下面加入下面的内容

 if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then
 echo never > /sys/kernel/mm/transparent_hugepage/enabled
 fi
 if [ -f /sys/kernel/mm/transparent_hugepage/defrag ]; then
 echo never > /sys/kernel/mm/transparent_hugepage/defrag
 fi






sudo service mongod restart

以上重启了mongod的daemon进程

之后可以使用mongo 命令行操作

 


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *