본문 바로가기

리눅스

[LDAP] OpenLDAP 서버 이전

728x90

OpenLDAP 서버 이전(ldap data migration)

slapd 서비스 중지

$ systemctl stop slapd.service

기존 데이터 삭제

$ rm -rf /var/lib/ldap

$ mkdir -m 700 /var/lib/ldap

$ cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG


$ rm -rf /etc/openldap/slapd.d

$ mkdir -m 750 /etc/openldap/slapd.d

config 파일 복원

$ slapadd -n 0 -F /etc/openldap/slapd.d -l ldap_config_2021061719.ldif
_#################### 100.00% eta   none elapsed            none fast!
Closing DB...

data 파일 복원

$ slapadd -n 2 -F /etc/openldap/slapd.d -l ldap_data_2021061719.ldif
_#################### 100.00% eta   none elapsed            none fast!
Closing DB...

권한 및 소유자 변경

$ chown -Rf ldap:ldap /var/lib/ldap


$ chmod -Rf u+rwX /etc/openldap/slapd.d

$ chown ldap:ldap -R /etc/openldap/slapd.d

slapd 서비스 재기동

$ systemctl restart slapd.service

resotre.sh 편집

$ vim resotre.sh
#!/bin/bash

systemctl stop slapd.service

rm -rf /var/lib/ldap
mkdir -m 700 /var/lib/ldap
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

rm -rf /etc/openldap/slapd.d
mkdir /etc/openldap/slapd.d

#$1=config, $2=data
slapadd -n 0 -F /etc/openldap/slapd.d -l $1
slapadd -n 2 -F /etc/openldap/slapd.d -l $2

chown -Rf ldap:ldap /var/lib/ldap

chmod -Rf u+rwX /etc/openldap/slapd.d
chown ldap:ldap -R /etc/openldap/slapd.d

systemctl restart slapd.service
728x90