暂无图片
暂无图片
3
暂无图片
暂无图片
暂无图片

redis7.2.4的安装尝鲜

原创 virvle 2024-04-12
1388

中间件的选择,有时候要结合多方面的,比如JDK,比如redis(缓存),本次项目选择了redis目前最新版本,,接下来安装试试

一、下载地址:

https://redis.io/download/#redis-downloads

wget https://download.redis.io/redis-stable.tar.gz 
Latest Stable
The latest stable release is always available at the fixed https://download.redis.io/redis-stable.tar.gz URL along with its SHA-256 sum.

二、安装文档:

https://redis.io/docs/install/

三、安装过程:

1. 安装相关依赖包,不然编译安装redis的时候,报错

安装gc++

sudo yum install gcc-c++ -y

++ 安装python3++

[test@localhost redis-7.2.4]$ sudo yum install python3 -y
[sudo] password for test:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-21.el7_9 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-21.el7_9 for package: python3-3.6.8-21.el7_9.x86_64
--> Processing Dependency: python3-setuptools for package: python3-3.6.8-21.el7_9.x86_64
--> Processing Dependency: python3-pip for package: python3-3.6.8-21.el7_9.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-21.el7_9.x86_64
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-21.el7_9 will be installed
--> Processing Dependency: libtirpc.so.1()(64bit) for package: python3-libs-3.6.8-21.el7_9.x86_64
---> Package python3-pip.noarch 0:9.0.3-8.el7 will be installed
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
--> Running transaction check
---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================
 Package                             Arch                    Version                            Repository                Size
===============================================================================================================================
Installing:
 python3                             x86_64                  3.6.8-21.el7_9                     updates                   71 k
Installing for dependencies:
 libtirpc                            x86_64                  0.2.4-0.16.el7                     base                      89 k
 python3-libs                        x86_64                  3.6.8-21.el7_9                     updates                  7.0 M
 python3-pip                         noarch                  9.0.3-8.el7                        base                     1.6 M
 python3-setuptools                  noarch                  39.2.0-10.el7                      base                     629 k

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

Total download size: 9.3 M
Installed size: 48 M
Downloading packages:
(1/5): python3-3.6.8-21.el7_9.x86_64.rpm                                                                |  71 kB  00:00:00
(2/5): libtirpc-0.2.4-0.16.el7.x86_64.rpm                                                               |  89 kB  00:00:00
(3/5): python3-setuptools-39.2.0-10.el7.noarch.rpm                                                      | 629 kB  00:00:01
(4/5): python3-pip-9.0.3-8.el7.noarch.rpm                                                               | 1.6 MB  00:00:03
(5/5): python3-libs-3.6.8-21.el7_9.x86_64.rpm                                                           | 7.0 MB  00:00:08
-------------------------------------------------------------------------------------------------------------------------------
Total                                                                                          1.1 MB/s | 9.3 MB  00:00:08
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libtirpc-0.2.4-0.16.el7.x86_64                                                                              1/5
  Installing : python3-setuptools-39.2.0-10.el7.noarch                                                                     2/5
  Installing : python3-pip-9.0.3-8.el7.noarch                                                                              3/5
  Installing : python3-3.6.8-21.el7_9.x86_64                                                                               4/5
  Installing : python3-libs-3.6.8-21.el7_9.x86_64                                                                          5/5
  Verifying  : libtirpc-0.2.4-0.16.el7.x86_64                                                                              1/5
  Verifying  : python3-libs-3.6.8-21.el7_9.x86_64                                                                          2/5
  Verifying  : python3-3.6.8-21.el7_9.x86_64                                                                               3/5
  Verifying  : python3-setuptools-39.2.0-10.el7.noarch                                                                     4/5
  Verifying  : python3-pip-9.0.3-8.el7.noarch                                                                              5/5

Installed:
  python3.x86_64 0:3.6.8-21.el7_9

Dependency Installed:
  libtirpc.x86_64 0:0.2.4-0.16.el7              python3-libs.x86_64 0:3.6.8-21.el7_9     python3-pip.noarch 0:9.0.3-8.el7
  python3-setuptools.noarch 0:39.2.0-10.el7

Complete!

2. 编译

cd /data/redis-7.2.4/
make

最后编译成功出现如下说明:

    CC logreqres.o
    LINK redis-server
    INSTALL redis-sentinel
    CC redis-cli.o
    CC redisassert.o
    CC cli_common.o
    CC cli_commands.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' ;)

make[1]: Leaving directory `/data/redis-7.2.4/src'
[test@localhost redis-7.2.4]$

3.安装并指定安装目录

[test@localhost redis-7.2.4]$ mkdir …/redis

[test@localhost redis-7.2.4]$ make PREFIX=/data/redis install

4.修改redis.conf 配置

bind 127.0.0.1 10.10.100.232

daemonize yes
 pidfile /data/redis/redis_6379.pid
 port 5278
databases 16
maxmemory 512mb
logfile "redis.log"

为了安全起见,防止危险命令 ,编辑配置文件,进行重命名 redis.conf

rename-command FLUSHALL  "YKFLUSHALL"
rename-command FLUSHDB   "YKFLUSHDB"
rename-command CONFIG    "YKCONFIG"
rename-command KEYS      "YKKEYS"
rename-command SHUTDOWN  "YKSHUTDOWN"
rename-command DEL       "YKDEL"
rename-command EVAL      "YKEVAL"

设置后需要重启,设置前后比对:

++ 设置前++

127.0.0.1:5278> shutdown
not connected> 

++ 设置后++

127.0.0.1:5278> shutdown
(error) ERR unknown command 'shutdown', with args beginning with:
127.0.0.1:5278>
127.0.0.1:5278> ykshutdown
not connected> exit

5.验证客户端连接

[test@localhost conf]$ /data/redis/bin/redis-cli -p 5278
127.0.0.1:5278> auth Ykocredis#2024
OK
127.0.0.1:5278>

6.制作启动脚本

 vi /data/script/redis-start

#!/bin/bash

app_home="/data/redis"
cd $app_home

7. 启动 redis

$app_home/bin/redis-server $app_home/conf/redis.conf

四、常见问题

若是未安装python,会出现如下报错

cd src && make install
which: no python3 in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin)
make[1]: Entering directory `/data/redis-7.2.4/src'
    CC Makefile.dep
make[1]: Leaving directory `/data/redis-7.2.4/src'
which: no python3 in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/test/.local/bin:/home/test/bin)
make[1]: Entering directory `/data/redis-7.2.4/src'

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

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli
make[1]: Leaving directory `/data/redis-7.2.4/src'
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论