Redis operation and maintenance common operations

1. Log in

  • Use the redis client to connect to redis at 10.123.123.123:6379, the password is akdiqj
redis-cli -a akdiqj -h 10.123.123.123 -p 6379

2. View a certain configuration of redis

  • View the currently configured protection mode value,
> config get protected-mode

3. Data backup and recovery

Backup

> config get dir
> save
  • The backup data will be stored in the path shown by dir, named dump.db

Restore
Copy the archived dump.db, put it in the path of dir, restart redis

cp /backups/redis-rdb/2020-11-5.rdb ${
    
    redis_dir}/dump.rdb
service redis restart

4. Redis data migration

> slaveof 127.0.0.1 6379
> slaveof no one

5. Redis opens access to other servers in the intranet

Modify /etc/redis.conf

bind 0.0.0.0
protected-mode no

Restart service

service redis restart

6. Redis real-time command monitoring

redis-cli monitor > /tmp/x.log
tail -n -f 200 /tmp/x.log

Guess you like

Origin blog.csdn.net/fwhezfwhez/article/details/109519185