redis 3.2.0以降で以下メッセージが出るようになった。
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You on
# 0.0.0.0はインターネットからも接続できるため使わない方が安全 bind <private ip addr> # 接続用パスワード requirepass <password> # 接続用パスワードを設定したくない場合 protected-mode no
「client list」で接続一覧を取得するときに「name=」でconnection名が表示されるようになる。
プログラムからのアクセスや、人のアクセスとの区別ができるので付けた方が良さそう。
redis 127.0.0.1:6379> CLIENT SETNAME connection-name
redis-cli -n 0 --bigkeys
redis-cli -h localhost -p 6379 -n 0 flushdb # ncを使う場合 (echo -e "select 0"; sleep 1; echo "flushdb"; sleep 1) | nc localhost 6379
redis-cli -h localhost -p 6379 flushall
sudo yum install redis # ping/pong redis-cli -h localhost -p 6379 ping PONG
(echo ping;sleep 1) | nc localhost 6379 +PONG
redis-cli -h localhost -p 6379 info | grep ^db db0:keys=101,expires=360,avg_ttl=12345678 (echo -e "info";sleep 1) | nc localhost 6379 | grep ^db db0:keys=101,expires=360,avg_ttl=12345678
redis-cli -h localhost -n 0 dbsize (integer) 101 (echo -e "select 0"; sleep 1; echo "dbsize"; sleep 1) | nc localhost 6379 +OK :101