1
1
## Install & config apache airflow mysql
2
2
### 1. Install mysql <a href =' https://dev.mysql.com/downloads/mysql/ ' >here</a >
3
3
- Homebrew in Macbook
4
- ``` bash
5
- brew install mysql
6
- ```
7
- - Mannually install without Admin right, refer [ here] ( ../mysql )
4
+ ``` bash
5
+ brew install mysql
6
+ ```
7
+ - Mannually install without Admin right, refer [ here] ( ../mysql )
8
8
9
9
### 2. Install mysql-python
10
10
``` bash
@@ -13,119 +13,124 @@ pip install mysqlclient
13
13
```
14
14
15
15
- Create airflow db
16
- ``` bash
17
- chmod +x scripts/create_db.sh
18
- . scripts/create_db.sh
19
- ```
16
+ ``` bash
17
+ chmod +x scripts/create_db.sh
18
+ . scripts/create_db.sh
19
+ ```
20
20
21
21
- Test mysql-python connection
22
- ``` python
23
- from sqlalchemy import create_engine
24
-
25
- eng = create_engine(' mysql://root:@localhost:3306/mysql' )
26
- with eng.connect() as con:
27
-
28
- rs = con.execute(' SELECT 6' )
29
-
30
- data = rs.fetchone()[0 ]
31
-
32
- print " Data: %s " % data
33
- ```
34
-
35
- ### 3. Install apache airflow, official site <a href =' http://airflow.incubator.apache.org/installation.html ' >here</a >
36
-
37
- - Install airflow[ celery,mysql]
38
- ``` bash
39
- pip install " pip install airflow[celery,mysql]"
40
- ```
41
-
42
- - Config airflow
43
- ###### a. Initialize an airflow home
44
- ``` bash
45
- export AIRFLOW_HOME=~ /airflow
46
- export PATH=/Users/txuantu/anaconda2/lib/python2.7/site-packages/airflow/bin:$PATH
47
-
48
- airflow version
49
- ```
50
-
51
- ###### b. Go to airflow home and config mysql connection
52
- ``` bash
53
- cd $AIRFLOW_HOME
54
- vi airflow.cfg
55
- ```
56
-
57
- - Default mysql
58
- ``` bash
59
- # The executor class that airflow should use. Choices include
60
- # SequentialExecutor, LocalExecutor, CeleryExecutor
61
- executor = CeleryExecutor
62
-
63
-
64
- # The SqlAlchemy connection string to the metadata database.
65
- # SqlAlchemy supports many different database engine, more information
66
- # their website
67
- sql_alchemy_conn = mysql://airflow:airflow@localhost/airflow
68
-
69
- # The Celery broker URL. Celery supports RabbitMQ, Redis and experimentally
70
- # a sqlalchemy database. Refer to the Celery documentation for more
71
- # information.
72
- broker_url = sqla+mysql://airflow:airflow@localhost:3306/airflow
22
+ ``` python
23
+ from sqlalchemy import create_engine
73
24
74
- # Another key Celery setting
75
- celery_result_backend = db+mysql://airflow:airflow@localhost:3306/airflow
76
- ```
25
+ eng = create_engine(' mysql://root:@localhost:3306/mysql' )
26
+ with eng.connect() as con:
77
27
78
- - Mannual mysql
79
- ``` bash
80
- # The executor class that airflow should use. Choices include
81
- # SequentialExecutor, LocalExecutor, CeleryExecutor
82
- executor = CeleryExecutor
28
+ rs = con.execute(' SELECT 6' )
83
29
30
+ data = rs.fetchone()[0 ]
84
31
85
- # The SqlAlchemy connection string to the metadata database.
86
- # SqlAlchemy supports many different database engine, more information
87
- # their website
88
- sql_alchemy_conn = mysql+mysqldb://airflow:airflow@localhost/airflow? unix_socket=/path/to/thesock
32
+ print " Data: %s " % data
33
+ ```
89
34
90
- # The Celery broker URL. Celery supports RabbitMQ, Redis and experimentally
91
- # a sqlalchemy database. Refer to the Celery documentation for more
92
- # information.
93
- broker_url = sqla+mysql://airflow:airflow@localhost:3306/airflow? unix_socket=/path/to/thesock
35
+ ### 3. Install apache airflow, official site <a href =' http://airflow.incubator.apache.org/installation.html ' >here</a >
94
36
95
- # Another key Celery setting
96
- celery_result_backend = db+mysql://airflow:airflow@localhost:3306/airflow? unix_socket=/path/to/thesock
97
- ```
37
+ - Install airflow[ celery,mysql]
38
+ ``` bash
39
+ pip install " pip install airflow[celery,mysql]"
40
+ ```
98
41
99
- - Enable SSL
100
- ``` bash
101
- [webserver]
102
- # The base url of your website as airflow cannot guess what domain or
103
- # cname you are using. This is used in automated emails that
104
- # airflow sends to point links to the right web server
105
- base_url = http://localhost:443
106
-
107
- # The ip specified when starting the web server
108
- web_server_host = 0.0.0.0
109
-
110
- # The port on which to run the web server
111
- web_server_port = 443
112
-
113
- # Paths to the SSL certificate and key for the web server. When both are
114
- # provided SSL will be enabled. This does not change the web server port.
115
- web_server_ssl_cert = ~ /airflow/mycert.pem
116
- web_server_ssl_key = ~ /airflow/mykey.key
117
- ```
42
+ - Config airflow
43
+ ###### a. Initialize an airflow home
44
+ ``` bash
45
+ export AIRFLOW_HOME=~ /airflow
46
+ export PATH=/Users/txuantu/anaconda2/lib/python2.7/site-packages/airflow/bin:$PATH
118
47
119
- ###### c. Initialise db connection
120
- ``` bash
121
- airflow initdb
122
- ```
48
+ airflow version
49
+ ```
123
50
124
- ###### d. Launch airflow webserver
125
- ``` bash
126
- airflow webserver
127
- ```
51
+ ###### b. Go to airflow home and config mysql connection
52
+ ``` bash
53
+ cd $AIRFLOW_HOME
54
+ vi airflow.cfg
55
+ ```
128
56
129
- ``` bash
130
- ariflow worker
131
- ```
57
+ - Default mysql
58
+ ``` bash
59
+ # The executor class that airflow should use. Choices include
60
+ # SequentialExecutor, LocalExecutor, CeleryExecutor
61
+ executor = CeleryExecutor
62
+
63
+
64
+ # The SqlAlchemy connection string to the metadata database.
65
+ # SqlAlchemy supports many different database engine, more information
66
+ # their website
67
+ sql_alchemy_conn = mysql://airflow:airflow@localhost/airflow
68
+
69
+ # The Celery broker URL. Celery supports RabbitMQ, Redis and experimentally
70
+ # a sqlalchemy database. Refer to the Celery documentation for more
71
+ # information.
72
+ broker_url = sqla+mysql://airflow:airflow@localhost:3306/airflow
73
+
74
+ # Another key Celery setting
75
+ celery_result_backend = db+mysql://airflow:airflow@localhost:3306/airflow
76
+ ```
77
+
78
+ - Mannual mysql
79
+ ``` bash
80
+ # The executor class that airflow should use. Choices include
81
+ # SequentialExecutor, LocalExecutor, CeleryExecutor
82
+ executor = CeleryExecutor
83
+
84
+
85
+ # The SqlAlchemy connection string to the metadata database.
86
+ # SqlAlchemy supports many different database engine, more information
87
+ # their website
88
+ sql_alchemy_conn = mysql+mysqldb://airflow:airflow@localhost/airflow? unix_socket=/path/to/thesock
89
+
90
+ # The Celery broker URL. Celery supports RabbitMQ, Redis and experimentally
91
+ # a sqlalchemy database. Refer to the Celery documentation for more
92
+ # information.
93
+ broker_url = sqla+mysql://airflow:airflow@localhost:3306/airflow? unix_socket=/path/to/thesock
94
+
95
+ # Another key Celery setting
96
+ celery_result_backend = db+mysql://airflow:airflow@localhost:3306/airflow? unix_socket=/path/to/thesock
97
+ ```
98
+
99
+ - Enable SSL
100
+ ``` bash
101
+ # generate your own certificate
102
+ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout mykey.key -out mycert.pem
103
+ ```
104
+
105
+ ``` bash
106
+ [webserver]
107
+ # The base url of your website as airflow cannot guess what domain or
108
+ # cname you are using. This is used in automated emails that
109
+ # airflow sends to point links to the right web server
110
+ base_url = http://localhost:443
111
+
112
+ # The ip specified when starting the web server
113
+ web_server_host = 0.0.0.0
114
+
115
+ # The port on which to run the web server
116
+ web_server_port = 443
117
+
118
+ # Paths to the SSL certificate and key for the web server. When both are
119
+ # provided SSL will be enabled. This does not change the web server port.
120
+ web_server_ssl_cert = ~ /airflow/mycert.pem
121
+ web_server_ssl_key = ~ /airflow/mykey.key
122
+ ```
123
+
124
+ ###### c. Initialise db connection
125
+ ``` bash
126
+ airflow initdb
127
+ ```
128
+
129
+ ###### d. Launch airflow webserver
130
+ ``` bash
131
+ airflow webserver
132
+ ```
133
+
134
+ ``` bash
135
+ ariflow worker
136
+ ```
0 commit comments