16. HBase. Установка и настройка

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

Использованные материалы

  1. Manually Configuring TLS/SSL Encryption for CDH Services

1. Добавление сервиса HBase

  1. В консоли Cloudera Manager в меню выбираем «Add Service»:
  2. Выбираем HBase.
  3. Распределяем роли. Хосты с именем hbr под HBase Region Servers…
  4. На следующем шаге оставляем настройки без изменений:
  5. Ждём добавления сервиса в кластер.
  6. После успешного завершения процесса заканчиваем мастер нажатием на ‘Finish’.
  7. Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.

2. Перенастройка размещения log’ов

  1. В настройках HBase, используя фильтр ‘/var/’, изменяем следующие параметры, добавляя ‘/data’ вместо ‘/var’:
PropertyValueDescription
HBase REST Server Log Directory
hadoop.log.dir
/data/log/hbase Directory where HBase REST Server will place its log files.
HBase Thrift Server Log Directory
hadoop.log.dir
/data/log/hbase Directory where HBase Thrift Server will place its log files.
Master Log Directory
hadoop.log.dir
/data/log/hbase Directory where Master will place its log files.
RegionServer Log Directory
hadoop.log.dir
/data/log/hbase Directory where RegionServer will place its log files.
  1. Нажимаем Save Change.

3. Настройка TLS для HBase

3.1. Прежде чем вы начнете

  • Перед включением TLS убедитесь, что хранилища ключей, содержащие сертификаты, привязанные к соответствующим доменным именам, должны быть доступны на всех хостах, на которых работает хотя бы одна роль демона HBase. Хранилища ключей для HBase должны принадлежать группе hbase и иметь разрешения 0440 (то есть быть доступными для чтения владельцем и группой).
  • Вы должны указать абсолютные пути к файлам хранилища ключей и доверенных сертификатов. Эти настройки применяются ко всем хостам, на которых выполняются роли демонов службы HBase. Следовательно, выбранные вами пути должны быть действительны на всех хостах.
  • Cloudera Manager поддерживает конфигурацию TLS для HBase на уровне сервиса. Убедитесь, что вы указали абсолютные пути к файлам хранилища ключей и доверенных сертификатов. Эти настройки применяются ко всем хостам, на которых выполняются роли демонов рассматриваемой службы. Следовательно, выбранные вами пути должны быть действительны на всех хостах.
  • Следствием этого является то, что имена файлов хранилища ключей для данной службы должны быть одинаковыми на всех хостах. Если, например, вы получили отдельные сертификаты для демонов HBase на хостах node1.example.com и node2.example.com, вы могли выбрать для хранения этих сертификатов файлы с именами hbase-node1.keystore и hbase-node2.keystore ( соответственно). При развертывании этих хранилищ ключей вы должны дать им одинаковое имя на целевом хосте, например, hbase.keystore.

3.2. Настройка TLS для HBase

В настройках службы HBase, используя фильтр «TLS», изменяем следующие параметры:

PropertyValueDescription
Web UI TLS/SSL Encryption Enabled
hadoop.ssl.enabled, hbase.ssl.enabled
Enable TLS/SSL encryption for the HBase Master, RegionServer, Thrift Server, and REST Server web UIs.
HBase TLS/SSL Server JKS Keystore File Location
ssl.server.keystore.location
/opt/cloudera/security/pki/server.jks Path to the keystore file containing the server certificate and private key used for encrypted web UIs.
HBase TLS/SSL Server JKS Keystore File Password
ssl.server.keystore.password
По умолчанию: changeit. Password for the server keystore file used for encrypted web UIs.
HBase TLS/SSL Server JKS Keystore Key Password
ssl.server.keystore.keypassword
По умолчанию: changeit. Password that protects the private key contained in the server keystore used for encrypted web UIs.
  1. Настройка TLS для HBase REST Server.
PropertyValueDescription
Enable TLS/SSL for HBase REST Server
Encrypt communication between clients and HBase REST Server using Transport Layer Security (TLS).
HBase REST Server 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 HBase REST Server is acting as a TLS/SSL server. The keystore must be in JKS format.file.
HBase REST Server TLS/SSL Server JKS Keystore File Password
По умолчанию: changeit. The password for the HBase REST Server JKS keystore file.
HBase REST Server TLS/SSL Server JKS Keystore Key Password
По умолчанию: changeit. The password that protects the private key contained in the JKS keystore used when HBase REST Server is acting as a TLS/SSL server.
  1. Настройка TLS для HBase Thrift Server.
PropertyValueDescription
Enable TLS/SSL for HBase Thrift Server over HTTP
Encrypt communication between clients and HBase Thrift Server over HTTP using Transport Layer Security (TLS).
HBase Thrift Server over HTTP TLS/SSL Server JKS Keystore File Location
/opt/cloudera/security/pki/server.jks Path to the TLS/SSL keystore file (in JKS format) with the TLS/SSL server certificate and private key. Used when HBase Thrift Server over HTTP acts as a TLS/SSL server.
HBase Thrift Server over HTTP TLS/SSL Server JKS Keystore File Password
По умолчанию: changeit. Password for the HBase Thrift Server JKS keystore file.
HBase Thrift Server over HTTP TLS/SSL Server JKS Keystore Key Password
По умолчанию: changeit. Password that protects the private key contained in the JKS keystore used when HBase Thrift Server over HTTP acts as a TLS/SSL server.
  1. Нажимаем Save Changes.

4. Configuring Encrypted Transport for HBase

  1. В настройках службы HBase, используя категорию ‘Security’, изменяем следующие параметры:
PropertyValueDescription
HBase Secure Authentication
hbase.security.authentication
HBase (Service-Wide)
○ simple
◉ kerberos
Choose the authentication mechanism used by HBase.
HBase Secure Authorization
hbase.security.authorization
Enable HBase authorization.
HBase Thrift Authentication
hbase.thrift.security.qop
HBase (Service-Wide)
○ none
○ auth
○ auth-int
◉ auth-conf

If this is set, HBase Thrift Server authenticates its clients. HBase Proxy User Hosts and Groups should be configured to allow specific users to access HBase through Thrift Server.

Установка этого параметра вызывает предупреждение в логах: "Use authentication/integrity/privacy as value for rpc protection configurations instead of auth/auth-int/auth-conf."

Возможно правильно оставить в 'none'.

HBase REST Authentication
hbase.rest.authentication.type
HBase (Service-Wide)

○ simple ◉ kerberos
If this is set to "kerberos", HBase REST Server will authenticate its clients. HBase Proxy User Hosts and Groups should be configured to allow specific users to access HBase through REST Server.
HBase Transport Security
hbase.rpc.protection
HBase (Service-Wide)
○ authentication
○ integrity
◉ privacy
Configure the type of encrypted communication to be used with RPC.
  1. Нажимаем Save Changes.

7. Настройка аутентификации

Дополнительно разобраться с этой темой.

https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/cdh_sg_hbase_authorization.html

  1. В настройках службы HBase изменяем следующие параметры:
PropertyValueDescription
HBase Service Advanced Configuration Snippet (Safety Valve) for hbase-site.xml
Name:
hbase.security.exec.permission.checks
Value:
true
Description:
Without this option, all users will continue to have access to execute endpoint coprocessors.
For advanced use only, a string to be inserted into hbase-site.xml. Applies to configurations of all roles in this service except client configuration.
  1. Нажимаем Save Changes.

5. Настройка доступа к HBase-таблицам из Hue

По умолчанию, HBase Thrift Server Compact Protocol включён, что мешает доступу к HBase-таблицам из браузера Hue. При попытке увидеть таблицы HBase из Hue, выводится транспарант ‘Api Error: TSocket read 0 bytes’. Решение нашёл здесь: How to create a HBase table on Kerberized Hadoop clusters.

1.В настройках службы HBase изменяем/добавляем следующие параметры:

PropertyValueDescription
Enable HBase Thrift Http Server
hbase.regionserver.thrift.http
Use this to enable Http server usage on thrift, which is mainly needed for "doAs" functionality.
Enable HBase Thrift Proxy Users
hbase.thrift.support.proxyuser
Use this to allow proxy users on thrift gateway, which is mainly needed for "doAs" functionality.
Enable HBase Thrift Server Compact Protocol
hbase.regionserver.thrift.compact
Use the TCompactProtocol instead of the default TBinaryProtocol. TCompactProtocol is a binary protocol that is more compact than the default and typically more efficient.
Enable HBase Thrift Server Framed Transport
hbase.regionserver.thrift.framed
Use framed transport. When using the THsHaServer or TNonblockingServer, framed transport is always used irrespective of this configuration value.
HBase Service Advanced Configuration Snippet (Safety Valve) for hbase-site.xml
Name: hbase.thrift.spnego.principal
Value: HTTP/[email protected]
Description: Principal of Thrift Server. Use for access from Hue.

Name: hbase.thrift.spnego.keytab.file
Value: hbase.keytab
Description: Use for access from Hue.
For advanced use only, a string to be inserted into hbase-site.xml. Applies to configurations of all roles in this service except client configuration.
HBase Proxy User Groups
hadoop.proxyuser.hbase.groups
* Comma-delimited list of groups that you want to allow the HBase user to impersonate. The default '*' allows all groups. To disable entirely, use a string that does not correspond to a group name, such as '_no_group_'. Note: This property is used only if HBase REST/Thrift Server Authentication is enabled.
HBase Proxy User Hosts
hadoop.proxyuser.hbase.hosts
* Comma-delimited list of hosts where you want to allow the HBase user to impersonate other users. The default '*' allows all hosts. To disable entirely, use a string that does not correspond to a host name, such as '_no_host'. Note: This property is used only if HBase REST/Thrift Server Authentication is enabled.
  1. Нажимаем Save Changes.

После применения этих настроек становится возможным управлять таблицами HBase из интерфейса Hue.

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

  1. Добавление группы во FreeIPA. Так как установка кластера производится с машины, домен которой отличен от домена настраиваемых машин, то вновь используем ansible:
$ ADM_USER='nifantevea' \
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='HBase superusers for cluster ${CL_NAME}' ${CL_NAME_L}_hbase_su"
  1. В настройках службы HBase изменяем следующие параметры, указывая пользователей и/или группы (группы указываются с префиксом @):
PropertyValueDescription
HBase Superusers
hbase.superuser
@test1_hbase_su (@ — признак указания группы)
eugene (если требуется указать пользователя)
Идентично командам:
$ echo "grant '@test1_hbase_su', 'RWXCA'" | hbase shell
$ echo "grant 'nifantevea', 'RWXCA'" | hbase shell
Но группа '@test1_hbase_su', добавленная через 'hbase.superuser', не видна в списке команды 'user_permission', в отличии от пользователя 'nifantevea'. Также, обе эти записи невозможно удалить командой 'revoke'.
List of users or groups, who are allowed full privileges, regardless of stored ACLs, across the cluster. Only used when HBase security is enabled.
  1. Нажимаем Save Changes.
  2. Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.

7. Добавление jaas.conf для HBase Thrift Server для связи с ZooKeeper’ом

В логах HBase Thrift Server’а, например, при добавлении базы, обнаруживаются ошибки:

ClientCnxn
SASL configuration failed: javax.security.auth.login.LoginException: Zookeeper client cannot authenticate using the 'Client' section of the supplied JAAS configuration: '/var/run/cloudera-scm-agent/process/4323-hbase-HBASETHRIFTSERVER/jaas.conf' because of a RuntimeException: java.lang.SecurityException: java.io.IOException: /var/run/cloudera-scm-agent/process/4323-hbase-HBASETHRIFTSERVER/jaas.conf (No such file or directory) Will continue connection to Zookeeper server without SASL authentication, if Zookeeper server allows it.

Действительно, файл jaas.conf для этой роли не создаётся автоматически. Я не смог найти настройки, которые помогли бы решить эту проблему, поэтому пошёл обходным путём.

  1. На узле с ролью ‘HBase Thrift Server’ cоздаём необходимые файлы:
USERNAME="eugene"
DIR="/opt/hbase"
PRINCIPAL="hbase"
REALMNAME="TEST.LAN"

mkdir -p $DIR
cd $DIR

ipa service-allow-retrieve-keytab $PRINCIPAL/$(hostname) --users=${USERNAME}
ipa-getkeytab -r -p $PRINCIPAL/$(hostname) -k $DIR/$PRINCIPAL.keytab
ipa service-disallow-retrieve-keytab $PRINCIPAL/$(hostname) --users=${USERNAME}

cat << EOF > jaas.conf
Client {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  useTicketCache=false
  keyTab="$DIR/$PRINCIPAL.keytab"
  principal="$PRINCIPAL/$(hostname)@${REALMNAME}";
};
EOF

chmod 640 $DIR/jaas.conf
chown hbase.hbase $DIR/*

kdestroy
  1. В настройках службы HBase изменяем следующих параметры:
PropertyValueDescription
Java Configuration Options for HBase Thrift Server
{{JAVA_GC_ARGS}} -Djava.security.auth.login.config=/opt/hbase/jaas.conf

В одну строку!
These arguments will be passed as part of the Java command line. Commonly, garbage collection flags, PermGen, or extra debugging flags would be passed here. Note: When CM version is 6.3.0 or greater, {{JAVA_GC_ARGS}} will be replaced by JVM Garbage Collection arguments based on the runtime Java JVM version.
  1. Нажимаем Save Changes.
  2. Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.