This file contains 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/bash | |
host_slave=`mysql -h'Endpoint do Banco de dados' -u'Usuário' –p’Senha’ -e "select hostname | |
from cluster_redis.servidores where nome='secundario';" | sed 1d` | |
#Limpa fila remota | |
ssh -o 'StrictHostKeyChecking no' redis@$host_slave '/usr/local/sbin/limpa_fila.sh' | |
#Fim |
This file contains 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/bash | |
#Script primario | |
#Inserir o meu hostname | |
mysql -h'Endpoint do Banco de dados' -u'Usuário' -p’Senha‘ -e "update cluster_redis.servidores SET hostname='$HOSTNAME' where nome='primario';" | |
#Limpa fila remota | |
su - redis /usr/local/sbin/limpa_fila_remota.sh | |
#Inicializando o Redis | |
/etc/init.d/redis-server restart |
This file contains 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/bash | |
/sbin/iptables -F | |
host_master=`cat /etc/redis/redis.conf | grep slaveof |grep 6379 | cut -d " " -f2` | |
IP_master=`host $host_master | cut -d " " -f4` | |
/sbin/iptables -A INPUT -p tcp --dport 6379 -s 127.0.0.1 -j ACCEPT | |
/sbin/iptables -A INPUT -p tcp --dport 6379 -s $IP_master -j ACCEPT | |
/sbin/iptables -A INPUT -p tcp --dport 6379 -j REJECT |
This file contains 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/bash | |
/usr/local/sbin/testa_master.sh | |
sleep 20 | |
/usr/local/sbin/testa_master.sh | |
sleep 20 | |
/usr/local/sbin/testa_master.sh |
This file contains 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
Conteúdo: | |
#!/bin/bash | |
#Limpa a Fila local | |
redis-cli -a "Senha definida nos passos anteriores" flushall | |
#Fim |
This file contains 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/bash | |
#Script secundario | |
#Inserir o meu nome de host | |
mysql -h'Endpoint do Banco de dados' -u'Usuário' -p’Senha‘ -e "update cluster_redis.servidores SET hostname='$HOSTNAME' where nome='secundario';" | |
# Ve quem é o primario | |
nome_primario_redis=`mysql -h'Endpoint do Banco de dados' -u'Usuário' -p’Senha‘ -e "select hostname from cluster_redis.servidores where nome='primario';" | sed 1d` | |
# Seta o primario para replicacao |
This file contains 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/bash | |
#Ve Host primario no arquivo, faz o teste | |
host_master=`cat /etc/redis/redis.conf | grep slaveof | grep 6379 | cut -d " " -f2` | |
pasta=/usr/local/sbin | |
nc -w 5 -z $host_master 6379 && echo "Master OK 1" && $pasta/bloqueia_porta.sh && echo "Bloqueio de porta 1" && exit | |
#Se retornar erro, antes de liberar entrada ele vai chamar o startup pra ver se o host esta certo |
This file contains 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
setacl -m u:redis:r-x -R /usr/local/sbin/ |
This file contains 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
su - redis; | |
ssh-keygen; | |
cat ~/.ssh/id_rsa.pub | |
#A chave copiada deste comando deverá ser inserida em um arquivo ~/.ssh/authorized_keys do outro servidor. |
This file contains 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
-- Crie a base de dados e tabela para controle: | |
Create database cluster_redis; use cluster_redis ; create table servidores(id int, nome varchar(15),hostname varchar(30)); | |
-- Insira as linhas a serem utilizadas para controle do cluster redis: | |
insert into servidores values (1, 'primario','host'); insert into servidores values (2, 'secundario','host'); | |
-- Crie a tabela de status da fila: | |
create table status_fila(id int,nome_fila varchar(20),status varchar(30)); |
OlderNewer