线上问诊:业务数据采集
线上问诊:数仓数据同步
线上问诊:数仓开发(一)
线上问诊:数仓开发(二)
线上问诊:数仓开发(三)
线上问诊:可视化展示
这次博客我们就可以完成线上问诊的离线数仓项目。
正常应该使用DolphinScheduler进行全流程调度,但是由于博主的电脑硬件的极限。所以为了完成整个项目,我们自己写一个bash脚本,来进行流程调度
vim /opt/module/maxwell/config.properties
medical_mock.sh 1
在数据库中查看是否出现10号数据。
这个脚本是我自己写的,项目中原本没有
vim ~/bin/medical_run.sh
#!/bin/bash
/bin/bash /home/atguigu/bin/medical_mysql_to_hdfs_full.sh all $1
/bin/bash /home/atguigu/bin/medical_hdfs_to_ods.sh all $1
/bin/bash /home/atguigu/bin/medical_ods_to_dwd.sh all $1
/bin/bash /home/atguigu/bin/medical_ods_to_dim.sh all $1
/bin/bash /home/atguigu/bin/medical_dwd_to_dws_1d.sh all $1
/bin/bash /home/atguigu/bin/medical_dws_1d_to_dws_nd.sh all $1
/bin/bash /home/atguigu/bin/medical_dws_1d_to_dws_td.sh all $1
/bin/bash /home/atguigu/bin/medical_dws_to_ads.sh all $1
/bin/bash /home/atguigu/bin/medical_hdfs_to_mysql.sh all
添加权限
chmod +x ~/bin/medical_run.sh
先打开之前创建的所有通道
myhadoop.sh start
zk.sh start
kf.sh start
mxw.sh start
medical-f1.sh start
hiveservices.sh start
medical_run.sh 2023-05-10
当数据库中出现10号,代表成功。
这里我们就不需要通道了,如果硬件不太够,可以把通道关闭。
minconda3清华源
bash Miniconda3-latest-Linux-x86_64.sh
安装地址修改一下。
/opt/module/miniconda3
激活环境
source ~/.bashrc
取消默认激活base
conda config --set auto_activate_base false
换源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --set show_channel_urls yes
conda create --name superset python=3.8.16
激活环境
conda activate superset
sudo yum install -y gcc gcc-c++ libffi-devel python-devel python-pip python-wheel python-setuptools openssl-devel cyrus-sasl-devel openldap-devel
编写一个base.txt文件
vim base.txt
aiohttp==3.8.1
# via slackclient
aiosignal==1.2.0
# via aiohttp
alembic==1.6.5
# via flask-migrate
amqp==5.1.0
# via kombu
apispec[yaml]==3.3.2
# via flask-appbuilder
async-timeout==4.0.2
# via aiohttp
attrs==21.2.0
# via
# aiohttp
# jsonschema
babel==2.9.1
# via flask-babel
backoff==1.11.1
# via apache-superset
billiard==3.6.4.0
# via celery
bleach==3.3.1
# via apache-superset
brotli==1.0.9
# via flask-compress
cachelib==0.4.1
# via apache-superset
celery==5.2.2
# via apache-superset
cffi==1.14.6
# via cryptography
charset-normalizer==2.0.4
# via aiohttp
click==8.0.4
# via
# apache-superset
# celery
# click-didyoumean
# click-plugins
# click-repl
# flask
# flask-appbuilder
click-didyoumean==0.3.0
# via celery
click-plugins==1.1.1
# via celery
click-repl==0.2.0
# via celery
colorama==0.4.4
# via
# apache-superset
# flask-appbuilder
convertdate==2.3.2
# via holidays
cron-descriptor==1.2.24
# via apache-superset
croniter==1.0.15
# via apache-superset
cryptography==3.4.7
# via apache-superset
deprecation==2.1.0
# via apache-superset
dnspython==2.1.0
# via email-validator
email-validator==1.1.3
# via flask-appbuilder
flask==2.0.3
# via
# apache-superset
# flask-appbuilder
# flask-babel
# flask-caching
# flask-compress
# flask-jwt-extended
# flask-login
# flask-migrate
# flask-sqlalchemy
# flask-wtf
flask-appbuilder==4.1.3
# via apache-superset
flask-babel==1.0.0
# via flask-appbuilder
flask-caching==1.10.1
# via apache-superset
flask-compress==1.10.1
# via apache-superset
flask-jwt-extended==4.3.1
# via flask-appbuilder
flask-login==0.4.1
# via flask-appbuilder
flask-migrate==3.1.0
# via apache-superset
flask-sqlalchemy==2.5.1
# via
# flask-appbuilder
# flask-migrate
flask-talisman==0.8.1
# via apache-superset
flask-wtf==0.14.3
# via
# apache-superset
# flask-appbuilder
frozenlist==1.3.0
# via
# aiohttp
# aiosignal
func-timeout==4.3.5
# via apache-superset
geographiclib==1.52
# via geopy
geopy==2.2.0
# via apache-superset
graphlib-backport==1.0.3
# via apache-superset
gunicorn==20.1.0
# via apache-superset
hashids==1.3.1
# via apache-superset
holidays==0.10.3
# via apache-superset
humanize==3.11.0
# via apache-superset
idna==3.2
# via
# email-validator
# yarl
isodate==0.6.0
# via apache-superset
itsdangerous==2.1.1
# via
# flask
# flask-wtf
jinja2==3.0.3
# via
# flask
# flask-babel
jsonschema==3.2.0
# via flask-appbuilder
kombu==5.2.4
# via celery
korean-lunar-calendar==0.2.1
# via holidays
mako==1.1.4
# via alembic
markdown==3.3.4
# via apache-superset
markupsafe==2.0.1
# via
# jinja2
# mako
# wtforms
marshmallow==3.13.0
# via
# flask-appbuilder
# marshmallow-enum
# marshmallow-sqlalchemy
marshmallow-enum==1.5.1
# via flask-appbuilder
marshmallow-sqlalchemy==0.23.1
# via flask-appbuilder
msgpack==1.0.2
# via apache-superset
multidict==5.1.0
# via
# aiohttp
# yarl
numpy==1.22.1
# via
# apache-superset
# pandas
# pyarrow
packaging==21.3
# via
# bleach
# deprecation
pandas==1.3.4
# via apache-superset
parsedatetime==2.6
# via apache-superset
pgsanity==0.2.9
# via apache-superset
polyline==1.4.0
# via apache-superset
prison==0.2.1
# via flask-appbuilder
prompt-toolkit==3.0.28
# via click-repl
pyarrow==5.0.0
# via apache-superset
pycparser==2.20
# via cffi
pyjwt==2.4.0
# via
# apache-superset
# flask-appbuilder
# flask-jwt-extended
pymeeus==0.5.11
# via convertdate
pyparsing==3.0.6
# via
# apache-superset
# packaging
pyrsistent==0.16.1
# via jsonschema
python-dateutil==2.8.2
# via
# alembic
# apache-superset
# croniter
# flask-appbuilder
# holidays
# pandas
python-dotenv==0.19.0
# via apache-superset
python-editor==1.0.4
# via alembic
python-geohash==0.8.5
# via apache-superset
pytz==2021.3
# via
# babel
# celery
# convertdate
# flask-babel
# pandas
pyyaml==5.4.1
# via
# apache-superset
# apispec
redis==3.5.3
# via apache-superset
selenium==3.141.0
# via apache-superset
simplejson==3.17.3
# via apache-superset
six==1.16.0
# via
# bleach
# click-repl
# flask-talisman
# holidays
# isodate
# jsonschema
# polyline
# prison
# pyrsistent
# python-dateutil
# sqlalchemy-utils
# wtforms-json
slackclient==2.5.0
# via apache-superset
sqlalchemy==1.3.24
# via
# alembic
# apache-superset
# flask-appbuilder
# flask-sqlalchemy
# marshmallow-sqlalchemy
# sqlalchemy-utils
sqlalchemy-utils==0.37.8
# via
# apache-superset
# flask-appbuilder
sqlparse==0.3.0
# via apache-superset
tabulate==0.8.9
# via apache-superset
typing-extensions==3.10.0.0
# via apache-superset
urllib3==1.26.6
# via selenium
vine==5.0.0
# via
# amqp
# celery
# kombu
wcwidth==0.2.5
# via prompt-toolkit
webencodings==0.5.1
# via bleach
werkzeug==2.0.3
# via
# flask
# flask-jwt-extended
wtforms==2.3.3
# via
# flask-appbuilder
# flask-wtf
# wtforms-json
wtforms-json==0.3.3
# via apache-superset
yarl==1.6.3
# via aiohttp
# The following packages are considered to be unsafe in a requirements file:
# setuptools
pip install apache-superset==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple -r base.txt
CREATE DATABASE superset DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
create user superset@'%' identified WITH mysql_native_password BY 'superset';
grant all privileges on *.* to superset@'%' with grant option;
flush privileges;
vim /opt/module/miniconda3/envs/superset/lib/python3.8/site-packages/superset/config.py
SQLALCHEMY_DATABASE_URI = ‘mysql://superset:superset@hadoop102:3306/superset?charset=utf8’
conda install mysqlclient
export FLASK_APP=superset
superset db upgrade
superset fab create-admin
密码自己输入一下,其他的默认就行了。
superset init
pip install gunicorn -i https://pypi.douban.com/simple/
vim ~/bin/superset.sh
#!/bin/bash
superset_status(){
result=`ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | wc -l`
if [[ $result -eq 0 ]]; then
return 0
else
return 1
fi
}
superset_start(){
source ~/.bashrc
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
conda activate superset ; gunicorn --workers 5 --timeout 120 --bind hadoop102:8787 --daemon 'superset.app:create_app()'
else
echo "superset正在运行"
fi
}
superset_stop(){
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "superset未在运行"
else
ps -ef | awk '/gunicorn/ && !/awk/{print $2}' | xargs kill -9
fi
}
case $1 in
start )
echo "启动Superset"
superset_start
;;
stop )
echo "停止Superset"
superset_stop
;;
restart )
echo "重启Superset"
superset_stop
superset_start
;;
status )
superset_status >/dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "superset未在运行"
else
echo "superset正在运行"
fi
esac
添加权限
chmod +x ~/bin/superset.sh
启动superset
superset.sh start
访问http://hadoop102:8787
用之前设置的密码登录。
可以和数据库数据对比一下。
检查一下数据
自己拖拽三个框
直接拖进去
自己调整一下大小就可以保存了。
把得到的连接复制到浏览器即可使用。
至此线上问诊离线数仓项目完成。可以考虑抓个快照。