Get the App
SLTechnology News&Howtos  ›  Servers  › 

Redis (3) Advanced applications

Shulou Source: shulou.com Published: 2022-06-03 04:07:22 09月22日 Update

(1) .Redis data backup and recovery. The Redis SAVE command is used to create a backup of the current database. The basic syntax is SAVE

192.168.180.23 6379 > saveOK

This command creates the dump.rdb file in the redis installation directory.

[root@localhost redis-3.2.9] # ls00-RELEASENOTES dump.rdb redis.conf src

Recover the data. If you need to recover the data, simply move the backup file (dump.rdb) to the redis installation directory and start the service. You can use the CONFIG command to get the redis directory, as follows:

192.168.180.23 config get dir1) "dir" 2) "/ root"

Config get dir gets the directory / root of redis data, and if you want to restore, just move the backup file / root/dump.rdb to the redis installation directory and start the service. You can also use the command BGSAVE to create a redis backup file, which is executed in the background.

127.0.0.1 purl 6379 > bgsaveBackground saving started

(2) redis is safe. To secure Redis, you need to set a password in the configuration file.

127.0.1 6379 > config get requirepass1) "requirepass" 2) "

By default, the password for redis access is not set, and if you want to do so, you can use the following command:

192.168.180.23 OK192.168.180.23:6379 6379 > config set requirepass "redis123" OK192.168.180.23:6379 > config get requirepass1) "requirepass" 2) "redis123"

After setting the password, if any client runs the command without authentication, it will return a (error) NOAUTH Authentication required. The error message of. Therefore, the client needs to use the AUTH command to verify.

(3) redis performance test. Redis performance testing is achieved by executing multiple commands simultaneously. Syntax: redis-benchmark [option] [option value]

[root@localhost src] #. / redis-benchmark-n 10000 = PING_INLINE = 10000 requests completed in 0.11 seconds 50 parallel clients 3 bytes payload keep alive: 1100.00%

Tags: Commands services instances data multiple files servers backups clients clients directories tests that is performance methods pipes scope processing support different Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft Xiaomi OPPO Reno Apple