我已经设置了 OpenLdap,它可以正常启动,之后由于某些问题我终止了该进程。现在,无论何时我尝试,systemctl start slapd.service
我都会得到
slapd.service 的作业失败,因为控制进程退出并显示错误代码。有关详细信息,请参阅“systemctl status slapd.service”和“journalctl -xe”。
该命令journalctl -xe
提供以下信息
Nov 28 21:54:36 suredevbana3 systemd[1]: Starting OpenLDAP Server Daemon...
-- Subject: Unit slapd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit slapd.service has begun starting up.
Nov 28 21:54:36 suredevbana3 runuser[2898]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2898]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 slapcat[2902]: DIGEST-MD5 common mech free
Nov 28 21:54:36 suredevbana3 runuser[2909]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2909]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 runuser[2911]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2911]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 runuser[2913]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2913]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 runuser[2915]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2915]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 runuser[2917]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2917]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 check-config.sh[2894]: Read/write permissions for DB file '/var/lib/ldap/__db.001' are required.
Nov 28 21:54:36 suredevbana3 runuser[2919]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2919]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 check-config.sh[2894]: Read/write permissions for DB file '/var/lib/ldap/__db.002' are required.
Nov 28 21:54:36 suredevbana3 runuser[2921]: pam_unix(runuser:session): session opened for user ldap by (uid=0)
Nov 28 21:54:36 suredevbana3 runuser[2921]: pam_unix(runuser:session): session closed for user ldap
Nov 28 21:54:36 suredevbana3 check-config.sh[2894]: Read/write permissions for DB file '/var/lib/ldap/__db.003' are required.
Nov 28 21:54:36 suredevbana3 systemd[1]: slapd.service: control process exited, code=exited status=1
Nov 28 21:54:36 suredevbana3 systemd[1]: Failed to start OpenLDAP Server Daemon
-- Subject: Unit slapd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit slapd.service has failed.
--
-- The result is failed. Nov 28 21:54:36 suredevbana3 systemd[1]: Unit slapd.service entered failed state. Nov 28 21:54:36 suredevbana3 systemd[1]: slapd.service failed. Nov 28 21:54:36 suredevbana3 polkitd[717]: Unregistered Authentication Agent for unix-process:2887:70553439 (system bus name :1.2956, object path /org/freedesktop/PolicyKit1lines 2393-2430/2430 (END)
在此之后我检查了这个slapd -d 1
,它给了我以下信息
dap_url_parse_ext(ldap://localhost/)
ldap_init: trying /etc/openldap/ldap.conf
ldap_init: using /etc/openldap/ldap.conf
ldap_init: HOME env is /root
ldap_init: trying /root/ldaprc
ldap_init: trying /root/.ldaprc
ldap_init: LDAPCONF env is NULL
ldap_init: LDAPRC env is NULL
5a1d9112 @(#) $OpenLDAP: slapd 2.4.44 (Jun 6 2017 18:04:02) $
[email protected]:/builddir/build/BUILD/openldap-2.4.44/openldap-2.4.44/servers/slapd
ldap_pvt_gethostbyname_a: host=suredevbana3, r=0
5a1d9112 daemon_init: listen on ldap:///
5a1d9112 daemon_init: 1 listeners to open...
ldap_url_parse_ext(ldap:///)
5a1d9112 daemon: bind(7) failed errno=98 (Address already in use)
5a1d9112 daemon: bind(7) failed errno=98 (Address already in use)
5a1d9112 slap_open_listener: failed on ldap:///
5a1d9112 slapd stopped.
5a1d9112 connections_destroy: nothing to destroy.
如下请见
" ============================================================================
" Netrw Directory Listing (netrw v149)
" /etc/openldap/slapd.d/cn=config
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
../
./
cn=schema/
cn=schema.ldif
olcDatabase={-1}frontend.ldif
olcDatabase={0}config.ldif
olcDatabase={1}monitor.ldif
olcDatabase={2}hdb.ldif
.swp
另一个信息是使用此命令启动的
slapd -d -1 -F /etc/openldap/slapd.d
答案1
check-config.sh[2894]: Read/write permissions for DB file '/var/lib/ldap/__db.003' are required.
slapdldap
默认以用户身份运行,如果您尝试以 root 用户身份启动它(或加载 ldif 等),它会创建具有错误权限的文件。尝试chown -R ldap.ldap /var/lib/ldap
修复权限并启动服务。
答案2
我也面临同样的问题,但我已经通过以下命令解决了:
setenforce 0
getenforce
如果你想保留它:
vi /etc/selinux/config
将此参数更改SELINUX=enforcing
为SELINUX=permissive
答案3
禁用您的 SELINUX。
安装文件中指定的所需证书:
olcDatabase={2}hdb.ldif