AirFlow初始化的时候遇到 Global variable explicit_defaults_for_timestamp needs to be on (1) for mysql

Stella981
• 阅读 847

在安装airflow后,初始化遇到这样的问题

Traceback (most recent call last):
  File "/opt/anaconda3/bin/airflow", line 32, in <module>
    args.func(args)
  File "/opt/anaconda3/lib/python3.7/site-packages/airflow/bin/cli.py", line 1102, in initdb
    db.initdb(settings.RBAC)
  File "/opt/anaconda3/lib/python3.7/site-packages/airflow/utils/db.py", line 106, in initdb
    upgradedb()
  File "/opt/anaconda3/lib/python3.7/site-packages/airflow/utils/db.py", line 377, in upgradedb
    command.upgrade(config, 'heads')
  File "/opt/anaconda3/lib/python3.7/site-packages/alembic/command.py", line 298, in upgrade
    script.run_env()
  File "/opt/anaconda3/lib/python3.7/site-packages/alembic/script/base.py", line 489, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/opt/anaconda3/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 98, in load_python_file
    module = load_module_py(module_id, path)
  File "/opt/anaconda3/lib/python3.7/site-packages/alembic/util/compat.py", line 173, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/anaconda3/lib/python3.7/site-packages/airflow/migrations/env.py", line 92, in <module>
    run_migrations_online()
  File "/opt/anaconda3/lib/python3.7/site-packages/airflow/migrations/env.py", line 86, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File "/opt/anaconda3/lib/python3.7/site-packages/alembic/runtime/environment.py", line 846, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/opt/anaconda3/lib/python3.7/site-packages/alembic/runtime/migration.py", line 518, in run_migrations
    step.migration_fn(**kw)
  File "/opt/anaconda3/lib/python3.7/site-packages/airflow/migrations/versions/0e2a74e0fc9f_add_time_zone_awareness.py", line 45, in upgrade
    "Global variable explicit_defaults_for_timestamp needs to be on (1) for mysql"
Exception: Global variable explicit_defaults_for_timestamp needs to be on (1) for mysql

解决方法:
进入mysql airflow 数据库,设置global explicit_defaults_for_timestamp

mysql>  show global variables like '%timestamp%';
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| explicit_defaults_for_timestamp | OFF   |
| log_timestamps                  | UTC   |
+---------------------------------+-------+
2 rows in set (0.00 sec)

mysql> set global explicit_defaults_for_timestamp =1;
Query OK, 0 rows affected (0.00 sec)

mysql>
点赞
收藏
评论区
推荐文章
技术小男生 技术小男生
2年前
linux环境jdk环境变量配置
1:编辑系统配置文件vi/etc/profile2:按字母键i进入编辑模式,在最底部添加内容:JAVAHOME/opt/jdk1.8.0152CLASSPATH.:$JAVAHOME/lib/dt.jar:$JAVAHOME/lib/tools.jarPATH$JAVAHOME/bin:$PATH3:生效配置
待兔 待兔
4个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Easter79 Easter79
3年前
svn服务器搭建
1.安装SVNcentos安装:yuminstallsubversionubuntu安装:aptgetinstallsubversion2.安装成功后,创建仓库存放目录,例如:mkdirp/opt/svn/创建SVN仓库,例如创建仓库"repos":mkdirp/opt/svn/rep
Easter79 Easter79
3年前
spring项目异常
org.springframework.beans.factory.BeanDefinitionStoreException:Failedtoreadcandidatecomponentclass:file\/opt/tong/slszy/turbo/WEBINF/classes/cn/com/dhcc/app/pub/core/tag/
Wesley13 Wesley13
3年前
MySQL 5.6 Generic Binary安装与配置
安装软件包\mkdirp/opt/mysql\mvmysql5.6.17linuxglibc2.5x86\_64.tar.gz/opt/mysql\cd/opt/mysql\tarxvfzmysql5.6.17linuxglibc2.5x86\_64.tar.gz\创建数据库
Stella981 Stella981
3年前
Fedora DNF 报错
升级fedora24以后,安装软件报错Complete!Traceback(mostrecentcalllast):File"/bin/dnf",line58,in<modulemain.user_main(sys.argv1:,exit_codeTrue)Fi
Stella981 Stella981
3年前
Airflow笔记
1\.依赖MySqlOperator的数据库交互通过MySQLdb模块来实现,使用前需要安装相关依赖:pipinstallapacheairflowmysql2\.使用使用MySqlOperator执行sql任务的一个简单例子:fromairflowimp
Wesley13 Wesley13
3年前
ubuntu 安装python3.6后,terminal终端打不开问题
由于Ubuntu16.04,自带Python2.7和Python3.5当我安装完Python3.6.5后,terminal终端打不开了,jekay@jekaypc:~$gnometerminalTraceback(mostrecentcalllast): File"/usr/bin/gnometerminal",
Stella981 Stella981
3年前
Python spyder Ipython console 连接失败问题
启动spyder之后,Ipythonconsole 中ConnectingtoKernel,出现错误,一直在连接,但是连接不上,ResetSpyderSettings也解决不了问题。Traceback(mostrecentcalllast):File"F:\Anaconda_pakage\lib\runpy.p
Stella981 Stella981
3年前
Mac上python3.8导入jenkins报错
python3在importjenkins报错找不到lookup3.so依赖。importjenkinsTraceback(mostrecentcalllast):File"<stdin",line1,in<moduleFile"/usr/local/lib/pyth