简体   繁体   中英

How to Connect Superset to Redis with Password?

I'm trying to set up Apache Superset in production mode, and all ocurred well until the Redis connection. I installed superset and redis and made the connection config in superset_config.py . When I start Redis server without password, the Superset connect and works well, but when I start Redis with password, anything that I try to do on Superset Webserver (like change something on Databases) gives the error:["Authentication Required"]1

How I did the installation (I'm using Centos 6 and Python 3.6):

sudo yum -y install redis
sudo sed -i 's/ENABLE_TIME_ROTATE = False/ENABLE_TIME_ROTATE = True/g' redis.conf
sudo sed -i '/# maxmemory <bytes>/a maxmemory 10gb\nmaxmemory-policy allkeys-lru' redis.conf
sudo sed -i 's/bind 127.0.0.1/bind 0.0.0.0/g' redis.conf
sudo sed -i '/# requirepass foobared/a requirepass redis_pass' redis.conf

sudo /path/to/my/pip3.6 install --upgrade setuptools pip
sudo /path/to/my/pip3.6 install apache-superset
sudo /path/to/my/pip3.6 install wheel
sudo /usr/local/bin/pip3.6 install impyla
sudo /usr/local/bin/pip3.6 install psycopg2-binary    
sudo /path/to/my/pip3.6 install gevent
sudo /path/to/my/pip3.6 install redis
sudo /path/to/my/pip3.6 install werkzeug==0.16.0
sudo /path/to/my/pip3.6 install cachelib

sudo sed -i 's/null/redis/g' /usr/local/lib/python3.6/site-packages/superset/config.py
superset db upgrade
export FLASK_APP=superset && flask fab create-admin  --username admin --firstname admin --lastname admin --email admin@admin.com --password admin
superset init

My superset_config.py :

import os

from werkzeug.middleware.proxy_fix import ProxyFix from cachelib.file import FileSystemCache from werkzeug.contrib.cache import RedisCache

MAPBOX_API_KEY = os.getenv('MAPBOX_API_KEY', '') 
REDIS_SERVER_IP ='redis_ip' 
REDIS_PASSWORD = 'redis_pass' 
POSTGRES_SERVER_IP = 'psql_ip' 
POSTGRES_USER = 'user' 
POSTGRES_PASSWORD = 'psql_pass'

SUPERSET_CACHE_REDIS_URL = "".join(['redis://:', REDIS_PASSWORD, '@', REDIS_SERVER_IP, ':6379/1']) SUPERSET_BROKER_URL = "".join(['redis://:', REDIS_PASSWORD, '@', REDIS_SERVER_IP, ':6379/0']) SUPERSET_CELERY_RESULT_BACKEND = "".join(['redis://:', REDIS_PASSWORD, '@', REDIS_SERVER_IP, ':6379/0'])

CACHE_CONFIG = {
    'CACHE_TYPE': 'redis',
    'CACHE_DEFAULT_TIMEOUT': 300,
    'CACHE_KEY_PREFIX': 'superset_',
    'CACHE_REDIS_HOST': 'redis',
    'CACHE_REDIS_PORT': 6379,
    'CACHE_REDIS_DB': 1,
    'CACHE_REDIS_URL': SUPERSET_CACHE_REDIS_URL }

SQLALCHEMY_DATABASE_URI = SUPERSET_SQLALCHEMY_DATABASE_URI SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'secret_key'

class CeleryConfig(object):
    BROKER_URL = SUPERSET_BROKER_URL
    CELERY_IMPORTS = ('superset.sql_lab', )
    CELERY_RESULT_BACKEND = SUPERSET_CELERY_RESULT_BACKEND
    CELERY_ANNOTATIONS = {'tasks.add': {'rate_limit': '10/s'}} CELERY_CONFIG = CeleryConfig RESULTS_BACKEND = RedisCache(
    host=REDIS_SERVER_IP,
    port=6379,
    key_prefix='superset_results',
    password=REDIS_PASSWORD
)

Versions used: Superset 0.36.0 (Used Gunicorn to set up the webserver), Redis 3.2.12, Flask 1.1.2

Someone can help me to fix this error? I think this happens because superset try to use redis without password, but in my superset config I put the redis password.

Redis with password is officially supported in Helm Chart.

It has been already solved and released in offical Superset's Helm Chart. It was added in this MR and it is supported since superset-helm-chart-0.5.9 version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM