MongoDB安装部署

1.软件下载

MongoDB官网地址

https://www.mongodb.com/community

MongoDB下载地址

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.21.tgz

2.规划目录

###安装依赖包
yum install libcurl openssl -y  

### 创建软件目录
mkdir /opt/mongo_cluster/ -p

###解压到指定的目录
tar -zxvf mongodb-linux-x86_64-3.6.21.tgz -C /opt/mongo_cluster/ 

###创建软连接
ln -s mongodb-linux-x86_64-3.6.21/ mongodb 

###创建配置文件
mkdir /opt/mongo_cluster/mongo_27017/{conf,logs,pid} -p 

### 创建数据目录
mkdir /data/mongo_cluster/mongo_27017 -p

###配置一下环境变量
vim /etc/profile
export PATH=/opt/mongo_cluster/mongodb/bin:$PATH

3.配置启动文件

cat > /opt/mongo_cluster/mongo_27017/conf/mongo.conf <<EOF
systemLog: destination:
file path: /opt/mongo_cluster/mongo_27017/logs/mongodb.log logAppend: true storage: journal: enabled: true dbPath: /data/mongo_cluster/mongo_27017 directoryPerDB: true #engine: wiredTiger wiredTiger: engineConfig: cacheSizeGB: 1 directoryForIndexes: true collectionConfig: blockCompressor: zlib indexConfig: prefixCompression: true processManagement: fork: true net: port: 27017 bindIp: 10.0.0.51,127.0.0.1
EOF

4.启动MongoDB,并检查状态

###启动MongoDB
mongod -f /opt/mongo_cluster/mongo_27017/conf/mongo.conf

###检查
ps -ef |grep mongo
netstat -lnp |grep 27017

###登录MongoDB
mongo 10.0.0.51:27017

###关闭MongoDB
mongod -f /opt/mongo_cluster/mongo_27017/conf/mongo.conf --shutdown

 

posted @ 2020-12-25 19:49  鄧萌  阅读(281)  评论(0)    收藏  举报