1.Install Redis in Ubuntu
sudo apt update
sudo apt install redis-server
* Config Redis:
sudo nano /etc/redis/redis.conf
- Change to:
. . .
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous liveness pings back to your supervisor.
supervised systemd
. . .
2. Using Redis
* Restart redis
sudo systemctl restart redis.service
* Check redis
sudo systemctl status redis
* Disable redis
sudo systemctl disable redis
* Using cli
* Bind with localhost
- chagng config redis only access from localhost
sudo nano /etc/redis/redis.conf
find
# bind 127.0.0.1 ::1
change to
bind 127.0.0.1 ::1
- restart redis
sudo systemctl restart redis
- Check result
sudo netstat -lnp | grep redis
- if dont has netstat then install
sudo apt install net-tools
3. Security for Redis
- Change strong password
- open config to set password for redis
sudo nano /etc/redis/redis.conf
find directive # requirepass foobared,
then remove # in head then change foobared to yourpassword
- create strong password
openssl rand 60 | openssl base64 -A
- restart redis
sudo systemctl restart redis.service
- Check password working
redis-cli
set key1 10
// auth redis
auth {your_redis_password}
* Change dangerous cli
sudo nano /etc/redis/redis.conf
. . .
# It is also possible to completely kill a command by renaming it into
# an empty string:
#
rename-command FLUSHDB ""
rename-command FLUSHALL ""
rename-command DEBUG ""
. . .
# or rename-command CONFIG ""
rename-command SHUTDOWN SHUTDOWN_MENOT
rename-command CONFIG ASC12_CONFIG
- Restart redis
sudo systemctl restart redis.service
- Check cli
redis-cli
Assuming that you renamed the CONFIG command to ASC12_CONFIG, now try using the CONFIG command as it was:
config get requirepass
systme will return error:
Output
(error) ERR unknown command `config`, with args beginning with:
Now run again with the new command name:
asc12_config get requirepass
Output
1) "requirepass"
2) "your_redis_password"
exit
4. Backup data
Run save to save data into file dump.rdb
Run config get dir to known where file dump.rdb
Goto server need restore:
Run config get dir to know where file dump.rdb
stop redis (ex: sudo service redis-server stop)
Delete dump.rdb and copy new file dump.rdb
restart redis
Image:

Thank you.