Redhat7.4
CDH5.15
采用root用户进行操作
192.168.8.181 master1.com (主机)
192.168.8.182 master2.com(备机)
192.168.8.183 slave183.com(客户机)
https://mp.weixin.qq.com/s/Xhl65FpAkG2mR4zMPdh8pA
https://mp.weixin.qq.com/s/7ZiSOgJIysn5zEv6eC7rVg
yum -y install krb5-server krb5-libs krb5-workstation
yum -y install krb5-workstation krb5-libs
[root@master1 ~]# cat /var/kerberos/krb5kdc/kdc.conf
[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88
[realms]
MASTER.COM = {
#master_key_type = aes256-cts
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
max_renewable_life= 7d 0h 0m 0s
}
[root@master1 ~]# vi /var/kerberos/krb5kdc/kadm5.acl
[root@master1 ~]# cat /var/kerberos/krb5kdc/kadm5.acl
*/[email protected] *
[root@master1 ~]# vi /etc/krb5.conf
[root@master1 ~]# cat /etc/krb5.conf
# Configuration snippets may be placed in this directory as well
includedir /etc/krb5.conf.d/
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
dns_lookup_realm = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
rdns = false
default_realm = MASTER.COM
#default_ccache_name = KEYRING:persistent:%{uid}
[realms]
MASTER.COM = {
kdc = master1.com
admin_server = master1.com
}
[domain_realm]
.master1.com = MASTER.COM
master1.com = MASTER.COM
[root@master1 ~]# kdb5_util create –r MASTER.COM -s
Loading random data
Initializing database '/var/kerberos/krb5kdc/principal' for realm 'MASTER.COM',
master key name 'K/[email protected]'
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter KDC database master key:
Re-enter KDC database master key to verify:
[root@master1 ~]# kadmin.local
Authenticating as principal root/[email protected] with password.
kadmin.local: addprinc admin/[email protected]
WARNING: no policy specified for admin/[email protected]; defaulting to no policy
Enter password for principal "admin/[email protected]":
Re-enter password for principal "admin/[email protected]":
Principal "admin/[email protected]" created.
kadmin.local: exit
[root@master1 ~]# systemctl enable krb5kdc
Created symlink from /etc/systemd/system/multi-user.target.wants/krb5kdc.service to /usr/lib/systemd/system/krb5kdc.service.
[root@master1 ~]# systemctl enable kadmin
Created symlink from /etc/systemd/system/multi-user.target.wants/kadmin.service to /usr/lib/systemd/system/kadmin.service.
[root@master1 ~]# systemctl start krb5kdc
[root@master1 ~]# systemctl start kadmin
[root@master1 ~]# kinit admin/[email protected]
Password for admin/[email protected]:
[root@master1 ~]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: admin/[email protected]
Valid starting Expires Service principal
2019-01-18T14:10:11 2019-01-19T14:10:11 krbtgt/[email protected]
yum -y install openldap-clients
10.将181上krb.conf文件拷贝到183上
[root@master1 ~]# scp /etc/krb5.conf [email protected]:/etc/
The authenticity of host 'slave183.com (192.168.8.183)' can't be established.
ECDSA key fingerprint is SHA256:Jdb5Ro09SUtqVOcg5tbcXWjLQDSiTapSKKET8ov1Acc.
ECDSA key fingerprint is MD5:8f:bb:27:49:db:76:06:fe:24:d4:05:7c:bd:92:26:67.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'slave183.com' (ECDSA) to the list of known hosts.
[email protected]'s password:
krb5.conf 100% 562 262.2KB/s 00:00
1.切换181进行操作,修改/etc/krb5.conf的配置文件,在realms配置下增加备Kerberos的配置
# Configuration snippets may be placed in this directory as well
includedir /etc/krb5.conf.d/
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
dns_lookup_realm = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
rdns = false
default_realm = MASTER.COM
# default_ccache_name = KEYRING:persistent:%{uid}
[realms]
MASTER.COM = {
kdc = master1.com
admin_server = master1.com
kdc = master2.com
admin_server = master2.com
}
[domain_realm]
.master1.com = MASTER.COM
master1.com = MASTER.COM
[root@master1 ~]# scp /etc/krb5.conf [email protected]:/etc/
[email protected]'s password:
krb5.conf 100% 611 330.4KB/s 00:00
systemctl restart krb5kdc
systemctl restart kadmin
[root@master1 ~]# kadmin.local
Authenticating as principal admin/[email protected] with password.
kadmin.local: addprinc -randkey host/master1.com
WARNING: no policy specified for host/[email protected]; defaulting to no policy
Principal "host/[email protected]" created.
kadmin.local: addprinc -randkey host/master2.com
WARNING: no policy specified for host/[email protected]; defaulting to no policy
Principal "host/[email protected]" created.
kadmin.local: ktadd host/master1.com
Entry for principal host/master1.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type des3-cbc-sha1 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type arcfour-hmac added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type camellia256-cts-cmac added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type camellia128-cts-cmac added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type des-hmac-sha1 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master1.com with kvno 2, encryption type des-cbc-md5 added to keytab FILE:/etc/krb5.keytab.
kadmin.local: ktadd host/master2.com
Entry for principal host/master2.com with kvno 2, encryption type aes256-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type aes128-cts-hmac-sha1-96 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type des3-cbc-sha1 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type arcfour-hmac added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type camellia256-cts-cmac added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type camellia128-cts-cmac added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type des-hmac-sha1 added to keytab FILE:/etc/krb5.keytab.
Entry for principal host/master2.com with kvno 2, encryption type des-cbc-md5 added to keytab FILE:/etc/krb5.keytab.
[root@master1 ~]# scp /etc/krb5.conf [email protected]:/etc/
The authenticity of host 'master2.com (192.168.8.182)' can't be established.
ECDSA key fingerprint is SHA256:DMDXYXKebRxKaoL4NYWeas9WIMLoC+JtedQn2jy7334.
ECDSA key fingerprint is MD5:f6:00:37:3a:33:f1:d2:42:22:a4:92:98:f5:57:06:bb.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'master2.com,192.168.8.182' (ECDSA) to the list of known hosts.
[email protected]'s password:
krb5.conf 100% 611 254.1KB/s 00:00
[root@master1 ~]# scp /etc/krb5.keytab [email protected]:/etc/
[email protected]'s password:
krb5.keytab 100% 1170 757.8KB/s 00:00
[root@master1 ~]# scp /var/kerberos/krb5kdc/.k [email protected]:/etc/
.k5.MASTER.COM .kadm5.acl.swp .kdc.conf.swm .kdc.conf.swn .kdc.conf.swo .kdc.conf.swp
[root@master1 ~]# scp /var/kerberos/krb5kdc/.k5.MASTER.COM [email protected]:/var/kerberos/krb5kdc/
[email protected]'s password:
.k5.MASTER.COM 100% 75 54.4KB/s 00:00
[root@master1 ~]# scp /var/kerberos/krb5kdc/kadm5.acl [email protected]:/var/kerberos/krb5kdc/
[email protected]'s password:
kadm5.acl 100% 21 22.0KB/s 00:00
[root@master1 ~]# scp /var/kerberos/krb5kdc/k [email protected]:/var/kerberos/krb5kdc/
kadm5.acl kdc.conf
[root@master1~]#scp /var/kerberos/krb5kdc/kdc.conf [email protected]:/var/kerberos/krb5kdc/
[email protected]'s password:
kdc.conf 100% 483 440.6KB/s 00:00
[root@master1 krb5kdc]# cat kpropd.acl
host/[email protected]
host/[email protected]
[root@master1 krb5kdc]# systemctl status kprop
● kprop.service - Kerberos 5 Propagation
Loaded: loaded (/usr/lib/systemd/system/kprop.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2019-01-18 15:05:05 CST; 4s ago
Process: 35171 ExecStart=/usr/sbin/_kpropd $KPROPD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 35172 (kpropd)
Tasks: 1
CGroup: /system.slice/kprop.service
└─35172 /usr/sbin/kpropd
1月 18 15:05:05 master2.com systemd[1]: Starting Kerberos 5 Propagation...
1月 18 15:05:05 master2.com systemd[1]: Started Kerberos 5 Propagation.
[root@master1 ~]# kdb5_util dump /var/kerberos/krb5kdc/master.dump
[root@master1 ~]# cd /var/kerberos/krb5kdc/
[root@master1 krb5kdc]# ll
总用量 48
-rw------- 1 root root 21 1月 18 11:20 kadm5.acl
-rw------- 1 root root 483 1月 18 11:44 kdc.conf
-rw------- 1 root root 8980 1月 18 15:06 master.dump
-rw------- 1 root root 1 1月 18 15:06 master.dump.dump_ok
-rw------- 1 root root 16384 1月 18 14:45 principal
-rw------- 1 root root 8192 1月 18 11:52 principal.kadm5
-rw------- 1 root root 0 1月 18 11:52 principal.kadm5.lock
-rw------- 1 root root 0 1月 18 14:45 principal.ok
[root@master1 krb5kdc]# kprop -f /var/kerberos/krb5kdc/master.dump -d -P 754 master2.com
8980 bytes sent.
Database propagation to master2.com: SUCCEEDED
[root@master1 krb5kdc]# cd /var/kerberos/krb5kdc/
[root@master1 krb5kdc]# ll
总用量 48
-rw------- 1 root root 8980 1月 18 15:09 from_master
-rw------- 1 root root 21 1月 18 14:53 kadm5.acl
-rw------- 1 root root 483 1月 18 14:57 kdc.conf
-rw-r--r-- 1 root root 56 1月 18 15:03 kpropd.acl
-rw------- 1 root root 16384 1月 18 15:09 principal
-rw------- 1 root root 8192 1月 18 15:09 principal.kadm5
-rw------- 1 root root 0 1月 18 15:09 principal.kadm5.lock
-rw------- 1 root root 0 1月 18 15:09 principal.ok
[root@master1 krb5kdc]# systemctl stop kprop
[root@master1 krb5kdc]# mv kpropd.acl kpropd.acl.bak
[root@master1 krb5kdc]# systemctl start krb5kdc
[root@master1 krb5kdc]# systemctl start kadmin
[realms]
MASTER.COM = {
# kdc = master1.com
# admin_server = master1.com
kdc = master2.com
admin_server = master2.com
}
[root@master1 krb5kdc]# kinit admin/[email protected]
Password for admin/[email protected]:
[root@master1 krb5kdc]# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: admin/[email protected]
Valid starting Expires Service principal
2019-01-18T15:24:56 2019-01-19T15:24:56 krbtgt/[email protected]
renew until 2019-01-25T15:24:56
[root@master1 krb5kdc]# systemctl stop krb5kdc
[root@master1 krb5kdc]# systemctl stop kadmin
[root@master1 krb5kdc]# mv kpropd.acl.bak kpropd.acl
[root@master1 krb5kdc]# vi /etc/krb5.conf
[root@master1 krb5kdc]# systemctl start kprop
[root@master1 krb5kdc]# cat kprop_sync.sh
#!/bin/bash
DUMP=/var/kerberos/krb5kdc/master.dump
PORT=754
SLAVE="master2.com"
TIMESTAMP=`date`
echo "Start at $TIMESTAMP"
sudo kdb5_util dump $DUMP
sudo kprop -f $DUMP -d -P $PORT $SLAVE
root@master1 krb5kdc]# chmod 700 /var/kerberos/krb5kdc/kprop_sync.sh
[root@master1 krb5kdc]# sh /var/kerberos/krb5kdc/kprop_sync.sh
Start at 2019年 01月 18日 星期五 15:41:47 CST
8980 bytes sent.
Database propagation to master2.com: SUCCEEDED
[root@master1 krb5kdc]# crontab -e
0 * * * * root/var/kerberos/krb5kdc/kprop_sync.sh >/var/kerberos/krb5kdc/lastupdate
crontab: installing new crontab
[root@master1 krb5kdc]# systemctl enable crond
[root@master1 krb5kdc]# systemctl start crond