1. 安装前配置
# 关闭防火墙systemctl stop firewalldsystemctl disable firewalld# 关闭selinuxsetenforce 0sed -i "/^SELINUX/s/enforcing/disabled/" /etc/selinux/config
2. OpenLdap Server安装
安装包
- openldap: OpenLDAP服务端和客户端用的库文件。
- openldap-servers: 服务端程序。
- openldap-clients: 客户端程序。
- openldap-devel: 开发包,可选。
- openldap-servers-sql: 支持sql模块,可选。
- compat-openldap: OpenLDAP兼容性库。
[info]注:目前 yum安装最新版,只能使用 2.4.44版本。
安装软件
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmyum -y install openldap openldap-servers openldap-clients compat-openldap openldap-devel
生成加密密码
cd /etc/openldapmv slapd.d slapd.d.bakmkdir slapd.dslappasswd // 生成加密密钥###################################################New password:Re-enter new password:{SSHA}z5YYHEO0yiu6twspLjuJjFGvgqBxmT4w
配置 ```bash cp /usr/share/openldap-servers/slapd.ldif /etc/openldap/ vim /etc/openldap/slapd.ldif
#
…… include: file:///etc/openldap/schema/corba.ldif include: file:///etc/openldap/schema/core.ldif include: file:///etc/openldap/schema/cosine.ldif …… olcSuffix: dc=xiodi,dc=cn olcRootDN: cn=xiodiadmin,dc=xiodi,dc=cn olcRootPW: {SSHA}z5YYHEO0yiu6twspLjuJjFGvgqBxmT4w
#
cd /etc/openldap/ slapadd -n 0 -F slapd.d -l slapd.ldif chown -R ldap:ldap slapd.d cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG chown -R ldap:ldap /var/lib/ldap systemctl start slapd && systemctl status slapd systemctl enable slapd
<a name="0oqz3"></a># 3. OpenLdap配置```bash# 配置基本域(可选)mkdir /root/ldifcd /root/ldifvim config_init.ldif########################################################dn: dc=xiodi,dc=cnobjectclass: dcObjectobjectclass: organizationo: aishangweidc: xiodi########################################################ldapadd -x -D "cn=xiodiadmin,dc=xiodi,dc=cn" -W -f config_init.ldif# 查询ldapsearch -x -b ‘dc=xiodi,dc=cn’ ‘(objectClass=*)’ldapsearch -H ldapi:/// -Y EXTERNAL -b "cn=config" -LLL –Q
