Centos7 安装部署 Airflow

本人在centos7 的环境下部署,怎么在centos7 下配置静态 IP 关闭防火墙 以及安装jdk在这里不多赘述,

centos7 配置静态ip可以参考:https://www.cnblogs.com/braveym/p/8523100.html  和  https://www.cnblogs.com/braveym/p/9096402.html

Airflow 基础安装

1、默认自带python2环境,自行安装pip
sudo yum -y install epel-release
sduo yum install python-pip

2、进行pip的更新,否则很多安装会报错
sudo pip install --upgrade pip
sudo pip install --upgrade setuptools

3、安装开发库
sudo yum install python-devel
sudo yum install libevent-devel
sudo yum install mysql-devel

4、安装centos7下的mysql

在安装mysql前建议先更新一下源,不然下载老失败

打开centos的yum文件夹(需要root权限或者拥有该目录的操作权限才可以)

输入命令cd  /etc/yum.repos.d

用wget下载repo文件

输入命令sudo wget  http://mirrors.aliyun.com/repo/Centos-7.repo(如果wget命令不生效,说明还没有安装wget工具,输入sudo yum -y install wget 回车进行安装)

备份系统原来的repo文件

sudo mv  CentOS-Base.repo CentOS-Base.repo.bak

替换系统原理的repo文件

sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo

在更新源之前先把自带的mariadb删除,会报类似这样的错误

 

[[email protected] ~]$ rpm -qa|grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
[[email protected] ~]$ rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
error: can‘t create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
[[email protected] ~]$ sudo rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[[email protected] ~]$ rpm -qa|grep mariadb
[[email protected] ~]$ 

执行yum源更新命令

sudo yum clean all

sudo yum makecache

sudo yum -y update (需要比较长的时间)

https://dev.mysql.com/downloads/mysql/下载mysql的离线安装包

下载完之后把包上传到集群

解压

把以上解压包每一个都安装一遍,但是,安装的时候建议安装顺序来,不要随便拿起一个就安装,不然会报这样的错误

所以建议按照下面的顺序进行安装

[email protected] mysql]$ sudo rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-common-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-common-5.7.27-1.e################################# [100%]
[[email protected] mysql]$ sudo rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-libs-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-5.7.27-1.el7################################# [100%]
[[email protected] mysql]$ sudo rpm -ivh mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-libs-compat-5.7.2################################# [100%]
[[email protected] mysql]$ sudo rpm -ivh mysql-community-embedded-compat-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-embedded-compat-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-embedded-compat-5################################# [100%]
[[email protected] mysql]$ sudo rpm -ivh mysql-community-devel-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-devel-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-devel-5.7.27-1.el################################# [100%]
[[email protected] mysql]$ sudo rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-client-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-client-5.7.27-1.e################################# [100%]
[[email protected] mysql]$ sudo rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.27-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-server-5.7.27-1.e################################# [100%]
[[email protected] mysql]$

先关闭mysql服务

修改MySql配置

skip-grant-tables #添加这句话,这时候登入mysql就不需要密码

启动mysql

[[email protected] mysql]$ sudo systemctl start mysqld.service
[[email protected] mysql]$ sudo systemctl status mysqld.service
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-08-20 11:49:49 CST; 3s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 4759 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 4679 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 4762 (mysqld)
    Tasks: 27
   CGroup: /system.slice/mysqld.service
           └─4762 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

Aug 20 11:49:45 bigdata systemd[1]: Starting MySQL Server...
Aug 20 11:49:49 bigdata systemd[1]: Started MySQL Server.

登录mysql,输入密码处直接回车就可以

退出并停止Mysql服务

修改配置文件

设置MySql开机自启

sudo systemctl enable mysqld

5、初始化配置mysql,可以设定允许root远程登录

先通过root登录mysql,密码是刚刚给root用户设置的密码我这里是:root

Mysql默认不允许远程登录,我们需要设置下,并且防火墙开放3306端口;(备注 mysql5.7默认密码策略要求密码必须是大小写字母数字特殊字母的组合,至少8位)

可以看到,太简单的密码是不可行的,这里需要注意的!!!

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘root‘ WITH GRANT OPTION;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘Root123‘ WITH GRANT OPTION;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘Admin123!‘ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit;
Bye

对于防火墙开启的情况下,就需要开发3306端口,我这里是把防火墙关闭

[[email protected] mysql]$ sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
FirewallD is not running
[[email protected] mysql]$ sudo firewall-cmd --reload
FirewallD is not running

6、配置Mysql默认编码为UTF-8

修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置

character_set_server=utf8
init_connect=‘SET NAMES utf8‘

编辑保存完 重启mysql服务: sudo systemctl restart mysqld.service

查看下编码:

[[email protected] mysql]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> show variables like ‘%character%‘;
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

mysql> 

7、安装AirFlow

给airflow设置环境变量

sudo vim /etc/profile

#airflow
export AIRFLOW_HOME=/opt/modules/airflow
export SLUGIFY_USES_TEXT_UNIDECODE=yes

是环境变量生效

安装airflow

sudo pip install apache-airflow

可以看到出现以下错误

这样解决:

sudo pip install six --user -U
sudo pip install ipython --user -Usudo pip install --ignore-installed dnspython

sudo yum install python-devel

sudo yum install openldap-devel

sudo pip install --ignore-installed python-ldap

sudo pip install --ignore-installed enum34

前面的问题解决了,又开始新的问题

这个问题这样解决:

sudo pip install --ignore-installed requests

最后再重新安装一次airflow,可以看到成功了

8、 设置mysql数据库连接

sudo pip install apache-airflow[mysql]

创建airflow用户,创建airflow数据库并给出所有权限给此用户(注意在设置密码的时候还是前面讲的问题,不能太简单,否则不能通过)

mysql> create database airflow;
Query OK, 1 row affected (0.00 sec)

mysql> create user ‘airflow‘@‘%‘ identified by ‘AirFlow123!‘;
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT all privileges on airflow.* TO ‘airflow‘@‘%‘  IDENTIFIED BY ‘AirFlow123!‘;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
修改airflow配置文件,指向数据库mysql
airflow.cfg 文件通常在~/airflow目录下

executor =  LocalExecutor
sql_alchemy_conn = mysql://airflow:[email protected]/airflow对应字段解释如下: dialect+driver://username:[email protected]:port/database

修改mysql的配置文件

vim /etc/my.cnf

添加这一句

explicit_defaults_for_timestamp=1

重启mysql

9、初始化airflow并启动web服务

sudo airflow initdb
sudo airflow webserver
sudo airflow scheduler
sudo airflow worker 

在浏览器打开地址 192.168.189.11:8080

原文地址:https://www.cnblogs.com/braveym/p/11378851.html

时间: 2024-10-08 02:30:43

Centos7 安装部署 Airflow的相关文章

基于CentOS7安装部署 Oracle 12c ?

基于CentOS7安装部署 Oracle 12c 简介 Oracle Database,又名Oracle RDBMS,或简称Oracle.是甲骨文公司的一款关系数据库管理系统.是目前最流行的客户/服务器(CLIENT/SERVER)或B/S体系结构的数据库之一.Oracle数据库最新版本为Oracle Database 12c.Oracle数据库12c 引入了一个新的多承租方架构,使用该架构可轻松部署和管理数据库云. 特点 1.完整的数据管理功能: 1)数据的大量性 2)数据的保存的持久性 3)

Centos7安装部署ImageMagick

Centos7安装部署ImageMagick 系统信息 # cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) 安装基础包 # yum install -y libjpeg* libpng* libtiff* libungif* freetype zlib ImageMagick介绍 ImageMagick是一个用于创建.编辑.组合或转换位图图像的软件套件.它可以读写各种格式的图像,比如GIF.JPEG.PNG.Postscr

Centos7安装部署免费confluence wiki

Centos7安装部署免费confluence wiki链接:https://pan.baidu.com/s/1uzVQqnO2whaNsnKUWI49ow 提取码:6od6 注意:4个包一个是放在windows上进行破解的,另一个是wiki安装包分别是windows java包 还有linux java包 还有confluence包 还有破解工具windows安装好java配置好环境变量才可以点开破解工具进入部署环境下载安装所需的jdktar –zxvf jdk-8u211-linux-x64

Centos7安装部署Gitlab

环境说明 操作系统:CentOS 7.1 IP地址:10.0.0.76 关闭防火墙 关闭SELinux 安装gitlab 安装基础环境 # yum install curl openssh-server openssh-clients postfix cronie# systemctl start postfix 安装gitlab-ce # curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/scr

OpenVPN CentOS7 安装部署配置详解

一 .概念相关 1.vpn 介绍 vpn 虚拟专用网络,是依靠isp和其他的nsp,在公共网络中建立专用的数据通信网络的技术.在vpn中任意两点之间的链接并没有传统的专网所需的端到端的物理链路,而是利用公共网络资源动态组成的,可以理解为通过私有的隧道技术在公共数据网络上模拟出来的和专网有相同功能的点到点的专线技术,所谓虚拟是指不需要去拉实际的长途物理线路,而是借用公共的Internet网络实现. 2.vpn 作用 vpn可以帮助公司用的远程用户(出差,家里)公司的分之机构.商业合作伙伴及供应商等

Centos7安装部署Kubernetes(K8s)集群

Kubernetes集群的安装有多种方式:下载源码包编译安装.下载编译好的二进制包安装.使用kubeadm工具安装等.本文是以二进制文件方式安装Kubernetes集群.系统环境 主机名 IP地址 操作系统 安装组件 k8s-master 192.168.2.212 Centos 7.5 64位 etcd.kube-apiserver.kube-controller-manager.kube-scheduler k8s-node1 192.168.2.213 Centos 7.5 64位 kub

linux centos7安装部署gitlab服务器

我这里使用的是centos 7 64bit系统,我试过centos 64bit系统也是可以的. 1. 安装依赖软件 yum -y install policycoreutils openssh-server openssh-clients postfix 2.设置postfix开机自启,并启动,postfix支持gitlab发信功能 systemctl enable postfix && systemctl start postfix 3.下载gitlab安装包,然后安装 centos 6

Centos7安装部署汉化Gitlab

环境centos7,内存至少4G,Gitlab还是挺耗内存的.GitHub安装参考:https://about.gitlab.com/install/组件安装参考:https://docs.gitlab.com/ce/development/architecture.html 安装 配置Yum源使用国内的软件镜像站,这里使用清华大学开源软件镜像站.cat /etc/yum.repos.d/tsinghua.repo [gitlab-ce] name=Gitlab CE Repository ba

Centos7安装部署Jenkins

Jenkins是Java编写的,所以需要先安装JDK.可以使用源码安装也可以使用yum安装.笔者使用的是源码安装. # tar xf jdk-8u121-linux-x64.gz -C /usr/local/ 设置Java环境变量 ###在/etc/profile文件最下面添加如下配置 # vim /etc/profile export JAVA_HOME=/usr/local/jdk1.8.0_121 export JRE_HOME=$JAVA_HOME/jre export PATH=$JA