MIT Kerberos と互換性のある 認証方法のサポートに加え、E-MapReduce クラスター内の Kerberos サーバーでは認証を実行するための ID 情報として Alibaba Cloud RAM(Resource Access Management) の使用もサポートされています。
RAM ID 認証
RAMでは RAM ユーザーアカウントの作成と管理がサポートされ、また、RAM ユーザーアカウントを使用してクラウド上のさまざまなリソースへのアクセスが制御されます。
マスターアカウントの管理者は、RAM ユーザー管理ページ (ユーザー名は Linux ユーザー名の仕様に準拠する必要があります) で RAM ユーザーを作成し、対応する開発者の AccessKey をダウンロードします。 開発者は AccessKey 設定してを Kerberos 認証を通し、クラスターサービスにアクセスします。
MIT Kerberos 認証と異なり、RAM ID 認証ではあらかじめ Kerberos サーバーにプリンシパルを追加する必要はありません。
以下の例では、すでに作成されている RAM ユーザーアカウントを使用してゲートウェイにアクセスします。
- E-MapReduce クラスターへの RAM ユーザーの追加
E-MapReduce セキュリティクラスターの YARN では LinuxContainerExecutor が使用されます。 クラスターで YARN ジョブを実行するには、ジョブを実行するユーザーアカウントをすべてのクラスターノードに追加する必要があります。 LinuxContainerExecutor ではプロセスの実行中にユーザーアカウントに基づいて関連する権限が検証されます。
E-MapReduce クラスターの管理者はクラスターのマスターノードで以下のコードを実行します。
adduser.sh のコードは以下のとおりです。sudo su hadoop sh adduser.sh test 1 2
# Username user_name=$1 # Master node count in the cluster. For example, the HA cluster has two master nodes. master_cnt=$2 # Worker node count in the cluster worker_cnt=$3 for((i=1;i<=$master_cnt;i++)) do ssh -o StrictHostKeyChecking=no emr-header-$i sudo useradd $user_name done for((i=1;i<=$worker_cnt;i++)) do ssh -o StrictHostKeyChecking=no emr-worker-$i sudo useradd $user_name done
- ゲートウェイの管理者によるゲートウェイマシンへの test ユーザーアカウントの追加.
useradd test
- ゲートウェイの管理者による基本的な Kerberos 環境の設定
config_gateway_kerberos.sh スクリプトは以下のとおりです。sudo su root sh config_gateway_kerberos.sh 10.27.230.10 /pathto/emrheader1_pwd_file # Ensures the value of the /etc/ecm/hadoop-conf/core-site.xml file on the Gateway is true <property> <name>hadoop.security.authentication.use.has</name> <value>true</value> property
# IP address of the emr-header-1 in the EMR cluster masterip=$1 # Saves the corresponding root logon password file for masterip masterpwdfile=$2 if ! type sshpass >/dev/null 2>&1; then yum install -y sshpass fi ## Kerberos conf sshpass -f $masterpwdfile scp root@$masterip:/etc/krb5.conf /etc/ mkdir /etc/has sshpass -f $masterpwdfile scp root@$masterip:/etc/has/has-client.conf /etc/has sshpass -f $masterpwdfile scp root@$masterip:/etc/has/truststore /etc/has/ sshpass -f $masterpwdfile scp root@$masterip:/etc/has/ssl-client.conf /etc/has/ # Modifies Kerberos client configuration, changing the default auth_type from EMR to RAM # This file can be manually modified sed -i 's/EMR/RAM/g' /etc/has/has-client.conf
- test ユーザーによるゲートウェイへのログインと AccessKey の設定
AccessKey を変更するための add_accesskey.sh スクリプトは以下のとおりです。# Log on the test account of Gateway # Run the script sh add_accesskey.sh test
user=$1 if [[ `cat /home/$user/.bashrc | grep 'export AccessKey'` == "" ]];then echo " # Change to the test user's AccessKeyId/AccessKeySecret export AccessKeyId=YOUR_AccessKeyId export AccessKeySecret=YOUR_AccessKeySecret " >>~/.bashrc else echo $user AccessKey has been added to .bashrc fi
- test ユーザーによるコマンドの実行
test ユーザーは関連するコマンドを実行してクラスターサービスにアクセスします。
HDFS コマンドを実行します。
Hadoop ジョブを実行します。[test@gateway ~]$ hadoop fs -ls / 17/11/19 12:32:15 INFO client.HasClient: The plugin type is: RAM Found 4 items drwxr-x--- - has hadoop 0 2017-11-18 21:12 /apps drwxrwxrwt - hadoop hadoop 0 2017-11-19 12:32 /spark-history drwxrwxrwt - hadoop hadoop 0 2017-11-18 21:16 /tmp drwxrwxrwt - hadoop hadoop 0 2017-11-18 21:16 /user
Spark ジョブを実行します。[test@gateway ~]$ hadoop jar /usr/lib/hadoop-current/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar pi 10 1
[test@gateway ~]$ spark-submit --conf spark.ui.view.acls=* --class org.apache.spark.examples.SparkPi --master yarn-client --driver-memory 512m --num-executors 1 --executor-memory 1g --executor-cores 2 /usr/lib/spark-current/examples/jars/spark-examples_2.11-2.1.1.jar 10