redash迁移

工作中,需要把一台自有实体机上的redash迁移到公司容器中。目标容器系统为centos6。迁移过程如下:

redash基础环境搭建

redis
  • 安装redis
cd /opt/xxx/apps
[xxx@set-xxx-xxx02 apps]$ mkdir redis
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
tar -zxvf redis-5.0.5.tar.gz
cd redis-5.0.5
make
  • 启动redis
cd redis-5.0.5/src
./redis-server
  • 测试redis启动ok
cd redis-5.0.5/src
./redis-cli
127.0.0.1:6379> ping
PONG
PostgreSQL

以下操作为root权限

  • 安装PostgreSQL
sudo yum install -y postgresql96-server
  • 启动PostgreSQL
pg_ctl -D /opt/xxx/pgdata/ start

若启动报错:

[xxx@set-xxx-xxx02 ~]$ < 2019-07-22 11:33:20.555 CST > FATAL:  could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied

解决方法:给other用户加写权限

sudo chmod a+w /var/run/postgresql

然后再次启动。
进入psql报错:

psql
psql: FATAL:  database "xxx" does not exist

解决方法: https://stackoverflow.com/questions/17633422/psql-fatal-database-user-does-not-exist

[xxx@set-xxx-xxx02 ~]$ createdb xxx
[xxx@set-xxx-xxx02 ~]$ psql
psql (9.6.14)
Type "help" for help.

xxx=#

修改密码:

xxx=# \password
Enter new password:
Enter it again:
xxx=#
  • 可执行文件加入到xxx用户的环境变量,修改/home/xxx/.bash_profile
export PATH=/usr/pgsql-9.6/bin:$PATH
source /home/xxx/.bash_profile
nodejs
  • 安装nodejs
cd /opt/xxx/apps
wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz
tar -xvf node-v10.9.0-linux-x64.tar.xz
mv node-v10.9.0-linux-x64 nodejs
ln -s /opt/xxx/apps/nodejs/bin/npm /usr/local/bin/
ln -s /opt/xxx/apps/nodejs/bin/node /usr/local/bin/
Python2.7

以下操作为root权限

yum install -y gcc openssl-devel bzip2-devel
cd /home/xxx/
wget https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tgz
tar xzf Python-2.7.16.tgz
cd Python-2.7.16
./configure --enable-optimizations
make altinstall
  • 安装pip
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python2.7 get-pip.py
  • 可执行文件加入到xxx用户的环境变量,修改/home/xxx/.bash_profile
export PATH=/usr/local/bin:/usr/pgsql-9.6/bin:$PATH
source /home/xxx/.bash_profile
  • 安装Python隔离环境
pip install virtualenv
virtualenv -p /usr/local/bin/python2.7 current
原redash代码和数据备份,并copy到新机器上
  • 数据备份
pg_dump -U postgres -d postgres -f postgres.sql
pg_dump -U postgres -d qa_mgmt -f qa_mgmt.sql
pg_dump -U postgres -d redash -f redash.sql
redash
  • 安装python包
source /home/xxx/current/bin/activate
cd /home/xxx/redash-7.0.0
pip install -r requirements.txt -r requirements_dev.txt -r requirements_all_ds.tx
  • 安装nodejs包
cd /home/xxx/redash-7.0.0/client
npm install
npm run build
  • 还远原数据库数据到新机器上的postgresql中
psql -U xxx -d redash -f redash.sql
psql -U xxx -d qa_mgmt -f qa_mgmt.sql
psql -U xxx -d postgres -f postgres.sql
  • 配置.env
REDASH_DATABASE_URL="postgresql://xxx:xxxxxx@localhost/redash"
Supervisor

以下为root权限

  • 安装Supervisor
pip install supervisor
  • 创建配置文件
echo_supervisord_conf > /etc/supervisord.conf
  • 修改配置文件
    修改以下几处:
[unix_http_server]
file=/var/run/supervisor.sock   ; the path to the socket file
[supervisord]
logfile=/var/log/supervisord.log ; main log file; default $CWD/supervisord.log
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
[include]
files = /etc/supervisor.d/*.conf
  • 加写权限
chmod 777 /var/run/supervisor.sock
chmod 777 /var/log/supervisord.log
  • 进程配置
mkdir -p /etc/supervisor.d
touch redash.conf

文件内容从原机器的.conf中copy出,主要改以下几个地方:目录替换为新目录,用户替换为xxx

[group:redash]
programs=redash_server,redash_celery,redash_celery_scheduled

[program:redash_server]
#environment=PYTHONPATH=/home/xxx/current/bin:%(ENV_PYTHONPATH)s,PATH=/home/xxx/current/bin:%(ENV_PATH)s
command=/home/xxx/redash-7.0.0/bin/run gunicorn -b 0.0.0.0:5000 --name redash -w 4 --max-requests 1000 redash.wsgi:app
directory=/home/xxx/redash-7.0.0
process_name=redash_server
user=xxx
numprocs=1
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /home/xxx/redash-7.0.0/logs/redash_server_stdout.log

# 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]
#environment=PYTHONPATH=/home/xxx/current/bin:%(ENV_PYTHONPATH)s,PATH=/home/xxx/current/bin:%(ENV_PATH)s
command=/home/xxx/redash-7.0.0/bin/run celery worker --app=redash.worker --beat -c2 -Qqueries,celery --maxtasksperchild=10 -Ofair
directory=/home/xxx/redash-7.0.0
process_name=redash_celery
user=xxx
numprocs=1
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /home/xxx/redash-7.0.0/logs/redash_celery_stdout.log

[program:redash_celery_scheduled]
#environment=PYTHONPATH=/home/xxx/current/bin:%(ENV_PYTHONPATH)s,PATH=/home/xxx/current/bin:%(ENV_PATH)s
command=/home/xxx/redash-7.0.0/bin/run celery worker --app=redash.worker -c2 -Qscheduled_queries --maxtasksperchild=10 -Ofair
directory=/home/xxx/redash-7.0.0
process_name=redash_celery_scheduled
user=xxx
numprocs=1
autostart=true
autorestart=true
redirect_stderr = true
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
stdout_logfile = /home/xxx/redash-7.0.0/logs/redash_celery_scheduled_stdout.log
启动redash
supervisord -c /etc/supervisord.conf
遇到的问题
  • redash启动调试服务 ./bin/run python manage.py run --host=0.0.0.0报错
[2019-07-22 16:06:08,618][PID:5136][DEBUG][redash.query_runner] TreasureData query runner enabled but not supported, not registering. Either disable or install missing dependencies.
Traceback (most recent call last):
  File "manage.py", line 6, in <module>
    from redash.cli import manager
  File "/home/xxx/redash-7.0.0/redash/__init__.py", line 80, in <module>
    import_query_runners(settings.QUERY_RUNNERS)
  File "/home/xxx/redash-7.0.0/redash/query_runner/__init__.py", line 271, in import_query_runners
    __import__(runner_import)
  File "/home/xxx/redash-7.0.0/redash/query_runner/sqlite.py", line 2, in <module>
    import sqlite3
  File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3

解决方法:

https://stackoverflow.com/questions/1210664/no-module-named-sqlite3
(1)yum install -y sqlite-devel
(2)重新编译安装Python2.7
  • python sasl包安装失败
yum install -y cyrus-sasl-devel
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,847评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,208评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,587评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,942评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,332评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,587评论 1 218
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,853评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,568评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,273评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,542评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,033评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,373评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,031评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,073评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,830评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,628评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,537评论 2 269