Skip to content

Instantly share code, notes, and snippets.

@sanikolaev
Last active February 19, 2021 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanikolaev/51adc72196fc797b029c26667b012b44 to your computer and use it in GitHub Desktop.
Save sanikolaev/51adc72196fc797b029c26667b012b44 to your computer and use it in GitHub Desktop.
Manticore Search replication sandbox
#!/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