1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenLDAP構築手順(CentOS7同梱版)

Last updated at Posted at 2019-12-28

前提

・今回はCentOS7.5を使用
・スキーマファイルは作成済み
 (スキーマファイル作成については別記事にて記載予定)
・1台構成
 (レプリケーション構成については別記事にて記載予定)
・インターネットにつながる状態であること

基盤の準備

firewallやらsyslogやら

SELinuxの無効化

これをやっておかないと、なんか動かなくって細かい設定が必要らしいのだけど
よくわからんのでとりあえず無効化します。

getenforce

⇒Enable=有効、Disabled=無効です。

vi /etc/sysconfig/selinux

----------以下部分を変更------------

SELINUX=disabled  ←有効時はここがenableになっています。

そんで再起動

reboot
もしくは
shutdown -r now

firewallの穴あけ

必要なポートを開けます
※LDAPSは必要に応じて

# firewall-cmd --add-service=ldap --zone=public --permanent
# firewall-cmd --add-service=ldaps --zone=public --permanent
# firewall-cmd --reload
# firewall-cmd --list-all

最後のコマンドで、以下のようになっていればok

~
services: ssh dhcpv6-client ldap
~

OpenLDAPインストール

以下コマンドでOpenLDAPのインストールを行う

# yum install -y openldap-servers openldap-clients

DB_CONFIGファイルを持ってきます

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

スキーマファイルを/etc/openldap/schema/に配置する。

slapd.confを以下に/etc/openldap/に配置する。
rootdnのパスワードを更新

# slapppasswd

SSHA{xxxxxxxxxxxxxxx}が表示されるので
それをコピペしてslapd.confの以下に張り付け

slapd.conf
~
rootpw SSHA{xxxxxxxxxxxxxxx} ←ここ
~

baseDNの登録

以下内容を参考にbaseDN登録用LDIFファイルを作成する
※dnは設定によってよしなり修正ください

# baseDN
dn: dc=hoge,dc=co,dc=jp
objectClass: top
objectClass: dcObject
objectClass: organization
dc: hoge
o: hoge

以下コマンドでベースDNを登録します。

slapdd -l /tmp/basedn.ldif

OLCの再構成

rm -rf /etc/openldap/slapd.d/*
slaptest -f /etc/openldap/slapd.conf
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
chown -R ldap:ldap /etc/openldap/slapd.d/

ユーザデータDBの所有権を変更します。

chown ldap:ldap -R /var/lib/ldap

サービスを起動して、自動化します。

systemctl start slapd
systemctl enable slapd

syslogの設定

OpenLDAPのログはlocal4のファシリティを使用するので
以下コマンドで設定します。

vi /etc/rsyslog.conf

適当な箇所に以下を入力し保存する

# Save LDAP messages also to slapd.log
local4.*                   /var/log/ldap.log

ログローテートの設定

# vim /etc/logrotate.d/syslog

以下のように追記

/etc/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
/var/log/slapd.log
{
    missingok
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}

サービスの再起動

systemctl restart rsyslog
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?