hue的web界面无法切换用户问题
作者:互联网
一、问题描述
在hue的web界面登录了超级管理员用户(admin),想要切换其他用户(hive),注销不成功(地址栏报错:hue 500 服务器错误,然后又自动登录到超级管理员账户admin)。无其他明显报错,错误日志摘要:
'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
二、环境描述
CM和CDH都是6.2.0版本,hue为4.3.0版本
三、错误日志
[01/Sep/2021 15:05:21 +0800] exception ERROR Internal Server Error: /accounts/logout/ Traceback (most recent call last): File "/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11-py2.7.egg/django/utils/decorators.py", line 185, in inner return func(*args, **kwargs) File "/opt/cloudera/parcels/CDH-6.2.0-1.cdh6.2.0.p0.967373/lib/hue/desktop/core/src/desktop/auth/views.py", line 216, in dt_logout LOG.warn("Error closing Impala session: %s" % e) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)
四、解决方法
在/opt/cloudera/parcels/CDH/lib/hue/build/env/lib/python2.7/site-packages目录下创建sitecustomize.py文件,编辑内容如下:
#encoding=utf8 import sys reload(sys) sys.setdefaultencoding('utf8')
配置完成后在CM平台重启hue服务。
恢复正常登录。
五、总结
因为当前系统的Python版本为Python 2.x,默认编码是ascii,注销过程中出现了无法解析的字符,解决方法是设置utf-8字符集。
标签:opt,hue,界面,lib,web,CDH,6.2,response 来源: https://www.cnblogs.com/ngrhl/p/15218545.html