After we install the Redis service, then we look at the basic configuration.
Redis configuration file default location/etc/redis.conf:
Egrep-v "(^#|^$)"/etc/redis.conf
Enter the Redis command line:
Redis-cli
Where 6379 is the listening port.
View all configurations: Configget *
To view a configuration: Configget loglevel
Modify a configuration: ConfigSet loglevel Warning
Note: After the completion of the above, the default will only modify the memory configuration, if the Redis service restarts, will re-read the configuration file to overwrite the modified configuration:
To write back to the configuration file, you can use rewrite:
By default, Redis only listens for the loopback address of the native, so the default is only for local clients to be able to connect to the Redis service, and to timeout from other clients on the same network:
We edit the configuration file and change it to 0 address:
bind0.0.0.0
After editing, restart the Redis service, intranet and other clients as well as the public network can be accessed:
Public network:
To do some basic security reinforcement configuration:
Disabling of some dangerous commands (added in/etc/redis.conf file):
Rename-commandflushall ""
Rename-commandflushdb ""
Rename-commandconfig ""
Rename-commandkeys ""
Rename-commandeval ""
Of course, you can also rename these dangerous commands:
Enable passwd authentication:
Once enabled, we verify the configuration above:
First go directly to the local redis-cli and use the Config command to modify the loglevel:
As you can see, the Config command is unrecognizable because of the previous settings, and we'll try again with the command defined earlier:
And because we set the Requirepass earlier, the default use of REDIS-CLI does not provide certified pass leads to no permissions.
You can use the following command to provide passwd when entering REDISCLI:
Redis-cli-h
You can also enter REDIS-CLI and use the AUTH command to authenticate:
Auth<passwd>