centos7 安装mongodb

news/2024/10/18 2:25:25/

Yum 安装

vi /etc/yum.repos.d/mongodb-org-6.0.repo

填充内容如下:

 
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

sudo yum install -y mongodb-org

 

用这个命令可以指定版本:

sudo yum install -y mongodb-org-6.0.2 mongodb-org-database-6.0.2 mongodb-org-server-6.0.2 mongodb-mongosh-6.0.2 mongodb-org-mongos-6.0.2 mongodb-org-tools-6.0.2

vi /etc/mongod.conf

修改

# where to write logging data.
systemLog:destination: filelogAppend: truepath: /var/log/mongodb/mongod.log# Where and how to store data.
storage:dbPath: /var/lib/mongojournal:enabled: true
#  engine:
#  wiredTiger:# how the process runs
processManagement:fork: true  # fork and run in backgroundpidFilePath: /var/run/mongodb/mongod.pid  # location of pidfiletimeZoneInfo: /usr/share/zoneinfo# network interfaces
net:port: 2007bindIp: 0.0.0.0  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.

启动:

systemctl start mongod

遇到问题:

journalctl -xe

10月 10 06:07:17 localhost.localdomain systemd[1]: Unit mongod.service entered failed state. 
10月 10 06:07:17 localhost.localdomain systemd[1]: mongod.service failed. 
10月 10 06:07:17 localhost.localdomain polkitd[787]: Unregistered Authentication Agent for unix-process:32471:1252991 (system bus name :1.227, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, 
10月 10 06:07:19 localhost.localdomain polkitd[787]: Registered Authentication Agent for unix-process:32496:1253177 (system bus name :1.228 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org 
10月 10 06:07:19 localhost.localdomain systemd[1]: Starting MongoDB Database Server... -- Subject: Unit mongod.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mongod.service has begun starting up. 
10月 10 06:07:19 localhost.localdomain mongod[32511]: about to fork child process, waiting until server is ready for connections. 
10月 10 06:07:19 localhost.localdomain mongod[32511]: forked process: 32513 
10月 10 06:07:19 localhost.localdomain mongod[32511]: ERROR: child process failed, exited with 48 
10月 10 06:07:19 localhost.localdomain mongod[32511]: To see additional information in this output, start without the "--fork" option. 
10月 10 06:07:19 localhost.localdomain systemd[1]: mongod.service: control process exited, code=exited status=48 
10月 10 06:07:19 localhost.localdomain systemd[1]: Failed to start MongoDB Database Server. -- Subject: Unit mongod.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit mongod.service has failed. -- -- The result is failed.

查看日志 vi /var/log/mongodb/mongod.log, 得到:

{"t": {"$date": "2022-10-10T06:36:19.084-04:00"},"s": "E","c": "CONTROL","id": 20568,"ctx": "initandlisten","msg": "Error setting up listener","attr": {"error": {"code": 9001,"codeName": "SocketException","errmsg": "Permission denied"}}
}

解决方案:

用命令 mongod -f /etc/mongod.conf --nounixsocket --fork 启动

不用 systemctl start

 

附: nounixsocket: 套接字文件,默认为false ,意为生成socket文件。可在 conf 中配置 当设置为true时,不会生成socket文件。 nounixsocket = false

参考:

Install MongoDB Community Edition on Red Hat or CentOS — MongoDB Manual

https://www.jianshu.com/p/ba63f6c5ad04

https://blog.csdn.net/kakalairen/article/details/119395309


http://www.ppmy.cn/news/411527.html

相关文章

ad18学习笔记四:层叠管理器

Altium Designer(AD)软件使用记录05-PCB叠层设计_ad层叠管理器_朱万利的博客-CSDN博客 Altium Designer(AD)软件使用记录05-PCB叠层设计_ad层叠管理器_朱万利的博客-CSDN博客 AD使用教程 图文并茂 AD2020四层板_ad层叠管理器_知立的博客-CSDN博客 AD使用教程 图文并茂 AD202…

蓝牙耳机哪个品牌的质量好?佩戴舒适的真无线耳机

不管是听歌煲剧还是打游戏上分,很多人都会佩戴蓝牙耳机,摆脱有线的束缚和缠绕带来的困扰,蓝牙耳机更贴合当下年轻人的态度与风格。现在,市面上蓝牙耳机的形态及种类也越来越多,下面我来推荐几款佩戴舒适的蓝牙耳机&…

蓝牙耳机品牌哪个质量好?2023质量好的蓝牙耳机推荐

相较于有线耳机,蓝牙耳机凭借更方便地使用而受到不少人的喜爱,蓝牙耳机各种性能的发展也越来越先进。哪个品牌的蓝牙耳机质量好?针对这个问题,我来给大家推荐几款质量好的蓝牙耳机,一起来看看吧。 一、南卡小音舱蓝牙耳…

蓝牙耳机哪个品牌质量好?四大高质量蓝牙耳机推荐

蓝牙耳机哪个品牌质量好?现在各种品牌的蓝牙耳机更新换代频率越来越高,不同耳机所侧重的功能都不一样。下面,针对这个问题,我来给大家推荐几款质量好的蓝牙耳机,一起来看看吧。 一、南卡小音舱Lite2蓝牙耳机 参考价&…

2023蓝牙耳机哪个品牌的质量好?耐用的蓝牙耳机推荐

2023年,蓝牙耳机依然是最受欢迎的数码产品之一。随着蓝牙耳机品牌的增多,知名的不知名的蓝牙耳机数不胜数。接下来,我来给大家推荐几款耐用的蓝牙耳机,一起来看看吧。 一、南卡小音舱Lite2蓝牙耳机 参考价:239 蓝牙…

【Hadoop】大数据开发环境配置

【Hadoop】大数据开发环境配置 文章目录 【Hadoop】大数据开发环境配置1 设置静态ip2 设置主机名3 关闭防火墙4 ssh免密码登录5 JDK配置6 hadoop安装并配置6.1 集群节点之间时间同步6.2 SSH免密码登录完善6.3 hadoop配置 1 设置静态ip 进入ifcfg-ens33文件 vi /etc/sysconfig/n…

酷比魔方的系统重装记录

酷比魔方的系统重装记录 1、情况 这台酷比魔方我依稀记得是在闲鱼上以一百一的价格收购的,刚拿到的时候,Android系统和Windows 10系统都是安装好了的,并且所有驱动都完好无损,要是当时能否理解他的价值,现在也不必要…

酷比魔方i7手写版linux网卡驱动,酷比魔方i7手写板安装Ubuntu 16.04

本文记录了在酷比魔方i7手写板上安装LUbuntu (Ubuntu with LXDE) Linux 16.04,Windows 10双系统,以及解决网卡驱动,双系统配对 Bluetooth LE 鼠标MS Designer mouse等问题的过程 u盘安装Ubuntu linux 16.04 lts 首先在windows下安装一个无损分…