Preface
Since I have been using version 3.0 before, I feel that the version is too low, so I installed the latest version 5.0.5 of redis on my notebook today, and made a record of its detailed installation process for your reference.
Step 1: Download the new version of redis
You can go to the official website to download, personally recommend to download here: download all versions of redis
Step 2: Upload to Linux (my installation directory is: /usr/local/redis)
- Create a new redis folder under /usr/local/ and enter
[root@localhost ~]# cd /usr/local/
[root@localhost local]# mkdir redis
[root@localhost local]# cd redis/
- Upload the downloaded redis compressed package
[root@localhost redis]# rz
Note: I am using the Xshell tool, and input rz on the command line to upload (the rz upload function can be supported after executing yum install -y lrzsz)
Step 3: Decompress, compile and install
1. Use the tar command to decompress
[root@localhost redis]# tar -zxvf redis-5.0.5.tar.gz
2. Install the gcc environment
Redis is written in C language, and its operation requires a C environment, so you need to install gcc before compiling
[root@localhost redis]# yum install gcc-c++
The installation process needs to download a package, enter y, press Enter to continue the installation, and Complete! appears at the end to indicate that the installation is complete
3. Compile
Enter the decompressed redis-5.0.5 directory and execute the make command (slightly slower)
[root@localhost redis]# cd redis-5.0.5
[root@localhost redis-5.0.5]# make
This step on the official website is over, maybe the new version can be used, but I am still used to install
4. Installation
The directory structure of redis-5.0.5 is as follows, after entering the src directory, execute make install (soon)
[root@localhost redis-5.0.5]# cd src/
[root@localhost src]# make install
Step 4: Configure and start
1. Create bin and etc folders in the redis directory
[root@localhost src]# cd /usr/local/redis/
[root@localhost redis]# mkdir bin
[root@localhost redis]# mkdir etc
Note: These two folders are actually created for the convenience of use and management (you can also go directly to the third step below without creating them):
bin: used to store the main commands, you can understand it as the main startup class of springboot
etc: use Stored in the core configuration file redis.conf of redis
2. Move files
(1) First move the main configuration file redis.conf in redis-5.0.5 to the newly created etc folder
[root@localhost redis]# cd redis-5.0.5
[root@localhost redis-5.0.5]# mv redis.conf /usr/local/redis/etc/
(2) Move all the files with green marks in the src directory to the newly created bin folder
[root@localhost redis-5.0.5]# cd src/
[root@localhost src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb /usr/local/redis/bin/
3. Modify the main configuration file
Enter the etc directory and modify the redis.conf file
[root@localhost src]# cd /usr/local/redis/etc/
[root@localhost etc]# vi redis.conf
(1) Comment out the line bind 127.0.0.1 (to solve the limitation that only a specific network segment can be connected; official server deployment such as Alibaba Cloud, you can keep the comment for strict project security, and comment it out if you use it yourself) (2) Put
protected- The mode attribute is changed to no (turn off the protection mode, otherwise it will prevent remote access; as above, the official server project can not be modified) (
3) Change the daemonize attribute to yes (so that it will start in the background when it starts)
(4) Set the password (you can Choose, personal suggestion is to set a password)
After the modification is completed, wq saves and exits (press Esc first, then enter: wq)
4. start
Execute in the redis directory:
[root@localhost etc]# cd /usr/local/redis/
[root@localhost redis]# ./bin/redis-server /usr/local/redis/etc/redis.conf
[root@localhost redis]# ps -ef | grep redis
Enter: quit to exit the client, and you can also connect to redis through the visualization tool RedisDesktopManager to view and operate
5. Set the boot to start automatically:
[root@localhost redis]# vim /etc/rc.d/rc.local
Add at the end: /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
So far, the installation of redis5.0.5 under Linux has been completed, and I hope it can help everyone.