Install and configure Redis under Ubuntu16.04

Time:2019-10-23

Statement: the content of this article is reproduced to [Ubuntu16.04 installation and configuration of Redis]

I. preconditions

You need to connect to the Internet and then execute the sudo apt-get update package

Execute the installation command

sudo  apt-get install redis-server 

After execution, as shown below, we enter y to confirm the installation and use the space

Install and configure Redis under Ubuntu16.04

The following execution is completed, we can see the version information including redis, and so on, executionservice redis statusYou can see that the status of redis service is running, indicating that the system has started the service automatically
Install and configure Redis under Ubuntu16.04

3. Configure redis service

3.1: open remote connection

find/et/redis/redis.confThe file changes as follows by commenting out 127.0.0.1 #bind 127.0.0.1, which is not required if redis is not connected remotely
Install and configure Redis under Ubuntu16.04

3.2: set password

Find /et/redis/redis.conf file and change it as follows, add requirepass kingredis (password set to kingredis)
Install and configure Redis under Ubuntu16.04

Finally, the redis service is restartedservice redis restart

Test redis service

4.1: the test password is set successfully

When executing redis-cli command to open redis client set operation, I was asked to enter the password, indicating that the password was set successfully. After executing auth password verification password, the set operation could be executed
Install and configure Redis under Ubuntu16.04

4.2: test remote login

Open a client locally, CD to redis installation directory, the main is to have redis-cli.exe directory input redis-cli-h redis server ip-p redis server port number (default 6379)
Install and configure Redis under Ubuntu16.04

As shown in the figure above, access to the remote redis service was successful and redis operation was successful, indicating that our remote redis installation and configuration of security password was successful

【 note 】 if ali cloud server, remember to the security group, joined the service port security policy, to allow access to all the address, the following figure, can, namely in ali cloud server, all service need port mapping out to, if not do this step, the above redis – cli command will be in a state of has been waiting for

Install and configure Redis under Ubuntu16.04