目录
?
1.安装hue
2.配置MySQL作为HUE的元数据库
3.错误排查
3.1执行hive查询语句报错org.apache.hadoop.security.AccessControlException: Permission denied: user=root...
3.2 User: root is not allowed to impersonate root
1.安装hue
hue最简单的安装方式即通过docker镜像的方式:
docker run -it -p 8888:8888 gethue/hue:latest
?默认配置下,hue会使用sqllite3作为元数据库,但是,在日常使用种,hue集成hive访问报database is locked,为了解决这一问题,我们采用MySQL作为元数据库。
2.配置MySQL作为HUE的元数据库
具体操作如下:
[root@fluxes-node4 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7858719c8b1 gethue/hue "./startup.sh" 4 days ago Up 17 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp sweet_antonelli
进入容器内部:
[root@fluxes-node4 ~]# docker exec -it e7858719c8b1 /bin/bash
hue@e7858719c8b1:/usr/share/hue$
配置hui.ini文件中的database选项:
vi /usr/share/hue/desktop/conf/hui.ini,修改database部分为以下内容:
[[database]]
engine=mysql
host=your-mysql-host
port=3306
user=your-mysql-username
password=your-mysql-password
name=hue
初始化数据库:
hue@e7858719c8b1:/usr/share/hue/build/env/bin$ ./hue syncdb
[07/Apr/2022 08:35:22 ] settings INFO Welcome to Hue 4.10.0
Traceback (most recent call last):
File "/usr/share/hue/build/env/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 15, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
查看env脚本内容:?
hue@e7858719c8b1:/usr/share/hue/build/env/bin$ cat hue
#!/usr/share/hue/build/env/bin/python3.8
# EASY-INSTALL-ENTRY-SCRIPT: 'desktop','console_scripts','hue'
import re
import sys
...
进入到python所在目录:/usr/share/hue/build/env/bin,通过./pip3 list(注意"./")查看已安装模块:确认确实没有安装pymysql,则通过pip3安装:(pip3前面别忘了加“./”,否则又去系统默认环境执行了!!)
root@e7858719c8b1:/usr/share/hue/build/env/bin# ./pip3 install pymysql
Collecting pymysql
Using cached PyMySQL-1.0.2-py3-none-any.whl (43 kB)
Installing collected packages: pymysql
Successfully installed pymysql-1.0.2
再次通过pip3 list确认模块是否安装正确:
修改hue脚本所用到的__init__.py文件:
从错误日志中可发现该文件所在路径:/usr/share/hue/build/env/lib/python3.8/site-packages/django/db/backends/mysql,修改之:
hue@e7858719c8b1:/usr/share/hue/build/env/lib/python3.8/site-packages/django/db/backends/mysql$ cat __init__.py
import pymysql
pymysql.install_as_MySQLdb()
再次执行脚本,错误解决,成功初始化数据库:
hue@e7858719c8b1:/usr/share/hue/build/env/bin$ ./hue syncdb
[07/Apr/2022 09:13:12 ] settings INFO Welcome to Hue 4.10.0
[07/Apr/2022 02:13:13 -0700] backend WARNING pam module not found
[07/Apr/2022 02:13:13 -0700] backend WARNING mozilla_django_oidc module not found
[07/Apr/2022 02:13:13 -0700] client WARNING gcs_oauth2_boto_plugin module not found
[07/Apr/2022 02:13:13 -0700] apps INFO AXES: BEGIN LOG
[07/Apr/2022 02:13:13 -0700] apps INFO AXES: Using django-axes version 5.13.0
[07/Apr/2022 02:13:13 -0700] apps INFO AXES: blocking by IP only.
[07/Apr/2022 02:13:13 -0700] api3 WARNING simple_salesforce module not found
[07/Apr/2022 02:13:13 -0700] jdbc WARNING Failed to import py4j
[07/Apr/2022 02:13:14 -0700] views WARNING httplib2 module not found
[07/Apr/2022 02:13:14 -0700] backend WARNING httplib2 module not found
No changes detected
重启hue docker镜像:
[root@fluxes-node4 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7858719c8b1 gethue/hue "./startup.sh" 4 days ago Up 2 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp sweet_antonelli
[root@fluxes-node4 ~]# docker restart e7858719c8b1
3.错误排查
3.1执行hive查询语句报错org.apache.hadoop.security.AccessControlException: Permission denied: user=root...
产生原因:
在hdfs的文件系统上,没有root用户,而hive的操作默认使用了root用户,在检查文件的权限的时候,发生报错
解决思路:
1、关闭hdfs的权限检查
在hdfs-site.xml的配置文件中,将dfs.permissions修改为False 默认为开启状态 ?
<property>
<name>dfs.permissions</name>
<value>false</value>
<description>关闭权限检查</description>
</property>
3.2 User: root is not allowed to impersonate root
修改hadoop?配置文件 etc/hadoop/core-site.xml,加入如下配置项
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
Hadoop.proxyuser.root.hosts配置项名称中root部分为报错User:* 中的用户名部分
例如User: rain is not allowed to impersonate anonymous则需要将xml变更为如下格式
<property>
<name>hadoop.proxyuser.rain.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.rain.groups</name>
<value>*</value>
</property>
在开启hadoop时候报错:localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
此时 ssh localhost也会失败 原因是秘钥没有给自己。
解决方案如下:
首先在服务器上制作密钥对。首先用密码登录到你打算使用密钥登录的账户,然后执行以下命令:
$ ssh-keygen <== 建立密钥对
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): <== 按 Enter
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): <== 输入密钥锁码,或直接按 Enter 留空
Enter same passphrase again: <== 再输入一遍密钥锁码
Your identification has been saved in /root/.ssh/id_rsa. <== 私钥
Your public key has been saved in /root/.ssh/id_rsa.pub. <== 公钥
The key fingerprint is:
0f:d3:e7:1a:1c:bd:5c:03:f1:19:f1:22:df:9b:cc:08 root@host
运行ssh-copy-id -i /root/.ssh/id_rsa.pub root@localhost即可解决。
在$HADOOP_HOME/sbin/start-yarn.sh 文件中添加root用户的定义
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
HDFS_NAMENODE_USER=root
在集群环境下,即使各结点都正确地配置了JAVA_HOME,也会报如下错误:
# ./start-yarn.sh
Starting resourcemanager
Last login: Wed Apr 6 10:57:22 CST 2022 from ::1 on pts/4
resourcemanager is running as process 17491. Stop it first and ensure /tmp/hadoop-root-resourcemanager.pid file is empty before retry.
Starting nodemanagers
Last login: Wed Apr 6 10:58:18 CST 2022 on pts/1
localhost: ERROR: JAVA_HOME is not set and could not be found.
解决方法:
?????在hadoop-env.sh中,再显示地重新声明一遍JAVA_HOME
在Hadoop安装目录下找到sbin文件夹
在里面修改四个文件
1、对于start-dfs.sh和stop-dfs.sh文件,添加下列参数:
#!/usr/bin/env bash
HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
?2、对于start-yarn.sh和stop-yarn.sh文件,添加下列参数:
#!/usr/bin/env bash
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
3、hiveserver2 后台运行
启动hivemetastore hive --service metastore
启动hiveserver2 hive --service hiveserver2
beeline
!connect jdbc:hive2://172.16.145.124:10000 hive hive
后台运行
hivemetastore nohup hive --service metastore &
hiveserver2 nohup hive --service hiveserver2 &
在浏览器中可以访问:
http://192.168.1.1**:8088/cluster
|