Linux系统之源码编译部署Redis数据库

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
云数据库 Tair(兼容Redis),内存型 2GB
简介: Linux系统之源码编译部署Redis数据库

一、Redis数据库介绍

1.Redis简介

Redis 是完全开源的,遵守 BSD 协议,是一个高性能的 key-value 数据库。

2.Redis特点

  • Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次加载进行使用。
  • Redis不仅仅支持简单的key-value类型的数据,同时还提供list,set,zset,hash等数据结构的存储。
  • Redis支持数据的备份,即master-slave模式的数据备份。

二、检查本地系统版本

[root@node data]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

三、下载Redis软件包

1.下载软件

[root@node redis]# wget https://download.redis.io/releases/redis-6.2.6.tar.gz
--2022-11-06 16:33:47--  https://download.redis.io/releases/redis-6.2.6.tar.gz
Resolving download.redis.io (download.redis.io)... 45.60.125.1
Connecting to download.redis.io (download.redis.io)|45.60.125.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2476542 (2.4M) [application/octet-stream]
Saving to: ‘redis-6.2.6.tar.gz’

100%[=========================================================================================================>] 2,476,542   4.90MB/s   in 0.5s   

2022-11-06 16:33:49 (4.90 MB/s) - ‘redis-6.2.6.tar.gz’ saved [2476542/2476542]

2.查看redis安装包

[root@node redis]# ls
redis-6.2.6.tar.gz

四、安装redis前环境准备工作

1.解压redis压缩包

[root@node redis]# tar -xzf redis-6.2.6.tar.gz 
[root@node redis]# ls
redis-6.2.6  redis-6.2.6.tar.gz

2.安装gcc模块

[root@node redis]# yum -y install gcc automake autoconf libtool make
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
base                                                                                                                        | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                            | 3.5 kB  00:00:00     
extras                                                                                                                      | 2.9 kB  00:00:00     
mongodb-org                                                                                                                 | 2.9 kB  00:00:00     
mysql-connectors-community                                                                                                  | 2.6 kB  00:00:00     
mysql-tools-community                                                                                                       | 2.6 kB  00:00:00     
mysql57-community                                                                                                           | 2.6 kB  00:00:00     
updates                                                                                                                     | 2.9 kB  00:00:00     
mongodb-org/7/primary_db                                                                                                    | 130 kB  00:00:01     
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
--> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch
---> Package automake.noarch 0:1.13.4-3.el7 will be installed
--> Processing Dependency: perl(Thread::Queue) for package: automake-1.13.4-3.el7.noarch
--> Processing Dependency: perl(TAP::Parser) for package: automake-1.13.4-3.el7.noarch
---> Package gcc.x86_64 0:4.8.5-44.el7 will be installed
--> Processing Dependency: libgomp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-44.el7.x86_64
---> Package libtool.x86_64 0:2.4.2-22.el7_3 will be installed
---> Package make.x86_64 1:3.82-23.el7 will be updated
---> Package make.x86_64 1:3.82-24.el7 will be an update
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-44.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-326.el7_9 will be installed
--> Processing Dependency: glibc-headers = 2.17-326.el7_9 for package: glibc-devel-2.17-326.el7_9.x86_64
--> Processing Dependency: glibc = 2.17-326.el7_9 for package: glibc-devel-2.17-326.el7_9.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-326.el7_9.x86_64
---> Package libgcc.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-44.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgomp.x86_64 0:4.8.5-44.el7 will be an update
---> Package m4.x86_64 0:1.4.16-10.el7 will be installed
---> Package perl-Test-Harness.noarch 0:3.28-3.el7 will be installed
---> Package perl-Thread-Queue.noarch 0:3.02-2.el7 will be installed
--> Running transaction check
---> Package glibc.x86_64 0:2.17-260.el7 will be updated
--> Processing Dependency: glibc = 2.17-260.el7 for package: glibc-common-2.17-260.el7.x86_64
---> Package glibc.x86_64 0:2.17-326.el7_9 will be an update
---> Package glibc-headers.x86_64 0:2.17-326.el7_9 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-326.el7_9.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-326.el7_9.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-260.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-326.el7_9 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-1160.76.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================
 Package                                Arch                        Version                                     Repository                    Size
===================================================================================================================================================
Installing:
 autoconf                               noarch                      2.69-11.el7                                 base                         701 k
 automake                               noarch                      1.13.4-3.el7                                base                         679 k
 gcc                                    x86_64                      4.8.5-44.el7                                base                          16 M
 libtool                                x86_64                      2.4.2-22.el7_3                              base                         588 k
Updating:
 make                                   x86_64                      1:3.82-24.el7                               base                         421 k
Installing for dependencies:
 cpp                                    x86_64                      4.8.5-44.el7                                base                         5.9 M
 glibc-devel                            x86_64                      2.17-326.el7_9                              updates                      1.1 M
 glibc-headers                          x86_64                      2.17-326.el7_9                              updates                      691 k
 kernel-headers                         x86_64                      3.10.0-1160.76.1.el7                        updates                      9.1 M
 m4                                     x86_64                      1.4.16-10.el7                               base                         256 k
 perl-Test-Harness                      noarch                      3.28-3.el7                                  base                         302 k
 perl-Thread-Queue                      noarch                      3.02-2.el7                                  base                          17 k
Updating for dependencies:
 glibc                                  x86_64                      2.17-326.el7_9                              updates                      3.6 M
 glibc-common                           x86_64                      2.17-326.el7_9                              updates                       12 M
 libgcc                                 x86_64                      4.8.5-44.el7                                base                         103 k
 libgomp                                x86_64                      4.8.5-44.el7                                base                         159 k

Transaction Summary
===================================================================================================================================================
Install  4 Packages (+7 Dependent packages)
Upgrade  1 Package  (+4 Dependent packages)

Total size: 51 M
Total download size: 35 M
Downloading packages:
(1/11): automake-1.13.4-3.el7.noarch.rpm                                                                                    | 679 kB  00:00:00     
(2/11): autoconf-2.69-11.el7.noarch.rpm                                                                                     | 701 kB  00:00:00     
(3/11): glibc-devel-2.17-326.el7_9.x86_64.rpm                                                                               | 1.1 MB  00:00:00     
(4/11): libtool-2.4.2-22.el7_3.x86_64.rpm                                                                                   | 588 kB  00:00:00     
(5/11): m4-1.4.16-10.el7.x86_64.rpm                                                                                         | 256 kB  00:00:00     
(6/11): perl-Test-Harness-3.28-3.el7.noarch.rpm                                                                             | 302 kB  00:00:00     
(7/11): perl-Thread-Queue-3.02-2.el7.noarch.rpm                                                                             |  17 kB  00:00:00     
(8/11): kernel-headers-3.10.0-1160.76.1.el7.x86_64.rpm                                                                      | 9.1 MB  00:00:01     
(9/11): cpp-4.8.5-44.el7.x86_64.rpm                                                                                         | 5.9 MB  00:00:02     
(10/11): glibc-headers-2.17-326.el7_9.x86_64.rpm                                                                            | 691 kB  00:00:03     
(11/11): gcc-4.8.5-44.el7.x86_64.rpm                                                                                        |  16 MB  00:00:06     
---------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                              4.7 MB/s |  35 MB  00:00:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-44.el7.x86_64                                                                                                     1/21 
  Updating   : glibc-common-2.17-326.el7_9.x86_64                                                                                             2/21 
  Updating   : glibc-2.17-326.el7_9.x86_64                                                                                                    3/21 
warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
  Installing : cpp-4.8.5-44.el7.x86_64                                                                                                        4/21 
  Installing : m4-1.4.16-10.el7.x86_64                                                                                                        5/21 
  Installing : autoconf-2.69-11.el7.noarch                                                                                                    6/21 
  Updating   : libgomp-4.8.5-44.el7.x86_64                                                                                                    7/21 
  Installing : perl-Thread-Queue-3.02-2.el7.noarch                                                                                            8/21 
  Installing : perl-Test-Harness-3.28-3.el7.noarch                                                                                            9/21 
  Installing : automake-1.13.4-3.el7.noarch                                                                                                  10/21 
  Installing : kernel-headers-3.10.0-1160.76.1.el7.x86_64                                                                                    11/21 
  Installing : glibc-headers-2.17-326.el7_9.x86_64                                                                                           12/21 
  Installing : glibc-devel-2.17-326.el7_9.x86_64                                                                                             13/21 
  Installing : gcc-4.8.5-44.el7.x86_64                                                                                                       14/21 
  Installing : libtool-2.4.2-22.el7_3.x86_64                                                                                                 15/21 
  Updating   : 1:make-3.82-24.el7.x86_64                                                                                                     16/21 
  Cleanup    : libgomp-4.8.5-36.el7.x86_64                                                                                                   17/21 
  Cleanup    : 1:make-3.82-23.el7.x86_64                                                                                                     18/21 
  Cleanup    : glibc-common-2.17-260.el7.x86_64                                                                                              19/21 
  Cleanup    : glibc-2.17-260.el7.x86_64                                                                                                     20/21 
  Cleanup    : libgcc-4.8.5-36.el7.x86_64                                                                                                    21/21 
  Verifying  : kernel-headers-3.10.0-1160.76.1.el7.x86_64                                                                                     1/21 
  Verifying  : autoconf-2.69-11.el7.noarch                                                                                                    2/21 
  Verifying  : glibc-2.17-326.el7_9.x86_64                                                                                                    3/21 
  Verifying  : perl-Test-Harness-3.28-3.el7.noarch                                                                                            4/21 
  Verifying  : automake-1.13.4-3.el7.noarch                                                                                                   5/21 
  Verifying  : glibc-common-2.17-326.el7_9.x86_64                                                                                             6/21 
  Verifying  : perl-Thread-Queue-3.02-2.el7.noarch                                                                                            7/21 
  Verifying  : cpp-4.8.5-44.el7.x86_64                                                                                                        8/21 
  Verifying  : gcc-4.8.5-44.el7.x86_64                                                                                                        9/21 
  Verifying  : glibc-headers-2.17-326.el7_9.x86_64                                                                                           10/21 
  Verifying  : glibc-devel-2.17-326.el7_9.x86_64                                                                                             11/21 
  Verifying  : 1:make-3.82-24.el7.x86_64                                                                                                     12/21 
  Verifying  : m4-1.4.16-10.el7.x86_64                                                                                                       13/21 
  Verifying  : libgcc-4.8.5-44.el7.x86_64                                                                                                    14/21 
  Verifying  : libgomp-4.8.5-44.el7.x86_64                                                                                                   15/21 
  Verifying  : libtool-2.4.2-22.el7_3.x86_64                                                                                                 16/21 
  Verifying  : libgcc-4.8.5-36.el7.x86_64                                                                                                    17/21 
  Verifying  : glibc-common-2.17-260.el7.x86_64                                                                                              18/21 
  Verifying  : glibc-2.17-260.el7.x86_64                                                                                                     19/21 
  Verifying  : libgomp-4.8.5-36.el7.x86_64                                                                                                   20/21 
  Verifying  : 1:make-3.82-23.el7.x86_64                                                                                                     21/21 

Installed:
  autoconf.noarch 0:2.69-11.el7       automake.noarch 0:1.13.4-3.el7       gcc.x86_64 0:4.8.5-44.el7       libtool.x86_64 0:2.4.2-22.el7_3      

Dependency Installed:
  cpp.x86_64 0:4.8.5-44.el7                             glibc-devel.x86_64 0:2.17-326.el7_9          glibc-headers.x86_64 0:2.17-326.el7_9         
  kernel-headers.x86_64 0:3.10.0-1160.76.1.el7          m4.x86_64 0:1.4.16-10.el7                    perl-Test-Harness.noarch 0:3.28-3.el7         
  perl-Thread-Queue.noarch 0:3.02-2.el7                

Updated:
  make.x86_64 1:3.82-24.el7                                                                                                                        

Dependency Updated:
  glibc.x86_64 0:2.17-326.el7_9      glibc-common.x86_64 0:2.17-326.el7_9      libgcc.x86_64 0:4.8.5-44.el7      libgomp.x86_64 0:4.8.5-44.el7     

Complete!

五、编译redis源码包

1.进入软件目录

[root@node redis]# cd redis-6.2.6/
[root@node redis-6.2.6]# ls
00-RELEASENOTES  CONDUCT       COPYING  INSTALL   MANIFESTO  redis.conf  runtest-cluster    runtest-sentinel  src    TLS.md
BUGS             CONTRIBUTING  deps     Makefile  README.md  runtest     runtest-moduleapi  sentinel.conf     tests  utils
[root@node redis-6.2.6]# cd deps/
[root@node deps]# ls
hdr_histogram  hiredis  jemalloc  linenoise  lua  Makefile  README.md  update-jemalloc.sh

2.编译redis前准备工作

[root@node deps]# make lua hiredis linenoise hdr_histogram jemalloc

3.编译redis

[root@node src]# make PREFIX=/usr/local/redis MALLOC=libc install
    CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d scripting.d bio.d rio.d rand.d memtest.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d gopher.d tracking.d connection.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d
(cd ../deps && make distclean)
make[1]: Entering directory `/aa/redis/redis-6.2.6/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(rm -f .make-*)
make[1]: Leaving directory `/aa/redis/redis-6.2.6/deps'
(cd modules && make clean)
make[1]: Entering directory `/aa/redis/redis-6.2.6/src/modules'
rm -rf *.xo *.so
make[1]: Leaving directory `/aa/redis/redis-6.2.6/src/modules'
(cd ../tests/modules && make clean)
make[1]: Entering directory `/aa/redis/redis-6.2.6/tests/modules'
rm -f commandfilter.so basics.so testrdb.so fork.so infotest.so propagate.so misc.so hooks.so blockonkeys.so blockonbackground.so scan.so datatype.so auth.so keyspace_events.so blockedclient.so getkeys.so test_lazyfree.so timer.so defragtest.so hash.so zset.so stream.so commandfilter.xo basics.xo testrdb.xo fork.xo infotest.xo propagate.xo misc.xo hooks.xo blockonkeys.xo blockonbackground.xo scan.xo datatype.xo auth.xo keyspace_events.xo blockedclient.xo getkeys.xo test_lazyfree.xo timer.xo defragtest.xo hash.xo zset.xo stream.xo
make[1]: Leaving directory `/aa/redis/redis-6.2.6/tests/modules'
(rm -f .make-*)
echo STD=-pedantic -DREDIS_STATIC='' -std=c99 >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=libc >> .make-settings
echo BUILD_TLS= >> .make-settings
echo USE_SYSTEMD= >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-pedantic -DREDIS_STATIC='' -std=c99 -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb   -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -I../deps/hdr_histogram >> .make-settings
echo PREV_FINAL_LDFLAGS=  -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua hdr_histogram)
make[1]: Entering directory `/aa/redis/redis-6.2.6/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(cd hdr_histogram && make clean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static 
make[2]: Entering directory `/aa/redis/redis-6.2.6/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb alloc.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb net.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb sds.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb async.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb read.c
cc -std=c99 -pedantic -c -O3 -fPIC   -Wall -W -Wstrict-prototypes -Wwrite-strings -Wno-missing-field-initializers -g -ggdb sockcompat.c
ar rcs libhiredis.a alloc.o net.o hiredis.o sds.o async.o read.o sockcompat.o
make[2]: Leaving directory `/aa/redis/redis-6.2.6/deps/hiredis'
MAKE linenoise
cd linenoise && make
make[2]: Entering directory `/aa/redis/redis-6.2.6/deps/linenoise'
cc  -Wall -Os -g  -c linenoise.c
make[2]: Leaving directory `/aa/redis/redis-6.2.6/deps/linenoise'
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP " MYLDFLAGS="" AR="ar rc"
make[2]: Entering directory `/aa/redis/redis-6.2.6/deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lcode.o lcode.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldo.o ldo.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldump.o ldump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o llex.o llex.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lobject.o lobject.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lstring.o lstring.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lundump.o lundump.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lvm.o lvm.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lzio.o lzio.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o fpconv.o fpconv.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lauxlib.o lauxlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lbaselib.o lbaselib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ldblib.o ldblib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lmathlib.o lmathlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o loslib.o loslib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o linit.o linit.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_cjson.o lua_cjson.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_struct.o lua_struct.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_cmsgpack.o lua_cmsgpack.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua_bit.o lua_bit.c
ar rc liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o fpconv.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o lua_bit.o    # DLL needs all object files
ranlib liblua.a
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o lua.o lua.c
cc -o lua  lua.o liblua.a -lm 
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o luac.o luac.c
cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -DLUA_USE_MKSTEMP    -c -o print.o print.c
cc -o luac  luac.o print.o liblua.a -lm 
make[2]: Leaving directory `/aa/redis/redis-6.2.6/deps/lua/src'
MAKE hdr_histogram
cd hdr_histogram && make
make[2]: Entering directory `/aa/redis/redis-6.2.6/deps/hdr_histogram'
cc  -Wall -Os -g  -c  hdr_histogram.c 
make[2]: Leaving directory `/aa/redis/redis-6.2.6/deps/hdr_histogram'
make[1]: Leaving directory `/aa/redis/redis-6.2.6/deps'
    CC adlist.o
    CC quicklist.o
    CC ae.o
    CC anet.o
    CC dict.o
    CC server.o
    CC sds.o
    CC zmalloc.o
    CC lzf_c.o
    CC lzf_d.o
    CC pqsort.o
    CC zipmap.o
    CC sha1.o
    CC ziplist.o
    CC release.o
    CC networking.o
    CC util.o
    CC object.o
    CC db.o
    CC replication.o
    CC rdb.o
    CC t_string.o
    CC t_list.o
    CC t_set.o
    CC t_zset.o
    CC t_hash.o
    CC config.o
    CC aof.o
    CC pubsub.o
    CC multi.o
    CC debug.o
    CC sort.o
    CC intset.o
    CC syncio.o
    CC cluster.o
    CC crc16.o
    CC endianconv.o
    CC slowlog.o
    CC scripting.o
    CC bio.o
    CC rio.o
    CC rand.o
    CC memtest.o
    CC crcspeed.o
    CC crc64.o
    CC bitops.o
    CC sentinel.o
    CC notify.o
    CC setproctitle.o
    CC blocked.o
    CC hyperloglog.o
    CC latency.o
    CC sparkline.o
    CC redis-check-rdb.o
    CC redis-check-aof.o
    CC geo.o
    CC lazyfree.o
    CC module.o
    CC evict.o
    CC expire.o
    CC geohash.o
    CC geohash_helper.o
    CC childinfo.o
    CC defrag.o
    CC siphash.o
    CC rax.o
    CC t_stream.o
    CC listpack.o
    CC localtime.o
    CC lolwut.o
    CC lolwut5.o
    CC lolwut6.o
    CC acl.o
    CC gopher.o
    CC tracking.o
    CC connection.o
    CC tls.o
    CC sha256.o
    CC timeout.o
    CC setcpuaffinity.o
    CC monotonic.o
    CC mt19937-64.o
    LINK redis-server
    INSTALL redis-sentinel
    CC redis-cli.o
    CC cli_common.o
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

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

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli

六、启动redis

1.配置环境变量

[root@node src]# vim /etc/profile.d/redis.sh
[root@node src]# cat /etc/profile.d/redis.sh 
#!/bin/bash
##########################################################
#File Name:/etc/profile.d/redis.sh
#Version:V1.0
#Aurhor:jeven
#Emali:111116@qq.com
#Created Time:2022-11-06 16:53:28
#Description:
##########################################################
export PATH=$PATH:/usr/local/redis/bin
[root@node src]# source !$
source /etc/profile.d/redis.sh

2.检查redis版本

[root@node src]# redis-server --version
Redis server v=6.2.6 sha=00000000:0 malloc=libc bits=64 build=50e1147e6629be9b

3.创建redis相关目录

mkdir -p /usr/local/redis/{etc,logs,data}

4.编辑redis配置文件

[root@node src]# cat  /usr/local/redis/etc/redis.conf
daemonize yes
supervised systemd
pidfile /var/run/redis.pid
port 6379
logfile /usr/local/redis/logs/redis.log
dbfilename dump.rdb
dir /usr/local/redis/data

maxmemory 1G

bind 192.168.3.166 127.0.0.1

timeout 300
loglevel notice

databases 16
save 900 1
save 300 10
save 60 10000

rdbcompression yes

maxclients 10000
appendonly yes
appendfilename appendonly.aof
appendfsync everysec

5.启动redis数据库服务

redis-server /usr/local/redis/etc/redis.conf

七、连接redis数据库

1.检查redis状态

[root@node src]#  ps -ef |grep redis
root      62216      1  0 16:57 ?        00:00:00 redis-server 192.168.3.166:6379
root      62271  40947  0 16:58 pts/1    00:00:00 grep --color=auto redis

2.连接redis

[root@node src]# redis-cli  -h 192.168.3.166 -p 6379
192.168.3.166:6379> info
# Server
redis_version:6.2.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:50e1147e6629be9b
redis_mode:standalone
os:Linux 3.10.0-957.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:62216
process_supervised:no
run_id:2214123488103e78bca63970b6830e53341b9a66
tcp_port:6379
server_time_usec:1667725122023863
uptime_in_seconds:86
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:6780738
executable:/aa/redis/redis-6.2.6/src/redis-server
config_file:/usr/local/redis/etc/redis.conf
io_threads_active:0

# Clients
connected_clients:1
cluster_connections:0
maxclients:10000
client_recent_max_input_buffer:48
client_recent_max_output_buffer:0
blocked_clients:0
tracking_clients:0
clients_in_timeout_table:0

# Memory
used_memory:936080
used_memory_human:914.14K
used_memory_rss:2478080
used_memory_rss_human:2.36M
used_memory_peak:990912
used_memory_peak_human:967.69K
used_memory_peak_perc:94.47%
used_memory_overhead:901168
used_memory_startup:884112
used_memory_dataset:34912
used_memory_dataset_perc:67.18%
allocator_allocated:901664
allocator_active:2440192
allocator_resident:2440192
total_system_memory:8182054912
total_system_memory_human:7.62G
used_memory_lua:37888
used_memory_lua_human:37.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:1000000000
maxmemory_human:953.67M
maxmemory_policy:noeviction
allocator_frag_ratio:2.71
allocator_frag_bytes:1538528
allocator_rss_ratio:1.00
allocator_rss_bytes:0
rss_overhead_ratio:1.02
rss_overhead_bytes:37888
mem_fragmentation_ratio:2.75
mem_fragmentation_bytes:1576416
mem_not_counted_for_evict:20
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:17032
mem_aof_buffer:24
mem_allocator:libc
active_defrag_running:0
lazyfree_pending_objects:0
lazyfreed_objects:0

# Persistence
loading:0
current_cow_size:0
current_cow_size_age:0
current_fork_perc:0.00
current_save_keys_processed:0
current_save_keys_total:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1667725036
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:0
aof_enabled:1
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0
module_fork_in_progress:0
module_fork_last_cow_size:0
aof_current_size:0
aof_base_size:0
aof_pending_rewrite:0
aof_buffer_length:0
aof_rewrite_buffer_length:0
aof_pending_bio_fsync:0
aof_delayed_fsync:0

# Stats
total_connections_received:1
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:31
total_net_output_bytes:20324
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
expire_cycle_cpu_milliseconds:1
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
total_forks:0
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0
tracking_total_keys:0
tracking_total_items:0
tracking_total_prefixes:0
unexpected_error_replies:0
total_error_replies:0
dump_payload_sanitizations:0
total_reads_processed:2
total_writes_processed:1
io_threaded_reads_processed:0
io_threaded_writes_processed:0

# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:1a8b2d03ea009393183110d55ca0c6b619127210
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.132352
used_cpu_user:0.044117
used_cpu_sys_children:0.000000
used_cpu_user_children:0.000000
used_cpu_sys_main_thread:0.132334
used_cpu_user_main_thread:0.044111

# Modules

# Errorstats

# Cluster
cluster_enabled:0

# Keyspace
相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
11天前
|
Linux
在 Linux 系统中,“cd”命令用于切换当前工作目录
在 Linux 系统中,“cd”命令用于切换当前工作目录。本文详细介绍了“cd”命令的基本用法和常见技巧,包括使用“.”、“..”、“~”、绝对路径和相对路径,以及快速切换到上一次工作目录等。此外,还探讨了高级技巧,如使用通配符、结合其他命令、在脚本中使用,以及实际应用案例,帮助读者提高工作效率。
47 3
|
11天前
|
监控 安全 Linux
在 Linux 系统中,网络管理是重要任务。本文介绍了常用的网络命令及其适用场景
在 Linux 系统中,网络管理是重要任务。本文介绍了常用的网络命令及其适用场景,包括 ping(测试连通性)、traceroute(跟踪路由路径)、netstat(显示网络连接信息)、nmap(网络扫描)、ifconfig 和 ip(网络接口配置)。掌握这些命令有助于高效诊断和解决网络问题,保障网络稳定运行。
36 2
|
5天前
|
Ubuntu Linux 网络安全
linux系统ubuntu中在命令行中打开图形界面的文件夹
在Ubuntu系统中,通过命令行打开图形界面的文件夹是一个高效且实用的操作。无论是使用Nautilus、Dolphin还是Thunar,都可以根据具体桌面环境选择合适的文件管理器。通过上述命令和方法,可以简化日常工作,提高效率。同时,解决权限问题和图形界面问题也能确保操作的顺利进行。掌握这些技巧,可以使Linux操作更加便捷和灵活。
13 3
|
11天前
|
安全 网络协议 Linux
本文详细介绍了 Linux 系统中 ping 命令的使用方法和技巧,涵盖基本用法、高级用法、实际应用案例及注意事项。
本文详细介绍了 Linux 系统中 ping 命令的使用方法和技巧,涵盖基本用法、高级用法、实际应用案例及注意事项。通过掌握 ping 命令,读者可以轻松测试网络连通性、诊断网络问题并提升网络管理能力。
43 3
|
10天前
|
监控 Linux
如何检查 Linux 内存使用量是否耗尽?这 5 个命令堪称绝了!
本文介绍了在Linux系统中检查内存使用情况的5个常用命令:`free`、`top`、`vmstat`、`pidstat` 和 `/proc/meminfo` 文件,帮助用户准确监控内存状态,确保系统稳定运行。
92 6
|
19天前
|
缓存 监控 Linux
|
22天前
|
Linux Shell 数据安全/隐私保护
|
23天前
|
域名解析 网络协议 安全
|
6天前
|
运维 监控 网络协议
运维工程师日常工作中最常用的20个Linux命令,涵盖文件操作、目录管理、权限设置、系统监控等方面
本文介绍了运维工程师日常工作中最常用的20个Linux命令,涵盖文件操作、目录管理、权限设置、系统监控等方面,旨在帮助读者提高工作效率。从基本的文件查看与编辑,到高级的网络配置与安全管理,这些命令是运维工作中的必备工具。
33 3
|
29天前
|
运维 监控 网络协议
下一篇
无影云桌面