#!/bin/sh
clustername=$1
tidbversion=$2
ip=$3
sed -i "s/- host:.*/- host: ${ip}/g" topo.yaml
echo "vm.swappiness = 0">> /etc/sysctl.conf
swapoff -a && swapon -a
sysctl -p
sudo systemctl stop firewalld.service
sleep 2
sudo systemctl disable firewalld.service
sleep 2
ntpstat
yum install -p ntp ntpdate && \
systemctl start ntpd.service && \
systemctl enable ntpd.service
sleep 5
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.bash_profile
tiup update --self && tiup update cluster
tiup cluster deploy $clustername $tidbversion ./topo.yaml --user root -p
yum -y install mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin