Second, check the version of GCC
[root@centos8 liuhongdi]# GCC --version GCC (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4) Copyright © 2018 Free Software Foundation, Inc. This program is free software; See the copyright notice for the source code. The software is not guaranteed; Including warranties of fitness without merchantability and for a particular purpose.Copy the code
If you can’t find GCC, it’s not installed.
You can run the DNF command to install it
[root@centos8 liuhongdi]# dnf install gcc
Copy the code
GCC version should not be too low, should be above GCC 5.3
If the version is too early, you are advised to upgrade GCC
Third, download redis6 and unzip it
download
[root @ centos8 source] # wget HTTP: / / http://download.redis.io/releases/redis-6.0.1.tar.gzCopy the code
unzip
[root@centos8 source]# tar -zxvf redis-6.0.1.tar.gz
Copy the code
Install redis6.0.1
1, install redis
#PREFIX= /usr/local/sof/redis6: specifies the installation directory, where we specify /usr/local/sof/redis6
[root@centos8 source]# cd redis-6.0.1/
[root@centos8 redis-6.0.1]# make PREFIX=/usr/local/soft/redis6 install
Copy the code
2. Generate the configuration file
Creating an installation directory
[root @ centos8 redis - the 6.0.1] # mkdir/usr/local/soft/redis6 / confCopy the code
Copy redis.conf from the source directory to the installation directory
[root @ centos8 redis - the 6.0.1] # cp redis. Conf/usr/local/soft/redis6 / conf /Copy the code
Create a directory for Redis to run
Used to store redis logs and data respectively
Logs: Stores logs
Data: stores snapshot data
[root@centos8 data]# mkdir -p /data/redis6
[root@centos8 data]# cd /data/redis6/
[root@centos8 redis6]# mkdir logs
[root@centos8 redis6]# mkdir data
Copy the code
Edit the redis configuration file:
[root@centos8 conf]# vi redis.conf
Copy the code
Configuration items:
Comment it out for external access
# bind 127.0.0.1
Start in background process mode
daemonize yes
#requirepass foobared Remove the comment and change foobared to its own password
# Log save directory
logfile "/data/redis6/logs/redis.log"
Copy the code
# Data save directory
dir /data/redis6/data/
Copy the code
# The maximum amount of memory used
maxmemory 128MB
Copy the code
# IO number of threads
The recommended setting is 3/4 of the number of CPU cores. My machine has 4 cores, so set this to 3
io-threads 3
Copy the code
With the original instructions in redis. Conf:
# So for instance if you have a four cores boxes, try to use 2 or 3 I/O
# threads, if you have a 8 cores, try to use 6 threads. In order to
# enable I/O threads use the following configuration directive:
Copy the code
How to view the number of cores:
[root@centos8 ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
...
Copy the code
The CPU(S) display is four coresCopy the code
Generate a service file for systemd
[root@centos8 ~]# vi /lib/systemd/system/redis6.service
Copy the code
Content:
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/soft/redis6/bin/redis-server /usr/local/soft/redis6/conf/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Copy the code
Reload the service file
[root@centos8 ~]# systemctl daemon-reload
Copy the code
Redis6:
Activation:
[root@centos8 ~]# systemctl start redis6
Copy the code
Stop:
[root@centos8 ~]# systemctl stop redis6
Copy the code
Test access from local connection:
[root @ centos8 conf] # / usr/local/soft/redis6 / bin/redis - cli - h 192.168.1.7 192.168.1.7:6379 > set a aaaa OK 192.168.1.7:6379 > get a "aaaa"Copy the code
Nine, check the version of Redis installed
[root @ centos8 conf] # / usr/local/soft/redis6 / bin/redis server - v redis server v = the 6.0.1 sha = 00000000:0 The malloc = jemalloc - 5.1.0 bits = 64 build = 0Copy the code
Check the centos version
[root@centos8 conf]# cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)
Copy the code