目录
安装步骤:
2.1 配置yum源
2.2 安装MongoDB
2.3 启
动MongoDB
ProxmoxVE上新装的CentOS7.4虚拟机,安装MongoDB6。
安装步骤:
2.1 配置yum源
# 创建mongodb yum源(https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/))
[root@host ~]# cd /etc/yum.repos.d/
[root@host yum.repos.d]# vi 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
2.2 安装MongoDB
[root@host yum.repos.d]# yum install -y mongodb-org
2.3 启
动MongoDB
[root@host yum.repos.d]# systemctl start mongod
启动MongoDB,测试mongosh连接时连接报错
[root@host yum.repos.d]# mongosh
Current Mongosh Log ID: 64d1c1a5ad16cdb9245f8893
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.3
MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017
[root@host yum.repos.d]#
参照MongoDB官方文档,将CPU模式改为SandyBridge
重启服务器后,再次启动mongo,成功
[root@host ~]# mongosh
Current Mongosh Log ID: 64d0b3d80866e4ace3bc9c6f
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.10.3
Using MongoDB: 6.0.8
Using Mongosh: 1.10.3For mongosh info see: https://docs.mongodb.com/mongodb-shell/To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.------The server generated these startup warnings when booting2023-08-07T17:03:37.033+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted2023-08-07T17:03:37.033+08:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'2023-08-07T17:03:37.033+08:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'2023-08-07T17:03:37.033+08:00: vm.max_map_count is too low
------test>
消除2个错误提示
[root@host ~]# echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
[root@host ~]# echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
[root@host ~]# systemctl stop mongod
[root@host ~]# systemctl start mongod
完成。