16
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

インフラエンジニアがいざという時に抑えておきたい sidekiq の中身を redis-cli を使って確認する流れ

Posted at

redis-cli を使ってログイン

$ redis-cli -h host -p port -a password
コマンド 説明
KEYS * redis に登録されているキーの一覧を取得
TYPE <key> VALUE の種類
GET <key> TYPE が string だった場合の値をみる
LRANGE <key> 0 -1 TYPE が list だった場合の値をみる
SMEMBERS <key> TYPE が set だった場合の値をみる
ZRANGE <key> 0 -1 TYPE が zsetだった場合の値をみる
HGETALL <key> TYPE が hash だった場合の値をみる
HKEYS <key> TYPE が hash だった場合に field の一覧をみる
HVALS <key> TYPE が hash だった場合に value の一覧をみる
MONITOR redisサーバが受けとったコマンドを表示する

sidekiq が使っている key を確認する

host:port>  KEYS 'sidekiq:*'`
 1) "sidekiq:worker.x.x:x:xxxxxx"
 2) "sidekiq:worker.x.x:x:xxxxxx"
 3) "sidekiq:queues"
 4) "sidekiq:worker.x.x:x:xxxxxx"
 5) "sidekiq:dead"
 6) "sidekiq:processes"
 7) "sidekiq:worker.x.x:x:xxxxxx"
 8) "sidekiq:worker.x.x:x:xxxxxx:workers"
 9) "sidekiq:worker.x.x:x:xxxxxx"
10) "sidekiq:worker.x.x:x:xxxxxx"
11) "sidekiq:worker.x.x:x:xxxxxx:workers"
12) "sidekiq:stat:processed:2017-04-14"
13) "sidekiq:stat:failed"
14) "sidekiq:worker.x.x:x:xxxxxx"
15) "sidekiq:worker.x.x:x:xxxxxx"
16) "sidekiq:worker.x.x:x:xxxxxx"
17) "sidekiq:worker.x.x:x:xxxxxx:workers"
18) "sidekiq:worker.x.x:x:xxxxxx:workers"
19) "sidekiq:schedule"
20) "sidekiq:worker.x.x:x:xxxxxx"
21) "sidekiq:stat:processed"
22) "sidekiq:worker.x.x:x:xxxxxx"
23) "sidekiq:worker.x.x:x:xxxxxx:workers"
24) "sidekiq:retry"
25) "sidekiq:worker.x.x:x:xxxxxx"

Sidekiq.jpg

1つ1つの queue の数を把握する

queue の type を調べる

host:port> type "sidekiq:queues"
set

queue の種類を調べる

host:port> smembers  "sidekiq:queues"
1) "search"
2) "push"
3) "outgoing_webhook"
4) "default"
host:port> LLEN  "sidekiq:queues:search"
(integer) 0
host:port> LLEN  "sidekiq:queues:push"
(integer) 0
・・・・

現在スケジューリングされている job を確認する

schedule の type を調べる

host:port> type "sidekiq:schedule"
zset

最初の1件

host:port> ZRANGE "sidekiq:schedule" 0 0
1) "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"

ざっくり 5 件調べる

host:port> ZRANGE "sidekiq:schedule" 0 4
1) "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"
2) "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"
3) "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"
4) "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"
5) "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"

今予定しているJobを全部見る

host:port> ZRANGEBYSCORE "sidekiq:schedule" -inf +inf

一個削除したい

host:port> ZREM schedule "{\"class\":\"Elasticsearch\",\"args\":[\"message\",hoge,\"index\"],\"retry\":true,\"queue\":\"elasticsearch\",\"jid\":`\"xxxxxxxxxxx\",\"created_at\":xxxxxx}"

もうはいってるもの全部消して復旧させたい

host:port>  FLUSHALL
OK
16
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?