14. HDFS. Настройка

В этой части описывается настройка HDFS.

2021-07-09 – 2021-10-15

1. Enable High Availability

Enabling HDFS HA

  1. В настройках сервиса HDFS, используя фильтр по слову «dfs.journalnode.edits.dir», изменяем следующий параметр:
PropertyValueDescription
JournalNode Edits Directory
dfs.journalnode.edits.dir
JournalNode Default Group:
/data/dfs/jn
Directory on the local file system where NameNode edits are written.
  1. Нажимаем Save Changes.
  2. На странице службы HDFS, через кнопку Actions, запускаем wizard включения HA:
  3. Getting Started. Задаём уникальное имя для Nameservice:
  4. Assign Roles.
    JournalNodes должны работать на хостах с такими же hardware specification, как NameNodes. Cloudera рекомендует поместить две JournalNode на те же хосты с NameNodes, а третий JournalNode на хост с похожими ресурсами, таким как JobTracker.
    Распределяем роли:
  5. Review Changes.
    Знакомимся с предварительными результатами и указываем каталог для JournalNode /data/dfs/jn:
  6. Command Details.
  7. Final Steps.

2. Настройка LDAP-аутентификации в HDFS

При прямом подключении к LDAP не работают вложенные пользовательские группы?

Полезно в /etc/sssd/sssd.conf добавить фильтрацию Hadoop’овских УЗ и групп из LDAP в секции ‘[nss]’, иначе одноимённая доменная УЗ возобладает преимуществом и нарушит работу hadoop-кластера.

[nss]
filter_groups = root,mysql,hadoop,yarn,hdfs,mapred,kms,httpfs,hbase,hive,sentry,spark,solr,sqoop,oozie,hue,flume,impala,llama,postgres,sqoop2,kudu,kafka,accumulo,zookeeper,cloudera-scm,keytrustee
filter_users = root,mysql,cloudera-scm,zookeeper,yarn,hdfs,mapred,kms,httpfs,hbase,hive,sentry,spark,solr,sqoop,oozie,hue,flume,impala,llama,sqoop2,postgres,kudu,kafka,accumulo,keytrustee
reconnection_retries = 3

Возможно, что полезно указывать, если используется прямое подключение к LDAP:

  1. В настройках службы HDFS, используя фильтр по слову «hadoop.security.group.mapping.ldap.ssl», изменяем следующие параметры:
PropertyValueDescription
Hadoop User Group Mapping LDAP TLS/SSL Truststore
hadoop.security.group.mapping.ldap.ssl.keystore
/usr/java/jdk1.8.0_181-cloudera/jre/lib/security/jssecacerts File path to a jks-format truststore containing the TLS/SSL certificate used sign the LDAP server's certificate. Note that in previous releases this was erroneously referred to as a "keystore".
Hadoop User Group Mapping LDAP TLS/SSL Truststore Password
hadoop.security.group.mapping.ldap.ssl.keystore.password
По умолчанию: changeit. The password for the TLS/SSL truststore.
  1. Нажимаем Save Changes.
  2. Используем следующие настройки только в случае использования прямого подключения Hadoop’а к LDAP, вместо рекомендованного подключения через SSSD.
    В настройках службы HDFS, используя категорию «Security», изменяем следующие параметры:

PropertyValueDescription
Hadoop User Group Mapping Implementation
hadoop.security.group.mapping
○ org.apache.hadoop.security.JniBasedUnixGroupsMapping
○ org.apache.hadoop.security.ShellBasedUnixGroupsMapping
◉ org.apache.hadoop.security.LdapGroupsMapping
Class for user to group mapping (get groups for a given user).
Hadoop User Group Mapping LDAP URL
hadoop.security.group.mapping.ldap.url
ldaps://dev-ipa01p.test.lan ldaps://dev-ipa02p.test.lan ldaps://dev-ipa03p.test.lan
Список из URL, разделённых пробелами.
The URL of the LDAP server. The URL must be prefixed with ldap:// or ldaps://. The URL can optionally specify a custom port, for example: ldaps://ldap_server.example.com:1636. Note that usernames and passwords will be transmitted in the clear unless either an ldaps:// URL is used, or "Enable LDAP TLS" is turned on (where available). Also note that encryption must be in use between the client and this service for the same reason.

For more detail on the LDAP URL format, see RFC 2255 . A space-separated list of URLs can be entered; in this case the URLs will each be tried in turn until one replies.

Hadoop User Group Mapping LDAP TLS/SSL Enabled
hadoop.security.group.mapping.ldap.use.ssl
Whether or not to use TLS/SSL when connecting to the LDAP server.
Hadoop User Group Mapping LDAP TLS/SSL Truststore
hadoop.security.group.mapping.ldap.ssl.keystore
/usr/java/jdk1.8.0_181-cloudera/jre/lib/security/jssecacerts File path to a jks-format truststore containing the TLS/SSL certificate used sign the LDAP server's certificate. Note that in previous releases this was erroneously referred to as a "keystore".
Hadoop User Group Mapping LDAP TLS/SSL Truststore Password
hadoop.security.group.mapping.ldap.ssl.keystore.password
По умолчанию: changeit. The password for the TLS/SSL truststore.
Hadoop User Group Mapping LDAP Bind User Distinguished Name
hadoop.security.group.mapping.ldap.bind.user
uid=binddn_test2,cn=sysaccounts,cn=etc,dc=test2,dc=lan Distinguished name of the user to bind as. This is used to connect to LDAP/AD for searching user and group information. This may be left blank if the LDAP server supports anonymous binds.
Hadoop User Group Mapping LDAP Bind User Password
hadoop.security.group.mapping.ldap.bind.password
Пароль для вышеуказанного системного аккаунта binddn_test2. The password of the bind user.
Hadoop User Group Mapping Search Base
hadoop.security.group.mapping.ldap.base
cn=accounts,dc=test2,dc=lan The search base for the LDAP connection. This is a distinguished name, and will typically be the root of the LDAP directory.
Hadoop User Group Mapping LDAP User Search Filter
hadoop.security.group.mapping.ldap.search.filter.user
(&(objectClass=person)(uid={0})) An additional filter to use when searching for LDAP users. The default will usually be appropriate for Active Directory installations. If connecting to a generic LDAP server, ''sAMAccountName'' will likely be replaced with ''uid''. {0} is a special string used to denote where the username fits into the filter.
Hadoop User Group Mapping LDAP Group Search Filter
hadoop.security.group.mapping.ldap.search.filter.group
(objectClass=ipausergroup) An additional filter to use when searching for groups.
Hadoop User Group Mapping LDAP Group Membership Attribute
hadoop.security.group.mapping.ldap.search.attr.member
member The attribute of the group object that identifies the users that are members of the group. The default will usually be appropriate for any LDAP installation.
Hadoop User Group Mapping LDAP Group Name Attribute
hadoop.security.group.mapping.ldap.search.attr.group.name
cn The attribute of the group object that identifies the group name. The default will usually be appropriate for all LDAP systems.
  • Нажимаем Save Changes.

3. Создание группы для доступа в HDFS с правами superuser

Проверено в кластере TEST2 в домене test2.lan.

  • HDFS-сервис не был переведён на ‘org.apache.hadoop.security.LdapGroupsMapping’, то есть испытания проводились в режиме ‘org.apache.hadoop.security.ShellBasedUnixGroupsMapping’.
  • Posix-группа ’test2_hdfs_su’ создана во FreeIPA и указана в параметре ‘dfs.permissions.superusergroup’. Non-posix группа не сработала.
  • В группу ’test2_hdfs_su’ была вложена группа ‘dom_admins’, участником которой была УЗ ’eugene’.

В результате, наблюдаем, что УЗ ’eugene’, которая является участником группы ‘dom_admins’, также распознаётся hadoop’ом, как участник и родительской группы ’test2_hdfs_su’:

$ hdfs groups eugene eugene : eugene test2_hdfs_su dom_admins

В другом кластере применил схему eugene –> dom_admins –> test01_superadmins. А нруппа test01_superadmins является участником всех кластерных групп. Результат:

hdfs groups eugene eugene : eugene dom_admins test01_yarn_admins test01_hbase_su test01_hdfs_su test01_superadmins test01_sentry_admins test01_hue_admins

3.1. Добавление группы во FreeIPA

Чтобы иметь возможность, например, создавать в HDFS home-каталоги для пользователей, нам нужен доступ к HDFS-superuser аккаунту. Напомню, что CDH автоматически создаёт HDFS superuser аккаунт — ‘hdfs’ — на каждом узле кластера в процессе первичной инстралляции. Но после включения Kerberos для HDFS служб, мы теряем доступ к использованию sudo -u hdfs. Поэтому, мы создадим в IPA posix-группу ’test1_hdfs_su’, укажем её в соответствующей настройке HDFS-сервиса, в результате чего участники этой группы, а также участники подгрупп, возобладают правами superuser’а в HDFS.

  1. Добавление группы во FreeIPA. Так как установка кластера производится с машины, домен которой отличен от домена настраиваемых машин, то вновь используем ansible:
ADM_USER='eugene'
ADM_PASS='JL9d]qtw$p=2=M2K=~z?|EU,'
CL_NAME="TEST1"          # UPPERCASE
CL_NAME_L=${CL_NAME,,}   # lowercase

ansible mgm -i cluster.inv -m shell -a "echo '${ADM_PASS}' | kinit ${ADM_USER} && \
ipa group-add --desc='HDFS superusers for cluster ${CL_NAME}' ${CL_NAME_L}_hdfs_su"
stdout...
10.15.120.140 | CHANGED | rc=0 >>
Password for [email protected]:
---------------------------
Added group "test1_hdfs_su"
---------------------------
  Group name: test1_hdfs_su
  Description: HDFS superusers for cluster TEST1
  GID: 1262100012

3.2. Указание Non-Default Superuser Group

  1. В настройках службы HDFS, используя фильтр по слову «dfs.permissions.superusergroup», изменяем следующий параметр:
PropertyValueDescription
Superuser Group
dfs.permissions.superusergroup
test1_hdfs_su The name of the group of superusers.
  1. Нажимаем Save Changes.

4. Configuring Encrypted Transport for HDFS

Перед настройкой передачи зашифрованных данных HDFS необходимо включить Kerberos. См. Инструкции в разделе «Аутентификация».

  1. В настройках службы HDFS, используя фильтр «Protection», изменяем следующие параметры:
PropertyValueDescription
DataNode Data Transfer Protection
dfs.data.transfer.protection
HDFS (Service-Wide)
○ Authentication
○ Integrity
◉ Privacy
SASL protection mode for secured connections to the DataNodes when reading or writing data. Value is the type of SASL protection to be used for secured connections to the DataNode when reading or writing block data. Possible values are 'authentication', 'integrity' and 'privacy'. authentication means authentication only and no integrity or privacy; integrity implies that only authentication and integrity are enabled; and privacy implies all of authentication, integrity and privacy are enabled. If "Enable Data Transfer Encryption" is set to true, then it supersedes the setting for this parameter and enforces that all connections must use a specialized encrypted SASL handshake. This property is ignored for connections to a DataNode listening on a privileged port. In this case, it is assumed that the use of a privileged port establishes sufficient trust.
Hadoop RPC Protection
hadoop.rpc.protection
○ authentication
○ integrity
◉ privacy
Quality of protection for secured RPC connections between NameNode and HDFS clients. For effective RPC protection, enable Kerberos authentication.
Enable Data Transfer Encryption
dfs.encrypt.data.transfer
Enable encryption of data transfer between DataNodes and clients, and among DataNodes. When enabled, block data that is read/written from/to HDFS will be encrypted on the wire. For effective data transfer protection, enable Kerberos authentication and pick privacy for "Hadoop RPC Protection".
  1. В настройках службы HDFS, используя фильтр «dfs.encrypt.data.transfer.algorithm», проверяем следующие параметры:
PropertyValueDescription
Data Transfer Encryption Algorithm
dfs.encrypt.data.transfer.algorithm
HDFS (Service-Wide)
○ 3des
○ rc4
◉ AES/CTR/NoPadding
Algorithm to encrypt data transfer between DataNodes and clients, and among DataNodes. If 3des or rc4 are chosen, the entire communication is encrypted with that algorithm. In CDH 5.4 and higher, if AES/CTR/NoPadding is chosen, 3des is used for the initial key exchange, and then AES/CTR/NoPadding is used for the transfer of data. This is the most secure option, and is recommended for clusters running CDH 5.4 or higher. It also requires that the "openssl-devel" package be installed on all machines in the cluster. When this parameter is changed, a full, nonrolling restart of the cluster must be performed.
  1. Нажимаем Save Changes.
  2. Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.

5. Включение ACL для HDFS

В настройках роли HDFS, используя фильтр «dfs.namenode.acls.enabled», включаем параметр «Enable Access Control Lists».

6. Настройка TLS для HttpFS

  1. В настройках службы HDFS, используя фильтр «HttpFS TLS», изменяем следующие параметры:
PropertyValueDescription
Signature Secret
hdfs.httpfs.signature.secret
???? (разобраться, что здесь указано или надо указывать) (этот параметр пересекается с таким же параметром из Hue) The secret to use for signing client authentication tokens.
Enable TLS/SSL for HttpFS
Encrypt communication between clients and HttpFS using Transport Layer Security (TLS) (formerly known as Secure Socket Layer (SSL)).
HttpFS TLS/SSL Server JKS Keystore File Location
/opt/cloudera/security/pki/server.jks The path to the TLS/SSL keystore file containing the server certificate and private key used for TLS/SSL. Used when HttpFS is acting as a TLS/SSL server. The keystore must be in JKS format.
HttpFS TLS/SSL Server JKS Keystore File Password
По умолчанию: changeit. The password for the HttpFS JKS keystore file.
HttpFS TLS/SSL Client Trust Store File
/usr/java/jdk1.8.0_181-cloudera/jre/lib/security/jssecacerts The location on disk of the trust store, in .jks format, used to confirm the authenticity of TLS/SSL servers that HttpFS might connect to. This is used when HttpFS is the client in a TLS/SSL connection. This trust store must contain the certificate(s) used to sign the service(s) connected to. If this parameter is not provided, the default list of well-known certificate authorities is used instead.
HttpFS TLS/SSL Client Trust Store Password
По умолчанию: changeit. The password for the HttpFS TLS/SSL Certificate Trust Store File. This password is not required to access the trust store; this field can be left blank. This password provides optional integrity checking of the file. The contents of trust stores are certificates, and certificates are public information.
  1. Нажимаем Save Changes.

    Connect to the HttpFS Web UI using TLS/SSL (HTTPS)

    Use https://<httpfs_server_hostname>:14000/webhdfs/v1/, though most browsers should automatically redirect you if you use http://<httpfs_server_hostname>:14000/webhdfs/v1/

7. Настройка HSTS для HDFS

Настройка строгой транспортной безопасности HTTP (HSTS) для HDFS гарантирует, что веб-браузер не загружает служебную информацию с помощью HTTP. Кроме того, все попытки загрузить информацию с помощью HTTP будут автоматически преобразованы в HTTPS.

Perform the following steps to configure HSTS for HDFS:

  1. Go to the HDFS service.
  2. Click the Configuration tab.
  3. Set the HSTS credentials in Cluster-wide Advanced Configuration Snippet (Safety Valve) for core-site.xml.
<property>
<name>hadoop.http.header.Strict_Transport_Security</name>
<value>max-age=63072000;includeSubDomains;preload</value>
</property>
  1. If required, configure additional headers by using the safety value specified in the previous step for the hadoop.http.header.http-header property.
  2. Нажимаем Save Changes.
  3. Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.