最後の行のスペースまで含めてコピーしてターミナルに貼り付けると、一気に全行のコマンドを実行できます。
3.2.5 構築手順
- リスト3.1 Ubuntuユーザ作成
sudo adduser isucon
cat /etc/passwd | grep isucon
sudo gpasswd -a isucon sudo
su - isucon
timedatectl set-timezone Asia/Tokyo
- リスト3.2 sudo設定編集:エディタ呼び出し
sudo visudo
- リスト3.3 sudo設定編集:エディタ
isucon ALL=NOPASSWD: ALL
- リスト3.4 sudo設定編集:有効化確認
sudo ls
- リスト3.5 SSH鍵作成
mkdir -p /home/isucon/.ssh
ssh-keygen -o -C "isucon" -f /home/isucon/isucon9q-key
ls /home/isucon/ -l
- リスト3.6 SSH鍵配置
cd
touch .ssh/authorized_keys
cat isucon9q-key.pub >> .ssh/authorized_keys
cat .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
ls -l .ssh/authorized_keys
chmod 644 isucon9q-key
ls -l isucon9q-key
- リスト3.7 ソフトウェアインストール
sudo apt-get update
sudo apt-get install -y gcc make unzip golang mysql-server mysql-client nginx
go get -u github.com/go-sql-driver/mysql
go get -u github.com/gorilla/sessions
go get -u github.com/jmoiron/sqlx
go get -u goji.io
go get -u goji.io/pat
go get -u golang.org/x/crypto/bcrypt
go get -u github.com/morikuni/failure
go get -u github.com/skip2/go-qrcode
go get -u github.com/isucon/isucon9-qualify/bench/asset
go get -u github.com/isucon/isucon9-qualify/bench/fails
go get -u github.com/isucon/isucon9-qualify/bench/scenario
go get -u github.com/isucon/isucon9-qualify/bench/server
go get -u github.com/isucon/isucon9-qualify/bench/session
go get -u github.com/najeira/measure
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
- リスト3.8 データ準備
cd
git clone https://github.com/isucon/isucon9-qualify.git
cd isucon9-qualify/initial-data
sudo make
cd ..
cd webapp/public
wget -q https://github.com/isucon/isucon9-qualify/releases/download/v2/initial.zip
unzip -q initial.zip
rm -rf upload
mv v3_initial_data upload
cd ../../initial-data/
wget -q https://github.com/isucon/isucon9-qualify/releases/download/v2/bench1.zip
unzip -q bench1.zip
rm -rf images
mv v3_bench1 images
- リスト3.9 データベース初期化
cd ~/isucon9-qualify/webapp/sql/
cat 00_create_database.sql | sudo mysql
sudo mysql -e 'select user from mysql.user where user = "isucari" and host = "localhost"'
sudo mysql -e 'show databases;'
mysql -uisucari -pisucari
exit
- リスト3.10 データベース初期化
cd ~/isucon9-qualify/webapp/sql/
./init.sh
sudo mysql -e 'use isucari;show tables;'
- リスト3.11 アプリケーションの実行
cd ~/isucon9-qualify/webapp/go
sudo make
./isucari
- リスト3.12 決済サービス実行
cd ~/isucon9-qualify
sudo make
./bin/payment
- リスト3.13 発送サービス実行
cd ~/isucon9-qualify
./bin/shipment
- リスト3.14 アプリケーションIP設定上書き
xxx.xxx.xxx.xxx部分はインスタンスの外部IPに書き換えてください。
cd
echo '{"payment_service_url":"http://xxx.xxx.xxx.xxx:5555","shipment_service_url":"http://xxx.xxx.xxx.xxx:7000"}' > overwriteip.json
curl -XPOST http://127.0.0.1:8000/initialize -H 'Content-Type: application/json' -d @overwriteip.json
- リスト3.15 ベンチマークの実行
cd ~/isucon9-qualify
./bin/benchmarker
- リスト3.16 nginx設定変更
cd
git clone https://github.com/team-fratty/rec4isucon.git code-ng1
cat code-ng1/nginx/nginx.conf | sudo tee /etc/nginx/nginx.conf
sudo nginx -t
sudo nginx -s reload
- リスト3.17 自動起動設定
cd
git clone https://github.com/team-fratty/rec4isucon.git code-sys
cp code-sys/systemd/env.sh /home/isucon/
sudo cp code-sys/systemd/*.service /etc/systemd/system
sudo systemctl enable isucari.golang.service
sudo systemctl enable payment.service
sudo systemctl enable shipment.service
sudo systemctl list-unit-files --type=service |grep -e isu -e pay -e ship
sudo reboot
- リスト3.18 ベンチマーク再実行
cd ~/isucon9-qualify
sudo systemctl stop payment.service
sudo systemctl stop shipment.service
./bin/benchmarker