-
-
Save tridungle/06eea1076bccaca2b1746c4c9a7117fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#instalação pacotes iniciais do sistema operacional | |
apt-get update | |
apt-get upgrade -y | |
apt-get autoremove | |
apt-get autocleanapt-get -y install build-essential binutils gcc make git htop nethogs tmux | |
#Instalação do postgres | |
apt-get -y install postgresql postgresql-contrib libpq-dev postgresql-client postgresql-client-common | |
echo "CREATE USER airflow PASSWORD 'airflow'; CREATE DATABASE airflow; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO airflow;" | sudo -u postgres psql | |
sudo -u postgres sed -i "s|#listen_addresses = 'localhost'|listen_addresses = '*'|" /etc/postgresql/*/main/postgresql.conf | |
sudo -u postgres sed -i "s|127.0.0.1/32|0.0.0.0/0|" /etc/postgresql/*/main/pg_hba.conf | |
sudo -u postgres sed -i "s|::1/128|::/0|" /etc/postgresql/*/main/pg_hba.conf | |
service postgresql restart | |
apt-get -y install redis-server | |
sed -i "s|bind |#bind |" /etc/redis/redis.conf | |
sed -i "s|protected-mode yes|protected-mode no|" /etc/redis/redis.conf | |
sed -i "s|supervised no|supervised systemd|" /etc/redis/redis.conf | |
service redis restart | |
#instalação do python | |
apt-get -y install python3 python3-dev python3-pip python3-wheel | |
pip3 install - upgrade pip | |
pip3 install futures pandas SQLAlchemy psycopg2 celery redis flower flask-bcrypt boto3 ldap3 pymssql | |
#Criando user airflow e dando permissões | |
adduser airflow - gecos "airflow,,," - disabled-password | |
echo "airflow:airflow" | chpasswd | |
usermod -aG sudo airflow | |
echo "airflow ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
#instalando o airflow e os pacotes necessários | |
pip3 install "apache-airflow[s3, postgres, rabbitmq, slack, redis, crypto, celery, async]" | |
mkdir /opt/airflow | |
sudo chown airflow /opt/airflow | |
sudo chgrp airflow /opt/airflow | |
echo export AIRFLOW_HOME=/opt/airflow > /etc/profile.d/airflow.sh | |
echo "in airflow user" | |
su - airflow | |
cd $AIRFLOW_HOME | |
#Inicializa a base de dados do airflow | |
airflow initdb | |
#Altera o endereço de metadados da base de dados cuidado com a senha explicita | |
sed -i "s|result_backend = .*|result_backend = db+postgresql://airflow:airflow@localhost/airflow |g" "$AIRFLOW_HOME"/airflow.cfg | |
sed -i "s|sql_alchemy_conn = .*|sql_alchemy_conn = postgresql+psycopg2://airflow:airflow@$localhost:5432/airflow|g" "$AIRFLOW_HOME"/airflow.cfg | |
#Altera o endereço do redis instalado anteriormente | |
sed -i "s|broker_url = .*|broker_url = redis://localhost:6379/0|g" "$AIRFLOW_HOME"/airflow.cfg | |
sed -i "s|celery_result_backend = .*|celery_result_backend = redis://redis:6379/0|g" "$AIRFLOW_HOME"/airflow.cfg | |
#Altera o executor do airflow para Celery Executor | |
sed -i "s|executor = .*|executor = CeleryExecutor|g" "$AIRFLOW_HOME"/airflow.cfg | |
#Não carrega os exemplos que vem na instalação padrão do airflow | |
sed -i "s|load_examples = .*|load_examples = False|g" "$AIRFLOW_HOME"/airflow.cfg | |
#Altera a cor da barra de navegação do airflow | |
sed -i "s|navbar_color = .*|navbar_color = #296d98|g" "$AIRFLOW_HOME"/airflow.cfg | |
#Após alterações necessário executar novamente o initdb | |
airflow initdb | |
#Inicializando o serviço de webserver para acessar a interface web | |
airflow webserver -D | |
#Inicializando o serviço scheduler | |
airflow scheduler -D | |
#Inicializando o serviço worker | |
airflow worker -D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment