Last active
August 21, 2021 00:41
-
-
Save staybuzz/88c59dbcbf20fd21fdd0e58a739c5727 to your computer and use it in GitHub Desktop.
for ISUCON
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 -x | |
APP_NAME=webapp | |
APP_ROOT=/home/isucon/${APP_NAME} | |
cd $APP_ROOT | |
# update repo | |
git pull origin master | |
# nginx | |
sudo cp -r configs/nginx /etc/nginx | |
# mysql | |
#sudo cp configs/mysql/my.cnf /etc/mysql/my.cnf | |
sudo cp configs/mysql /etc/mysql | |
# log-lotate and restart services | |
./pre_bench.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
#!/bin/bash -x | |
APP_NAME=webapp | |
# packages | |
sudo apt update | |
sudo apt install -y wget curl git htop dstat sysstat bash-completion unzip tmux iftop | |
# git repo | |
mkdir -p ~/.ssh | |
cat <<EOF >> ~/.ssh/config | |
Host github.com | |
User git | |
Identityfile ~/.ssh/deploykey | |
EOF | |
pushd ~/${APP_NAME} | |
git init | |
git config user.name "isucon" | |
git config user.email "isu@example.com" | |
wget -O .gitignore http://gitignore.io/api/vim,ruby,linux,python,visualstudiocode | |
echo "db" >> .gitignore | |
### scripts | |
wget https://gist.githubusercontent.com/staybuzz/88c59dbcbf20fd21fdd0e58a739c5727/raw/df062635ac4aa7f506866f147e46a5b7b7249b3c/deploy.sh | |
wget https://gist.githubusercontent.com/staybuzz/88c59dbcbf20fd21fdd0e58a739c5727/raw/df062635ac4aa7f506866f147e46a5b7b7249b3c/pre_bench.sh | |
chmod +x deploy.sh | |
chmod +x pre_bench.sh | |
### middleware&sysctl config | |
mkdir -p configs | |
cp -R /etc/mysql configs/ | |
cp -R /etc/nginx configs/ | |
cp /etc/sysctl.conf configs/ | |
### push | |
git add . | |
git commit -m "initial" | |
git remote add origin git@github.com:staybuzz/isucon11q.git | |
git push origin master | |
popd | |
# alp | |
wget https://github.com/tkuchiki/alp/releases/download/v1.0.7/alp_linux_amd64.zip | |
unzip alp_linux_amd64.zip | |
sudo install ./alp /usr/local/bin/alp | |
# percona-toolkit | |
#sudo apt install -y percona-toolkit | |
### xenial | |
#wget https://www.percona.com/downloads/percona-toolkit/3.0.13/binary/debian/xenial/x86_64/percona-toolkit_3.0.13-1.xenial_amd64.deb | |
#sudo dpkg -i percona-toolkit_3.0.13-1.xenial_amd64.deb | |
### bionic | |
#wget https://www.percona.com/downloads/percona-toolkit/3.0.13/binary/debian/bionic/x86_64/percona-toolkit_3.0.13-1.bionic_amd64.deb | |
#sudo dpkg -i percona-toolkit_3.0.13-1.bionic_amd64.deb | |
wget https://repo.percona.com/apt/percona-release_latest.generic_all.deb | |
sudo apt install ./percona-release_latest.generic_all.deb | |
sudo apt update | |
sudo apt-get install -y percona-toolkit | |
# netdata | |
#bash <(curl -Ss https://my-netdata.io/kickstart.sh) | |
# bashrc | |
### ref: https://qiita.com/ryosukue/items/bc1eae639e3950790eb9 | |
cat <<'EOF' >>~/.bashrc | |
if [ -f /etc/bash_completion ]; then | |
. /etc/bash_completion | |
fi | |
if [ -f /etc/bash_completion.d/git-prompt ]; then | |
export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w$(__git_ps1) \n\[\033[01;34m\]\$\[\033[00m\] ' | |
else | |
export PS1='\[\033[01;32m\]\u@\h\[\033[01;33m\] \w \n\[\033[01;34m\]\$\[\033[00m\] ' | |
fi | |
EOF | |
source ~/.bashrc |
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 -x | |
# from: https://gist.github.com/asflash8/0cbb743fd23385f32b412c908959a032 | |
set -ex | |
if [ -f /var/log/mysql/mysql-slow.log ]; then | |
sudo mv /var/log/mysql/mysql-slow.log /var/log/mysql/mysql-slow.log.$(date "+%Y%m%d_%H%M%S") | |
fi | |
if [ -f /var/log/nginx/access.log ]; then | |
sudo mv /var/log/nginx/access.log /var/log/nginx/access.log.$(date "+%Y%m%d_%H%M%S") | |
fi | |
sudo systemctl restart mysql | |
# sudo service memcached restart | |
# bundle install | |
sudo systemctl restart niita_ruby | |
sudo systemctl restart nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment