導入共匙
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
創建源列表
echo 'deb https://repo.mongodb.com/apt/ubuntu PRecise/mongodb-enterprise/stable multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-enterprise.list
刷新包
sudo apt-get update
安裝企業版
sudo apt-get install mongodb-enterprise
防止意外升級到最新版,可以運行如下命令
echo "mongodb-enterprise hold" | sudo dpkg --set-selectionsecho "mongodb-enterprise-server hold" | sudo dpkg --set-selectionsecho "mongodb-enterprise-shell hold" | sudo dpkg --set-selectionsecho "mongodb-enterprise-mongos hold" | sudo dpkg --set-selectionsecho "mongodb-enterprise-tools hold" | sudo dpkg --set-selections
啟動運行
sudo /etc/init.d/mongod start
驗證啟動成功
驗證是否啟動成功可以到日志文件查看,具體位置在 /var/log/mongodb/mongod.log.
停止
sudo /etc/init.d/mongod stop
重啟
sudo /etc/init.d/mongod restart
附:update失敗 提示有一個舊項的解決辦法更新源至國內我用的是阿里云的源具體的操作是 vi /etc/apt/sources.list 在文件最前面添加以下條目(!!!操作前請做好相應備份!!!)
deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
配置文件
#fork=true #以守護進程的方式運行MongoDB,創建服務器進程,linux有效dbpath=D:/Ruby/mongo/db #指定數據庫路徑logpath=D:/Ruby/mongo/logs/db.log #指定MongoDB日志文件,注意是指定文件不是目錄logappend=true #使用追加的方式寫日志journal=true #啟用日志選項,MongoDB的數據操作將會寫入到journal文件夾的文件里pidfilepath=D:/Ruby/mongo/pids/db.pid #PID File 的完整路徑,如果沒有設置,則沒有PID文件bind_ip=127.0.0.1 # 綁定服務IP,若綁定127.0.0.1,則只能本機訪問,不指定默認本地所有IPport=1986 #指定服務端口號,默認端口27017directoryperdb=true #設置每個數據庫將被保存在一個單獨的目錄oplogSize=100 #設置oplog的大小(MB)auth=true #啟用驗證
具體如何配置 移步官網企業版介紹中查詢
The package configures MongoDB using the/etc/mongod.conffile in conjunction with the control scripts.
新聞熱點
疑難解答
圖片精選