How to install Redis database on Alibaba Cloud server

1. Connect to Alibaba Cloud server to create related directories;

Connect to Alibaba Cloud ECS through XShell or other tools, and create a redis folder in the /usr/local directory;

移动到目标路径: cd /usr/local/
创建redis文件夹:mkdir redis

Folder creation

2. Download the Redis compressed package;

Redis historical version download URL: http://download.redis.io/releases/

Download method 1: Select the required version, download it to the local and upload it to the created /usr/local/redis directory via Xftp. It is not demonstrated here;

Download method 2: Select the version you want to download (here, take 3.2.10 as an example), right click to copy the link address, and then proceed as follows;

 

进入刚创建好的redis目录:cd ./redis   (或cd /usr/local/redis)
下载redis压缩包命令:wget http://download.redis.io/releases/redis-3.2.10.tar.gz

After waiting for the upload or download to complete through the above two steps, the following compressed packages exist in the redis directory:

Archive

3. Unzip

解压命令:tar -xzvf redis-3.2.10.tar.gz

4. Installation and related configuration

After the decompression is complete, enter the decompression directory to install;

进入解压目录:cd ./redis-3.2.10
进行安装(在解压解压好的redis文件夹下及redis-3.2.10下)命令:make

After the installation is complete, perform the relevant configuration first, and then start the service;

To ensure that the installation is complete, the configuration steps are as follows:

①打开配置文件命令:vim ./redis.conf

The following configuration files can be opened:

redis.conf configuration file

②. At about line 61 of the configuration file (the number of lines is in the lower right corner), comment out 172.0.0.1 (default redis can only be accessed from the internal network 127.0.0.1, if you want to access the external network, you need to modify the bound address)

③. Set redis to run in the background all the time, running as a daemon process, that is, closing the SSH tool program and running.
Change daemonize no to daemonize yes (around line 128)

④. Password setting, remove "#requirepass foobared" and change the comment to requirepass 123456 (or other password you need) (about line 480)

Note: When removing the comment, remove the space in front of it;

⑤Save and exit: press Esc in Insert mode to enter command mode, and then enter: wq to save and exit

5. Service start

 

进入redis的src目录:cd ./src(在redis解压目录下)  cd /usr/local/redis/redis-3.2.10/src(绝对路径)

 

启动服务:./redis-server  ../redis.conf

6. Check if the startup is successful

 

ps aux | grep redis

6. Alibaba Cloud configuration

After the service is started successfully, if you want to connect remotely through the tool, you also need to configure Alibaba Cloud;

First log in to the Alibaba Cloud console; console-->cloud server ECS-->security and network-->security group-->configuration rules

Note: both in and out direction must be configured

7. Connect

 

 

Guess you like

Origin blog.csdn.net/wx_15323880413/article/details/108506047