Redis installation and deployment (CentOS7 environment, Redis 6.0.9)

 

table of Contents

 

1. Redis official website

Second, install Redis

1. Unzip

2. Compile the source code

3. Installation

Three, deploy Redis

1. Create bin and etc folders

2. Move files

Fourth, start Redis


1. Redis official website

https://redis.io/download

This article uses the latest stable version V6.0.9

Second, install Redis

1. Unzip

tar -zxf redis-6.0.9.tar.gz

2. Compile the source code

make

Note: An error may be reported during the make process, the error message is as follows

In file included from server.c:30:0:
server.h:1072:5: error: expected specifier-qualifier-list before ‘_Atomic’
     _Atomic unsigned int lruclock; /* Clock for LRU eviction */
     ^
server.c: In function ‘serverLogRaw’:
server.c:1031:31: error: ‘struct redisServer’ has no member named ‘logfile’
     int log_to_stdout = server.logfile[0] == '\0';
                               ^
server.c:1034:23: error: ‘struct redisServer’ has no member named ‘verbosity’
     if (level < server.verbosity) return;
                       ^
server.c:1036:47: error: ‘struct redisServer’ has no member named ‘logfile’
     fp = log_to_stdout ? stdout : fopen(server.logfile,"a");
                                               ^
server.c:1049:47: error: ‘struct redisServer’ has no member named ‘timezone’
         nolocks_localtime(&tm,tv.tv_sec,server.timezone,server.daylight_active);
                                               ^
........

The cause of the error: GCC version is low, the new version of Redis uses c11, the default version of the system is 4.8.5

[root@10 redis-6.0.9]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Solution: need to update gcc to version 5.4 or higher, the installation command is as follows

yum groupinstall "Development Tools"

strings /usr/lib64/libstdc++.so.6 | grep GLIBC

cd /usr/local/src/

wget http://ftp.gnu.org/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.gz //The speed is slow, use the mirror station: wget http://mirror.hust.edu .cn/gnu/gcc/gcc-10.2.0/gcc-10.2.0.tar.gz

tar -zxf gcc-10.2.0.tar.gz

cd gcc-10.2.0

./contrib/download_prerequisites

./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

make -j4

ls /usr/local/bin | grep gcc

make install

Due to the slow installation process, another way to upgrade:

yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
gcc -v

3. Installation

make install

[root@10 redis-6.0.9]# cd src/
[root@10 src]# make install

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

Three, deploy Redis

1. Create bin and etc folders

[root@10 redis-6.0.9]# mkdir etc
[root@10 redis-6.0.9]# mkdir bin


2. Move files

[root@10 src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server ../bin/
[root@10 src]# cd ../bin/
[root@10 bin]# ls
mkreleasehdr.sh  redis-check-aof  redis-cli
redis-benchmark  redis-check-rdb  redis-server
[root@10 bin]# cd ..
[root@10 redis-6.0.9]# mv redis.conf etc/
[root@10 redis-6.0.9]# cd etc
[root@10 etc]# ls
redis.conf

Fourth, start Redis

[root@10 bin]# ./redis-server
13660:C 05 Dec 2020 11:57:20.929 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
13660:C 05 Dec 2020 11:57:20.929 # Redis version=6.0.9, bits=64, commit=00000000                                                      , modified=0, pid=13660, just started
13660:C 05 Dec 2020 11:57:20.929 # Warning: no config file specified, using the                                                       default config. In order to specify a config file use ./redis-server /path/to/re                                                      dis.conf
13660:M 05 Dec 2020 11:57:20.931 * Increased maximum number of open files to 100                                                      32 (it was originally set to 1024).
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 6.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 13660
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           http://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

13660:M 05 Dec 2020 11:57:20.934 # WARNING: The TCP backlog setting of 511 canno                                                      t be enforced because /proc/sys/net/core/somaxconn is set to the lower value of                                                       128.
13660:M 05 Dec 2020 11:57:20.934 # Server initialized
13660:M 05 Dec 2020 11:57:20.936 # WARNING overcommit_memory is set to 0! Backgr                                                      ound save may fail under low memory condition. To fix this issue add 'vm.overcom                                                      mit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl v                                                      m.overcommit_memory=1' for this to take effect.
13660:M 05 Dec 2020 11:57:20.937 # WARNING you have Transparent Huge Pages (THP)                                                       support enabled in your kernel. This will create latency and memory usage issue                                                      s with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/t                                                      ransparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order                                                       to retain the setting after a reboot. Redis must be restarted after THP is disab                                                      led (set to 'madvise' or 'never').
13660:M 05 Dec 2020 11:57:20.937 * Ready to accept connections

 

 

 

 

 

Guess you like

Origin blog.csdn.net/xlyrh/article/details/110729261