redis Skills Summary

A, Redis password settings and view the password
redis not have this access control function, but it provides a lightweight authentication method, you can edit redis.conf configured to enable authentication.
1, Redis initialization code:
There are parameters in the configuration file: requirepass, this is the configuration parameters redis access password;
such as password requirepass
(Ps: Redis need to restart to take effect) redis query speed is very fast, one second external users how much can try within 150K passwords; password to it as long as possible (there is no need for the DBA must remember the password);

2, do not restart Redis password:
Configure requirepass password (password is still valid when redis restart) in the configuration file.
redis 127.0.0.1:6379> config set requirepass password
query password:
Redis 127.0.0.1:6379> config GET requirepass
(error) ERR Operation not permitted

Password verification:
Redis 127.0.0.1:6379> auth password
the OK

Again query:
redis 127.0.0.1:6379> config GET requirepass
1) "requirepass"
2) "password"
PS: If the configuration file to add a password so redis not restart, password failure;

3, landing there Redis password:
log in when the time to enter the password:
redis-cli 6379 -a -p password
after the first login authentication:
redis-cli -p 6379
redis 127.0.0.1:6379> auth password
the OK
aUTH command with other redis command, is not encrypted; can not prevent attackers from stealing your passwords over the network;
target authentication layer is to provide an extra layer of protection. If the firewall or redis system to protect against external attack fails, or if there is no external users can not access redis through password authentication.

Second, start, stop redis:
start redis:
node02 execute the following command to start the Redis
cd /export/servers/redis-3.2.8/
src / Server redis.conf Redis-
stop redis:
Redis-cli -h node02 the shutdown -p 6379

Or directly kill -9 redis process ID

 

Third, the client connection redis:
amdha01 the following command to connect the client redis
CD /export/servers/redis-3.2.8
the src / redis-CLI 6379 -H amdha01 -p password -a

Fourth, the bulk delete keys:
1. With the unregistered client:
Redis is the default port number 6379, no connection password, delete command is as follows:
Redis-cli Keys "Key *" | xargs del Redis-cli

redis is not the default port number 6379, connection password is "password", delete the following command:
redis-cli 6379 -a -p password -h node02 Keys "itcast *" | xargs redis-cli 6379 -a -p password -h node02 del
but being given: (error) ERR wrong number of arguments for 'del' command

2. Log redis client, you can bulk delete, as follows:
DEL key1 key2 # delete multiple key
flushdb # delete the current database of all Key
flushall # delete key database for all

 

Guess you like

Origin www.cnblogs.com/mediocreWorld/p/11462429.html