centos7 rpm方式安装mongoDB
#下载三个rpm包
wget https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el7-4.2/RPMS/mongodb-org-tools-4.2.8-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el7-4.2/RPMS/mongodb-org-server-4.2.8-1.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el7-4.2/RPMS/mongodb-org-shell-4.2.8-1.el7.x86_64.rpm
#安装包
sudo rpm -ivh mongodb-org-server-4.2.8-1.el7.x86_64.rpm
sudo rpm -ivh mongodb-org-shell-4.2.8-1.el7.x86_64.rpm
sudo rpm -ivh mongodb-org-tools-4.2.8-1.el7.x86_64.rpm
#修改配置文件,这样就可以远程连接
sudo vi /etc/mongod.conf
把bindIp: 127.0.0.1改成 bindIp: 0.0.0.0
#启动服务
service mongod start
#设置开机自启动
systemctl enable mongod.service
#复制jar到共享空间
sudo cp bson-3.12.5.jar /usr/share/java/bson-3.12.5.jar
sudo cp mongodb-driver-3.12.5.jar /usr/share/java/mongodb-driver-3.12.5.jar
sudo cp mongodb-driver-core-3.12.5.jar /usr/share/java/mongodb-driver-core-3.12.5.jar
#jvm链接
sudo ln -s /usr/share/java/bson-3.12.5.jar /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/ext/bson-3.12.5.jar
sudo ln -s /usr/share/mongodb-driver-3.12.5.jar /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/ext/mongodb-driver-3.12.5.jar
sudo ln -s /usr/share/java/mongodb-driver-core-3.12.5.jar /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/lib/ext/mongodb-driver-core-3.12.5.jar