包安装
下载安装包
tar -zxvf mongodb-linux-x86_64-rhel70-4.2.0.tgz
pwd
/opt/mongodb/mongodb-linux-x86_64-rhel70-4.2.0
安装依赖
- centos6:
yum install cyrus-sasl cyrus-sasl-plain cyrus-sasl-gssapi krb5-libs libcurl libpcap net-snmp openldap openssl
- centos7:
yum install cyrus-sasl cyrus-sasl-gssapi cyrus-sasl-plain krb5-libs libcurl libpcap lm_sensors-libs net-snmp net-snmp-agent-libs openldap openssl rpm-libs tcp_wrappers-libs
环境变量
-
vi /etc/profile
# MongoDB_HOME export MongoDB_HOME=/opt/mongodb/mongodb-linux-x86_64-rhel70-4.2.0 export PATH=$MongoDB_HOME/bin:$PATH
-
source /etc/profile
运行
前提条件:
mkdir -p /data/db
- 用户可读写
mongod
[initandlisten] waiting for connections on port 27017
另启界面:
mongo --host 127.0.0.1:27017
服务
sudo systemctl start mongod
sudo systemctl restart mongod
sudo systemctl stop mongod
sudo systemctl enable mongod
yum 安装
参考: