CentOS8本地安装Redash中文版,并且配置为生产环境
Centos8内置的Python为3.6.8版本,以下是在内置Python3.6.8基础上的安装步骤。由于安装多版本Python会导致系统底层库需要下载源码重新编译,比较麻烦,不建议在多版本Python环境下安装Redash中文版。
本地安装Redash中文版
1、初始化
改国内源:
cd /etc/yum.repos.d/
sudo rm -f CentOS-Base.repo CentOS-AppStream.repo CentOS-PowerTools.repo CentOS-centosplus.repo CentOS-Extras.repo
sudo curl -o CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
sudo yum makecache
更新系统包:
sudo yum update
安装常用包:
sudo yum -y install gcc gcc-c++ kernel-devel make zlib zlib-devel libffi-devel openssl-devel git
当前用户添加到root组:
sudo usermod -aG root 当前centos用户名
2、安装PostgreSql9.6
安装PostgreSql9.6初始化并配置为系统启动时自动启动:
sudo dnf install @postgresql:9.6
sudo dnf install postgresql-contrib
sudo yum install postgresql-devel
sudo postgresql-setup initdb
sudo systemctl enable --now postgresql
登录Postgresql:
sudo -u postgres psql
更改postges密码:
alter user postgres with password '密码';
创建角色:
create role 当前centos用户名;
赋予登录权限:
alter role 当前centos用户名 login;
退出postgresql终端:
\q
3、安装Redis
sudo yum install redis
sudo systemctl start redis
sudo systemctl enable redis.service
4、安装Nodejs
sudo yum install nodejs
sudo npm config set registry https://registry.npm.taobao.org
sudo npm install n -g
sudo /usr/local/bin/n stable
5、安装Redash中文版
1、下载代码:
git clone https://github.com/dazdata/redash.git
cd redash
2、前端安装依赖包:npm install
3、前端打包:npm run build
4、配置pip国内源:sudo cp pip.conf /etc/pip.conf
5、安装Python虚拟环境:sudo pip3 install virtualenv
6、创建Python虚拟环境:virtualenv venv
7、激活Python虚拟环境:source venv/bin/activate
8、安装Pip包:
pip install -r requirements.txt -r requirements_dev.txt -r requirements_bundles.txt
9、初始化数据库表结构:./manage.py database create_tables
10、退出虚拟环境,安装完成:deactivate
6、启动
分别打开三个终端,都执行cd redash进入目录后分别执行下列三个命令之一:
source venv/bin/activate
./manage.py runserver --debugger --reload
和
source venv/bin/activate
./manage.py rq worker
和
source venv/bin/activate
./manage.py rq scheduler
打开浏览器,输入地址:http://localhost:5000
配置为生产环境
在此基础上升级为Nginx+Supervisor+uWSGI的生产环境部署
一、安装和测试uWSGI
1、安装:
sudo yum -y install python36-devel
sudo pip3 install uwsgi
2、配置:
进入项目目录:cd ~/redash
创建配置文件:sudo nano uwsgi.ini
[uwsgi]
http=:5000
chdir=/home/当前centos用户名/redash/
wsgi-file=redash/wsgi.py
callable=app
master=true
virtualenv=/home/当前centos用户名/redash/venv/
pythonpath=/home/当前centos用户名/redash/
processes=1
threads=2
保存退出,先配置成http方式,便于从浏览器访问,后续配合nginx将改为socket方式。
注意这只是基本配置,高级配置请参考uWSGI官网中文文档
https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/WSGIquickstart.html
3、启动:
uwsgi uwsgi.ini
进入浏览器输入http://localhost:5000即可访问,
注意其它worker和scheduler还是以终端方式进虚拟环境启动。
运行无问题,证明已用uwsgi启动了redash,先Ctrl+C停止uwsgi服务继续进行后续配置。
二、安装和测试Supervisor
1、安装SuperVisor:
sudo pip3 install supervisor
2、配置:
进入项目目录:cd ~/redash
先用命令生成默认配置文件:echo_supervisord_conf > supervisord.conf
打开配置文件:sudo nano supervisord.conf 修改其中86/87行,去掉行头注释符;
[program:redash]
command = uwsgi uwsgi.ini
在文件结尾插入下列内容,用于启动redash的worker和scheduler
[program:worker]
directory=/home/当前centos用户名/redash/
command=venv/bin/python3 ./manage.py rq worker
[program:scheduler]
directory=/home/当前centos用户名/redash/
command=venv/bin/python3 ./manage.py rq scheduler
保存退出,注意这只是基本配置,高级配置请参考http://supervisord.org/
3、启动
supervisord -c supervisord.conf
进入浏览器输入http://localhost:5000即可访问,注意这时worker和scheduler也已用supervisor进行管理,
不需要另外启动。可用supervisorctl status查看三个进程,运行无问题,
证明已用supervisor启动了含uwsgi的redash全部进程。
先运行supervisorctl stop all停止进程(最好重启系统),继续后续配置。
三、安装Nginx并全部启动
1、安装Nginx:
sudo yum install nginx
2、修改配置:sudo nano /etc/nginx/nginx.conf 将location /加入如下内容
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:5000;
}
保存退出
3、改uwsgi协议:
进入项目目录:cd ~/redash
修改配置文件:sudo nano uwsgi.ini的第2行并新增第3行
socket=127.0.0.1:5000
chmod-socket=666
保存退出
4、启动:
supervisord -c supervisord.conf
systemctl start nginx
进入浏览器输入http://127.0.0.1:80能够正常访问即为安装成功。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2019-09-20 mysql+canal+kafka+elasticsearch构建数据查询平台
2019-09-20 zookeeper集群搭建
2019-09-20 另类--kafka集群中jmx端口设置
2019-09-20 kafka集群中jmx端口设置
2019-09-20 使用zookeeper报错 stat is not executed because it is not in the whitelist. envi is not executed because it is not in the whitelist.