16. HBase. Установка и настройка
Использованные материалы
1. Добавление сервиса HBase
- В консоли Cloudera Manager в меню выбираем «Add Service»:
- Выбираем HBase.
- Распределяем роли. Хосты с именем hbr под HBase Region Servers…
- На следующем шаге оставляем настройки без изменений:
- Ждём добавления сервиса в кластер.
- После успешного завершения процесса заканчиваем мастер нажатием на ‘Finish’.
- Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.
2. Перенастройка размещения log’ов
- В настройках HBase, используя фильтр ‘/var/’, изменяем следующие параметры, добавляя ‘/data’ вместо ‘/var’:
Property | Value | Description |
---|---|---|
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. |
- Нажимаем 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», изменяем следующие параметры:
Property | Value | Description |
---|---|---|
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. |
- Настройка TLS для HBase REST Server.
Property | Value | Description |
---|---|---|
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. |
- Настройка TLS для HBase Thrift Server.
Property | Value | Description |
---|---|---|
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. |
- Нажимаем Save Changes.
4. Configuring Encrypted Transport for HBase
- В настройках службы HBase, используя категорию ‘Security’, изменяем следующие параметры:
Property | Value | Description |
---|---|---|
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. |
- Нажимаем Save Changes.
7. Настройка аутентификации
Дополнительно разобраться с этой темой.
https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/cdh_sg_hbase_authorization.html
- В настройках службы HBase изменяем следующие параметры:
Property | Value | Description |
---|---|---|
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. |
- Нажимаем 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 изменяем/добавляем следующие параметры:
Property | Value | Description |
---|---|---|
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/dev-hbr91p.test.lan@TEST.LAN 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. |
- Нажимаем Save Changes.
После применения этих настроек становится возможным управлять таблицами HBase из интерфейса Hue.
6. Создание группы для доступа в HBase с правами superuser
- Добавление группы во FreeIPA. Так как установка кластера производится с машины, домен которой отличен от домена настраиваемых машин, то вновь используем ansible:
$ ADM_USER='ken' \
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"
- В настройках службы HBase изменяем следующие параметры, указывая пользователей и/или группы (группы указываются с префиксом @):
Property | Value | Description |
---|---|---|
HBase Superusers hbase.superuser |
@test1_hbase_su (@ — признак указания группы) dmr (если требуется указать пользователя) Идентично командам:
Но группа '@test1_hbase_su', добавленная через 'hbase.superuser', не видна в списке команды 'user_permission', в отличии от пользователя 'ken'. Также, обе эти записи невозможно удалить командой '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. |
- Нажимаем Save Changes.
- Перезапускаем все зависимые сервисы по приглашению 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
для этой роли не создаётся автоматически. Я не смог найти настройки, которые помогли бы решить эту проблему, поэтому пошёл обходным путём.
- На узле с ролью ‘HBase Thrift Server’ cоздаём необходимые файлы:
USERNAME="dmr"
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
- В настройках службы HBase изменяем следующих параметры:
Property | Value | Description |
---|---|---|
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. |
- Нажимаем Save Changes.
- Перезапускаем все зависимые сервисы по приглашению Cloudera Manager Console.