Last active
February 19, 2021 11:57
-
-
Save sanikolaev/51adc72196fc797b029c26667b012b44 to your computer and use it in GitHub Desktop.
Manticore Search replication sandbox
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/sh | |
d="/tmp/manticore_replication_sandbox_docker_compose.yaml"; | |
cat << EOF > $d | |
version: '2.2' | |
services: | |
manticore-1: | |
image: manticoresearch/manticore | |
networks: | |
- manticore | |
manticore-2: | |
image: manticoresearch/manticore | |
networks: | |
- manticore | |
manticore-3: | |
image: manticoresearch/manticore | |
networks: | |
- manticore | |
networks: | |
manticore: | |
driver: bridge | |
EOF | |
r="/tmp/run_manticore.sh" | |
cat << EOF > $r | |
#!/bin/sh | |
until docker-compose -f \$2 exec \$1 echo ok > /dev/null 2>&1; do sleep 1; done; | |
if [ "\$1" = "manticore-1" ]; then | |
q="CREATE CLUSTER c; | |
CREATE TABLE t(f text); | |
ALTER CLUSTER c ADD t; | |
" | |
printf "\$q"|sed -e 's/^/mysql> /' | |
docker-compose -f \$2 exec \$1 mysql -e "\$q" | |
else | |
sleep 5 | |
q="JOIN CLUSTER c AT 'manticore-1'; | |
SHOW TABLES; | |
" | |
printf "\$q"|sed -e 's/^/mysql> /' | |
docker-compose -f \$2 exec \$1 mysql -e "\$q" | |
fi | |
docker-compose -f \$2 exec \$1 mysql | |
EOF | |
chmod +x $r | |
c="/tmp/manticore_replication_sandbox_docker_service.sh" | |
cat << EOF > $c | |
#!/bin/bash | |
trap "docker-compose -f \$1 down" EXIT | |
docker-compose -f \$1 up | |
EOF | |
chmod +x $c | |
s="/tmp/manticore_replication_sandbox_screen" | |
touch $s | |
echo "caption always \"%{= 45}%{+b w}Screen: %n | %h %=%t\" | |
hardstatus alwayslastline \"%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<\"" > $s | |
for i in 1 2 3; do | |
i="manticore-$i" | |
echo "screen -t $i $r $i $d" >> $s | |
done | |
echo "screen -t docker-compose $c $d" >> $s | |
screen -RdS manticore_replication_sandbox -c $s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment