redash安装

Centos部署

参考:https://redash.io/help-onpremise/dev/setup.html

系统环境:CentOS Linux release 7.4.1708 (Core)

  • 基础环境安装
yum install -y git python3-pip nodejs python3-devel supervisor nginx redis
更换npm国内源:npm config set registry https://registry.npm.taobao.org
安装nodejs版本管理器:npm install n -g
升级nodejs最新版本:n stable
  • PostgreSQL 9.5安装、配置

yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

yum install -y postgresql96-server

/usr/pgsql-9.6/bin/postgresql96-setup initdb

systemctl enable postgresql-9.6

systemctl start postgresql-9.6

sudo -u postgres psql

CREATE USER redash WITH PASSWORD 'resdash123';

CREATE DATABASE redash;

GRANT ALL PRIVILEGES ON DATABASE redash to redash;

未做数据库验证  如果安装的话 可以做一下

  • redis启动
systemctl start redis
  • 包下载
GIT_REPO="https://github.com/dazdata/redash.git"
git clone ${GIT_REPO}
cd redash
mkdir frontend
cd frontend
cp ../package.json ../package-lock.json .
cp -r ../viz-lib  .
npm ci --unsafe-perm
cp -r ../client .
cp  ../webpack.config.js .
npm run build
  • pip安装
cd ..
cp pip.conf /etc/pip.conf
pip3 install virtualenv
virtualenv -p python3 venv
source venv/bin/activate
pip install redis
pip install psycopg2-binary
pip install -r requirements.txt -r requirements_dev.txt
Python3.8安装pip包:pip install importlib_resources==1.5
若需要支持LDAP3:pip install ldap3 (试用建议不安装)
若需要支持Oracle数据源,先安装Oracle客户端程序,后执行:pip install -r requirements_oracle_ds.txt (试用建议不安装)
若需要支持mysql,请先启动一个新的命令行终端,执行:
pipt install default-libmysqlclient-dev (试用建议不安装)
再回到当前命令行终端执行:
pip install mysqlclient (试用建议不安装)
若需要其它数据源:pip install -r requirements_all_ds.txt (试用建议不安装)
  • pip安装报错
 ERROR: Command errored out with exit status 1:
     command: /data/redash/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yk8vv_j9/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yk8vv_j9/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"' '"'"', '"'"' '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-do8v_dow
         cwd: /tmp/pip-install-yk8vv_j9/psycopg2/
    Complete output (23 lines):
    running egg_info
    creating /tmp/pip-pip-egg-info-do8v_dow/psycopg2.egg-info
    writing /tmp/pip-pip-egg-info-do8v_dow/psycopg2.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-pip-egg-info-do8v_dow/psycopg2.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-pip-egg-info-do8v_dow/psycopg2.egg-info/top_level.txt
    writing manifest file '/tmp/pip-pip-egg-info-do8v_dow/psycopg2.egg-info/SOURCES.txt'
    
    Error: pg_config executable not found.
    
    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.
    
    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.
    
    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决办法:pip install psycopg2-binary   用psycopg2-binary代替psycopg2
  • 启动
启动之前可以检查一下 若有报错需要解决 没有就跳过
./manage.py database check_settings
  • 数据库创建
sudo -u postgres createuser redash --no-superuser --no-createdb --no-createrole
sudo -u postgres createdb redash --owner=redash
sudo -u redash bin/run ./manage.py database create_tables
  • supervisord配置
cp /opt/redash/current/setup/ubuntu/files/supervisord.conf /etc/supervisord.d/redash.ini
systemctl start supervisord
  • Nginx配置
cp /opt/redash/current/setup/ubuntu/files/nginx_redash_site /etc/nginx/conf.d/nginx_redash_site.conf
修改/etc/nginx/conf.d/nginx_redash_site.conf中端口为8080
  •  可能遇到的报错
[root@production-elk redash-3.0.0]# bin/run ./manage.py check_settings
Traceback (most recent call last):
  File "/opt/redash/redash-3.0.0/manage.py", line 6, in <module>
    from redash.cli import manager
  File "/opt/redash/redash-3.0.0/redash/cli/__init__.py", line 10, in <module>
    from redash.cli import users, groups, database, data_sources, organization
  File "/opt/redash/redash-3.0.0/redash/cli/users.py", line 10, in <module>
    from redash.handlers.users import invite_user
  File "/opt/redash/redash-3.0.0/redash/handlers/__init__.py", line 4, in <module>
    from redash.handlers.api import api
  File "/opt/redash/redash-3.0.0/redash/handlers/api.py", line 6, in <module>
    from redash.handlers.base import org_scoped_rule
  File "/opt/redash/redash-3.0.0/redash/handlers/base.py", line 8, in <module>
    from redash.authentication import current_org
  File "/opt/redash/redash-3.0.0/redash/authentication/__init__.py", line 11, in <module>
    from redash.authentication import google_oauth, saml_auth, remote_user_auth, ldap_auth
  File "/opt/redash/redash-3.0.0/redash/authentication/google_oauth.py", line 5, in <module>
    from flask_oauthlib.client import OAuth
  File "/usr/lib/python2.7/site-packages/flask_oauthlib/client.py", line 20, in <module>
    from .utils import to_bytes
  File "/usr/lib/python2.7/site-packages/flask_oauthlib/utils.py", line 5, in <module>
    from oauthlib.common import to_unicode, bytes_type
ImportError: cannot import name bytes_type
解决办法:pip install requests-oauthlib==1.1.0
[root@production-elk redash-3.0.0]# bin/run ./manage.py check_settings
Traceback (most recent call last):
  File "/opt/redash/redash-3.0.0/manage.py", line 9, in <module>
    manager()
  File "/usr/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/flask/cli.py", line 345, in main
    return AppGroup.main(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/flask/cli.py", line 228, in decorator
    with __ctx.ensure_object(ScriptInfo).load_app().app_context():
  File "/usr/lib/python2.7/site-packages/flask/cli.py", line 201, in load_app
    rv = self.create_app(self)
  File "/opt/redash/redash-3.0.0/redash/cli/__init__.py", line 15, in create
    app = current_app or create_app()
  File "/opt/redash/redash-3.0.0/redash/__init__.py", line 135, in create_app
    handlers.init_app(app)
  File "/opt/redash/redash-3.0.0/redash/handlers/__init__.py", line 24, in init_app
    from redash.handlers import embed, queries, static, authentication, admin, setup
  File "/opt/redash/redash-3.0.0/redash/handlers/setup.py", line 13, in <module>
    class SetupForm(Form):
  File "/opt/redash/redash-3.0.0/redash/handlers/setup.py", line 15, in SetupForm
    email = EmailField('Email Address', validators=[validators.Email()])
  File "/usr/lib/python2.7/site-packages/wtforms/validators.py", line 332, in __init__
    raise Exception("Install 'email_validator' for email validation support.")
Exception: Install 'email_validator' for email validation support.
解决办法:pip install email_validator

原文地址:https://www.cnblogs.com/fat-girl-spring/p/13803925.html