Learning should be carried out around the system. Appropriate learning of the underlying layer aims to establish the connection node of the system, rather than the underlying layer for the pursuit of the underlying layer.
- Homepage
- Contact
- Management
Article 43-0 comments-2 set to start systemctl enable redis
Centos7 Yum install and configure redis and set the password
1. Set the redis repository address
yum install epel-release
2. Install redis
yum install redis
Modify the configuration file and listen to all IP addresses
Vim/etc/redis. conf find the BIND 127.0.0.1 line below and comment out # bind 127.0.0.1
3. Start redis.
service redis start
If you need to set Automatic startup
chkconfig redis on
In addition:
If you need redis to configure the authentication Password
1. Configure through the configuration file
The redis configuration file installed in Yum mode is usually in/etc/redis. conf. Open the configuration file and find
#requirepass foobared
Remove the comments in front of the line, change the password to the required password, and save the file.
requirepass youpwd
Redis restarted
References
Install
Http://blog.csdn.net/sfeng95/article/details/62887701? Locationnum = 7 & FPS = 1
Set Password
Http://blog.csdn.net/zyz511919766/article/details/42268219
Redis does not require password authentication by default. That is to say, you can connect to the redis server as long as the host and port of the connected redis server are correct. This may cause security issues. Therefore, you need to enable the redis authentication password to increase the security of the redis server.
1. modify the configuration file
The configuration file of redis is/etc/redis.conf, Find the following line:
#requirepass foobared
Remove the preceding comment and change it to the required password:
Requirepass mypassword (in which mypassword is the password to be set)
2. Restart redis
If redis has been configuredserviceYou can restart the service in the following ways:
service redis restart
If redis is not configuredserviceYou can restart the service in the following ways:
/usr/local/bin/redis-cli shutdown/usr/local/bin/redis-server /etc/redis.conf
3. logon Verification
After setting the redis authentication password, you must use-aEnter the authentication password. If you do not add this parameter, you can log on successfully, but you do not have any operation permissions. As follows:
$ ./redis-cli -h 127.0.0.1 -p 6379127.0.0.1:6379> keys *(error) NOAUTH Authentication required.
Use the password to authenticate the logon and verify the operation permissions:
$ ./redis-cli -h 127.0.0.1 -p 6379 -a myPassword127.0.0.1:6379> config get requirepass1) "requirepass"2) "myPassword"
The above output shows that reids password authentication is successfully configured.
In addition to the above method-aEnter the logon password. You can also verify the connection without specifying it:
$ ./redis-cli -h 127.0.0.1 -p 6379127.0.0.1:6379> auth myPasswordOK127.0.0.1:6379> config get requirepass1) "requirepass"2) "myPassword"127.0.0.1:6379>
4. Configure the password on the command line client (valid before redis restarts)
As described aboveredis.confConfigure the password. In this way, you need to restart redis. You can also configure the password through the command line client. In this way, you do not need to restart redis. The configuration method is as follows:
127.0.0.1:6379> config set requirepass newPasswordOK127.0.0.1:6379> config get requirepass1) "requirepass"2) "newPassword"
Note::Use the command line client to configure the password. After redis is restarted, it will still be used.redis.confThe password in the configuration file.
5. Use the authentication password in the redis Cluster
If the redis server is used, the cluster is used. BesidesmasterIn addition to configuring the password, you also needslave. InslaveFind the following lines in the configuration file, remove the comments, and modifymasterWith the same password:
# masterauth master-password
Article transferred from: http://itbilu.com/linux/management/Ey_r7mWR.html
Centos7 Yum install and configure redis and set the password