├── repotest.txt ├── .gitignore ├── .idea ├── .gitignore ├── vcs.xml ├── misc.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml └── aleatory-stuff.iml ├── docker └── stop-all ├── nas-utilities ├── nas_neon.png ├── check-alive-ip └── make_nas ├── README.md ├── iptables-block-facebook ├── linux-tricks.md ├── spark-tricks.md ├── .tmux.conf ├── module-list.pl ├── docker-utils.md ├── after-install.sh ├── bigdata-notes.md └── LICENSE /repotest.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.sw* 2 | .idea/ 3 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /docker/stop-all: -------------------------------------------------------------------------------- 1 | #! /usr/bin/bash 2 | 3 | docker ps -a | cut -d ' ' -f1 | tail -n +2 | xargs docker rm 4 | 5 | -------------------------------------------------------------------------------- /nas-utilities/nas_neon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bang/aleatory-stuff/master/nas-utilities/nas_neon.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aleatory-stuff 2 | 3 | It's just some stuff that I build to solve my problems. I hope that it can be useful for other people. 4 | -------------------------------------------------------------------------------- /iptables-block-facebook: -------------------------------------------------------------------------------- 1 | sudo iptables -A INPUT -s 192.168.1.102 -d "facebook.com" -j REJECT && sudo iptables -A OUTPUT -s 192.168.1.102 -d "facebook.com" -j REJECT 2 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/aleatory-stuff.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /nas-utilities/check-alive-ip: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl 2 | 3 | use strict; 4 | use warnings; 5 | use feature qw/say/; 6 | use Net::Ping; 7 | 8 | my $p = Net::Ping->new(); 9 | 10 | 11 | foreach my $frag(100..200){ 12 | my $ip = '192.168.1.' . $frag; 13 | my $r = $p->ping($ip) ? 'is alive!' : 'is dead!'; 14 | say "$ip $r"; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /linux-tricks.md: -------------------------------------------------------------------------------- 1 | 2 | ### Prints when 'some-dataset.csv' file has a number of columns different than 21 3 | `cat some-dataset.csv | awk -F";" '{print NF}' | grep -n -v 21` 4 | 5 | ### In my opinion, Facebook is one of most wrong things on Internet! You should put this rule 6 | ``` 7 | sudo iptables -A INPUT -s -d "facebook.com" -j REJECT && sudo iptables -A OUTPUT -s -d "facebook.com" -j REJECT 8 | ``` 9 | -------------------------------------------------------------------------------- /spark-tricks.md: -------------------------------------------------------------------------------- 1 | # Spark tricks 2 | 3 | ## Deactivating output compression from hive through Spark 4 | ``` 5 | spark = SparkSession.builder \ 6 | .config("hive.exec.dynamic.partition", "true") \ 7 | .config("hive.exec.dynamic.partition.mode", "nonstrict") \ 8 | .config("hive.exec.compress.output", "false") \ 9 | .config("spark.hadoop.mapred.output.compress", "false") \ 10 | .enableHiveSupport().getOrCreate() 11 | ``` 12 | -------------------------------------------------------------------------------- /.tmux.conf: -------------------------------------------------------------------------------- 1 | setw -g xterm-keys on 2 | set -g set-titles on 3 | set -g history-limit 10000 4 | 5 | #set -g prefix C-a 6 | #bind-key C-a last-window 7 | 8 | unbind % 9 | bind | split-window -h 10 | bind - split-window -v 11 | 12 | # Set status bar 13 | set -g status-bg black 14 | set -g status-fg white 15 | set -g status-left '#[fg=green]#H' 16 | set -g status-right '#[fg=yellow]#(cut -d " " -f1-4 /proc/loadavg)' 17 | 18 | # Highlight active window 19 | set-window-option -g window-status-current-bg red 20 | 21 | # Automatically set window title 22 | setw -g automatic-rename 23 | 24 | # Set window notifications 25 | setw -g monitor-activity on 26 | set -g visual-activity on 27 | 28 | # 256 color 29 | set -g default-terminal "screen-256color" 30 | 31 | # @.bashrc: 32 | #PS2='$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I") $PWD)' 33 | #PS1="${PS1}${PS2}" 34 | bind-key C-c run-shell 'tmux neww -n bash "cd $(tmux display -p "\$TMUXPWD_#I"); exec bash"' 35 | 36 | bind -n M-Left previous-window 37 | bind -n M-Right next-window 38 | -------------------------------------------------------------------------------- /module-list.pl: -------------------------------------------------------------------------------- 1 | #!perl 2 | use strict; 3 | use warnings; 4 | use feature qw(:5.12); 5 | 6 | use ExtUtils::Installed; 7 | use Module::CoreList; 8 | use Module::Info; 9 | 10 | my $inst = ExtUtils::Installed->new(); 11 | my $count = 0; 12 | my %modules; 13 | foreach ( $inst->modules() ) { 14 | next if m/^[[:lower:]]/; # skip pragmas 15 | next if $_ eq 'Perl'; # core modules aren't present in this list, 16 | # instead coming under the name Perl 17 | my $version = $inst->version($_); 18 | $version = $version->stringify if ref $version; # version may be returned as 19 | # a version object 20 | $modules{$_} = { name => $_, version => $version }; 21 | $count++; 22 | } 23 | foreach ( Module::CoreList->find_modules() ) { 24 | next if m/^[[:lower:]]/; # skip pragmas 25 | my $module = Module::Info->new_from_module($_) or next; 26 | $modules{$_} = { name => $_, version => $module->version // q(???) }; 27 | $count++; 28 | } 29 | foreach ( sort keys %modules ) { 30 | say $_ ; 31 | } 32 | __END__ 33 | 34 | -------------------------------------------------------------------------------- /docker-utils.md: -------------------------------------------------------------------------------- 1 | # docker-utils 2 | Utilities for docker 3 | 4 | ## Recovering your Dockerfile after making some stupid thing with git or whatever 5 | #!/bin/bash 6 | 7 | ```bash 8 | case "$OSTYPE" in 9 | linux*) 10 | docker history --no-trunc --format "{{.CreatedBy}}" $1 | # extract information from layers 11 | tac | # reverse the file 12 | sed 's,^\(|3.*\)\?/bin/\(ba\)\?sh -c,RUN,' | # change /bin/(ba)?sh calls to RUN 13 | sed 's,^RUN #(nop) *,,' | # remove RUN #(nop) calls for ENV,LABEL... 14 | sed 's, *&& *, \\\n \&\& ,g' # pretty print multi command lines following Docker best practices 15 | ;; 16 | darwin*) 17 | docker history --no-trunc --format "{{.CreatedBy}}" $1 | # extract information from layers 18 | tail -r | # reverse the file 19 | sed -E 's,^(\|3.*)?/bin/(ba)?sh -c,RUN,' | # change /bin/(ba)?sh calls to RUN 20 | sed 's,^RUN #(nop) *,,' | # remove RUN #(nop) calls for ENV,LABEL... 21 | sed $'s, *&& *, \\\ \\\n \&\& ,g' # pretty print multi command lines following Docker best practices 22 | ;; 23 | *) 24 | echo "unknown OSTYPE: $OSTYPE" 25 | ;; 26 | esac 27 | ``` 28 | -------------------------------------------------------------------------------- /after-install.sh: -------------------------------------------------------------------------------- 1 | 2 | ## installing essential and useful packages 3 | echo "Installing essential modules" 4 | sudo apt install -y vim vim-gtk3 tmux \ 5 | git \ 6 | build-essential \ 7 | vlc \ 8 | nmap \ 9 | nfs-common \ 10 | neofetch \ 11 | watchdog 12 | echo "Done!" 13 | 14 | echo "Removing not-want shit!" 15 | # Removing don't-ask-for-install packages from Linux 16 | # * is not working on zsh, I don't know why! 17 | /bin/bash -c "sudo apt purge -y thunderbird* libreoffice*" 18 | echo "Done!" 19 | 20 | echo "Installing docker" 21 | ## installing docker according to https://docs.docker.com/engine/install/ubuntu/ 22 | # removing possible already installed docker package 23 | sudo apt-get remove docker docker-engine docker.io containerd runc 24 | for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done 25 | 26 | 27 | ## installing docker dependecies 28 | sudo apt-get update 29 | sudo apt-get install -y \ 30 | apt-transport-https \ 31 | ca-certificates \ 32 | curl \ 33 | gnupg-agent \ 34 | software-properties-common \ 35 | gnupg 36 | 37 | # Install keyrings 38 | sudo install -m 0755 -d /etc/apt/keyrings 39 | 40 | # adding repos, keys etc 41 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 42 | sudo chmod a+r /etc/apt/keyrings/docker.gpg 43 | 44 | 45 | # Set up repository 46 | echo \ 47 | "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ 48 | "$(. /etc/os-release && echo "$UBUNTU_CODENAME")" stable" | \ 49 | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 50 | 51 | sudo apt-get update 52 | 53 | # finally installing docker 54 | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 55 | 56 | # adding user to docker group 57 | sudo usermod -a -G docker $USER 58 | 59 | echo "Done!" 60 | 61 | echo "Installing Brave browser" 62 | # Installing brave browser 63 | sudo apt installing -y apt-transport-https curl gnupg 64 | curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add - 65 | echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list 66 | sudo apt update && sudo apt install -y brave-browser 67 | 68 | 69 | echo "Installing ohmyzsh" 70 | # Unset ZSH 71 | unset ZSH 72 | # Removing .oh-my-zsh directory 73 | rm -rf ~/.oh-my-zsh 74 | # To remember 75 | ZSH_THEME=refined 76 | # installing ohmyzsh 77 | sudo apt install -y zsh && sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 78 | # installing extra fonts for oh my zsh themes 79 | git clone https://github.com/powerline/fonts.git --depth=1 80 | cd fonts 81 | chmod +x install.sh 82 | ./install.sh 83 | cd .. 84 | rm -rf fonts 85 | 86 | echo "Done!" 87 | 88 | # Installing design/streaming programs 89 | echo "Installing design/streaming programs" 90 | sudo apt install -y gimp inkscape obs-studio blender 91 | echo "Done! 92 | 93 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 65 | -------------------------------------------------------------------------------- /nas-utilities/make_nas: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ## Color constants 4 | RED='\033[0;31m' 5 | GREEN='\033[0;32m' 6 | #CYAN='\033[0;36m' 7 | #BLUE='\033[0;34m' 8 | YELLOW='\033[0;33m' 9 | NC='\033[0m' 10 | 11 | ## Config 12 | 13 | #cache data and others 14 | data_dir=$HOME/.nas 15 | 16 | #directory where NAS will be mount 17 | nas_mountpoint="/mnt/nas" 18 | 19 | ## End Config 20 | 21 | ## Functions 22 | 23 | IP_FORCED="192.168.15" 24 | 25 | function track_ip { 26 | ip=$1 27 | ok=0 28 | if [ -z "$ip" ]; then 29 | # Getting Gateway IP 30 | gateway=$(ip route show |head -n1|cut -d ' ' -f3) 31 | echo "GATEWAY: $gateway" 32 | 33 | target=$(echo "$gateway" |perl -ne '@l=split/\./,$_;pop@l;$q=join(".",@l) . ".0/24";print"$q";') 34 | echo "TARGET: $target" 35 | 36 | # FORCING TARGET! 37 | target="${IP_FORCED}.0/24" 38 | echo "FORCED TARGET: ${target}" 39 | 40 | # Getting all IPs that matters 41 | # iplist=`arp -a | cut -d ' ' -f2 | perl -ne 's/\(|\)//g;print$_;'` 42 | # iplist=$(nmap -sP -n $target | perl -ne '$s=$_;chomp$s;$s;if($s =~ /^.+?scan report for ([0-9\.]+).*?$/ ){print "$1"; }') 43 | iplist=$(nmap -sP -n $target | perl -ne '$s=$_;if($s =~ /^.+?scan report for(.*)$/s ){print "$1"; }') 44 | 45 | # Iterating ignoring gateway 46 | for ip in "${iplist[@]}" 47 | do 48 | if [ "$ip" == "$gateway" ]; then 49 | continue 50 | 51 | else 52 | echo "checking IP $ip" 53 | # Looking for "ShareCenter" on HTML page 54 | parse=`curl --connect-timeout 5 -s -k "https://$ip" |grep "ShareCenter"`; 55 | 56 | # NAS IP found 57 | if [ "$parse" ]; then 58 | echo "Found NAS on IP: $ip"; 59 | echo "mounting nas in $nas_mountpoint"; 60 | r=`sudo mount -o uid=${UID},ro -tnfs $ip:/mnt/HD/HD_a2 /mnt/nas/`; 61 | 62 | if [ ! -z "$r" ]; then 63 | echo "Problems trying to mount '$nas_mountpoint'. Aborting..."; 64 | read -rsp $'Press any key to continue...\n' -n1 key 65 | exit; 66 | 67 | else 68 | printf "\n${GREEN}mount in '$nas_mountpoint' from '$ip' ok!${NC}\n"; 69 | echo $ip >$data_dir/last_nas_ip 70 | ok=1 71 | break; 72 | fi 73 | fi 74 | fi 75 | done 76 | 77 | if [ $ok == 0 ];then 78 | printf "\n${YELLOW}No NAS found! Perhaps is the device off-line!? ${NC}\n" 79 | read -rsp $'Press any key to continue...\n' -n1 key 80 | exit; 81 | fi 82 | else 83 | echo "Trying to find NAS..." 84 | 85 | #scrapping the NAS web page on CURL response content with grep command 86 | parse=`curl --connect-timeout 5 -s -k "https://$ip" |grep "ShareCenter"`; 87 | 88 | #Mount NAS in $nas_mountpoint if found. Otherwise abort! 89 | if [ "$parse" ]; then 90 | echo "Found NAS on IP: $ip"; 91 | echo "mounting nas in $nas_mountpoint"; 92 | r=`sudo mount -tnfs $ip:/mnt/HD/HD_a2 $nas_mountpoint`; 93 | if [ ! -z "$r" ]; then 94 | printf "\n${RED}Problems when mount '$nas_mountpoint'. Aborting...${NC}\n"; 95 | else 96 | printf "\n${GREEN}mount in '$nas_mountpoint' from '$ip' ok!${NC}\n"; 97 | echo $ip >$data_dir/last_nas_ip 98 | read -rsp $'Press any key to continue...\n' -n1 key 99 | exit; 100 | fi 101 | else 102 | printf "\n${YELLOW}No NAS was found in the network! Check if it's off or offline!${NC}\n" 103 | printf "\nDo you want to try track some IPs in your network in order to try to find the NAS device? (y/n)" 104 | read scan_ip 105 | if [ "${scan_ip}" == "y" ]; then 106 | printf "\n${YELLOW}OK! Since the last is useless now, it will be deleted from cache file.${NC}\n" 107 | rm $data_dir/last_nas_ip 108 | track_ip 109 | fi 110 | read -rsp $'Press any key to continue...\n' -n1 key 111 | exit; 112 | fi 113 | fi 114 | return $ok 115 | } 116 | 117 | ## End Functions 118 | 119 | ### MAIN ## 120 | 121 | echo "Running..." 122 | 123 | #check if mountpoint is already mount. If it is, ask to umount 124 | if [ "$(mount | grep -c $nas_mountpoint )" == 1 ]; then 125 | printf "\n${YELLOW}'${nas_mountpoint}' is already mounted!\n${NC}"; 126 | read -p "Do you want to umount it(y/n)?" -n 1 -r 127 | if [ $REPLY == "y" ]; then 128 | printf "\n${YELLOW}Unmounting $nas_mountpoint${NC}" 129 | r=`sudo umount $nas_mountpoint` 130 | if [ -z "$r" ]; then 131 | printf "${GREEN}OK!${NC}" 132 | fi 133 | echo 'bye!';sleep 2 134 | exit 135 | else 136 | printf "\n${GREEN}Nothing changes then! Bye! ${NC}";sleep 2 137 | exit 0 138 | fi 139 | fi 140 | 141 | #creating data_dir for storage ip data and others 142 | if [ ! -d "$data_dir" ]; then 143 | echo "Creating data_dir for make_nas in '$data_dir'"; 144 | mkdir $data_dir 145 | fi 146 | 147 | echo "Checking NAS mount point in '$nas_mountpoint'" 148 | if [ ! -d "$nas_mountpoint" ]; then 149 | r=`sudo mkdir $nas_mountpoint`; 150 | if [ ! -z "$r" ]; then 151 | printf "\n${RED}Problems to create dir '$nas_mountpoint'. Aborting...${NC}\n"; 152 | read -rsp $'Press any key to continue...\n' -n1 key 153 | exit; 154 | fi 155 | fi 156 | 157 | echo "NAS mountpoint OK!" 158 | echo "Checking last NAS IP..." 159 | if [ -f "$data_dir/last_nas_ip" ]; then 160 | 161 | ip=`cat <$data_dir/last_nas_ip` 162 | echo "Last NAS IP found: '$ip'" 163 | track_ip $ip 164 | else 165 | 166 | echo "There is no IP registry for NAS!" 167 | echo "Tracking NAS IP..." 168 | track_ip 169 | fi 170 | 171 | read -rsp $'Press any key to continue...\n' -n1 key 172 | exit; 173 | 174 | 175 | ## end MAIN ## -------------------------------------------------------------------------------- /bigdata-notes.md: -------------------------------------------------------------------------------- 1 | ## Data Access 2 | 3 | ### PIG 4 | #### Casos de utilização 5 | - ETL 6 | - Pesquisa em dados "crus" 7 | - Processamento de dados iterativos 8 | 9 | #### Como o Pig é executado num cluster 10 | - Acessa o YARN através de jobs MapReduce ou Tez 11 | -- MapReduce é uma lib Java que utiliza os conceitos "map" e "reduce" para extrair informação do HDFS 12 | -- Tez é uma lib que permite construir "frameworks" que acessam o YARN utilizando tarefas acíclicas direcionadas a grafos para processar os dados do HDFS 13 | - Pig utiliza "Pig Latin" como linguagem de ETL, que permite descrever fluxos de dados para definir como os dados serão processados e transformados(ETL) 14 | 15 | ### Hive 16 | #### Como o Hive funciona no Hadoop 17 | - NÃO armazena dados, exatamente, mas metadados que representam tabelas de modo similar a um RDBMS 18 | - permite acesso aos dados do HDFS através de uma linguagem semelhante ao SQL 19 | - permite organizar os dados em forma de tabelas através de metadados 20 | 21 | ### Hive 22 | #### Tabelas 23 | - Cada tabela no Hive corresponde a um diretório no HDFS 24 | - As tabelas do Hive são armazenadas em no "Hive metastore" 25 | -- "Hive metastore" permite definir um banco de dados relacional(MSQL por default, Postgres, Oracle etc), manipular os dados do HDFS 26 | - HiveQL é um subconjunto do SQL e é a linguagem utilizada pelo Hive 27 | - HiveQL converte suas instruções para "Hadoop jobs", que podem ser despachados para Tez, MapReduce ou Spark 28 | - Os dados das tabelas gerenciadas pelo Hive(ou tabelas INTERNAS), são armazenados no diretório "Hive warehouse" (default: /apps/hive/warehouse/) 29 | - Tabelas NÃO gerenciadas pelo Hive(ou tabelas EXTERNAS), podem ser armazenadas em qualquer lugar do HDFS. 30 | - DROP em tabelas INTERNAS apagam DADOS E METADADOS 31 | - DROP em tabelas EXTERNAS apagam SOMENTE OS METADADOS 32 | - Tabelas "Bucketed" são eficientes para desempenhar bem "map-side jobs", que é consideravelmente mais eficiente do que "reduce-side jobs" 33 | - Tabelas "Partitioned" oferecem vantagens de desempenho quando organizadas em subdiretórios baseados em colunas específicas, já que cláusulas "WHERE" 34 | são executadas somente rastreando dados dos diretórios especificados na própria cláusula "WHERE". 35 | 36 | #### HCatalog 37 | - HCatalog é uma extensão do Hive para que outros frameworks como "Pig" e "Java MapReduce" possam acessar o HDFS através dos metadados do Hive 38 | - HCatalog permite compartilhar dados entre desenvolvedores Pig, Hive e Java(MapReduce) em uma "view" comum 39 | 40 | #### Tez: benefícios 41 | - Tez roda sobre o YARN e executa as DAGs(Direct Acyclic Graph) mais rapidamente e mais eficientemente do que MapReduce 42 | - Hive e Pig são mais eficientes quando rodam sobre Tez(quase sempre) 43 | 44 | ### Storm 45 | #### Onde se utiliza e alguns exemplos 46 | - Streaming de dados em tempo-real através de "storm bolts" 47 | - Storm se integra com o YARN através do "Apache Slider" 48 | - Storm é considerado para utilizar em operações que exigem governança e segurança de dados(operações com cartão de crédito, por exemplo) 49 | - Prevê eventos indesejados de negação de crédito de cartão de crédito, por exemplo, em tempo real 50 | - Otimiza resultados positivos baseados em análise em tempo-real para, por exemplo, oferecer descontos no varejo para clientes específicos 51 | 52 | ### HBase 53 | #### O que é? 54 | - Banco de dados não-relacional que roda no topo do HDFS 55 | - Escrita/Leitura em tempo-real para acessar bases de dados gigantescas 56 | - API em Java 57 | 58 | #### Para que serve? 59 | - Acesso em tempo-real a bases de dados gigantescas 60 | - Criação de tabelas gigantes para armazenamento multi-estruturado ou dados esparsos(dados não-estruturados) 61 | - É possível criar "tickers" na área financeira para monitorar ações(bolsa de valores), na ordem de mais de trinta mil leituras/segundo 62 | - Monitoramento de sistemas de segurança web em tempo-real através de eventos em logs na ordem de bilhões de linhas 63 | 64 | ### Spark 65 | #### Componentes 66 | - Spark SQL: Aceita HiveQL ou SQL básico para executar queries; 67 | - Spark Streaming: Permite manipular streaming de dados escaláveis, tolerante a falhas em tempo-real 68 | - Spark MLib: Biblioteca de "Machine Learning". Provê algoritmos padrão de "machine learning" fáceis de implementar e escaláveis 69 | - GraphX: Para trabalhar com grafos e computação paralela 70 | 71 | #### Como aplicações com Spark executam o YARN 72 | - Cluster mode: Diver Spark roda dentro do processo ApplicationMaster, que é gerenciado pelo YARN sobre o Cluster, e o cliente pode deixar o 73 | ciclo do Spark após a inicialização da aplicação 74 | - Client mode: o driver roda no processo do cliente. O AplicationMaster é usado apenas para requisitar recursos ao YARN, e a aplicação precisa 75 | permanecer rodando no ciclo do Spark até o fim. 76 | 77 | ### Solr 78 | #### Propóstio 79 | - Plataforma de pesquisa de dados armazenados em HDFS no Hadoop 80 | 81 | 82 | ## Data Management 83 | 84 | 85 | ### HDFS 86 | #### Intro 87 | - HDFS(Hadoop Distributed File System) é o sistema de armazenamento de dados do Hadoop 88 | - HDFS é escalável: Se for necessário mais armazenamento, é preciso apenas adicionar um "nó" ao cluster 89 | - HDFS é tolerante à falhas: Se um nó falha, o dado não é perdido 90 | - O "NameNode" é o "nó-mestre" que mantém o "namespace" do sistema de arquivos e envia comandos aos "DataNodes" 91 | - Um "StandBy NameNode" pode ser configurado para prover alta-disponibilidade ao "NameNode"(redundância) 92 | 93 | #### Replicação de bloco 94 | - Grandes dados em arquivos são separados em blocos que são distribuídos no cluster 95 | - O "NameNode" rastreia todos os nomes de arquivos e pastas, e também as localizações dos blocos nos "DataNodes" 96 | - Os "DataNodes" armazenam dados instruídos pelo "NameNode" 97 | 98 | ### YARN 99 | #### Intro 100 | - Prover o componente de processamento do Hadoop 101 | - O "ResourceManager" tem uma "agendador", que é responsável por alocar recursos das várias aplicações que estão executando no cluster, de acordo 102 | com suas restrições, tais como, capacidade de enfileiramento e limites de usuário 103 | - Os "NodeManagers" executa tarefas dirigidas pelo "ResourceManager" 104 | - A "ApplicationMaster" tem a responsabilidade de negociar containers de recursos apropriados do agendador, rastreando o seu status, e monitorando 105 | o seu progresso 106 | 107 | 108 | ## Data Governance and Workflow 109 | 110 | ### Falcon 111 | #### Intro 112 | - Falcon simplifica o desenvolvimento e gerenciamento de pipelines de processamento de dados com uma camada superior de abstração, levando codificação 113 | complexa do processamento de dados aplicativos, fornecendo uma solução "out-of-the-box" de serviços de gerenciamento de dados. 114 | - Operadores de Hadoop podem usar a UI web do Falcon ou a interface de linha de comando para criar pipelines de dados, que consiste em definições 115 | de localização de clusters, consumo de dados, e lógica de processamento 116 | 117 | ### Falcon 118 | #### Entidades 119 | - Cluster: Define onde o dado e os processos são armazenados 120 | - Feed: Define quais conjuntos de dados podem ser limpos e processados 121 | - Processo: Consome os "Feeds", invoca o processamento lógico, e produz outros "feeds" 122 | 123 | ### Atlas 124 | #### Intro 125 | - Projetado para trocar metadados com outras ferramentas dentro ou fora da "pilha Hadoop", assim possibilitando um controle de governança "agnóstica" de 126 | plataforma que efetivamente entrega o cumprimento dos requisitos 127 | - tags hierarquicas de controle de acesso a dados no HDFS 128 | - controle de origem/linhagem de dados manipulados por ferramentas como Hive, Spark, Pig, através de metadados 129 | 130 | 131 | ### Sqoop 132 | #### Intro 133 | - Sqoop é uma ferramenta para transferir dados entre um banco de dados relacional e o Hadoop 134 | - Funciona em ambas as direções: Tanto carregando de um EDW(Enterprise Datawarehouse) para processamento, e o resultado pode ser exportado de volta para 135 | o Hadoop. 136 | 137 | ### Flume 138 | #### Intro 139 | - Flume permite que usuários do Hadoop "ingiram" uma quantidade grande de dados via streaming do HDFS para armazenamento 140 | - Tipos comuns desses streams: logs de aplicação, dados de máquina e sensores, dados de geo-localização, e dados de mídia social 141 | 142 | ### Kafka 143 | #### Intro 144 | - Kafka é um enfileirador de mensagens 145 | - Kafka também é usado para substituir enfileiradores de mensagem tradicionais como JMS e AMQP por conta do seu rendimento, escalabilidade e confiança 146 | 147 | #### Componentes 148 | - Topic: Categoria definida pelo usuário para que a mensagem seja publicada 149 | - Producer: publica mensagens para um ou mais tópicos 150 | - Consumer: assina tópicos e processa as mensagens publicadas 151 | - Broker: Gerencia a persistência e replicação dos dados de mensagens 152 | 153 | ### Cloudbreak 154 | #### Intro 155 | - ferramenta de provisionamento de Clusters Hadoop em plataformas de cloud como Amazon e Azure 156 | - Usa o Ambari Blueprint para configurar dinamicamente e provisionar clusters HDP(Horton Data Plataform) na nuvem 157 | 158 | ### Zookeeper 159 | #### Papel do Zookeeper 160 | - Prover configuração de serviços distribuída 161 | - Prover sincronização de serviços 162 | - Prover um registro de nomes para sistemas distribuídos 163 | 164 | ### Oozie 165 | - É uma interface web para agendamento de jobs do Hadoop 166 | - Um agendamento no Oozie é uma sequência de ações, que podem envolver um script Pig, uma query Hive, um job MapReduce e asism por diante 167 | - Oozie mantém um "job" coordenador que é "engatilhado" quando um workflow é executado 168 | 169 | ### Ranger 170 | - É um framework centralizado de segurança para gerenciar acesso com alta granularidade sobre ferramentas como Hive e HBase 171 | - Usando um console, administradores podem facilmente gerenciar políticas de acesso à arquivos, pastas, bancos de dados, tabelas ou colunas 172 | 173 | ### Knox 174 | - Prover um "perímetro" de segurança(proxy) para clusters Hadoop 175 | - O Knox Gateway provê um ponto-único de acesso para TODAS as interações REST com clusters Hadoop 176 | - Knox pode trabalhar diretamente com o Kerberos para controlar autenticação e autorização de usuários 177 | 178 | 179 | 180 | ## Other components 181 | 182 | ### Thrift 183 | #### Intro 184 | - É uma linguagem de definição de interface e um protocolo binário que é utilizado para criar serviços em multiplas linguagens 185 | - Usado como uma chamada RPC 186 | - Combina uma pilha de aplicação com uma engine geradora de códigos para construir serviços "cross-plataform" 187 | 188 | #### Benefícios 189 | - Alternativa ao SOAP 190 | - Biblioteca simples e enxuta 191 | - Sem framework para implementar 192 | - Sem XML 193 | - O formato do nível de aplicação e o formato do nível de serialização estão separados de forma clara, e podem ser modificados de forma independente 194 | - Estilos de serialização: binary, HTTP-friendly and compact binary 195 | - Sem dependências de "builds", software-padrão. Sem mistura de licenças incompatíveis 196 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | 341 | --------------------------------------------------------------------------------