reagenzn
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    s1.cool-server.net s2.cool-server.net s3.cool-server.net hq.cool-server.net で接続可能 # 接続情報 netdata - https://s1-netdata.cool-server.net/#menu_system_submenu_cpu;theme=slate - https://s2-netdata.cool-server.net/#menu_system_submenu_cpu;theme=slate - https://s3-netdata.cool-server.net/#menu_system_submenu_cpu;theme=slate phpmyadmin - https://pma.cool-server.net/index.php?route=/ pprotein - https://pprotein.cool-server.net/#/group/ go - go1.23.3 # 当日の動き方 ## 接続情報リセット ```shell ssh-keygen -R hq.cool-server.net ssh-keygen -R s1.cool-server.net ssh-keygen -R s2.cool-server.net ssh-keygen -R s3.cool-server.net ``` ## 深澤 <details> ### 前日・当日やること ##### 前日まで - [x] zerosslで証明書を発行しておく - isucon-ansible-templateの更新をしておく - [x] cloudflareのdashboardにアクセスしてdnssecを有効化 ##### 前日 ###### レポジトリの作成 - [ ] app - [ ] isucon-app-templateからレポジトリを作る - [ ] 招待しておく(iyoshiha,sugiwa) - [ ] repoのdeploy keyをisucon-ansible-templateにあるid_ecdsa.pubに指定 - ※ 他で使っていたら消しておく - [ ] hq(環境のsetup) - [ ] isucon-ansible-templateからブランチ切る - [ ] app用のrepoを書いておく(inventory/group_vars/all.yml) ##### 当日 - [ ] EC2インスタンス立ち上げ - 同じvpc,サブネット,セキュリティグループ - Ubuntu Server 22.04 LTS (HVM), SSD Volume Type - t3a.large - パブリックIP有効化 - 1x 30GB gp2 - ユーザーデータは以下 ```bash #!/bin/bash mkdir -p /home/ubuntu/.ssh curl https://github.com/NatsukiFukazawa.keys >> /home/ubuntu/.ssh/authorized_keys curl https://github.com/iyoshiha.keys >> /home/ubuntu/.ssh/authorized_keys curl https://github.com/sugiwa.keys >> /home/ubuntu/.ssh/authorized_keys chmod 700 /home/ubuntu/.ssh chmod 600 /home/ubuntu/.ssh/authorized_keys ``` - [ ] レポジトリの修正 - [ ] app - [ ] APP_NAME,WEBAPP_DIR,SERVICE_NAMEの書き換え(deploy.sh) - [ ] hq - [ ] IPの書き換え(dns/zones/cool-server.net.yaml) - [ ] service名を確認して書き換える(inventory/group_vars/all.yml) ※ 別の鍵を使う場合 ```shell curl https://github.com/iyoshiha.keys >> /home/isucon/.ssh/authorized_keys chmod 700 /home/isucon/.ssh chmod 600 /home/isucon/.ssh/authorized_keys ``` ```bash curl https://github.com/sugiwa.keys >> /home/isucon/.ssh/authorized_keys chmod 700 /home/isucon/.ssh chmod 600 /home/isucon/.ssh/authorized_keys ``` ```bash= sudo systemctl restart sshd ``` - [x] DNSの設定(最悪手動) - [x] docker起動しておく - https://dash.cloudflare.com/2fee4f26de5e3bf12695d6c0a8bb1a4d/cool-server.net/dns/records で確認可能 ```bash cd dns make deploy ``` - [x] (app)isuconユーザー、(hq)ubuntuユーザーでsshできることを確認する - 反映に最大ttl時間がかかる 初回ログインしていないとansibleでこけるため、疎通確認の意味合いも込めてログイン可能か確認 ```bash ssh -i ~/.ssh/ssh_key ubuntu@hq.cool-server.net ssh -i ~/.ssh/ssh_key isucon@s1.cool-server.net ssh -i ~/.ssh/ssh_key isucon@s2.cool-server.net ssh -i ~/.ssh/ssh_key isucon@s3.cool-server.net ``` - [ ] hq用のplaybook起動 - 初回docker 起動でerrorになる ```bash ansible-playbook playbooks/hq.yml -u ubuntu ``` - [ ] app用のplaybook起動 ```bash ansible-playbook playbooks/srv.yml -u isucon ``` - [ ] レポジトリに管理物コピー(nginx,sqlも) ```bash # webappのcopy cp -R /home/isucon/webapp /home/isucon/webapp.bk rm -rf /home/isucon/webapp cd repo/app cp -R ../../webapp.bk ./webapp #(必要なら他のアプリケーションのディレクトリはrmしておく) # env.shのcopy cd ~ cat env.sh >> repo/common/env.sh # mysqlのコピー cd ~ sudo cp /etc/mysql/mysql.conf.d/mysqld.cnf repo/common/etc/mysql/mysql.conf.d/mysqld.cnf mkdir repo/common/etc/mysql/mariadb.conf.d sudo cp /etc/mysql/mariadb.conf.d/50-server.cnf repo/common/etc/mysql/mariadb.conf.d/50-server.cnf sudo chmod 777 repo/common/etc/mysql/* # nginxのコピー cd ~ sudo cp /etc/nginx/nginx.conf repo/common/etc/nginx/nginx.conf sudo chmod 777 repo/common/etc/nginx/* sudo chown isucon:isucon repo/common/etc/nginx/* sudo chown isucon:isucon repo/common/etc/mysql/* ``` - .gitignore編集 - `ls -l`などで重いファイル確認(特にsql) 設定例 ```bash cd repo/app/webapp vim .gitignore ``` ``` /sql/1_InitData.sql /rust/ /python/ /php/ /perl/ /nodejs/ /frontend/ /ruby/ /public/ /go/isucondition ``` - [ ] `cd ~/repo;git add .` - アプリのシンボリックリンク貼る ```bash cp -R /home/isucon/webapp /home/isucon/webapp.bk ln -sf /home/isucon/repo/app/webapp /home/isucon/ ``` - [ ] > sudo git config --global --add safe.directory /home/isucon/repo をやってからpushしてmake deploy - [ ] main.goをpprotein使えるようにするために修正安定しないのでブランチ切る https://hackmd.io/@to-hutohu/SJuUqzdsc?utm_source=preview-mode&utm_medium=rec#pprotein%E3%81%AE%E5%B0%8E%E5%85%A5 go使えるようにして、 ```go go get github.com/kaz/pprotein go mod tidy ``` </details> ## 伊藤 <details> ## 動いている実装をGoに変更する enable/startしていることを確認する ## interpolateParamsの有効化 なんかを true にする   ## デプロイスクリプトを作る ## nginxのログ設定 <details> path `/etc/nginx/nginx.conf` 絶対早くなるタイプの設定 (nginx.conf の上の方に書かれている) ``` worker_processes auto; # コア数と同じ数まで増やすと良いかも # nginx worker の設定 worker_rlimit_nofile 4096; events { worker_connections 1024; # 128より大きくするなら、 max connection 数を増やす必要あり。さらに大きくするなら worker_rlimit_nofile も大きくする(file descriptor数の制限を緩める) multi_accept on; # 複数acceptを有効化する # accept_mutex_delay 100ms; use epoll; # 待受の利用メソッドを指定(基本は自動指定されてるはず) } ``` ```txt log_format ltsv "time:$time_local" "\thost:$remote_addr" "\tforwardedfor:$http_x_forwarded_for" "\treq:$request" "\tstatus:$status" "\tmethod:$request_method" "\turi:$request_uri" "\tsize:$body_bytes_sent" "\treferer:$http_referer" "\tua:$http_user_agent" "\treqtime:$request_time" "\tcache:$upstream_http_x_cache" "\truntime:$upstream_http_x_runtime" "\tapptime:$upstream_response_time" "\tvhost:$host"; access_log /var/log/nginx/access.log ltsv; # access_log off; ``` </details> </details> ## 若杉 <details> ## ドキュメント読み込み ## ログ用のエンドポイント正規表現作成 alp設定例 ```yml matching_groups: - ^/api/condition/.+[0-9a-f\-]$ - ^/api/isu/.+[0-9a-f\-]$ - ^/api/isu/.+[0-9a-f\-]/icon$ - ^/api/isu/.+[0-9a-f\-]/graph$ - ^/isu/.+[0-9a-f\-]/condition$ - ^/isu/.+[0-9a-f\-]/graph$ - ^/isu/.+[0-9a-f\-]$ ``` - pprotain group 編集 <details> ```json [ { "Duration": 60, "Label": "s1", "Type": "pprof", "URL": "http://tun_s1:8888/debug/pprof/profile" }, { "Duration": 60, "Label": "s1", "Type": "httplog", "URL": "http://tun_s1:19000/debug/log/httplog" }, { "Duration": 60, "Label": "s1", "Type": "slowlog", "URL": "http://tun_s1:19000/debug/log/slowlog" }, { "Duration": 60, "Label": "s2", "Type": "pprof", "URL": "http://tun_s2:8888/debug/pprof/profile" }, { "Duration": 60, "Label": "s2", "Type": "httplog", "URL": "http://tun_s2:19000/debug/log/httplog" }, { "Duration": 60, "Label": "s2", "Type": "slowlog", "URL": "http://tun_s2:19000/debug/log/slowlog" }, { "Duration": 60, "Label": "s3", "Type": "pprof", "URL": "http://tun_s3:8888/debug/pprof/profile" }, { "Duration": 60, "Label": "s3", "Type": "httplog", "URL": "http://tun_s3:19000/debug/log/httplog" }, { "Duration": 60, "Label": "s3", "Type": "slowlog", "URL": "http://tun_s3:19000/debug/log/slowlog" } ] ``` </details> </details> # 最後 ## 色々やる前にベンチ回して動くことを確認 - nginx,mysqlの ## awsで再起動してベンチ回す - 再起動時はip変わらない ## nginx,sqlのログ落とす - ブランチ切ってdeploy.shでmysqlのログ、nginxのconfigファイルでログをオフ、goのpprofを消して全てのインスタンスでmake deploy <details> ```diff diff --git a/app/webapp/go/main.go b/app/webapp/go/main.go index ca7e305..462dbcf 100644 --- a/app/webapp/go/main.go +++ b/app/webapp/go/main.go @@ -18,7 +18,6 @@ import ( _ "github.com/go-sql-driver/mysql" "github.com/gorilla/sessions" "github.com/jmoiron/sqlx" - "github.com/kaz/pprotein/integration/standalone" goji "goji.io" "goji.io/pat" "golang.org/x/crypto/bcrypt" @@ -281,7 +280,7 @@ func init() { } func main() { - go standalone.Integrate(":8888") + // go standalone.Integrate(":8888") host := os.Getenv("MYSQL_HOST") if host == "" { diff --git a/common/deploy.sh b/common/deploy.sh index c591454..5311a1c 100755 --- a/common/deploy.sh +++ b/common/deploy.sh @@ -54,12 +54,12 @@ sudo systemctl reload nginx sudo systemctl restart $SERVICE_NAME # slow query logの有効化 -QUERY=" -set global slow_query_log_file = '/var/log/mysql/mysql-slow.log'; -set global long_query_time = 0; -set global slow_query_log = ON; -" -echo $QUERY | sudo mysql -uroot +# QUERY=" +# set global slow_query_log_file = '/var/log/mysql/mysql-slow.log'; +# set global long_query_time = 0; +# set global slow_query_log = ON; +# " +# echo $QUERY | sudo mysql -uroot # log permission sudo chmod -R 777 /var/log/nginx diff --git a/common/etc/nginx/nginx.conf b/common/etc/nginx/nginx.conf index 46cb44f..7390316 100755 --- a/common/etc/nginx/nginx.conf +++ b/common/etc/nginx/nginx.conf @@ -36,7 +36,8 @@ http { "\tapptime:$upstream_response_time" "\tvhost:$host"; - access_log /var/log/nginx/access.log ltsv; + # access_log /var/log/nginx/access.log ltsv; + access_log off; # TLS configuration ssl_protocols TLSv1.2; ``` </details> - ツール類落とす ```bash ansible-playbook playbooks/hq-stop.yml -u ubuntu ansible-playbook playbooks/srv-stop.yml -u isucon ``` - 再度再起動してベンチ回す # 改善例 - dbを他のものを使う # Q&A・トラブルシューティング - docker-composeで特定のサービスのみ停止 ```shell docker-compose rm -fsv {{ Service Name }} ``` - port 確認 ```shell sudo netstat -tuln ``` - hp server でのansible失敗時 ```shell sudo systemctl stop nginx ``` - リンク貼ったか確認する方法 ```shell ls -l ``` - サービス名の調べ方 ```bash sudo systemctl list-unit-files | grep isu ``` - pt-query-digest ```bash pt-query-digest /var/log/mysql/mysql-slow.log ``` - 鍵作成※緊急時 ```bash ssh-keygen -t ed25519 cat /home/ubuntu/.ssh/id_ed25519.pub ``` - mysqlにユーザー追加 bind-address を 0.0.0.0に変えることを忘れない ```sql CREATE USER isucon@'%' IDENTIFIED BY 'isucon'; GRANT ALL ON *.* TO isucon; ``` - server の ip address 確認 ``` ifconfig ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully