Install and configure to start Redis in Linux
1. Download redis
Download with command:
wget https://download.redis.io/releases/redis-6.0.10.tar.gz
ls
du sh redis-6.0.10.tar.gz
decompress
[root@node02 ~]# tar xzf redis-6.0.10.tar.gz
[root@node02 ~]# cd redis-6.0.10
[root@node02 redis-6.0.10]# ls
Install
[root@node02 redis-6.0.10]# yum install gcc-c++
compile
[root@node02 redis-6.0.10]# make
If the following error occurs when compiling:
solution:
Check whether the gcc version is below 5, if yes, it needs to be upgraded:
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
Under normal circumstances, make compiles as shown in the figure:
Install:
Check
[root@node02 ~]# ls /usr/local/redis/
[root@node02 ~]# ls /usr/local/redis/bin/
configuration file
[root@node02 ~]# mkdir /usr/local/redis/conf
[root@node02 ~]# ls
[root@node02 ~]# ls redis-6.0.10
[root@node02 ~]# cp redis-6.0.10/redis.conf /usr/local/redis/conf/
[root@node02 ~]# ls /usr/local/redis/conf/
start up
redis-server /usr/local/redis/conf/redis.conf
Redis starts in the foreground by default, and wants to start in the background:
nohup redis-server /usr/local/redis/conf/redis.conf &
[root@node02 ~]# netstat -antp | grep redis
[root@node02 ~]# ps -elf | grep redis
Operation linked database
[root@node02 ~]# redis-cli
127.0.0.1:6379>
By default, just press Enter
key value pair
127.0.0.1:6379> set a 10
OK
Inquire
127.0.0.1:6379> get a
"10"