美文网首页
CentOS7 二进制安装MongoDB

CentOS7 二进制安装MongoDB

作者: 无味wy | 来源:发表于2021-08-03 18:51 被阅读0次

1、下载mongodb
官网下载地址:https://www.mongodb.com/try/download/community
也可以wget安装,如下

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.22.tgz
tar xf mongodb-linux-x86_64-4.0.22.tgz
mv mongodb-linux-x86_64-4.0.22 /usr/local/mongodb

2、创建数据与日志存放目录

mkdir  /usr/local/mongodb/data
mkdir /usr/local/mongodb/logs

3、环境变量设置

echo 'export PATH=$PATH:/usr/local/mongodb/bin' >>/etc/profile
source  /etc/profile
#测试
[root@localhost mongodb]# mongo -version
MongoDB shell version v4.0.22
git version: 1741806fb46c161a1d42870f6e98f5100d196315
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64

4、创建配置文件mongodb.conf

#数据文件存放目录
dbpath=/usr/local/mongodb/data
#日志文件存放目录
logpath=/usr/local/mongodb/logs/mongodb.log
# pid文件
pidfilepath=/usr/local/mongodb/mongod.pid
logappend= true
#端口
port=27017
#监听ip
bind_ip=0.0.0.0
#以守护程序的方式启用,即在后台运行
fork=true
directoryperdb=true
#开启认证
auth=true
wiredTigerCacheSizeGB=1

5、启动

[root@localhost mongodb]# /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf 
#查看
[root@localhost mongodb]# ps -ef|grep mongodb
root      11520      1  0 16:39 ?        00:00:29 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.conf
root      21973  16960  0 18:35 pts/2    00:00:00 grep --color=auto mongodb

6、登录测试

[root@localhost ~]# mongo -port 27017
MongoDB shell version v4.0.22
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("1c7f47e7-35ea-4938-9a7f-ecd91c21c466") }
MongoDB server version: 4.0.22

相关文章

网友评论

      本文标题:CentOS7 二进制安装MongoDB

      本文链接:https://www.haomeiwen.com/subject/xezxvltx.html