redesh Centos参考地址:

python2.7 环境:https://ld246.com/article/1519440121831

我是按python3环境 :https://blog.csdn.net/htmljsp/article/details/126194715

一、环境准备

    • 单机安装 redis

官网安装地址:

https://redis.io/docs/getting-started/installation/install-redis-from-source/

选择按源码编译安装

wget https://download.redis.io/redis-stable.tar.gz

安装C++编译环境、make

yum -y install gcc automake autoconf libtool make
##验证成功
whereis make

错误:configure: error: no acceptable C compiler found in $PATH
解决:需要按照C++编译环境

To compile Redis, first the tarball, change to the root directory, and then run make:

tar -xzvf redis-stable.tar.gz
cd redis-stable
make

结果输出:
......
CC redis-cli.o
CC redisassert.o
CC cli_common.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
INSTALL redis-check-aof
Hint: It's a good idea to run 'make test' ;)
make[1]: Leaving directory '/var/tools/redis-stable/src'
-----------------------------------------------------------
make之后,会在src目录下增加两个目录:
-rwxr-xr-x 1 root root 7237624 Jan 11 04:09 redis-cli
... ...
-rwxr-xr-x 1 root root 14403144 Jan 11 04:09 redis-server

  • redis-server: the Redis Server itself

  • redis-cli is the command line interface utility to talk with Redis.

To install these binaries in /usr/local/bin, run:

make install
结果输出:
cd src && make install
make[1]: Entering directory '/var/tools/redis-stable/src'
/usr/bin/which: no python3 in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/var/jdk/bin:/root/bin)
/usr/bin/which: no python in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/var/jdk/bin:/root/bin)CC Makefile.dep
/usr/bin/which: no python3 in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/var/jdk/bin:/root/bin)
/usr/bin/which: no python in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/var/jdk/bin:/root/bin)Hint: It's a good idea to run 'make test' ;)INSTALL redis-serverINSTALL redis-benchmarkINSTALL redis-cli
make[1]: Leaving directory '/var/tools/redis-stable/src'

启动redis:

redis-server
结果输出:
50281:C 11 Jan 2023 04:19:56.559 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
50281:C 11 Jan 2023 04:19:56.559 # Redis version=7.0.7, bits=64, commit=00000000, modified=0, pid=50281, just started
50281:C 11 Jan 2023 04:19:56.559 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
50281:M 11 Jan 2023 04:19:56.560 * Increased maximum number of open files to 10032 (it was originally set to 1024).
50281:M 11 Jan 2023 04:19:56.560 * monotonic clock: POSIX clock_gettime_.__.-``__ ''-.__.-``    `.  `_.  ''-._           Redis 7.0.7 (00000000/0) 64 bit.-`` .-```.  ```\/    _.,_ ''-._(    '      ,       .-`  | `,    )     Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379|    `-._   `._    /     _.-'    |     PID: 50281`-._    `-._  `-./  _.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'||    `-._`-._        _.-'_.-'    |           https://redis.io`-._    `-._`-.__.-'_.-'    _.-'|`-._`-._    `-.__.-'    _.-'_.-'||    `-._`-._        _.-'_.-'    |`-._    `-._`-.__.-'_.-'    _.-'`-._    `-.__.-'    _.-'`-._        _.-'`-.__.-'50281:M 11 Jan 2023 04:19:56.561 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
50281:M 11 Jan 2023 04:19:56.561 # Server initialized
50281:M 11 Jan 2023 04:19:56.561 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
50281:M 11 Jan 2023 04:19:56.562 * Ready to accept connections

To stop Redis, enter Ctrl-C.

测试安装成功:

redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> set a1 111
OK
127.0.0.1:6379> get a1
"111"
127.0.0.1:6379>
    • 安装 PostgreSQL 数据库

安装

# Install the repository RPM:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm# Disable the built-in PostgreSQL module:
sudo dnf -qy module disable postgresql# Install PostgreSQL:
sudo dnf install -y postgresql15-server

初始化

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15

配置

postgresql.conf

安装后路径:/var/lib/pgsql/15,修改配置文件

vi /var/lib/pgsql/15/data/postgresql.conf
#增加一行:
listen_addresses = '*'

pg_hba.conf

配置文件修改:
/var/lib/pgsql/15/data
pg_hba.conf  添加
host    all        all        0.0.0.0/0        md5
host    replication    all        0.0.0.0/0        md5

设置用户密码

PostgreSQL会创建一个默认的linux用户postgres和一个数据库用户postgres,修改pg数据库帐号密码

注:后来思考,如有pg上已经有了postgres库及用户,会与存在的系统冲突;尝试新建用户redash及数据库redash,增强兼容性。

#通过su命令切换linux用户为postgres会自动进入命令行
su postgres
#启动SQL Shell
psql
#修改密码
ALTER USER postgres WITH PASSWORD 'NewPassword';

如:

[root@localhost ~]# su postgres

bash-4.4$ psql

could not change directory to "/root": Permission denied

psql (15.1)

Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'NewPassword';

psql基础知识点:

另一种登录方式:
在root帐号:
psql -h192.168.85.131 -U postgres

#类似show databases;
\l 或 select datname from pg_database;
#切换数据库
\c 数据库名
#类似show tables
\dt 或SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
#describe table_name;
\d tablename或 SELECT column_name FROM information_schema.columns WHERE table_name ='table_name';

重置linux用户postgres密码

#在root帐号下,删除postgres密码
passwd -d postgres
#设置新密码
sudo -u postgres passwd
sys
    • python环境

安装python隔离

yum install python3-pip
pip3 install virtualenv
#测试
virtualenv --version

验证

进入隔离环境

source current/bin/activate
如:
[root@localhost tools]# source current/bin/activate
(current) [root@localhost tools]#

退出隔离环境

deactivate
如:
(current) [root@localhost tools]# deactivate
    • 安装 nodejs 相关

可以查看node最新版本信息
https://github.com/nodesource/distributions
https://github.com/nodejs/Release

下载node 18

curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -

yum -y install nodejs

#安装node,这里应该安装16.X版本一下的,redash 需要14版本,到17版本以上,node增加了秘钥限制,造成后续build失败,我装的18版本
curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -
yum -y install nodejs##结果输出:=========================================================
## Installing the NodeSource Node.js 18.x repo...## Inspecting system...+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release || rpm -q --whatprovides fedora-release
+ uname -m## Confirming "el8-x86_64" is supported...+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_18.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'## As yum will try to install Node.js from the AppStream repository
instead of the NodeSource repository, the AppStream's version of Node.js has to be disabled.
## Run `sudo yum module enable -y nodejs` to reactivate the AppStream's Node.js repository.+ yum module disable -y nodejs
Node.js Packages for Enterprise Linux 8 - x86_64                                                                                                                                    72 kB/s | 401 kB     00:05
Last metadata expiration check: 0:00:02 ago on Thu 12 Jan 2023 03:04:34 AM EST.
Dependencies resolved.
Nothing to do.
Complete!## Downloading release setup RPM...+ mktemp
+ curl -sL -o '/tmp/tmp.FQAhDiThfX' 'https://rpm.nodesource.com/pub_18.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'## Installing release setup RPM...+ rpm -i --nosignature --force '/tmp/tmp.FQAhDiThfX'## Cleaning up...+ rm -f '/tmp/tmp.FQAhDiThfX'## Checking for existing installations...+ rpm -qa 'node|npm' | grep -v nodesource## Run `sudo yum install -y nodejs` to install Node.js 18.x and npm.
## You may run dnf if yum is not available:sudo dnf install -y nodejs
## You may also need development tools to build native addons:sudo yum install gcc-c++ make
## To install the Yarn package manager, run:curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.reposudo yum install yarn
===================================================

#验证

node -v

npm -v

#修改npm下载资源地址

[root@localhost var]# npm get registry

https://registry.npmjs.org/

[root@localhost var]# npm config set registry http://registry.npm.taobao.org/

[root@localhost var]# npm get registry

http://registry.npm.taobao.org/

    • 安装redash

下载源码

yum install git
git clone https://github.com/getredash/redash.git

创建项目虚拟环境

#先创建存储虚拟环境的独立目录
cd /var
mkdir -p py_virtual
python3 -m venv env_redash
注意:在py_virtual下生成一个目录 env_redash,下次启动虚拟环境时,进入这个目录,启动
#激活环境
source env_redash/bin/activate#可选,配置进入虚拟环境的快捷命令,在文件末尾增加一行,以后键入to_env_redash可以在任意目录进入虚拟环境
vi /etc/profile
alias to_env_redash='cd /var/py_virtula && source env_redash/bin/activate'
source /etc/profile

安装依赖包

-----------------------

注意:这块会因为网络延迟高反复报timeout错误,我是将反复下载不下来的包,在requirement txt文件进行#号注释,回头下载

requirements.txt 我注释了passlib 、psycopg2-2.8.3,这两个包手工解决,下面有操作。

requirements_all_ds 我只保留了3个package:pymssql, pyhive, mysqlclient:Successfully installed mysqlclient-1.3.14 pyhive-0.6.1 pymssql-2.1.4

如果全部安装会卡住:

Getting requirements to build wheel ...\ 之后无反应,暂时没有定位原因

#配置pip国内镜像,进入用户目录
cd ~
mkdir .pip
cd .pip
vi pip.conf
[global]
trusted-host =  mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple#在虚拟环境安装pip
pip install --upgrade pip
pip install --upgrade setuptools ##看情况安装
#安装redash需要的py环境
python -m pip install -r /var/tools/redash/requirements.txt
python -m pip install -r /var/tools/redash/requirements_dev.txt
python -m pip install -r /var/tools/redash/requirements_all_ds.txt
pip install wheel
pip3 install importlib_resources==1.5
pip3 install redis
yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib
pip install saslpip install thrift
pip install thrift-sasl

编译

npm install --legacy-peer-deps

##将路径切换到redash根目录,否则执行编译安装,会报下面问题;--legacy-peer-deps保证本地package版本与远程版本不一致时,保留本地版本
(env_redash) [root@localhost redash]# npm install --legacy-peer-deps
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /usr/include/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/usr/include/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoentnpm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-01-13T02_02_28_162Z-debug-0.log
解决:运行目录需要在redash根目录上,与package.json在一个位置

查看yarn是否被安装且镜像要设置国内

yarn -v

如果没有安装,参考下面问题解决方式

最终成功的结果输出:(env_redash) [root@localhost redash]# npm install --legacy-peer-deps
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'redash-client@11.0.0-dev',
npm WARN EBADENGINE   required: { node: '^14.16.1', yarn: '^1.22.10' },
npm WARN EBADENGINE   current: { node: 'v18.12.1', npm: '8.19.2' }
npm WARN EBADENGINE }> redash-client@11.0.0-dev preinstall
> cd viz-lib && yarn link --link-folder ../.yarnyarn link v1.22.19
warning There's already a package called "@redash/viz" registered. This command has had no effect. If this command was run in another folder with the same name, the other folder is still linked. Please run yarn unlink in the other folder if you want to register this folder.
Done in 0.05s.> redash-client@11.0.0-dev postinstall
> (cd viz-lib && yarn --frozen-lockfile && yarn build:babel) && yarn link --link-folder ./.yarn @redash/vizyarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > leaflet.markercluster@1.4.1" has incorrect peer dependency "leaflet@~1.3.1".
warning " > react-pivottable@0.9.0" has unmet peer dependency "react@>=15.0.0".
warning " > react-pivottable@0.9.0" has unmet peer dependency "react-dom@>=15.0.0".
warning "react-pivottable > react-sortablejs@1.5.1" has unmet peer dependency "react@>=15.0.0".
warning "react-pivottable > react-sortablejs@1.5.1" has unmet peer dependency "react-dom@>=15.0.0".
warning " > react-sortable-hoc@1.11.0" has unmet peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0".
warning " > react-sortable-hoc@1.11.0" has unmet peer dependency "react-dom@^0.14.0 || ^15.0.0 || ^16.0.0".
warning " > use-debounce@3.4.1" has unmet peer dependency "react@>=16.8.0".
warning " > use-media@1.4.0" has unmet peer dependency "react@^16.8.1".
warning " > enzyme-adapter-react-16@1.15.2" has unmet peer dependency "react@^16.0.0-0".
warning " > enzyme-adapter-react-16@1.15.2" has unmet peer dependency "react-dom@^16.0.0-0".
warning "enzyme-adapter-react-16 > enzyme-adapter-utils@1.13.0" has unmet peer dependency "react@0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0".
warning "enzyme-adapter-react-16 > react-test-renderer@16.13.1" has unmet peer dependency "react@^16.13.1".
warning "enzyme-adapter-react-16 > enzyme-adapter-utils > airbnb-prop-types@2.15.0" has unmet peer dependency "react@^0.14 || ^15.0.0 || ^16.0.0-alpha".
[4/4] Building fresh packages...
Done in 496.78s.
yarn run v1.22.19
$ yarn type-gen && yarn build:babel:base
$ tsc --emitDeclarationOnly
$ babel src --out-dir lib --source-maps --ignore 'src/**/*.test.js' --copy-files --no-copy-ignored --extensions .ts,.tsx,.js,.jsx
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Successfully compiled 169 files with Babel.
Done in 22.88s.
yarn link v1.22.19
success Using linked package for "@redash/viz".
Done in 0.05s.

npm run build

npm run build
##这块遇到一些版本冲突的问题,redash需要的版本14,安装的版本是18,造成失败,解决见下面问题说明##最终成功的输出:
(env_redash) [root@localhost redash]# npm run build> redash-client@11.0.0-dev build
> yarn clean && yarn build:viz && NODE_ENV=production webpackyarn run v1.22.19
$ rm -rf ./client/dist/
Done in 0.07s.
yarn run v1.22.19
$ (cd viz-lib && yarn build:babel)
$ yarn type-gen && yarn build:babel:base
$ tsc --emitDeclarationOnly
$ babel src --out-dir lib --source-maps --ignore 'src/**/*.test.js' --copy-files --no-copy-ignored --extensions .ts,.tsx,.js,.jsx
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Successfully compiled 169 files with Babel.
Done in 20.17s.
Hash: 0e418f37309c0dbd4af0
Version: webpack 4.44.2
Time: 137707ms
Built at: 01/13/2023 12:25:06 AMAsset       Size  Chunks                                Chunk Namesapp.ff07d294a870fae6461f.css    696 KiB       0  [emitted] [immutable]  [big]  appapp.ff07d294a870fae6461f.css.map    860 KiB       0  [emitted] [dev]               appapp.ff07d294a870fae6461f.js    607 KiB       0  [emitted] [immutable]  [big]  appapp.ff07d294a870fae6461f.js.map   1.28 MiB       0  [emitted] [dev]               appasset-manifest.json   10.4 KiB          [emitted]data/0962607.countries.geo.json    383 KiB          [emitted]              [big]data/dac34f3.japan.prefectures.geo.json    567 KiB          [emitted]              [big]data/eed73d1.usa-albers.geo.json    528 KiB          [emitted]              [big]fonts/Material-Design-Iconic-Font.a4d3112.woff2   37.5 KiB          [emitted]fonts/Material-Design-Iconic-Font.b351bd6.ttf   96.9 KiB          [emitted]fonts/Material-Design-Iconic-Font.d2a55d3.woff   49.1 KiB          [emitted]fonts/fontawesome-webfont.674f50d.eot    162 KiB          [emitted]fonts/fontawesome-webfont.af7ae50.woff2   75.4 KiB          [emitted]fonts/fontawesome-webfont.b06871f.ttf    162 KiB          [emitted]fonts/fontawesome-webfont.fee66e7.woff   95.7 KiB          [emitted]fonts/glyphicons-halflings-regular.448c34a.woff2   17.6 KiB          [emitted]fonts/glyphicons-halflings-regular.e18bbf6.ttf   44.3 KiB          [emitted]fonts/glyphicons-halflings-regular.f4769f9.eot   19.7 KiB          [emitted]fonts/glyphicons-halflings-regular.fa27723.woff   22.9 KiB          [emitted]fonts/roboto/Roboto-Bold-webfont.eot   20.5 KiB          [emitted]fonts/roboto/Roboto-Bold-webfont.svg   69.6 KiB          [emitted]fonts/roboto/Roboto-Bold-webfont.ttf     44 KiB          [emitted]fonts/roboto/Roboto-Bold-webfont.woff   24.2 KiB          [emitted]fonts/roboto/Roboto-Light-webfont.eot   20.4 KiB          [emitted]fonts/roboto/Roboto-Light-webfont.svg   72.6 KiB          [emitted]fonts/roboto/Roboto-Light-webfont.ttf   44.8 KiB          [emitted]fonts/roboto/Roboto-Light-webfont.woff     24 KiB          [emitted]fonts/roboto/Roboto-Medium-webfont.eot   20.9 KiB          [emitted]fonts/roboto/Roboto-Medium-webfont.svg   70.1 KiB          [emitted]fonts/roboto/Roboto-Medium-webfont.ttf   44.2 KiB          [emitted]fonts/roboto/Roboto-Medium-webfont.woff   24.5 KiB          [emitted]fonts/roboto/Roboto-Regular-webfont.eot   20.8 KiB          [emitted]fonts/roboto/Roboto-Regular-webfont.svg   71.5 KiB          [emitted]fonts/roboto/Roboto-Regular-webfont.ttf   44.3 KiB          [emitted]fonts/roboto/Roboto-Regular-webfont.woff   24.4 KiB          [emitted]fonts/roboto/Roboto-Thin-webfont.eot   21.2 KiB          [emitted]fonts/roboto/Roboto-Thin-webfont.svg   72.3 KiB          [emitted]fonts/roboto/Roboto-Thin-webfont.ttf   46.6 KiB          [emitted]fonts/roboto/Roboto-Thin-webfont.woff   24.4 KiB          [emitted]images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet-fullscreen/dist/fullscreen.png  299 bytes          [emitted]
images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet-fullscreen/dist/fullscreen@2x.png  420 bytes          [emitted]images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet/dist/images/layers-2x.png   1.23 KiB          [emitted]images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet/dist/images/layers.png  696 bytes          [emitted]images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet/dist/images/marker-icon-2x.png   2.41 KiB          [emitted]images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet/dist/images/marker-icon.png   1.43 KiB          [emitted]images/_/_/_/_/node_modules/@redash/viz/node_modules/leaflet/dist/images/marker-shadow.png  618 bytes          [emitted]images/_/_/_/_/node_modules/bootstrap/fonts/glyphicons-halflings-regular.svg    106 KiB          [emitted]images/_/_/_/_/node_modules/font-awesome/fonts/fontawesome-webfont.svg    434 KiB          [emitted]              [big]images/_/_/redash-font/fonts/redash-icons.svg   2.67 KiB          [emitted]images/avatar.svg   2.09 KiB          [emitted]images/db-logos/Cassandra.png   27.8 KiB          [emitted]images/db-logos/arangodb.png   96.9 KiB          [emitted]images/db-logos/athena.png   12.3 KiB          [emitted]images/db-logos/aws_es.png   8.08 KiB          [emitted]images/db-logos/axibasetsd.png   6.23 KiB          [emitted]images/db-logos/azure_kusto.png   4.95 KiB          [emitted]images/db-logos/bigquery.png   20.2 KiB          [emitted]images/db-logos/bigquery_gce.png   20.2 KiB          [emitted]images/db-logos/clickhouse.png   2.89 KiB          [emitted]images/db-logos/cloudwatch.png   4.08 KiB          [emitted]images/db-logos/cloudwatch_insights.png   4.08 KiB          [emitted]images/db-logos/cockroach.png   15.5 KiB          [emitted]images/db-logos/corporate_memory.png   1.54 KiB          [emitted]images/db-logos/couchbase.png   12.7 KiB          [emitted]images/db-logos/csv.png      6 KiB          [emitted]images/db-logos/databricks.png   2.82 KiB          [emitted]images/db-logos/db2.png   13.1 KiB          [emitted]images/db-logos/dgraph.png   42.3 KiB          [emitted]images/db-logos/drill.png   26.1 KiB          [emitted]images/db-logos/druid.png   11.2 KiB          [emitted]images/db-logos/dynamodb_sql.png   12.3 KiB          [emitted]images/db-logos/elasticsearch.png   16.2 KiB          [emitted]images/db-logos/elasticsearch2.png   16.2 KiB          [emitted]images/db-logos/elasticsearch2_OpenDistroSQLElasticSearch.png   16.2 KiB          [emitted]images/db-logos/elasticsearch2_XPackSQLElasticSearch.png   16.2 KiB          [emitted]images/db-logos/exasol.png   5.35 KiB          [emitted]images/db-logos/excel.png   3.63 KiB          [emitted]images/db-logos/firebolt.png   12.4 KiB          [emitted]images/db-logos/google_analytics.png   14.3 KiB          [emitted]images/db-logos/google_spreadsheets.png   13.4 KiB          [emitted]images/db-logos/graphite.png   21.6 KiB          [emitted]images/db-logos/hive.png   24.6 KiB          [emitted]images/db-logos/hive_http.png   24.6 KiB          [emitted]images/db-logos/impala.png   14.4 KiB          [emitted]images/db-logos/influxdb.png   18.5 KiB          [emitted]images/db-logos/jirajql.png   11.7 KiB          [emitted]images/db-logos/json.png   12.8 KiB          [emitted]images/db-logos/kibana.png   8.87 KiB          [emitted]images/db-logos/kylin.png   23.8 KiB          [emitted]images/db-logos/mapd.png   7.92 KiB          [emitted]images/db-logos/memsql.png   12.1 KiB          [emitted]images/db-logos/mongodb.png   9.08 KiB          [emitted]images/db-logos/mssql.png   23.1 KiB          [emitted]images/db-logos/mssql_odbc.png   23.1 KiB          [emitted]images/db-logos/mysql.png   12.3 KiB          [emitted]images/db-logos/nz.png   1.25 KiB          [emitted]images/db-logos/oracle.png   4.35 KiB          [emitted]images/db-logos/pg.png   25.2 KiB          [emitted]images/db-logos/phoenix.png   20.3 KiB          [emitted]images/db-logos/pinot.png     29 KiB          [emitted]images/db-logos/presto.png   13.5 KiB          [emitted]images/db-logos/prometheus.png   15.2 KiB          [emitted]images/db-logos/python.png   19.1 KiB          [emitted]images/db-logos/qubole.png   2.37 KiB          [emitted]images/db-logos/rds_mysql.png   13.5 KiB          [emitted]images/db-logos/redshift.png   6.01 KiB          [emitted]images/db-logos/redshift_iam.png   6.01 KiB          [emitted]images/db-logos/results.png   12.8 KiB          [emitted]images/db-logos/rockset.png   6.61 KiB          [emitted]images/db-logos/salesforce.png   18.2 KiB          [emitted]images/db-logos/scylla.png   22.7 KiB          [emitted]images/db-logos/snowflake.png   18.5 KiB          [emitted]images/db-logos/sparql_endpoint.png     31 KiB          [emitted]images/db-logos/sqlite.png   13.7 KiB          [emitted]images/db-logos/treasuredata.png   14.6 KiB          [emitted]images/db-logos/trino.png   23.2 KiB          [emitted]images/db-logos/uptycs.png   2.57 KiB          [emitted]images/db-logos/url.png   8.36 KiB          [emitted]images/db-logos/vertica.png   6.36 KiB          [emitted]images/db-logos/yandex_appmetrika.png   1.42 KiB          [emitted]images/db-logos/yandex_metrika.png  824 bytes          [emitted]images/destinations/chatwork.png   11.3 KiB          [emitted]images/destinations/email.png   6.14 KiB          [emitted]images/destinations/hangouts_chat.png   9.29 KiB          [emitted]images/destinations/hipchat.png   11.5 KiB          [emitted]images/destinations/mattermost.png     12 KiB          [emitted]images/destinations/microsoft_teams_webhook.png   4.11 KiB          [emitted]images/destinations/pagerduty.png   8.21 KiB          [emitted]images/destinations/slack.png   6.71 KiB          [emitted]images/destinations/webhook.png   11.9 KiB          [emitted]images/favicon-16x16.png   1.33 KiB          [emitted]images/favicon-32x32.png   1.96 KiB          [emitted]images/favicon-96x96.png   3.82 KiB          [emitted]images/fixtures/map-tile.png   5.32 KiB          [emitted]images/google_logo.svg  688 bytes          [emitted]images/illustrations/alert.svg   70.5 KiB          [emitted]images/illustrations/dashboard.svg    137 KiB          [emitted]images/illustrations/no-query-results.svg   1.56 KiB          [emitted]images/illustrations/query.svg     68 KiB          [emitted]images/logo.png   32.8 KiB          [emitted]images/logo_white.png   33.3 KiB          [emitted]images/redash_icon_small.png   5.97 KiB          [emitted]index.html   1.47 KiB          [emitted]multi_org.html    1.4 KiB          [emitted]robots.txt   31 bytes          [emitted]server.f5927c7d1e72ad202352.css    182 KiB       1  [emitted] [immutable]         serverserver.f5927c7d1e72ad202352.css.map    231 KiB       1  [emitted] [dev]               serverserver.f5927c7d1e72ad202352.js   1.02 KiB       1  [emitted] [immutable]         serverserver.f5927c7d1e72ad202352.js.map   4.55 KiB       1  [emitted] [dev]               serverstyles/login.css   1.01 KiB          [emitted]unsupported.html    1.5 KiB          [emitted]unsupportedRedirect.js  155 bytes          [emitted]vendors~app.417d1435f1002cd83105.css   75.7 KiB       2  [emitted] [immutable]         vendors~appvendors~app.417d1435f1002cd83105.css.map    103 KiB       2  [emitted] [dev]               vendors~appvendors~app.417d1435f1002cd83105.js   3.82 MiB       2  [emitted] [immutable]  [big]  vendors~appvendors~app.417d1435f1002cd83105.js.map     16 MiB       2  [emitted] [dev]               vendors~app
Entrypoint app [big] = vendors~app.417d1435f1002cd83105.css vendors~app.417d1435f1002cd83105.js vendors~app.417d1435f1002cd83105.css.map vendors~app.417d1435f1002cd83105.js.map app.ff07d294a870fae6461f.css app.ff07d294a870fae6461f.js app.ff07d294a870fae6461f.css.map app.ff07d294a870fae6461f.js.map
Entrypoint server = server.f5927c7d1e72ad202352.css server.f5927c7d1e72ad202352.js server.f5927c7d1e72ad202352.css.map server.f5927c7d1e72ad202352.js.map

配置

前端这边不得不提一点,redash 项目前后端分离。中间依托了前端 node 的一个叫 dev-server 的服务器用于转发前后端请求。所以当我们在访问 redash 的时候其实请求会先打到 node 服务器那边然后再由 node 的服务器进行转发到后端 flask 服务器。

这里因为我只打算在入口的位置来配置 nginx 服务器,并不打算在 redash 服务器这边再用 nginx 转发一下。所以这里我需要配置 redash 的 node 服务器去监听 0.0.0.0 所有范围的8080 端口。8080端口是默认的所以我修改了 node 里面的 webpack.config.js 配置指定让 devServer 监听 0.0.0.0 地址。

服务器端部分其实有很多值得注意的地方。首先 readsh 给我们的默认配置是默认我们刚才将那些组件都安装在了同一台机器上面,否则你就必须面临一个重新配置相关配置参数的局面。好在 redash 将配置文件的修改放在了还算清晰的地方。

如果你没有在代码里面添加 .env 文件,所有后端服务启动的时候会默认去读取环境变量中的配置。如果环境变量里面没有配置相关的参数,那么将会直接使用所有参数的默认值加载。

redash 的配置写在 -> redash/redash/settings/__init__.py 中,这里囊括了所有的配置。如果使用环境变量的配置要到这里来这里参考 key 的名称。

redash目录:/var/tools/redash

webpack.config.js

#localhost改成127.0.0.1,linux会把localhost解析成ipv6,导致前端请求在后台代理转发时,找不到ip
const redashBackend = process.env.REDASH_BACKEND || "http://127.0.0.1:5000";
devServer: {
##增加hosthost: '0.0.0.0',
... ...proxy: [{context: ["/login","/logout","/invite","/setup","/status.json","/api","/oauth"],target: redashBackend + "/",changeOrigin: true,##################################false 改成truesecure: false},{context: path => {// CSS/JS for server-rendered pages should be served from backendreturn /^\/static\/[a-z]+\.[0-9a-fA-F]+\.(css|js)$/.test(path);},target: redashBackend + "/",changeOrigin: true,secure: false}

package.json

在start 行末尾增加 --disableHostCheck=true,在后续启动node运行npm run start时,会运行这段代码

"scripts": {"start": "npm-run-all --parallel watch:viz webpack-dev-server --disableHostCheck=true",

redash/settings/__init__.py

配置redis地址:我是本地redis,不用动

_REDIS_URL = os.environ.get("REDASH_REDIS_URL", os.environ.get("REDIS_URL", "redis://localhost:6379/0")
)

配置redash数据库地址:指向postgres地址

SQLALCHEMY_DATABASE_URI = os.environ.get("REDASH_DATABASE_URL", os.environ.get("DATABASE_URL", "postgresql://用户名:密码@192.168.16.43/数据库")
)

配置加密key,key值随机生成

 python -c 'import secrets; print(secrets.token_hex())'结果输出:
#用于设置REDASH_COOKIE_SECRET
(env_redash) [root@localhost redash]# python -c 'import secrets; print(secrets.token_hex())'
1d651e7057be0307a9ef8527c19ffec18f22de2ab5fdf2a71ff5ceda79abfec0
#用于设置REDASH_SECRET_KEY
(env_redash) [root@localhost redash]# python -c 'import secrets; print(secrets.token_hex())'
3fb8928e0314191a9177097d6578e6276159e9b267a4dca108dc550a6f89654f
SECRET_KEY = os.environ.get("REDASH_COOKIE_SECRET","1d651e7057be0307a9ef8527c19ffec18f22de2ab5fdf2a71ff5ceda79abfec0")

新建.env文件

在redash根目录下建环境文件.env,REDASH_COOKIE_SECRET和REDASH_SECRET_KEY与__init__.py一致

NUNBUFFERED="0"
REDASH_LOG_LEVEL="INFO"
REDASH_REDIS_URL="redis://localhost:6379/0"
POSTGRES_PASSWORD="Gao****2"
REDASH_COOKIE_SECRET="1d651e7057be0307a9ef8527c19ffec18f22de2ab5fdf2a71ff5ceda79abfec0"
REDASH_SECRET_KEY="3fb8928e0314191a9177097d6578e6276159e9b267a4dca108dc550a6f89654f"
REDASH_DATABASE_URL="postgresql://postgres:Gao****2@192.168.85.131:5432/postgres"
REDASH_BACKEND="http://127.0.0.1:5000"

检查

bin/run ./manage.py check-settings

初始化数据库

#修改python报警忽略
vi /var/py_virtual/env_redash/lib64/python3.6/site-packages/psycopg2/__init__.py
增加下面内容:
# This is a wheel package: issue a warning on import
import warnings
warnings.filterwarnings("ignore")#初始化
bin/run ./manage.py database create-tables
输出结果:
(env_redash) [root@localhost redash]# bin/run ./manage.py database create-tables
NUNBUFFERED="0"
export REDASH_LOG_LEVEL="INFO"
export REDASH_REDIS_URL="redis://localhost:6379/0"
POSTGRES_PASSWORD="Gao6584802"
export REDASH_COOKIE_SECRET="1d651e7057be0307a9ef8527c19ffec18f22de2ab5fdf2a71ff5ceda79abfec0"
export REDASH_SECRET_KEY="3fb8928e0314191a9177097d6578e6276159e9b267a4dca108dc550a6f89654f"
export REDASH_DATABASE_URL="postgresql://postgres:Gao6584802@192.168.85.131:5432/postgres"[2023-01-15 13:11:05,819][PID:833507][INFO][alembic.runtime.migration] Context impl PostgresqlImpl.
[2023-01-15 13:11:05,820][PID:833507][INFO][alembic.runtime.migration] Will assume transactional DDL.
[2023-01-15 13:11:05,842][PID:833507][INFO][alembic.runtime.migration] Running stamp_revision  -> fd4fc850d7ea
注:12-19行是我修改了bin/run 文件的代码,打印临时文件内容cat $TEMP_ENV_FILE输出的;
#查看初始化结果
(env_redash) [root@localhost log]# psql -h192.168.85.131 -Upostgres
postgres=# \dtList of relationsSchema |           Name            | Type  |  Owner
--------+---------------------------+-------+----------public | access_permissions        | table | postgrespublic | alembic_version           | table | postgrespublic | alert_subscriptions       | table | postgrespublic | alerts                    | table | postgrespublic | api_keys                  | table | postgrespublic | changes                   | table | postgrespublic | dashboards                | table | postgrespublic | data_source_groups        | table | postgrespublic | data_sources              | table | postgrespublic | events                    | table | postgrespublic | favorites                 | table | postgrespublic | groups                    | table | postgrespublic | notification_destinations | table | postgrespublic | organizations             | table | postgrespublic | queries                   | table | postgrespublic | query_results             | table | postgrespublic | query_snippets            | table | postgrespublic | users                     | table | postgrespublic | visualizations            | table | postgrespublic | widgets                   | table | postgres
(20 rows)

6.启动

前端node server

npm run start
或
nohup npm run start </dev/null >out.log 2>&1 &

后端flask server

./manage.py runserver --debugger --reload
或
#加载.env 环境变量
bin/run ./manage.py runserver --debugger --reload

启动worker

./manage.py rq worker

启动schedule

./manage.py rq scheduler

参考

关键目录

pip

/root/.pip

/root/.pip/pip.conf

postgres

/var/lib/pgsql/15/

/var/lib/pgsql/15/data/postgresql.conf

/var/lib/pgsql/15/data/log

redash

/var/tools/redash

/var/tools/redash/redash/settting/__init__.py

参考文章:

Redis & 集群安装 https://zhuanlan.zhihu.com/p/57633787

python虚拟环境-virtualenv https://www.cnblogs.com/tian777/p/14946388.html

Python 扫盲https://blog.csdn.net/qxqxqzzz/article/details/47665553

Python.h: No such file or directory https://blog.csdn.net/tx1991427/article/details/126136676

Package.json 说明:https://blog.csdn.net/weixin_45626517/article/details/122820735

疑难问题:

Preparing metadata (setup.py) ... errorERROR: Command errored out with exit status 1:command: /var/tools/redash/redash-env/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ksb24he6/psycopg2_7bf87a09be7a46568623e974eaa10882/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ksb24he6/psycopg2_7bf87a09be7a46568623e974eaa10882/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-7lwoazqxcwd: /tmp/pip-install-ksb24he6/psycopg2_7bf87a09be7a46568623e974eaa10882/Complete output (23 lines):running egg_infocreating /tmp/pip-pip-egg-info-7lwoazqx/psycopg2.egg-infowriting /tmp/pip-pip-egg-info-7lwoazqx/psycopg2.egg-info/PKG-INFOwriting dependency_links to /tmp/pip-pip-egg-info-7lwoazqx/psycopg2.egg-info/dependency_links.txtwriting top-level names to /tmp/pip-pip-egg-info-7lwoazqx/psycopg2.egg-info/top_level.txtwriting manifest file '/tmp/pip-pip-egg-info-7lwoazqx/psycopg2.egg-info/SOURCES.txt'Error: pg_config executable not found.pg_config is required to build psycopg2 from source.  Please add the directorycontaining pg_config to the $PATH or specify the full executable path with theoption: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>).----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz#sha256=897a6e838319b4bf648a574afb6cabcb17d0488f8c7195100d48d872419f4457 (from https://pypi.org/simple/psycopg2/) (requires-python:>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement psycopg2==2.8.3 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3, 2.9.4, 2.9.5)
ERROR: No matching distribution found for psycopg2==2.8.3

解决:

vi /etc/profile, 修改path

python -m pip install -r /var/tools/redash/requirements.txt,python下载文件后,setup时报错

fatal error: Python.h: No such file or directory
解决:
sudo yum install python3-devel

python -m pip install -r /var/tools/redash/requirements_all_ds.txt 时报错

/bin/sh: mysql_config: command not found
解决:
sudo yum install mysql-devel

输出结果:
... ...
(16/16): openssl-devel-1.1.1k-7.el8.x86_64.rpm 2.1 MB/s | 2.3 MB 00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.8 MB/s | 6.2 MB 00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : zlib-devel-1.2.11-20.el8.x86_64 1/16
Installing : pcre2-utf32-10.32-3.el8.x86_64 2/16
Installing : pcre2-utf16-10.32-3.el8.x86_64 3/16
Installing : pcre2-devel-10.32-3.el8.x86_64 4/16
Installing : libverto-devel-0.3.2-2.el8.x86_64 5/16
Installing : libsepol-devel-2.9-3.el8.x86_64 6/16
Installing : libselinux-devel-2.9-6.el8.x86_64 7/16
Installing : libkadm5-1.18.2-21.el8.x86_64 8/16
Installing : libcom_err-devel-1.45.6-5.el8.x86_64 9/16
Installing : keyutils-libs-devel-1.5.10-9.el8.x86_64 10/16
Installing : krb5-devel-1.18.2-21.el8.x86_64 11/16
Installing : openssl-devel-1:1.1.1k-7.el8.x86_64 12/16
Installing : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 13/16
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
Installing : mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64 14/16
Installing : mysql-libs-8.0.26-1.module_el8.4.0+915+de215114.x86_64 15/16
Installing : mysql-devel-8.0.26-1.module_el8.4.0+915+de215114.x86_64 16/16
Running scriptlet: mysql-devel-8.0.26-1.module_el8.4.0+915+de215114.x86_64 16/16
Verifying : mariadb-connector-c-config-3.1.11-2.el8_3.noarch 1/16
Verifying : mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64 2/16
Verifying : mysql-devel-8.0.26-1.module_el8.4.0+915+de215114.x86_64 3/16
Verifying : mysql-libs-8.0.26-1.module_el8.4.0+915+de215114.x86_64 4/16
Verifying : keyutils-libs-devel-1.5.10-9.el8.x86_64 5/16
Verifying : krb5-devel-1.18.2-21.el8.x86_64 6/16
Verifying : libcom_err-devel-1.45.6-5.el8.x86_64 7/16
Verifying : libkadm5-1.18.2-21.el8.x86_64 8/16
Verifying : libselinux-devel-2.9-6.el8.x86_64 9/16
Verifying : libsepol-devel-2.9-3.el8.x86_64 10/16
Verifying : libverto-devel-0.3.2-2.el8.x86_64 11/16
Verifying : openssl-devel-1:1.1.1k-7.el8.x86_64 12/16
Verifying : pcre2-devel-10.32-3.el8.x86_64 13/16
Verifying : pcre2-utf16-10.32-3.el8.x86_64 14/16
Verifying : pcre2-utf32-10.32-3.el8.x86_64 15/16
Verifying : zlib-devel-1.2.11-20.el8.x86_64 16/16
Installed:
keyutils-libs-devel-1.5.10-9.el8.x86_64 krb5-devel-1.18.2-21.el8.x86_64 libcom_err-devel-1.45.6-5.el8.x86_64
libkadm5-1.18.2-21.el8.x86_64 libselinux-devel-2.9-6.el8.x86_64 libsepol-devel-2.9-3.el8.x86_64
libverto-devel-0.3.2-2.el8.x86_64 mariadb-connector-c-config-3.1.11-2.el8_3.noarch mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64
mysql-devel-8.0.26-1.module_el8.4.0+915+de215114.x86_64 mysql-libs-8.0.26-1.module_el8.4.0+915+de215114.x86_64 openssl-devel-1:1.1.1k-7.el8.x86_64
pcre2-devel-10.32-3.el8.x86_64 pcre2-utf16-10.32-3.el8.x86_64 pcre2-utf32-10.32-3.el8.x86_64
zlib-devel-1.2.11-20.el8.x86_64

问题:npm ERR! Could not resolve dependency:

解决方法:增加参数 --legacy-peer-deps,重新安装

npm install --legacy-peer-deps

(env_redash) [root@localhost redash]# npm install
npm notice
npm notice New major version of npm available! 8.19.2 -> 9.3.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.3.0
npm notice Run npm install -g npm@9.3.0npm notice Run npm install -g npm@9.3.0 to update!
npm notice
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: redash-client@11.0.0-dev
npm ERR! Found: axios@0.21.1
npm ERR! node_modules/axios
npm ERR! axios@"^0.21.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer axios@"~0.18.0 || ~0.19.1 || ~0.20.0" from axios-auth-refresh@3.0.0
npm ERR! node_modules/axios-auth-refresh
npm ERR! axios-auth-refresh@"^3.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-01-13T02_14_59_204Z-debug-0.log

问题:npm ERR! command git --no-replace-objects ls-remot

npm ERR! git@github.com: Permission denied (publickey).

解决:

此时!!!需要有一个github上的账号(我用我的跟人帐号登录)官网:https://github.com/

首先,在命令行创建公密钥,一路回车即可

ssh-keygen -t rsa
cat /root/.ssh/id_rsa.pub    #公钥,将以下内容加入 github 的 key

然后,登录https://github.com/,界面选择Settings --> SSH and GPG keys -->new SSH keys;

Title填入:自定义名称 和 Key填入:你虚拟机上的 /root/.ssh/id_rsa.pub 的公钥内容;保存即可。

code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.comnpm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/getredash/sql-formatter.git
npm ERR! Warning: Permanently added 'github.comnpm ERR! Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.

问题: idealTree:redash: sill idealTree buildDeps 卡住

分析:在用户根目录下的.npm/__catch__存在,清楚后重试

npm cache clean --force

问题:sh: yarn: command not found

npm ERR! command sh -c -- cd viz-lib && yarn link --link-folder ../.yarn

分析:没有安装yarn

解决:

wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
yum -y install yarn
yarn -v (env_redash) [root@localhost yum.repos.d]# yarn -v
1.22.19

问题:

An unexpected error occurred: "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz: connect ECONNREFUSED 104.16.25.35:443

解决:

yarn config set registry http://registry.npm.taobao.org/

yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz:error An unexpected error occurred: "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz: connect ECONNREFUSED 104.16.25.35:443".
info If you think this is a bug, please open a bug report with the information provided in "/var/tools/redash/viz-lib/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
npm ERR! code 1
npm ERR! path /var/tools/redash
npm ERR! command failed
npm ERR! command sh -c -- (cd viz-lib && yarn --frozen-lockfile && yarn build:babel) && yarn link --link-folder ./.yarn @redash/viz
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-01-13T04_31_07_103Z-debug-0.log

问题:

error redash-client@11.0.0-dev: The engine "node" is incompatible with this module. Expected version "^14.16.1"

... ..

error:0308010C:digital envelope routines::unsupported

分析:当前安装的node版本是18,产生版本冲突,因为 node.js V17版本中最近发布的OpenSSL3.0, 而OpenSSL3.0对允许算法和密钥大小增加了严格的限制

参考https://www.pudn.com/news/633d4b902aaf6043c9ecf2a2.html

解决1:不卸载当前版本,增加设置,我选的方法

yarn config set ignore-engines true#临时设置:
export NODE_OPTIONS=--openssl-legacy-provider
#永久设置:
vi /etc/profile
export NODE_OPTIONS="--openssl-legacy-provider"
source /etc/profile

解决2:重装14.x或16.x,没有实测过

root帐号运行:

curl -fsSL https://rpm.nodesource.com/setup_16.x | sudo bash -

curl -fsSL https://rpm.nodesource.com/setup_14.x | bash -

问题:运行 bin/run ./manage.py check-settings,

报错误:ModuleNotFoundError: No module named 'pystache'

ModuleNotFoundError: No module named 'passlib'

分析:在配置python虚拟环境时,安装requirement.txt引用的包时,注释了pystache,passlib

解决:安装

pip install pystache==0.5.4

pip install passlib==1.7.1

问题:安装pystache,error in pystache setup command: use_2to3 is invalid.

分析:

后面看这个项目的描述,原来是一个中文分词的库,一开始是用C++写的并提供给Ruby用的,后面作者又写了python的接口,不过支持的版本一直在python 2.5+,于是在python3的版本进行安装的时候,会在setuptools里的setup函数里增加一个use_2to3=True的参数进行转换。

但是setuptools>=58的版本是不支持这个参数了(黑人问号),于是需要把版本降低,小于58的最后一个版本是57.5.0,pip降一下就可以了

解决:

pip install setuptools==57.5.0
pip install pystache==0.5.4

问题:/var/py_virtual/env_redash/lib64/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.

解决:

pip install psycopg2-binary==2.8.3

问题:[HPM] Error occurred while trying to proxy request /login?next=/ from 192.168.85.131:8080 to http://localhost:5000/ (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)

分析:这个问题困扰我整整两天时间

原因是就是前端请求与后端服务监听的IP地址不一致,造成前端请求无法发送到争取的IP地址和端口。

npm run start启动之后,初始化的proxy target地址是localhost:5000

#webpack.config.js
const redashBackend = process.env.REDASH_BACKEND || "http://localhost:5000";
这里的localhost在执行npm run start时,被初始化
如下面日志
......
$ babel src --out-dir lib --source-maps --ignore 'src/**/*.test.js' --copy-files --no-copy-ignored --extensions .ts,.tsx,.js,.jsx --watch
[HPM] Proxy created: ['/login','/logout','/invite','/setup','/status.json','/api','/oauth'
]  ->  http://localhost:5000/
[HPM] Proxy created: [Function: context]  ->  http://localhost:5000/
... ...目前发现,这个localhost只能通过2行的位置设置,设置环境变量.env中的REDASH_BACKEND,不起作用,原因待调查。

在webpack runserver 时日志如下:

bin/run ./manage.py runserver --debugger --reload

(env_redash) [root@localhost redash]# bin/run ./manage.py runserver --debugger --reload
NUNBUFFERED="0"
export REDASH_LOG_LEVEL="INFO"
export REDASH_REDIS_URL="redis://localhost:6379/0"
POSTGRES_PASSWORD="Gao6584802"
export REDASH_COOKIE_SECRET="1d651e7057be0307a9ef8527c19ffec18f22de2ab5fdf2a71ff5ceda79abfec0"
export REDASH_SECRET_KEY="3fb8928e0314191a9177097d6578e6276159e9b267a4dca108dc550a6f89654f"
export REDASH_DATABASE_URL="postgresql://postgres:Gao6584802@192.168.85.131:5432/postgres"
export REDASH_BACKEND="http://192.168.85.131:5000"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
[2023-01-15 19:17:13,289][PID:7314][INFO][werkzeug] * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2023-01-15 19:17:13,300][PID:7314][INFO][werkzeug] * Restarting with inotify reloader
[2023-01-15 19:17:15,178][PID:7324][WARNING][werkzeug] * Debugger is active!
[2023-01-15 19:17:15,178][PID:7324][INFO][werkzeug] * Debugger PIN: 284-487-444

日志中 http://127.0.0.1:5000/ 为后端请求的地址,启动后,创建两个进程:一个服务进程,一个debugger进程

netstat -tlunp  #查看接口占用
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      853/postmaster
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN      7324/python
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      3089/redis-server *
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      845/sshd
tcp6       0      0 :::5432                 :::*                    LISTEN      853/postmaster
tcp6       0      0 :::6379                 :::*                    LISTEN      3089/redis-server *
tcp6       0      0 :::22                   :::*                    LISTEN      845/sshd
udp        0      0 0.0.0.0:36241           0.0.0.0:*                           5429/python
udp        0      0 127.0.0.1:323           0.0.0.0:*                           831/chronyd
udp        0      0 0.0.0.0:42587           0.0.0.0:*                           5388/python
udp6       0      0 ::1:323                 :::*                                831/chronyd
ps aux #查看具体执行进程号对应的命令
root        7324  2.7  1.7 1169436 138972 pts/3  Sl   19:17   0:15 /var/py_virtual/env_redash/bin/python /var/tools/redash/manage.py runserver --debugger --reload

从信息可以看出,服务监听的地址127.0.0.1 ,端口5000;而前端请求的地址是localhost,端口5000,但是linux解析localhost成IPV6,而不是127.0.0.1。造成前后端无法对齐。

解决:

  1. 修改webpack.config.js

const redashBackend = process.env.REDASH_BACKEND || "http://127.0.0.1:5000";

  1. .杀掉服务端进程包括8080端口、5000端口,然后重新运行npm run start,这时查看日志,地址已经改成127.0.0.1;

  1. 重新运行

bin/run ./manage.py runserver --debugger --reload

  1. 去浏览器请求8080端口,请求被正确转发。但这时因为没有登录,页面跳转到127.0.0.1:5000/setup.因为我在另外ip地址访问,造成页面出错

  1. 修改127.0.0.1 为192.168.85.131,顺利进入setup页面,问题解决

  1. 下面贴一张我在配置开发环境调通后的界面:username:407097480@qq.com;pass:redash

redash 在CentOS8环境部署(非docker)相关推荐

  1. openGauss 学习环境部署(docker方式),并使用dbeaver进行连接

    1.下载opengauss docker镜像 //搜索opengauss镜像源. [root@mongodb ~]# docker search opengauss INDEX NAME DESCRI ...

  2. Jeepay开源聚合支付系统生产环境部署

    文章目录 环境准备 服务端部署 前端部署 Nginx配置 测试账号 介绍Jeepay支付系统云服务环境部署(Docker等其他部署方式,后续推出),以下部署是在阿里云4核8G服务器部署,其他环境安装仅 ...

  3. Atlas 200 DK开发者套件环境部署(1.0.9.alpha)极简版

    Atlas 200 DK开发者套件环境部署(1.0.9.alpha)极简版 前言 Atlas 200 DK开发者套件介绍 环境部署介绍 资源要求 开发环境部署 安装Docker 获取镜像(两种方法任选 ...

  4. Docker selenium自动化 - Python调用容器实例跑自动化查天气实例演示,docker selenium自动化环境部署过程

    Docker selenium自动化 - 环境部署与 Python 自动化运行实战演示 第一章:docker selenium 环境部署 ① 下载 selenium 镜像 ② 容器 selenium ...

  5. linux查看docker使用率,Linux系统非Docker环境如何限制CPU使用率

    微服务时代,有时候为了方便,经常在一台高配置服务器运行很多服务,这个时候CPU资源抢占就成了一个非常头痛的问题.闲时不会出现什么问题,比如一台16核服务器,当某一个时刻某个微服出现高并发访问时,此服务 ...

  6. RocketMQ部署安装(非Docker安装)

    1.下载 下载地址:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.3.2/rocketmq-all-4.3.2-bin-release.z ...

  7. 20分钟完成Mac上的 LNMP 环境部署,优雅·高效开发(Docker方式)

    一.前言 对于很多开发者来说,突然转到在 mac 系统开发,可能会非常难受,主要有以下几个原因 1.mac 上安装软件程序坑多,比如安装 PHP.Nginx,会存在很多使用 linux 或 windo ...

  8. Rasa 3.x 学习系列- 内网环境部署Docker及Rasa duckling、Redis

    Rasa 3.x 学习系列- 内网环境部署Docker及Rasa duckling.Redis 在单位内网 centos 7.9 Linux 环境里面安装Docker及Rasa duckling.Re ...

  9. Linux环境打包Qt程序并部署到Docker容器

    Linux环境打包Qt程序并部署到Docker容器 根据项目需要,将UKylin版本的qt应用程序打包并且部署到docker容器中 系统版本 UKylin版本:Ubuntu18.04 Docker镜像 ...

最新文章

  1. pandas dataframe column_Python数据分析——Pandas 教程(下)
  2. java读取json数据并解析输出对象
  3. 【STM32】GPIO之蜂鸣器
  4. java 常见错误_Java常见错误的十大列表(前100名!)
  5. java request获取域,Java Web - Servlet(13)HttpServletRequest详解(获取请求数据、请求分派、请求域)(二)...
  6. 电影推荐之《白鹿原》 隐私策略(Privacy policy)
  7. 计算机组成原理实验二八位寄存器,计算机组成原理课后参考答案
  8. 富士通笔记本最新系统恢复方法——系统工具恢复
  9. 如何通俗地理解协方差和相关系数?
  10. 计算机组成原理实验——实验1 运算器实验
  11. java粒子特效_Java学习之粒子系统
  12. 高效能管理之要事第一 时间管理表格
  13. 华尔街见闻下操作mysql_GitHub - boshengw-shzq/reainl: 华尔街见闻和新浪财经新闻采集...
  14. 论5G无线射频芯片CB5746LP
  15. 几个好用Maven 镜像仓库地址
  16. 数学---之法线方程以及斜率
  17. 图解SQL面试题:多表如何查询?
  18. 金融时间序列分析:4. AR自回归模型
  19. 【王道】计算机组成原理第一章计算机系统概述(一)
  20. 200. Number of Islands**(岛屿数量)

热门文章

  1. 【代码片段】获取分辨率DPI和像素、毫米、英寸互相转换
  2. ROC曲线及如何计算AUC
  3. Python基础(三)_函数和代码复用
  4. 【HAL】stm32F103+TJA1050+USBCAN CAN数据收发
  5. 关于Python去掉字符串中的空格
  6. S50非接触式IC卡性能简介(M1)
  7. 从高级程序员到 CTO 的 4 次能力跃迁!
  8. 蒸压加气混凝土砌块荷载系数1.4取值依据
  9. python:函数中五花八门的参数形式(茴香豆的『回』字有四种写法)
  10. 欧格教育:拼多多搜索排名的算法是怎么样