博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Centos6安装airflow
阅读量:6581 次
发布时间:2019-06-24

本文共 5041 字,大约阅读时间需要 16 分钟。

hot3.png

安装Python3

./configure --prefix=/usr/local/python360make && make install#备份python 和pipmv /usr/bin/python /usr/bin/python_bakmv /usr/bin/pip/usr/bin/pip_bak#添加Python3软连接ln -s /usr/local/python360/bin/python3.6 /usr/bin/pythonln -s /usr/local/python360/bin/pip3 /usr/bin/pip

官网的很简单:

export AIRFLOW_HOME=~/airflow# install from pypi using pippip install apache-airflow# initialize the databaseairflow initdb# start the web server, default port is 8080airflow webserver -p 8080

airflow默认的数据库是sqlite3,当你初始化数据库的时候会报错:

ModuleNotFoundError: No module named '_sqlite3'

一般解决方法:

yum install sqlite-devel重新编译Python:./configure --prefix=/usr/local/python360make && make install

如果还是报错:可以重新安装sqlite3

wget https://www.sqlite.org/2017/sqlite-autoconf-3170000.tar.gz --no-check-certificatetar zxvf sqlite-autoconf-3170000.tar.gzcd sqlite-autoconf-3170000./configure --prefix=/usr/local/sqlite3 --disable-static --enable-fts5 --enable-json1 CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1"make && make install

然后重新编译Python:

LD_RUN_PATH=/usr/local/sqlite3/lib ./configure --prefix=/usr/local/python360 LDFLAGS="-L/usr/local/sqlite3/lib" CPPFLAGS="-I /usr/local/sqlite3/include"LD_RUN_PATH=/usr/local/sqlite3/lib makeLD_RUN_PATH=/usr/local/sqlite3/lib make install

目前使用的是mysql数据库:

运行 mysql -uroot -p 报错:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

解决方法:重启mysql

/etc/rc.d/init.d/mysqld restart

发现没有这个文件,解决方法是未安装mysql-server:

yum install mysql-server

建用户:

#设置root密码mysql -uroot -pSET PASSWORD=PASSWORD("123");FLUSH PRIVILEGES;mysql -uroot -p123create user 'airflow'@'%' identified by '123';flush privileges;create database airflowdb;grant all privileges on `airflowdb`.* to 'airflow'@'%' identified by '123';flush privileges;

运行命令 airflow  生成在根目录文件 ~/airflow,修改airflow.cfg配置文件

vi ~/airflow/airflow.cfgsql_alchemy_conn = mysql://airflow:123@xx.xx.xx.xx/airflowdbpip install cryptography mysqlclientyum install MySQL-python#初始化airflow数据库airflow initdb

运行airflow webserver 外网访问

vi ~/airflow/airflow.cfg[webserver]endpoint_url = http://xx.xx.xx.xx:8081base_url = http://xx.xx.xx.xx:8081web_server_port = 8081airflow webserver

浏览器输入:  http://xx.xx.xx.xx:8081

165341_rytS_1046672.png

 

界面加上用户在~/airflow/airflow.cfg [webserver]下添加(其他模块会有同名,不要加错了):

authenticate = Trueauth_backend = airflow.contrib.auth.backends.password_auth

181215_YzD2_1046672.png

并且在~/airflow/目录下运行以下代码:

cd ~/airflow./add_user.py 

add_user.py 代码:

#!/usr/bin/python# This little script creates users in an airflow instance so it can be open to the public.# It gets the password in plain text so be careful where you run it.# You can properly invoke the script as follows:# ./add_user.py 
import airflow, sysfrom airflow import models, settingsfrom airflow.contrib.auth.backends.password_auth import PasswordUseruser = PasswordUser(models.User())user.username = sys.argv[1]user.email = sys.argv[2]user.password = sys.argv[3]session = settings.Session()session.add(user)session.commit()session.close()exit()

但是运行的时候,通常会报错(“AttributeError: can't set attribute”)

原因是 sqlalchemy这个Python包版本大于1.2

解决方法:

pip uninstall sqlalchemypip install 'sqlalchemy<1.2'

Airflow添加CeleryExecutor:

添加依赖:

yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

安装Erlang:

wget http://erlang.org/download/otp_src_18.3.tar.gztar xvf otp_src_18.3.tar.gzcd otp_src_18.3./configure --prefix=/usr/local/erlang --with-ssl -enable-threads -enable-smmp-support -enable-kernel-poll --enable-hipe --without-javacmake && make install#配置环境vim /etc/profileexport ERLANG_HOME=/usr/local/erlangexport PATH=$ERLANG_HOME/bin:$PATHsource /etc/profile#输入命令检验是否安装成功erl

 

按照Rabbitmq:

wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.1/rabbitmq-server-generic-unix-3.6.1.tar.xzxz -d rabbitmq-server-generic-unix-3.6.1.tar.xztar -xvf rabbitmq-server-generic-unix-3.6.1.tarcp -rf ./rabbitmq_server-3.6.1 /usr/local/cd /usr/local/mv rabbitmq_server-3.6.1 rabbitmq-3.6.1#开启管理页面插件cd ./rabbitmq-3.6.1/sbin/./rabbitmq-plugins enable rabbitmq_management#启动命令,该命令ctrl+c后会关闭服务./rabbitmq-server#在后台启动Rabbit./rabbitmq-server -detached#关闭服务./rabbitmqctl stop#添加用户#rabbitmqctl add_user Username Password./rabbitmqctl add_user rabbitadmin 123456#分配用户标签#rabbitmqctl set_user_tags User Tag#[administrator]:管理员标签./rabbitmqctl set_user_tags rabbitadmin administrator

登录管理界面

浏览器输入地址:http://服务器IP地址:15672/ 

 

173314_OfRG_1046672.png

~/airflow/airflow.cfg 配置celery

创建Rabbitmq用户:

cd /usr/local/rabbitmq361/sbin./rabbitmqctl add_user ct 123./rabbitmqctl add_vhost ct_airflow./rabbitmqctl set_user_tags ct airflow./rabbitmqctl set_permissions -p ct_airflow ct ".*" ".*" ".*"

修改airflow.cfg文件: 

[core] executor = CeleryExecutor [celery] broker_url = amqp://ct:152108@localhost:5672/ct_airflow celery_result_backend = amqp://ct:152108@localhost:5672/ct_airflow

 

pip install celery

进入/usr/lib/python2.7/site-packages/airflow/executors,修改celery_executor.py源码文件

from celery import Celery, platformsplatforms.C_FORCE_ROOT = True

175050_gwXK_1046672.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

转载于:https://my.oschina.net/ilovetao/blog/1806915

你可能感兴趣的文章
Python面向对象编程(一)
查看>>
决心书
查看>>
如何把图片上的文字转换成word?
查看>>
7z命令行
查看>>
C语言编程实现 输入一个非负整数,返回组成它的数字之和(递归方法)
查看>>
c3p0
查看>>
redis cluster 集群搭建(增、删、改、查) :5.0.2
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
引号-下划线,连接多个变量
查看>>
游戏LOGO它应该长什么样?
查看>>
我的友情链接
查看>>
38线程1-Thread-local-Timer
查看>>
为Exchange server 2013 申请多域名证书
查看>>
处理svn的 File '/aa' is out of date
查看>>
解决 Ubuntu 16.04 LTSSublime text3中文问题
查看>>
mysql主从复制实现数据库同步
查看>>
面试-1
查看>>
CentOS自动登录Gnome
查看>>
第一章,重点总结
查看>>