389 Directory Server マルチマスタレプリケーション設定

Rocky Linux 8.4 にて 389 Directory Server のマルチマスタレプリケーション設定を試した手順(※SELinuxは無効にしてます)

#-- 構成
- 1台目(サプライヤー1)のIPアドレス 192.168.1.1
- 2台目(サプライヤー2)のIPアドレス 192.168.1.2

###### 1台目,2台目共通手順 ここから ######
#-- 389portの接続許可
# firewall-cmd --permanent --add-port=389/tcp
# firewall-cmd --reload

#-- 各種設定を変数に代入
# ROOT_DN="cn=Directory Manager"
# ROOT_PASSWORD="RootdnPassword"
# REP_DN="cn=replication manager,cn=config"
# REP_PASSWORD="ReplicaPassword"
# SUPIP1=192.168.1.1
# SUPIP2=192.168.1.2

#-- 389 Directory Serverのインストール
# dnf -y module enable 389-ds
# dnf -y install 389-ds-base openldap-clients

#-- version の確認
# rpm -qa 389-ds-base
389-ds-base-1.4.3.16-19.module+el8.4.0+636+837ee950.x86_64

#-- テンプレート作成
# dscreate create-template ldap.inf

#-- テンプレート編集
# sed -ri -e "s/;(root_password).*/\1=${ROOT_PASSWORD}\nroot_dn=${ROOT_DN}/" ldap.inf

#-- インスタンスを作成 (インスタンス名はデフォルトのlocalhostのまま)
# dscreate from-file ldap.inf
Starting installation...
Completed installation for localhost

#-- インスタンスを起動
# systemctl enable dirsrv@localhost.service
# systemctl start dirsrv@localhost

#-- データベースを作成
# dsconf localhost backend create --suffix="dc=example,dc=com" --be-name="userRoot"
The database was sucessfully created

###### 1台目,2台目共通手順 ここまで ######

###### 2台目のみで実行 ここから ######
#-- レプリケーション用のアカウントを作成(replica-id=2)
# dsconf localhost replication enable --suffix="dc=example,dc=com" --role="master" --replica-id=2 --bind-dn="${REP_DN}" --bind-passwd="${REP_PASSWORD}"
Replication successfully enabled for "dc=example,dc=com"

#-- 389-ds のバージョンが 1.4.4.14以降の場合は role に supplier を使用する
###### 2台目のみで実行 ここまで ######

###### 1台目のみで実行 ここから######
#-- ルートDNのエントリーを作成
# cat <<_EOL_> example_com.ldif
dn: dc=example,dc=com
objectClass: dcObject
objectClass: organization
dc: example
o: example.com

_EOL_

# ldapadd -x -h localhost -D "${ROOT_DN}" -w ${ROOT_PASSWORD} -f example_com.ldif
adding new entry "dc=example,dc=com"

#-- レプリケーション用のアカウントを作成(replica-id=1)
# dsconf localhost replication enable --suffix="dc=example,dc=com" --role="master" --replica-id=1 --bind-dn="${REP_DN}" --bind-passwd="${REP_PASSWORD}"
Replication successfully enabled for "dc=example,dc=com"

#-- レプリカ合意を作成し、サプライヤー2を初期化 (何故かコマンドの応答まで時間がかかる)
# dsconf localhost repl-agmt \
      create --suffix="dc=example,dc=com" --host="${SUPIP2}" --port=389 \
      --conn-protocol=LDAP --bind-dn="${REP_DN}" \
      --bind-passwd="${REP_PASSWORD}" --bind-method=SIMPLE --init \
      agreement-supplier1-to-supplier2
Successfully created replication agreement "agreement-supplier1-to-supplier2"
Agreement initialization started...

#-- ここまでで サプライヤー1 から サプライヤー2 へのデータ更新は同期されるが、
#-- まだ サプライヤー2 から サプライヤー1 へのデータ更新は同期されない

###### 1台目のみで実行 ここまで######

###### 2台目のみで実行 ここから ######
#-- レプリカ合意を作成
# dsconf localhost repl-agmt \
      create --suffix="dc=example,dc=com" --host="${SUPIP1}" --port=389 \
      --conn-protocol=LDAP --bind-dn="${REP_DN}" \
      --bind-passwd="${REP_PASSWORD}" --bind-method=SIMPLE \
      agreement-supplier2-to-supplier1
Successfully created replication agreement "agreement-supplier2-to-supplier1"

#-- これで双方向でデータ更新がされる状態となる

###### 2台目のみで実行 ここまで ######