1、两个kerberos集群之间distcp数据
以下配置适用于开启kerberos(不同kdc)的两个集群之间distcp数据
从10.1.236.55拷贝数据到10.1.235.36集群:
10.1.235.36(realm: cluster) 访问 10.1.236.55(realm: DRAGON)跨域配置:
1、添加krbtgt的Principal
在10.1.235.36的kdc服务器执行(realm: cluster) :
kadmin.local :
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/DRAGON@cluster
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/cluster@DRAGON
在10.1.236.55的kdc服务器执行(realm: DRAGON)
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/DRAGON@cluster
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/cluster@DRAGON
2、修改hdfds配置
修改10.1.235.36的hdfs配置(添加10.1.236.55的kerberos认证rule)
hadoop.security.auth_to_local 添加:
RULE:1:$1@$0s/^(.)@DRAGON$/$1/g
RULE:[2:$1@$0](^.@DRAGON$)s/^(.)@DRAGON$/$1/g
修改10.1.236.55的hdfs配置(因为distcp会使用mr任务,所以要用到rm,需要添加10.1.235.36的rm kerberos认证rule)
RULE:2:$1@$0s/./ocdc/](mailto:rm@cluster)s/./ocdc/)
添加自定义 hdfs-site(可在主机上执行hdfs getconf -confKey dfs.namenode.kerberos.principal.pattern查看,如果不为,修改为)
dfs.namenode.kerberos.principal.pattern=
完成后两个集群均需要重启hdfs。
3、修改/etc/krb5.conf
修改10.1.235.36:/etc/krb5.conf
添加内容:
[domain_realm]
.dragon = DRAGON
dragon = DRAGON
ocdp-42-57 = DRAGON #10.1.236.55集群的kdc主机
ocdp-42-55 = DRAGON #10.1.236.55集群的active namenode主机
添加10.1.236.55(realm: DRAGON)realms信息:
[realms]
DRAGON = {
admin_server = ocdp-42-57
kdc = ocdp-42-57
}
}
[capaths]
cluster = {
DRAGON =.
}
DRAGON = {
cluster=.
}
如图所示:
4、分发/etc/krb5.conf
拷贝10.1.235.36:/etc/krb5.conf到10.1.235.36集群其它主机(不需要重启kerberos服务)
5、准备keytab文件
拷贝10.1.236.55集群下生成的用户的keytab文件到10.1.235.36集群下认证(这个用户需要在两个集群中都存在,而且对distcp拷贝涉及的目录要有读写权限):
6、执行distcp命令
执行命令从10.1.236.55拷贝/tmp/test1目录到10.1.235.36:8020/test/下:
hadoop distcp -D ipc.client.fallback-to-simple-auth-allowed=true -Dmapreduce.job.queuename=default hdfs://10.1.236.55:8020/tmp/test1 hdfs://10.1.235.36:8020/test/
2、两个kerberos集群之间cp数据
以下配置适用于开启kerberos(不同kdc)的两个集群之间cp数据
从10.1.236.55 拷贝数据到10.1.235.36集群:
10.1.235.36(realm: cluster) 访问 10.1.236.55(realm: DRAGON)跨域配置:
1、添加krbtgt的Principal
在10.1.235.36的kdc服务器执行(realm: cluster) :
kadmin.local :
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/DRAGON@cluster
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/cluster@DRAGON
在10.1.236.55的kdc服务器执行(realm: DRAGON)
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/DRAGON@cluster
addprinc -e “aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal camellia256-cts:normal camellia128-cts:normal des-hmac-sha1:normal des-cbc-md5:normal” -pw admin krbtgt/cluster@DRAGON
2、修改hdfds配置
修改10.1.235.36的hdfs配置(添加10.1.236.55的kerberos认证rule)
hadoop.security.auth_to_local 添加:
RULE:1:$1@$0s/^(.)@DRAGON$/$1/g
RULE:[2:$1@$0](^.@DRAGON$)s/^(.)@DRAGON$/$1/g
添加自定义 hdfs-site(可在主机上执行hdfs getconf -confKey dfs.namenode.kerberos.principal.pattern查看,如果不为,修改为)
dfs.namenode.kerberos.principal.pattern=
完成后两个集群均需要重启hdfs。
3、修改/etc/krb5.conf
修改10.1.235.36:/etc/krb5.conf
添加内容:
[domain_realm]
.dragon = DRAGON
dragon = DRAGON
ocdp-42-57 = DRAGON #10.1.236.55集群的kdc主机
ocdp-42-55 = DRAGON #10.1.236.55集群的active namenode主机
添加10.1.236.55(realm: DRAGON)realms信息:
[realms]
DRAGON = {
admin_server = ocdp-42-57
kdc = ocdp-42-57
}
}
[capaths]
cluster = {
DRAGON =.
}
DRAGON = {
cluster=.
}
如图所示:
4、分发/etc/krb5.conf
拷贝10.1.235.36:/etc/krb5.conf到10.1.235.36集群其它主机(不需要重启kerberos服务)
5、准备keytab文件
拷贝10.1.236.55集群下生成的用户的keytab文件到10.1.235.36集群下认证(这个用户需要在两个集群中都存在,而且对distcp拷贝涉及的目录要有读写权限):
6、执行cp命令
在10.1.235.36集群执行:
hadoop fs -cp hdfs://10.1.236.55:8020/tmp/conf/ambari.properties hdfs://10.1.235.36:8020/test/
hadoop fs -cp hdfs://10.1.235.36:8020/tmp/gc.log-201901211406 hdfs://10.1.236.55:8020/tmp/
3、遇到问题:
问题1:
解决:源10.1.236.55集群添加
RULE:2:$1@$0s/./ocdc/](mailto:rm@cluster)s/./ocdc/)
问题2:
解决:出现上面错误是因为我开始只把/etc/krb5.conf没有拷贝到集群其它主机,所以distcp的时候会用到mr,就会在其它主机检测token,拷贝到其它主机后解决。
4、非kerberos集群数据distcp到kerberos集群
10.1.234.110 非kerberos集群
10.1.235.33 kerberos集群
测试从10.1.234.110拷贝hive表test到10.1.235.33集群
10.1.234.110(非kerberos)集群查看:
hadoop fs -ls /apps/hive/warehouse/test.db/test
在10.1.235.33(kerberos)集群查看源集群文件,看是否可以查看
hadoop fs -D ipc.client.fallback-to-simple-auth-allowed=true -ls hdfs://10.1.234.110:8020/apps/hive/warehouse/test.db/test
其它用户:
执行拷贝命令(在kerberos集群机器上执行):在raoyi用户下,这个用户需要能够访问源集群(非kerberos)和目标集群(kerberos)集群的权限
hadoop distcp -D ipc.client.fallback-to-simple-auth-allowed=true hdfs://10.1.234.110:8020/apps/hive/warehouse/test.db/test /warehouse/tablespace/external/hive/test.db/
在kerberos集群机器上查看拷贝结构:
步骤:
锦业路集群拷贝数据到ocdp5.0集群(锦业路集群非kerberos,ocdp5.0集群为kerberos集群)
1、在ocdp5.0上ldap上添加用户ocdc
2、在ocdp5.0上kdc服务器上生成ocdc用户的keytab
3、在ocdp5.0上给用户ocdc赋hdfs上的权限
4、在ocdp5.0上kinit ocdc.keytab ocdc@ASIAINFO.COM
5、在ocdp5.0上查看锦业路集群要拷贝的数据目录是否有权限
hadoop fs -D ipc.client.fallback-to-simple-auth-allowed=true -ls hdfs://10.1.234.110:8020/apps/hive/warehouse/test.db/test
6、在ocdp5.0上执行拷贝命令:(hdfs://10.1.234.110:8020为锦业路集群active namenode地址)
hadoop distcp -D ipc.client.fallback-to-simple-auth-allowed=true hdfs://10.1.234.110:8020/apps/hive/warehouse/test.db/test /warehouse/tablespace/external/hive/test.db/
ps:执行命令之后如果有host name找不到的,在ocdp5.0上/etc/hosts添加上对应的hostname映射