gpt4 book ai didi

mysql - 在 Hadoop 中使用 apache Airflow 配置 MySql 时遇到问题

转载 作者:行者123 更新时间:2023-12-02 09:38:29 33 4
gpt4 key购买 nike

我试图在具有以下配置/版本的三个节点的开发 Hadoop 集群上安装和配置 apache Airflow :

Operating System: Red Hat Enterprise Linux Server 7.7
python 3.7.3
anaconda 2
spark 2.45

a)sudo yum install gcc gcc-c++ -y
b)sudo yum install libffi-devel mariadb-devel cyrus-sasl-devel -y
c)pip install 'apache-airflow[all]'
d)airflow initdb -- airflow.cfgfile was created with SQLlite

然后我按照下面的一组命令用 mysql 配置它
a) rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm 
b) sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
c) yum --enablerepo=mysql80-community install mysql-community-server
d) systemctl start mysqld.service

在 mysql 下完成以下操作
a) CREATE DATABASE airflow CHARACTER SET utf8 COLLATE utf8_unicode_ci; 
b) create user 'airflow'@'localhost' identified by 'Airflow123';
c) grant all privileges on * . * to 'airflow'@'localhost';

这是我的 airflow.cfg 的一些细节文件
broker_url = sqla+mysql://airflow:airflow@localhost:3306/airflow
result_backend = db+mysql://airflow:airflow@localhost:3306/airflow
sql_alchemy_conn = mysql://airflow:Airflow123@localhost:3306/airflow
executor = CeleryExecutor

我在运行时遇到以下错误 airflow initdb命令
ImportError: /home/xyz/anaconda2/envs/python3.7.2/lib/python3.7/site-packages/_mysql.cpython-37m-x86_64-linux-gnu.so: symbol mysql_real_escape_string_quote, 
version libmysqlclient_18 not defined in file libmysqlclient.so.18 with link time reference

已将 .bashrc 文件设置为:
export AIRFLOW_HOME=~/airflow

这是我创建的目录:
[xyz@innolx5984 airflow]$ pwd
/home/xyz/airflow

当我寻找这个文件“ libmysqlclient”时,我发现了很多实例。
[xyz@innolx5984 airflow]$ find /home/xyz/ -name "*libmysqlclient*"
/home/xyz/anaconda2/pkgs/mysql-connector-c-6.1.11-h597af5e_1/lib/libmysqlclient.so
/home/xyz/anaconda2/pkgs/mysql-connector-c-6.1.11-h597af5e_1/lib/libmysqlclient.a
/home/xyz/anaconda2/pkgs/mysql-connector-c-6.1.11-h597af5e_1/lib/libmysqlclient.so.18
/home/xyz/anaconda2/pkgs/mysql-connector-c-6.1.11-h597af5e_1/lib/libmysqlclient.so.18.4.0
/home/xyz/anaconda2/lib/libmysqlclient.a
/home/xyz/anaconda2/lib/libmysqlclient.so
/home/xyz/anaconda2/lib/libmysqlclient.so.18
/home/xyz/anaconda2/lib/libmysqlclient.so.18.4.0

只需添加更多细节以防万一。
[xyz@innolx5984 airflow]$ mysql_config
Usage: /home/xyz/an
aconda2/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/home/xyz/anaconda2/include ]
--cxxflags [-I/home/xyz/anaconda2/include ]
--include [-I/home/xyz/anaconda2/include]
--libs [-L/home/xyz/anaconda2/lib -lmysqlclient ]
--libs_r [-L/home/xyz/anaconda2/lib -lmysqlclient ]
--plugindir [/home/xyz`/anaconda2/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [6.1.11]
--variable=VAR VAR is one of:
pkgincludedir [/home/xyz/anaconda2/include]
pkglibdir [/home/xyz/anaconda2/lib]
plugindir [/home/xyz/anaconda2/lib/plugin]

Looking for some help and suggestion to resolve this

问题。我不太确定是否朝着正确的方向前进。

最佳答案

按照以下步骤使用 Anaconda3 安装带有 MySQL 的 Apache Airflow

1) 安装先决条件

yum install gcc gcc-c++ -y
yum install libffi-devel mariadb-devel cyrus-sasl-devel -y
dnf install redhat-rpm-config

2) 安装 Anaconda3(Python 3.7.6 自带)
yum install libXcomposite libXcursor libXi libXtst libXrandr alsa-lib mesa-libEGL libXdamage mesa-libGL libXScrnSaver
wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh
chmod +x Anaconda3-2020.02-Linux-x86_64.sh
./Anaconda3-2020.02-Linux-x86_64.sh

确保你这样做 conda initialize在安装过程中出现提示时。
这将确保在后续步骤中使用正确版本的 python 和 pip。

3) 安装 Apache Airflow
pip install apache-airflow[mysql,celery]

您可以根据需要添加其他子包。我只包含了 Airflow 使用 MySQL 数据库作为后端所需的那些。

4) 初始化 Airflow
export AIRFLOW_HOME=~/airflow
airflow initdb

从这里开始,我模仿了您配置 MySQL 服务器所遵循的步骤

5) 安装 MySQL 服务器
rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm 
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/mysql-community.repo
yum --enablerepo=mysql80-community install mysql-server
systemctl start mysqld.service

6) 登录 MySQL 并为 Airflow 配置数据库
mysql> CREATE DATABASE airflow CHARACTER SET utf8 COLLATE utf8_unicode_ci; 
mysql> CREATE user 'airflow'@'localhost' identified by 'Airflow123';
mysql> GRANT ALL privileges on *.* to 'airflow'@'localhost';

7) 更新 Airflow 配置文件 (~/airflow/airflow.cfg)
sql_alchemy_conn = mysql://airflow:Airflow123@localhost:3306/airflow
executor = CeleryExecutor

8) 初始化 Airflow
airflow initdb

关于mysql - 在 Hadoop 中使用 apache Airflow 配置 MySql 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60987782/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com