UJP - サービス停止

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

ブログ - サービス停止

サービス停止

カテゴリ : 
Apple » MacBook » 2008 late
ブロガー : 
ujpblog 2026/7/7 23:48
 7月6日(月)になった途端に,大量アクセスがありWebサイトが停止状態.


 CPU Usageが振り切って,午前0時から18時くらいまで,ほぼデータが取れないくらいの負荷になっている.

 大量のSQL Injectionなど不正アクセスを疑ったけど,検知システムでも実際のログを見ても検知しておらず.アクセスログをみるとアンソロピックや検索エンジンの各種botからの大量のクローリングが原因でした.

 Webアクセスをみると,通常とどれだけ違うかわかります.普段はhttpdが12程度で処理できているのに,mpmでのMaxClientsの上限設定の160近くまで跳ね上がっています.


 CMSで使っているデータベース側もスレッドが積み上がり,ロックが多くなってしまいました.アクセスが多いとアクセスカウンターの更新処理が入るので,これが負荷になるのですが,攻撃以外でこんなにアクセスされる事はないのです.


 対処としてはHTTPDのMacClientsとデータベースのコネクション数を低減させ,大量のアクセスを受け付けずに処理をHTTP 500にさせて稼働を守る方向に.

 設定変更後,半日以上かかりましたが,やっと落ち着きました.

 なぜ急にアクセスが増えたのかは,今の段階ではわかりませんが,ドント来い設定だったのを最小限設定にできたのは良かったのかな.自宅サーバ運用21年目の夏.

  • データベースの現在の接続数を確認.
    mysql> SHOW VARIABLES LIKE 'max_connections';🆑
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 151   |
    +-----------------+-------+
    1 row in set (0.00 sec)
    
    mysql>
    
  • 設定値を100に変更.
    mysql> SET GLOBAL max_connections = 100;🆑
    Query OK, 0 rows affected (0.01 sec)
    
    mysql>
    
  • 設定値の確認.
    mysql> SHOW VARIABLES LIKE 'max_connections';🆑
    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 100   |
    +-----------------+-------+
    1 row in set (0.00 sec)
    
    mysql>
    
  • データベースのスレッド数を確認.
    mysql> SHOW STATUS LIKE 'Threads_connected';🆑
    +-------------------+-------+
    | Variable_name     | Value |
    +-------------------+-------+
    | Threads_connected | 86    |
    +-------------------+-------+
    1 row in set (0.00 sec)
    
    mysql>
    
  • Webサーバを再起動して,再度データベースのスレッドを確認.
    mysql> SHOW STATUS LIKE 'Threads_connected';🆑
    +-------------------+-------+
    | Variable_name     | Value |
    +-------------------+-------+
    | Threads_connected | 4     |
    +-------------------+-------+
    1 row in set (0.00 sec)
    
    mysql>
    
  • データベースエンジンのステータスを確認.
    mysql> SHOW ENGINE INNODB STATUS\G🆑
    *************************** 1. row ***************************
      Type: InnoDB
      Name:
    Status:
    =====================================
    260706  4:50:44 INNODB MONITOR OUTPUT
    =====================================
    Per second averages calculated from the last 16 seconds
    ----------
    BACKGROUND THREAD
    ----------
    srv_master_thread loops: 1 1_second, 1 sleeps, 0 10_second, 2 background, 2 flush
    srv_master_thread log flush and writes: 1  log writes only: 5
    ----------
    SEMAPHORES
    ----------
    OS WAIT ARRAY INFO: reservation count 3, signal count 3
    Mutex spin waits 0, rounds 0, OS waits 0
    RW-shared spins 3, OS waits 3; RW-excl spins 0, OS waits 0
    Spin rounds per wait: 0.00 mutex, 30.00 RW-shared, 0.00 RW-excl
    ------------
    TRANSACTIONS
    ------------
    Trx id counter D901
    Purge done for trx's n:o < 0 undo n:o < 0
    History list length 0
    LIST OF TRANSACTIONS FOR EACH SESSION:
    ---TRANSACTION 0, not started, OS thread id 2960855040
    MySQL thread id 11355, query id 1061000 localhost root
    SHOW ENGINE INNODB STATUS
    --------
    FILE I/O
    --------
    I/O thread 0 state: waiting for i/o request (insert buffer thread)
    I/O thread 1 state: waiting for i/o request (log thread)
    I/O thread 2 state: waiting for i/o request (read thread)
    I/O thread 3 state: waiting for i/o request (read thread)
    I/O thread 4 state: waiting for i/o request (read thread)
    I/O thread 5 state: waiting for i/o request (read thread)
    I/O thread 6 state: waiting for i/o request (write thread)
    I/O thread 7 state: waiting for i/o request (write thread)
    I/O thread 8 state: waiting for i/o request (write thread)
    I/O thread 9 state: waiting for i/o request (write thread)
    Pending normal aio reads: 0, aio writes: 0,
     ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
    Pending flushes (fsync) log: 0; buffer pool: 0
    42 OS file reads, 7 OS file writes, 7 OS fsyncs
    0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
    -------------------------------------
    INSERT BUFFER AND ADAPTIVE HASH INDEX
    -------------------------------------
    Ibuf: size 1, free list len 0, seg size 2,
    0 inserts, 0 merged recs, 0 merges
    Hash table size 553253, node heap has 0 buffer(s)
    0.00 hash searches/s, 0.00 non-hash searches/s
    ---
    LOG
    ---
    Log sequence number 44736
    Log flushed up to   44736
    Last checkpoint at  44736
    0 pending log writes, 0 pending chkp writes
    10 log i/o's done, 0.00 log i/o's/second
    ----------------------
    BUFFER POOL AND MEMORY
    ----------------------
    Total memory allocated 136937472; in additional pool allocated 0
    Dictionary memory allocated 20888
    Buffer pool size   8192
    Free buffers       8177
    Database pages     15
    Modified db pages  0
    Pending reads 0
    Pending writes: LRU 0, flush list 0, single page 0
    Pages read 16, created 0, written 1
    0.00 reads/s, 0.00 creates/s, 0.00 writes/s
    No buffer pool page gets since the last printout
    LRU len: 15, unzip_LRU len: 0
    I/O sum[0]:cur[0], unzip sum[0]:cur[0]
    --------------
    ROW OPERATIONS
    --------------
    0 queries inside InnoDB, 0 queries in queue
    1 read views open inside InnoDB
    Main thread id 2960240640, state: waiting for server activity
    Number of rows inserted 0, updated 0, deleted 0, read 0
    0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
    ----------------------------
    END OF INNODB MONITOR OUTPUT
    ============================
    
    1 row in set (0.00 sec)
    
    mysql>
    
  • エラーログの場所を確認.
    mysql> SHOW VARIABLES LIKE 'log_error';🆑
    +---------------+-----------------------+
    | Variable_name | Value                 |
    +---------------+-----------------------+
    | log_error     | /mysql.err            |
    +---------------+-----------------------+
    1 row in set (0.01 sec)
    
    mysql>
  • mysqlcheckを実施.
  • まずはソケットファイルの場所を確認.
    mysql> SHOW VARIABLES LIKE 'socket';
    +---------------+---------------------------------------+
    | Variable_name | Value                                 |
    +---------------+---------------------------------------+
    | socket        | /opt/local/var/run/mysql5/mysqld.sock |
    +---------------+---------------------------------------+
    1 row in set (0.00 sec)
    
    mysql>
  • データベースをチェック.
    server$ /usr/local/mysql/bin/mysqlcheck -u root -p --auto-repair --all-databases --socket=/opt/local/var/run/mysql5/mysqld.sock🆑
    Enter password:🔑
    db.db__altsys_language_constants           OK
    db.db__avatar                              OK
    db.db__avatar_user_link                    OK
    db.DB__banner
    warning  : 3 clients are using or haven't closed the table properly
    db.db__banner                              OK
    db.db__bannerclient                        OK
    
    ー略ー
    
    mysql.columns_priv
    error    : Table upgrade required. Please do "REPAIR TABLE `columns_priv`" or dump/reload to fix it!
    mysql.db
    error    : Table upgrade required. Please do "REPAIR TABLE `db`" or dump/reload to fix it!
    mysql.func
    error    : Table upgrade required. Please do "REPAIR TABLE `func`" or dump/reload to fix it!
    mysql.help_category
    
  • 高負荷でデータベーストランザクションの不整合が発生して問題が出てる感じ.
    server$ /usr/local/mysql/bin/mysqlcheck -u root -p --auto-repair --all-databases --socket=/opt/local/var/run/mysql5/mysqld.sock🆑
    Enter password:🔑
    db.db__altsys_language_constants           OK
    db.db__avatar                              OK
    db.db__avatar_user_link                    OK
    
    ー略ー
    
    mysql.time_zone                                    OK
    mysql.time_zone_leap_second                        OK
    mysql.time_zone_name                               OK
    mysql.time_zone_transition                         OK
    mysql.time_zone_transition_type                    OK
    mysql.user                                         OK
    mysql.user_info                                    OK
    server$
    
  • データベースは復旧した.
  • トラックバック


    広告スペース
    Google