1. 程式人生 > >redhat 安裝redash

redhat 安裝redash

作業系統Redhat7..2,近期遷移平臺元件,目前網上的安裝文件都是centos和unbut的,沒有紅帽平臺的,經過一天的折騰終於把redash安裝完畢,以下是安裝步驟
①     初始化
yum install python-pip python-dev nginx curl build-essential pwgen                          
yum install -y libffi-dev libssl-dev libmysqlclient-dev libpq-dev freetds-dev libsasl2-dev  
yum install -y gcc gcc-c++ cyrus-sasl-devel make                                            
yum install -y pwgen python-devel python-pip supervisor                                     
yum install -y nginx curl wget  redis                                                             
yum install -y libffi-devel mariadb-devel                                                   
yum install -y libpqxx-devel       
yum install -y crypto*      
②     PostgreSQL 安裝
yum install -y https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install -y postgresql-server postgresql-contrib  
yum install -y openssl-devel
postgresql-setup initdb  
systemctl enable postgresql.service
systemctl start postgresql.service
psql --version
alter database redash owner to worker;
 
③     啟動redis
systemctl start redis
systemctl enable redis
④     目錄和賬戶建立和包下載
mkdir -p   /opt/redash/
adduse worker
chown worker.worker   /opt/redash/   
cd      /opt/redash/          
su – worker 
wget https://github.com/getredash/redash/archive/v3.0.0.tar.gz          
tar -xf v3.0.0.tar.gz 
ln -nfs redash-3.0.0 current     
⑤     配置環境
pwgen -1s 32獲取值,用於REDASH_COOKIE_SECRET

[email protected]:~$ cat redash/.env 
export REDASH_LOG_LEVEL="INFO"
export REDASH_REDIS_URL=redis://localhost:6379/0
export REDASH_DATABASE_URL="postgresql:///redash"
export REDASH_COOKIE_SECRET=JbH84sRszAJFwUVLkUSFjmdCC14ibcjY
export REDASH_MAIL_SERVER="smtp.exmail.qq.com" # default: localhost
export REDASH_MAIL_PORT="465" # default: 25
export REDASH_MAIL_USE_TLS="false" # default: false
export REDASH_MAIL_USE_SSL="true" # default: false
export REDASH_MAIL_USERNAME="
[email protected]
" # default: None
export REDASH_MAIL_PASSWORD="[email protected]" # default: None
export REDASH_MAIL_DEFAULT_SENDER="[email protected]" # Email address to send from
export REDASH_HOST="10.1.12.13:8080"
ln -nfs /opt/redash/.env /opt/redash/current/.env
⑥     pip 安裝
cd /opt/redash/current
pip install --upgrade pip
pip install setproctitle
 
vim /root/.bash_profile
export PATH="/usr/pgsql-9.5/bin:$PATH"
 
pip install psycopg2
pip install -r requirements.txt
pip install setuptools==3.4.4
pip install -r requirements_all_ds.txt 
pip install -r requirements.txt -r requirements_dev.tx
注意要把requirements_all_ds.txt  裡Mysql註釋掉
⑦     npm安裝
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
yum install -y nodejs
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
cnpm run build
⑧     資料庫建立
yum install -y libpqxx-devel
cd /opt/redash/redash-3.0.0
sudo -u postgres createuser worker --no-superuser --no-createdb --no-createrole
sudo -u postgres createdb redash --owner=worker

bin/run ./manage.py check_settings
sudo -u worker bin/run ./manage.py database create_tables

[email protected]:/opt/redash/redash-3.0.0# sudo -u worker bin/run ./manage.py database create_tables
[2018-10-11 12:17:51,779][PID:498565][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2018-10-11 12:17:51,780][PID:498565][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2018-10-11 12:17:51,830][PID:498565][INFO][alembic.runtime.migration] Running stamp_revision  -> d1eae8b9893e   

nohup sudo -u worker /opt/redash/current/bin/run gunicorn -b 127.0.0.1:5000 --name redash -w 4 --max-requests 1000 redash.wsgi:app & 
  
chmod -R 755 /etc/supervisord.d/

⑨     supervisord配置

[email protected]:~# cat  /etc/supervisord.d/redash.ini 
[inet_http_server]
port = 10.1.12.13:9001

[program:redash_server]
command=/opt/redash/current/bin/run gunicorn -b 127.0.0.1:5000 --name redash -w 4 --max-requests 1000 redash.wsgi:app
directory=/opt/redash/current
#process_name=redash_server
user=worker
numprocs=1
autostart=true
autorestart=true

# There are two queue types here: one for ad-hoc queries, and one for the refresh of scheduled queries
# (note that "scheduled_queries" appears only in the queue list of "redash_celery_scheduled").
# The default concurrency level for each is 2 (-c2), you can increase based on your machine's resources.

[program:redash_celery]
command=/opt/redash/current/bin/run celery worker --app=redash.worker --beat -c2 -Qqueries,celery --maxtasksperchild=10 -Ofair
directory=/opt/redash/current
#process_name=redash_celery
user=worker
numprocs=1
autostart=true
autorestart=true

[program:redash_celery_scheduled]
command=/opt/redash/current/bin/run celery worker --app=redash.worker -c2 -Qscheduled_queries --maxtasksperchild=10 -Ofair
directory=/opt/redash/current
#process_name=redash_celery_scheduled
user=worker
numprocs=1
autostart=true
autorestart=true

mkdir /opt/redash/logs/ 
chown worker.worker /opt/redash/logs 
mkdir /opt/redash/tmp/
chown worker.worker /opt/redash/tmp/


[email protected]:~# cat /etc/supervisord.conf
[unix_http_server]
file=/opt/redash/tmp/supervisor.sock   ; (the path to the socket file)

[supervisord]
logfile=/opt/redash/logs/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=1000MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)
loglevel=trace                ; (log level;default info; others: debug,warn,trace)
pidfile=/opt/redash/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false               ; (start in foreground if true;default false)
minfds=1024                  ; (min. avail startup file descriptors;default 1024)
minprocs=200                 ; (min. avail process descriptors;default 200)


[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///opt/redash/tmp/supervisor.sock ; use a unix:// URL  for a unix socket

[include]
files = /etc/supervisord.d/*.ini
systemctl restart supervisord.service
⑩     nginx配置
[email protected]:~# cat  /etc/nginx/conf.d/redash
upstream rd_servers {
  server 127.0.0.1:5000;
 }
 server {

    server_tokens off;
        listen 8080 default;
        access_log /var/log/nginx/rd.access.log;
    gzip on;
        gzip_types *;
        gzip_proxied any
        location / {
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_pass       http://rd_servers;
          }
}

[email protected]:~# cat  /etc/nginx/conf.d/redash.conf 
upstream rd_servers {
  server 127.0.0.1:5000;
}

server {

  server_tokens off;

  listen 8080 default;

  access_log /var/log/nginx/rd.access.log;

  gzip on;
  gzip_types *;
  gzip_proxied any;

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass       http://rd_servers;
  }
}

[email protected]:~# cat /etc/nginx/nginx.conf|grep -v "#"

user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 65535;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;
}
systemctl restart nginx.service
訪問地址
10.1.12.13:8080