Resolve Redis remote access and password issues
- 2020-08-22 23:00:08
- OfStack
Redis enables remote access and password, as shown below:
1. Enable remote access
1. Open ports
firewall-cmd --zone=public --add-port=6379
firewall-cmd --zone=public --add-port=6379 --permanent
2. View the open port
firewall-cmd --list-port
3. Modify the configuration file
vim redis.conf
Comment bind 127.0.0.1 or change to bind 0.0.0.0
will
protected-mode yes
Instead of
protected-mode no;
2. Set a password
find
# requirepass foobared
Remove the comments and change foobared to your desired password, such as requirepass 123456
And then you can restart it
systemctl restart redis
ps: Redis startup error resolution
An error
redis_6379.service - LSB: start and stop redis_6379
Loaded: loaded (/etc/rc.d/init.d/redis_6379; bad; vendor preset: disabled)
Active: active (exited) since Wed 2019-09-18 15:40:08 CST; 7s ago
Docs: man:systemd-sysv-generator(8)
Process: 22652 ExecStop=/etc/rc.d/init.d/redis_6379 stop (code=exited, status=0/SUCCESS)
Process: 22692 ExecStart=/etc/rc.d/init.d/redis_6379 start (code=exited, status=0/SUCCESS)
Sep 18 15:40:08 ythzcpt-csmh systemd[1]: Starting LSB: start and stop redis_6379...
Sep 18 15:40:08 ythzcpt-csmh redis_6379[22692]: /var/run/redis_6379.pid exists, process is already running or crashed
Sep 18 15:40:08 ythzcpt-csmh systemd[1]: Started LSB: start and stop redis_6379.
> Delete the pid file
cd /var/run
mv redis_6379.pid redis_6379.pid_bak
> Delete the ES72en.rdb (memory snapshot) file
cd /var/lib/redis/6379
mv dump.rdb dump.rdb_bak
> Then check to see if the redis service is still started
ps -ef |grep redis
kill -9
> And then you can restart it
conclusion