Centos7環境啓動mongod報polkit服務啓動失敗

報錯記錄如下

[root@mongodb3 ~]# systemctl start mongod 
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to start mongod.service: Connection timed out
See system logs and 'systemctl status mongod.service' for details.
[root@mongodb3 ~]# systemctl status mongod.service
● mongod.service - SYSV: Mongo is a scalable, document-oriented database.
   Loaded: loaded (/etc/rc.d/init.d/mongod; bad; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)
[root@mongodb3 ~]# systemctl start mongod         
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to start mongod.service: Connection timed out
See system logs and 'systemctl status mongod.service' for details.
[root@mongodb3 ~]# systemctl status polkit
● polkit.service - Authorization Manager
   Loaded: loaded (/usr/lib/systemd/system/polkit.service; static; vendor preset: enabled)
   Active: failed (Result: timeout) since Tue 2020-02-04 19:07:15 CST; 9h ago
     Docs: man:polkit(8)
  Process: 6867 ExecStart=/usr/lib/polkit-1/polkitd --no-debug (code=killed, signal=TERM)
 Main PID: 6867 (code=killed, signal=TERM)

Feb 04 19:05:27 mongodb3 systemd[1]: Starting Authorization Manager...
Feb 04 19:05:29 mongodb3 polkitd[6867]: Started polkitd version 0.112
Feb 04 19:06:43 mongodb3 polkitd[6867]: Loading rules from directory /etc/polkit-1/rules.d
Feb 04 19:06:43 mongodb3 polkitd[6867]: Loading rules from directory /usr/share/polkit-1/rules.d
Feb 04 19:06:43 mongodb3 polkitd[6867]: Finished loading, compiling and executing 11 rules
Feb 04 19:06:43 mongodb3 polkitd[6867]: Acquired the name org.freedesktop.PolicyKit1 on the system bus
Feb 04 19:07:15 mongodb3 systemd[1]: polkit.service start operation timed out. Terminating.
Feb 04 19:07:15 mongodb3 systemd[1]: Failed to start Authorization Manager.
Feb 04 19:07:15 mongodb3 systemd[1]: Unit polkit.service entered failed state.
Feb 04 19:07:15 mongodb3 systemd[1]: polkit.service failed.
[root@mongodb3 ~]# systemctl stop polkit  
Authorization not available. Check if polkit service is running or see debug message for more information.
Failed to stop polkit.service: Connection timed out
See system logs and 'systemctl status polkit.service' for details.
Failed to get load state of polkit.service: Connection timed out

出現問題,就需要解決問題,不能較真的不斷嘗試…

1. /var/log/mongodb/mongod.log 日誌中並沒有先的日誌產生

polkit 這個是什麼服務?
參考網站
https://wiki.archlinux.org/index.php/Polkit_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
https://www.freedesktop.org/software/polkit/docs/latest/polkit.8.html
大概知道
polkit是linux服務器上的身份認證組件,目的是讓用戶證明自己屬於某個用戶組。更詳細的內容,可以參考上面的網址。

經過百度,找到解決方法

PolicyKit failing to start with error: polkit.service: main process exited, code=exited, status=1/FAILURE

1.Ensure the existence of a polkitd system user & group
Copy/paste the following 2 compound-commands to a root terminal to check for and conditionally create the user/group

getent group polkitd >/dev/null && echo -e "\e[1;32mpolkitd group already exists\e[0m" || { groupadd -r polkitd && echo -e "\e[1;33mAdded missing polkitd group\e[0m" || echo -e "\e[1;31mAdding polkitd group FAILED\e[0m"; }
getent passwd polkitd >/dev/null && echo -e "\e[1;32mpolkitd user already exists\e[0m" || { useradd -r -g polkitd -d / -s /sbin/nologin -c "User for polkitd" polkitd && echo -e "\e[1;33mAdded missing polkitd user\e[0m" || echo -e "\e[1;31mAdding polkitd user FAILED\e[0m"; }

2.Reset the permissions and user/group ownership for all files provided by the polkit and polkit-pkla-compat packages
Copy/paste the following compound-command to a root terminal to check for and conditionally reset user/group perms & ownership

rpm -Va polkit\* && echo -e "\e[1;32mpolkit* rpm verification passed\e[0m" || { echo -e "\e[1;33mResetting polkit* rpm user/group ownership & perms\e[0m"; rpm --setugids polkit polkit-pkla-compat; rpm --setperms polkit polkit-pkla-compat; }

3.Reboot
A reboot of the machine will be required to make sure that all changes take affect and that polkit has reconnected to the dbus

shutdown -r now

重啓服務之後,啓動mongod服務,啓動正常


```bash
[root@mongodb3 ~]# systemctl start mongod                                                                                                                             [root@mongodb3 ~]# mongo --port 27017 -u "admin" -p "admin" --authenticationDatabase "admin"
MongoDB shell version: 3.2.22
connecting to: 127.0.0.1:27017/test
Server has startup warnings: 
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] 
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] 
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] 
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2020-02-05T05:14:44.741+0800 I CONTROL  [initandlisten] 
replSet:SECONDARY> 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章