mongdb数据库安装配置


mongdb下载地址:https://download.csdn.net/download/zhaosongbin/12366856


安装

解压二进制安装包,并移动

tar -zxvf mongodb-linux-x86_64-4.0.5.tgz
mv mongodb-linux-x86_64-4.0.5 /usr/local/mongo

配置

环境变量配置
vim /etc/profile.d/mongo.sh
source /etc/profile.d/mongo.sh 
mongo -version

mongo.sh 详细如下:

export PATH=$PATH:/usr/local/mongo/bin

mongod.conf配置

新建文件夹和文件
注意mongod.log日志文件,是为了防止权限问题,直接保存即可

mkdir /usr/local/mongo/log/
mkdir /usr/local/mongo/data/
vim /usr/local/mongo/log/mongod.log

编辑mongod.conf
bind_ip: 0.0.0.0 是为了可以远程访问
auth: 为了开启账户密码

fork=true
auth=true
bind_ip=0.0.0.0
port=27017
quiet=true
dbpath=/usr/local/mongo/data
logpath=/usr/local/mongo/log/mongod.log
logappend=true
journal=true
storageEngine=wiredTiger
wiredTigerCacheSizeGB=3
syncdelay=30
wiredTigerCollectionBlockCompressor=snappy
directoryperdb=true

开机启动

echo "/usr/local/mongo/bin/mongod --dbpath=/usr/local/mongo/data -logpath=/usr/local/mongo/log -logappend  --auth --port=27017" >> /etc/rc.local

你可能感兴趣的:(mongodb,linux)