1. 安装
1.1. 安装环境
查看当前操作系统版本:
[[email protected] ~]# cat /etc/issue Red Hat Enterprise Linux Server release 5.3 (Tikanga)
1.2. 安装openldap-*包
使用yum源安装openldap包
[[email protected] yum.repos.d]# yum install openldap-* -y
1.3. 建立ldap数据的存储目录并设置权限
[[email protected] ~]# cd /opt/app [[email protected]-app app] mkdir ldap [[email protected]-app app]# chown ldap:ldap ldap/ [[email protected]-app app]# chmod -R 777 ldap/
1.4. 设置密码并修改配置文件
获取加密的密码:
[[email protected] ldap]# slappasswd -s 1234567 {SSHA}xhtiFVf/xgrIkjjqSZf1pjzHxSjsFWTx
修改配置文件:
vi /etc/openldap/slapd.conf
修改或添加的条目:
rootdn "cn=admin,dc=travelsky,dc=com" rootpw secret rootpw {SSHA}xhtiFVf/xgrIkjjqSZf1pjzHxSjsFWTx directory /opt/app/ldap
1.5. 启动LDAP服务
[[email protected] ldap]# /etc/init.d/ldap start
2. 备份与恢复
2.1. 备份
使用slapcat进行备份
[[email protected] backup]# /usr/sbin/slapcat -v -l /opt/app/backup/ldap/20150311.ldif
备份用脚本ldap_backup.sh
#!/bin/bash FILENAME=ldap$(date +%Y%m%d).ldif BACKDIR=/opt/app/backup/ldap /usr/sbin/slapcat -v -l $BACKDIR/$FILENAME gzip -9 $BACKDIR/$FILENAME
2.2. 数据恢复
关闭LDAP服务
[[email protected] ~]# /etc/init.d/ldap stop
删除已有数据
[[email protected] ldap]# cd /opt/app/ldap [[email protected]-app ldap]# rm -rf *
还原DB_CONFIG文件
[[email protected]app ldap]# locate DB_CONFIG /etc/openldap/DB_CONFIG.example [[email protected]-app ldap]# cp /etc/openldap/DB_CONFIG.example /opt/app/ldap/DB_CONFIG
还原数据及其权限
[[email protected] ldap]# /usr/sbin/slapadd -l /opt/app/backup/ldap/20150311.ldif [[email protected]-app ldap]# chmod -R 700 /opt/app/ldap [[email protected]-app ldap]# chown -R ldap:ldap /opt/app/ldap
启动LDAP服务
[[email protected] ldap]# /etc/init.d/ldap start
时间: 2024-10-31 19:46:36