diff --git a/kerberos/client/krb5.conf b/kerberos/client/krb5.conf index e6248e0..95071ff 100644 --- a/kerberos/client/krb5.conf +++ b/kerberos/client/krb5.conf @@ -4,7 +4,7 @@ kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] -default_realm = HADOOP.COM +default_realm = TEST.COM dns_lookup_realm = false dns_lookup_kdc = false ticket_lifetime = 24h @@ -12,7 +12,7 @@ renew_lifetime = 7d forwardable = true [realms] -HADOOP.COM = { +TEST.COM = { kdc = krb5-kdc-server:88 admin_server = krb5-kdc-server } diff --git a/kerberos/server/kadm5.acl b/kerberos/server/kadm5.acl index 3673218..e712aa5 100644 --- a/kerberos/server/kadm5.acl +++ b/kerberos/server/kadm5.acl @@ -1 +1 @@ -*/admin@HADOOP.COM * +*/admin@TEST.COM * diff --git a/kerberos/server/krb5.conf b/kerberos/server/krb5.conf index be08703..2067290 100644 --- a/kerberos/server/krb5.conf +++ b/kerberos/server/krb5.conf @@ -3,7 +3,7 @@ kdc_ports = 88 kdc_tcp_ports = 88 [realms] -HADOOP.COM = { +TEST.COM = { #master_key_type = aes256-cts acl_file = /etc/krb5kdc/kadm5.acl dict_file = /usr/share/dict/words diff --git a/kerberos/start.sh b/kerberos/start.sh index ad5e3fe..4d9374e 100755 --- a/kerberos/start.sh +++ b/kerberos/start.sh @@ -1,8 +1,8 @@ #!/bin/bash -FQDN="hadoop.com" +FQDN="test.com" ADMIN="admin" -PASS="airflow" +PASS="Admin12!" KRB5_KTNAME=/etc/admin.keytab @@ -10,21 +10,31 @@ cat /etc/hosts echo "hostname: ${FQDN}" -# create kerberos database -echo -e "${PASS}\n${PASS}" | kdb5_util create -s +inited="/app/inited" -# create admin -echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc ${ADMIN}/admin" +function init_user() { + if [ -f "${inited}" ];then + echo "user inited" + return; + fi + echo "begin init user" + # create kerberos database + echo -e "${PASS}\n${PASS}" | kdb5_util create -s + # create admin + echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc ${ADMIN}/admin" + # create hadoop + echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc hadoop" + echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc hadoop/${FQDN}" + kadmin.local -q "ktadd -norandkey -k ${KRB5_KTNAME} hadoop" + kadmin.local -q "ktadd -norandkey -k ${KRB5_KTNAME} hadoop/${FQDN}" + kadmin.local -q "xst -k /app/hadoop.keytab -norandkey hadoop/${FQDN}" + touch "${inited}" + echo "user inite success" +} -# create airflow -echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc -randkey airflow" - -echo -e "${PASS}\n${PASS}" | kadmin.local -q "addprinc -randkey airflow/${FQDN}" - -kadmin.local -q "ktadd -k ${KRB5_KTNAME} airflow" - -kadmin.local -q "ktadd -k ${KRB5_KTNAME} airflow/${FQDN}" - - -/usr/local/bin/supervisord -n -c /etc/supervisord.conf +function main() { + init_user + /usr/local/bin/supervisord -n -c /etc/supervisord.conf +} +main