server/client 端安装配置
在cdh05安装服务端
yum install -y krb5-server krb5-libs krb5-workstation krb5-devel krb5-auth-dialog
修改配置文件
配置名称 | 含义 |
---|
ticket_lifetime | 票据的有效时长,可以自行修改 | renew_lifetime | 票据失效后重新刷新的有效时长,可以自行修改 |
vim /etc/krb5.conf
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
pkinit_anchors = FILE:/etc/pki/tls/certs/ca-bundle.crt
default_realm = GOME_TZGS.COM
default_ccache_name = KEYRING:persistent:%{uid}
[realms]
GOME_TZGS.COM = {
kdc = cdh05:88
admin_server = cdh05:749
}
[domain_realm]
.gome_tzgs.com = GOME_TZGS.COM
gome_tzgs.com = GOME_TZGS.COM
配置 /var/kerberos/krb5kdc/kdc.conf 文件
[root@cdh05 ~]
[kdcdefaults]
kdc_ports = 88
kdc_tcp_ports = 88
[realms]
GOME_TZGS.COM = {
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
max_life = 24h
max_renewable_life = 7d
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
}
配置/var/kerberos/krb5kdc/kadm5.acl文件
[root@cdh05 ~]
*/admin@GOME_TZGS.COM *
将配置文件同步到其他节点:
rsync cdh05:/etc/krb5.conf /etc/
创建生成kerberos的KDC数据库文件
kdb5_util create -s -r GOME_TZGS.COM
该命令会提示输入两次数据库密码,执行结束后会在 /var/kerberos/krb5kdc/目录下创建 principal 数据库,如果遇到数据库已经存在的提示,可以把 /var/kerberos/krb5kdc/ 目录下的 principal 的相关文件都删除掉,再次执行该命令即可。
启动kerberos服务
systemctl start krb5kdc
systemctl start kadmin
systemctl status krb5kdc kadmin
设置kdc、kadmin开机自启
systemctl enable krb5kdc kadmin
安装kerberos客户端
在除了安装kerberos服务器端所在节点外的其他节点上都必须执行下面的命令,安装kerberos客户端! cdh01~cdh07 除cdh05外
yum install -y krb5-devel krb5-workstation krb5-client
测试kerberos安装是否成功
在kdc服务端执行:
kadmin.local -q "addprinc hadoop/admin"
或
echo -e "root\nroot" | kadmin.local -q "addprinc hadoop/admin"
当然,也可以执行 kadmin.local 命令后命令行执行:
addprinc admin/admin@GOME_TZGS.COM
addprinc root/admin@GOME_TZGS.COM
addprinc bigdata/bigdata@GOME_TZGS.COM
xst -k bigdata.keytab -norandkey bigdata/bigdata@GOME_TZGS.COM
xst -k yarn.keytab yarn/admin@GOME_TZGS.COM
xst -k hdfs.keytab hdfs/admin@GOME_TZGS.COM
$ kinit -kt bigdata.keytab bigdata/bigdata@GOME_TZGS.COM
kadmin.local: listprincs
K/M@GOME_TZGS.COM
admin/admin@GOME_TZGS.COM
bigdata/bigdata@GOME_TZGS.COM
kadmin/admin@GOME_TZGS.COM
kadmin/cdh05@GOME_TZGS.COM
kadmin/changepw@GOME_TZGS.COM
kiprop/cdh05@GOME_TZGS.COM
krbtgt/GOME_TZGS.COM@GOME_TZGS.COM
root/admin@GOME_TZGS.COM
在kerberos任意客户端节点执行初始化及登录命令
$ kinit bigdata/bigdata
Password for bigdata/bigdata@GOME_TZGS.COM:
附录
Kerberos 常用命令:
klist
kinit –R
kdestroy
kadmin.local -q "list_principals"
kadmin.local -q "addprinc user1"
kadmin.local -q "delprinc user1"
kinit user_name/admin@EXAMPLE.COM
kinit user1
kpasswd admin_user_name/admin
|