MongoDB之安裝並配置
系統環境:
[root@D2-LZY245 ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
如果是RHEL6版本,則需要先升級openssl:
[root@oeldb1 ~]# rpm -qa | grep openssl
openssl-devel-1.0.1e-57.el6.x86_64
openssl098e-0.9.8e-17.0.1.el6_2.2.x86_64
openssl-1.0.1e-57.el6.x86_64
安裝包及版本:
下載地址:
[root@D2-LZY245 ~]# ll mongodb-linux-x86_64-rhel70-3.4.7.tgz
-rw-rw-r-- 1 root root 100670645 Aug 10 17:06 mongodb-linux-x86_64-rhel70-3.4.7.tgz
建立安裝目錄:
[root@D2-LZY245 ~]# mkdir /usr/local/mongodb
解壓安裝包:
[root@D2-LZY245 ~]# tar -xvzf mongodb-linux-x86_64-rhel70-3.4.7.tgz
移動解壓後的檔案到安裝目錄:
[root@D2-LZY245 ~]# mv mongodb-linux-x86_64-rhel70-3.4.7/* /usr/local/mongodb/
[root@D2-LZY245 ~]# ll /usr/local/mongodb/
total 120
drwxrwxr-x 2 root root 4096 Aug 10 17:11 bin
-rw-r--r-- 1 root root 34520 Aug 8 03:37 GNU-AGPL-3.0
-rw-r--r-- 1 root root 16726 Aug 8 03:37 MPL-2
-rw-r--r-- 1 root root 1359 Aug 8 03:37 README
-rw-r--r-- 1 root root 55625 Aug 8 03:37 THIRD-PARTY-NOTICES
配置PATH:
[root@D2-LZY245 ~]# grep PATH .bash_profile
PATH=$PATH:$HOME/bin
export PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:/usr/local/mongodb/bin/
[root@D2-LZY245 ~]# source .bash_profile
建立資料庫目錄和日誌檔案:
[root@D2-LZY245 ~]# mkdir /usr/local/mongodb/db
[root@D2-LZY245 ~]# mkdir /usr/local/mongodb/log
[root@D2-LZY245 ~]# touch /usr/local/mongodb/log/mongodb.log
建立引數檔案:
[root@D2-LZY245 ~]# vim /usr/local/mongodb/mongodb.conf
dbpath=/usr/local/mongodb/db
logpath=/usr/local/mongodb/log/mongodb.log
logappend=true
noauth=true
port=27017
fork=true
啟動:
[root@D2-LZY245 ~]# mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 12610
child process started successfully, parent exiting
配置開機啟動:
[root@D2-LZY245 ~]# vi /etc/rc.d/rc.local
/usr/local/mongodb/bin/mongod –f /usr/local/mongodb/mongodb.conf
當MongoDB服務啟動後,可以使用mongo命令連線資料庫。
[root@oeldb1 ~]# mongo
MongoDB shell version v3.4.7
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.7
Welcome to the MongoDB shell.
#查詢所有資料庫:
> show databases;
admin 0.000GB
local 0.000GB
#關閉資料庫。
> use admin
switched to db admin
> db.shutdownServer();
或者:
[root@oeldb1 ~]# mongod -f /usr/local/mongodb/mongodb.conf --shutdown
killing process with pid: 11580
[root@D2-LZY245 ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
如果是RHEL6版本,則需要先升級openssl:
[root@oeldb1 ~]# rpm -qa | grep openssl
openssl-devel-1.0.1e-57.el6.x86_64
openssl098e-0.9.8e-17.0.1.el6_2.2.x86_64
openssl-1.0.1e-57.el6.x86_64
安裝包及版本:
下載地址:
[root@D2-LZY245 ~]# ll mongodb-linux-x86_64-rhel70-3.4.7.tgz
-rw-rw-r-- 1 root root 100670645 Aug 10 17:06 mongodb-linux-x86_64-rhel70-3.4.7.tgz
建立安裝目錄:
[root@D2-LZY245 ~]# mkdir /usr/local/mongodb
解壓安裝包:
[root@D2-LZY245 ~]# tar -xvzf mongodb-linux-x86_64-rhel70-3.4.7.tgz
移動解壓後的檔案到安裝目錄:
[root@D2-LZY245 ~]# mv mongodb-linux-x86_64-rhel70-3.4.7/* /usr/local/mongodb/
[root@D2-LZY245 ~]# ll /usr/local/mongodb/
total 120
drwxrwxr-x 2 root root 4096 Aug 10 17:11 bin
-rw-r--r-- 1 root root 34520 Aug 8 03:37 GNU-AGPL-3.0
-rw-r--r-- 1 root root 16726 Aug 8 03:37 MPL-2
-rw-r--r-- 1 root root 1359 Aug 8 03:37 README
-rw-r--r-- 1 root root 55625 Aug 8 03:37 THIRD-PARTY-NOTICES
配置PATH:
[root@D2-LZY245 ~]# grep PATH .bash_profile
PATH=$PATH:$HOME/bin
export PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:/usr/local/mongodb/bin/
[root@D2-LZY245 ~]# source .bash_profile
建立資料庫目錄和日誌檔案:
[root@D2-LZY245 ~]# mkdir /usr/local/mongodb/db
[root@D2-LZY245 ~]# mkdir /usr/local/mongodb/log
[root@D2-LZY245 ~]# touch /usr/local/mongodb/log/mongodb.log
建立引數檔案:
[root@D2-LZY245 ~]# vim /usr/local/mongodb/mongodb.conf
dbpath=/usr/local/mongodb/db
logpath=/usr/local/mongodb/log/mongodb.log
logappend=true
noauth=true
port=27017
fork=true
啟動:
[root@D2-LZY245 ~]# mongod -f /usr/local/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 12610
child process started successfully, parent exiting
配置開機啟動:
[root@D2-LZY245 ~]# vi /etc/rc.d/rc.local
/usr/local/mongodb/bin/mongod –f /usr/local/mongodb/mongodb.conf
當MongoDB服務啟動後,可以使用mongo命令連線資料庫。
[root@oeldb1 ~]# mongo
MongoDB shell version v3.4.7
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.7
Welcome to the MongoDB shell.
#查詢所有資料庫:
> show databases;
admin 0.000GB
local 0.000GB
#關閉資料庫。
> use admin
switched to db admin
> db.shutdownServer();
或者:
[root@oeldb1 ~]# mongod -f /usr/local/mongodb/mongodb.conf --shutdown
killing process with pid: 11580
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28536251/viewspace-2144058/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【mongodb安裝配置】MongoDB
- 【MongoDB】安裝與配置MongoDB
- MongoDB安裝配置教程MongoDB
- Mac 安裝與配置mongodbMacMongoDB
- mongodb的安裝配置,使用MongoDB
- Linux mongodb 安裝與配置LinuxMongoDB
- Mongodb入門——安裝與配置MongoDB
- 小丸子學MongoDB系列之——安裝MongoDBMongoDB
- 安裝並配置goldengateGo
- 學習MongoDB 一:MongoDB 入門(安裝與配置)MongoDB
- MongoDB Windows環境安裝及配置MongoDBWindows
- Mongodb在Windows下安裝及配置MongoDBWindows
- redhat linux 5 之配置YUM源並安裝包RedhatLinux
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- MongoDB系列二:Replica Sets安裝與配置MongoDB
- 【mongodb】mongodb的安裝MongoDB
- puppet之安裝配置
- docker 安裝 nginx 並配置反向代理DockerNginx
- 快速安裝配置 GitLab 並漢化Gitlab
- linux配置multipath 並安裝racLinux
- mongodb 安裝MongoDB
- 安裝mongodbMongoDB
- MongoDB安裝MongoDB
- mongodb 安裝MongoDB
- windows下安裝MongoDB擴充套件和配置WindowsMongoDB套件
- Linux下Mongodb安裝和啟動配置LinuxMongoDB
- TSM之——CLIENT安裝配置client
- linux下安裝node npm並配置LinuxNPM
- LINUX下安裝cassandra 並配置clusterLinux
- Ubuntu上安裝KVM並配置顯示卡直通Ubuntu
- Docker安裝mongodbDockerMongoDB
- MAC 安裝 MongoDBMacMongoDB
- MongoDB的安裝MongoDB
- Mac安裝MongoDBMacMongoDB
- mongodb 3.2.0.4安裝MongoDB
- centos安裝mongodbCentOSMongoDB
- 【mongodb】安裝pymongoMongoDB
- MongoDB安裝指南MongoDB