centos7安装mongodb
2019-12-04可以通过tar包或者yum安装
1、通过yum安装
#!/bin/sh
cat > /etc/yum.repos.d/mongodb.repo << EOF
[mongodb-org]
name=MongoDB Repository
baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/4.2/x86_64/
gpgcheck=0
enabled=1
EOF
yum -y install mongodb-org
2、通过tar包安装
#wget -c https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz
#tar zxf mongodb-linux-x86_64-rhel70-4.2.1.tgz
#mkdir -p /usr/local/mongodb
#/bin/cp -r mongodb-linux-x86_64-rhel70-4.2.1/bin/ /usr/local/mongdb
3、设置MONGODB_HOME
sed -i '/MONGODB_HOME/d' ~/.bash_profile;
cat << EOF >> ~/.bash_profile
export MONGODB_HOME=/usr/local/mongodb
export PATH=$PATH:\${MONGODB_HOME}/bin
EOF
4、启动
mongos --config /user/local/mongodb/config/mongos.conf