centos8.5安装过程mongod启动不了
Closed this issue · 5 comments
看前面的问题有人用centos8.4能正常安装,但是目前安装会自动更新到centos8.5后,脚本到了mongod这一步启动不了,有人遇到同样的问题吗
有详细一点的报错信息吗
MongoDB日志报错信息:
[root@b8f6d2eebad2 /]# cat /var/log/mongodb/mongod.log
2024-06-20T01:08:59.444+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2024-06-20T01:08:59.446+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2024-06-20T01:08:59.452+0000 I CONTROL [initandlisten] MongoDB starting : pid=21173 port=27017 dbpath=/var/lib/mongo 64-bit host=b8f6d2eebad2
2024-06-20T01:08:59.452+0000 I CONTROL [initandlisten] db version v4.0.28
2024-06-20T01:08:59.452+0000 I CONTROL [initandlisten] git version: af1a9dc12adcfa83cc19571cb3faba26eeddac92
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1k FIPS 25 Mar 2021
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] allocator: tcmalloc
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] modules: none
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] build environment:
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] distmod: rhel80
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] distarch: x86_64
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] target_arch: x86_64
2024-06-20T01:08:59.453+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid", timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2024-06-20T01:08:59.453+0000 I STORAGE [initandlisten] Detected data files in /var/lib/mongo created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2024-06-20T01:08:59.453+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1382M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2024-06-20T01:09:00.164+0000 I STORAGE [initandlisten] WiredTiger message [1718845740:164222][21173:0x7f1b94588b40], txn-recover: Main recovery loop: starting at 1/22656 to 2/256
2024-06-20T01:09:00.239+0000 I STORAGE [initandlisten] WiredTiger message [1718845740:239502][21173:0x7f1b94588b40], txn-recover: Recovering log 1 through 2
2024-06-20T01:09:00.284+0000 I STORAGE [initandlisten] WiredTiger message [1718845740:284466][21173:0x7f1b94588b40], txn-recover: Recovering log 2 through 2
2024-06-20T01:09:00.322+0000 I STORAGE [initandlisten] WiredTiger message [1718845740:322129][21173:0x7f1b94588b40], txn-recover: Set global recovery timestamp: 0
2024-06-20T01:09:00.330+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2024-06-20T01:09:00.331+0000 I STORAGE [initandlisten] Starting to check the table logging settings for existing WiredTiger tables
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten]
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten]
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten]
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten]
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2024-06-20T01:09:00.334+0000 I CONTROL [initandlisten]
2024-06-20T01:09:00.336+0000 I STORAGE [initandlisten] Finished adjusting the table logging settings for existing WiredTiger tables
2024-06-20T01:09:00.337+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'
2024-06-20T01:09:00.338+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2024-06-20T01:10:29.455+0000 I CONTROL [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2024-06-20T01:10:29.455+0000 I CONTROL [signalProcessingThread] Shutdown started
2024-06-20T01:10:29.455+0000 I REPL [signalProcessingThread] Stepping down the ReplicationCoordinator for shutdown, waitTime: 10000ms
2024-06-20T01:10:29.455+0000 I CONTROL [signalProcessingThread] Shutting down the LogicalSessionCache
2024-06-20T01:10:29.455+0000 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2024-06-20T01:10:29.455+0000 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2024-06-20T01:10:29.455+0000 I NETWORK [signalProcessingThread] Shutting down the global connection pool
2024-06-20T01:10:29.455+0000 I STORAGE [signalProcessingThread] Shutting down the PeriodicThreadToAbortExpiredTransactions
2024-06-20T01:10:29.455+0000 I REPL [signalProcessingThread] Shutting down the ReplicationCoordinator
2024-06-20T01:10:29.455+0000 I SHARDING [signalProcessingThread] Shutting down the ShardingInitializationMongoD
2024-06-20T01:10:29.455+0000 I COMMAND [signalProcessingThread] Killing all open transactions
2024-06-20T01:10:29.455+0000 I - [signalProcessingThread] Killing all operations for shutdown
2024-06-20T01:10:29.455+0000 I NETWORK [signalProcessingThread] Shutting down the ReplicaSetMonitor
2024-06-20T01:10:29.455+0000 I CONTROL [signalProcessingThread] Shutting down free monitoring
2024-06-20T01:10:29.455+0000 I CONTROL [signalProcessingThread] Shutting down free monitoring
2024-06-20T01:10:29.455+0000 I FTDC [signalProcessingThread] Shutting down full-time data capture
2024-06-20T01:10:29.455+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2024-06-20T01:10:29.457+0000 I STORAGE [signalProcessingThread] Shutting down the HealthLog
2024-06-20T01:10:29.457+0000 I STORAGE [signalProcessingThread] Shutting down the storage engine
2024-06-20T01:10:29.457+0000 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2024-06-20T01:10:29.457+0000 I STORAGE [signalProcessingThread] Shutting down session sweeper thread
2024-06-20T01:10:29.457+0000 I STORAGE [signalProcessingThread] Finished shutting down session sweeper thread
2024-06-20T01:10:29.515+0000 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2024-06-20T01:10:29.515+0000 I - [signalProcessingThread] Dropping the scope cache for shutdown
2024-06-20T01:10:29.515+0000 I CONTROL [signalProcessingThread] now exiting
2024-06-20T01:10:29.515+0000 I CONTROL [signalProcessingThread] shutting down with code:0
运行状态报错信息:
[root@b8f6d2eebad2 /]# systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: timeout) since Thu 2024-06-20 01:10:29 UTC; 3min 7s ago
Docs: https://docs.mongodb.org/manual
Process: 21171 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
Process: 21170 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 21169 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 21168 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Jun 20 01:08:59 b8f6d2eebad2 systemd[1]: Starting MongoDB Database Server...
Jun 20 01:09:00 b8f6d2eebad2 systemd[1]: mongod.service: New main PID 21173 does not belong to service, and PID file is not owned by root. Refusing.
Jun 20 01:09:00 b8f6d2eebad2 systemd[1]: mongod.service: New main PID 21173 does not belong to service, and PID file is not owned by root. Refusing.
Jun 20 01:10:29 b8f6d2eebad2 systemd[1]: mongod.service: start operation timed out. Terminating.
Jun 20 01:10:29 b8f6d2eebad2 systemd[1]: mongod.service: Failed with result 'timeout'.
Jun 20 01:10:29 b8f6d2eebad2 systemd[1]: Failed to start MongoDB Database Server.
麻烦看一下
看一下mongod.service文件吧,从报错上来看是启动mongodb时的权限问题,或者可以直接使用打包好的docker版本
看一下mongod.service文件吧,从报错上来看是启动mongodb时的权限问题,或者可以直接使用打包好的docker版本
我也是这个问题,请问这个需要什么命令启动特权呢
检查 PID 文件所有权:
错误信息表明新的主 PID 不属于服务,并且 PID 文件不属于 root。这是关键,因为 systemd 期望 PID 文件属于 root,且服务进程与此文件中的 PID 匹配。
检查配置文件:
核实 MongoDB 配置文件(通常是 /etc/mongod.conf)是否设置正确,特别是 pidFilePath 指令。
检查权限:
确保必要的目录和文件具有正确的所有权和权限。
解决步骤
验证 PID 文件所有权:
检查 PID 文件(通常是 /var/run/mongodb/mongod.pid)的所有权。
ls -l /var/run/mongodb/mongod.pid
确保该文件属于 mongod:mongod。
chown mongod:mongod /var/run/mongodb/mongod.pid
检查 MongoDB 配置:
打开 MongoDB 配置文件并检查 pidFilePath 设置。
nano /etc/mongod.conf
确保设置正确,例如:
processManagement:
pidFilePath: /var/run/mongodb/mongod.pid
检查目录权限:
确保 /var/run/mongodb 目录具有正确的所有权和权限。
chown -R mongod:mongod /var/run/mongodb
chmod 0755 /var/run/mongodb
重启 MongoDB 服务:
在进行必要的修正后,重启 MongoDB 服务。
systemctl restart mongod.service
检查服务状态:
验证 MongoDB 服务状态以确保其正常运行。
systemctl status mongod.service