[Ergänzung] AirFlow-Installation zur Unterstützung des industriellen Internets der Dinge und industrieller Big Data
Direkt auf Knoten1 installieren
1. Installieren Sie Python
-
Abhängigkeiten installieren
yum -y install zlib zlib-devel bzip2 bzip2-devel ncurses ncurses-devel readline readline-devel openssl openssl-devel openssl-static xz lzma xz-devel sqlite sqlite-devel gdbm gdbm-devel tk tk-devel gcc yum install mysql-devel -y yum install libevent-devel -y
-
Fügen Sie Linux-Benutzer und -Gruppen hinzu
# 添加py用户 useradd py # 设置密码 '123456' passwd py # 创建anaconda安装路径 mkdir /anaconda # 赋予权限 chown -R py:py /anaconda
-
Laden Sie das Anaconda-Installationsskript hoch und führen Sie es aus
cd /anaconda rz chmod u+x Anaconda3-5.3.1-Linux-x86_64.sh sh Anaconda3-5.3.1-Linux-x86_64.sh
-
Benutzerdefinierter Installationspfad
Anaconda3 will now be installed into this location: /root/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/root/anaconda3] >>> /anaconda/anaconda3
-
-
Zu Systemumgebungsvariablen hinzufügen
# 修改环境变量 vi /root/.bash_profile # 添加下面这行 export PATH=/anaconda/anaconda3/bin:$PATH # 刷新 source /root/.bash_profile # 验证 python -V
-
Pip konfigurieren
mkdir ~/.pip touch ~/.pip/pip.conf echo '[global]' >> ~/.pip/pip.conf echo 'trusted-host=mirrors.aliyun.com' >> ~/.pip/pip.conf echo 'index-url=http://mirrors.aliyun.com/pypi/simple/' >> ~/.pip/pip.conf # pip默认是10.x版本,更新pip版本 pip install PyHamcrest==1.9.0 pip install --upgrade pip # 查看pip版本 pip -V
2. Installieren Sie AirFlow
-
Installieren
pip install --ignore-installed PyYAML pip install apache-airflow[celery] pip install apache-airflow[redis] pip install apache-airflow[mysql] pip install flower pip install celery
-
verifizieren
airflow -h ll /root/airflow
3. Installieren Sie Redis
-
Herunterladen und installieren
wget https://download.redis.io/releases/redis-4.0.9.tar.gz tar zxvf redis-4.0.9.tar.gz -C /opt cd /opt/redis-4.0.9 make
-
Start-up
cp redis.conf src/ cd src nohup /opt/redis-4.0.9/src/redis-server redis.conf > output.log 2>&1 &
-
verifizieren
ps -ef | grep redis
4. Konfigurieren und starten Sie AirFlow
-
Ändern Sie die Konfigurationsdatei: airflow.cfg
[core] #18行:时区 default_timezone = Asia/Shanghai #24行:运行模式 # SequentialExecutor是单进程顺序执行任务,默认执行器,通常只用于测试 # LocalExecutor是多进程本地执行任务使用的 # CeleryExecutor是分布式调度使用(可以单机),生产环境常用 # DaskExecutor则用于动态任务调度,常用于数据分析 executor = CeleryExecutor #30行:修改元数据使用mysql数据库,默认使用sqlite sql_alchemy_conn = mysql://airflow:airflow@localhost/airflow [webserver] #468行:web ui地址和端口 base_url = http://localhost:8085 #474行 default_ui_timezone = Asia/Shanghai #480行 web_server_port = 8085 [celery] #735行 broker_url = redis://localhost:6379/0 #736 celery_result_backend = redis://localhost:6379/0 #743 result_backend = db+mysql://airflow:airflow@localhost:3306/airflow
-
Metadatendatenbank initialisieren
-
Geben Sie MySQL ein
mysql -uroot -p set global explicit_defaults_for_timestamp =1; exit
-
Initialisierung
airflow db init
-
-
Konfigurieren Sie den Webzugriff
airflow users create --lastname user --firstname admin --username admin --email [email protected] --role Admin --password admin
-
Start-up
# 以后台进程方式,启动服务 airflow webserver -D airflow scheduler -D airflow celery flower -D airflow celery worker -D
-
Schließen【Keine Ausführung erforderlich】
# 统一杀掉airflow的相关服务进程命令 ps -ef|egrep 'scheduler|flower|worker|airflow-webserver'|grep -v grep|awk '{print $2}'|xargs kill -9 # 下一次启动之前 rm -f /root/airflow/airflow-*
5. Überprüfen Sie AirFlow
-
Airflow-Web-Benutzeroberfläche:
node1:8085
-
Luftstrom-Sellerie-Web:
node1:5555