Redis -- 安装客户端redis-plus-plus

目录

访问reids客户端github链接

安装git 

如何安装?

下载/编译、安装客户端 

安装过程中可能遇到的问题


访问reids客户端github链接

GitHub - sewenew/redis-plus-plus: Redis client written in C++Redis client written in C++. Contribute to sewenew/redis-plus-plus development by creating an account on GitHub.icon-default.png?t=N7T8https://github.com/sewenew/redis-plus-plus

然后来到如图所示的installation页面。这个标签说明了如何安装Redis客户端。安装之前首先需要安装hiredis,因为redis依赖于hiredis。hiredis是c语言版本的redis 如果访问不了github页面,可以使用steam++(官网搜索steam++或者wait toolkit)安装进行加速。

安装git 

        在远程克隆代码之前需要使用到git命令,此时就需要下载git:

centos:  首先需要进入root模式有需要的可以更新yum:sudu yum update安装git:yum install gitubuntu: 仅仅以 sudo 权限用户身份运行下面的命令更新apt:sudo apt update安装:sudo apt install git运行下面的命令,打印 Git 版本,验证安装过程: git -- version

        重要的事情说三遍:请先安装hiredis,它是redis的依赖!!! 

        重要的事情说三遍:请先安装hiredis,它是redis的依赖!!! 

        重要的事情说三遍:请先安装hiredis,它是redis的依赖!!! 

如何安装hiredis?

通过源码安装

参考下面:

git clone https://github.com/redis/hiredis.gitcd hiredismakemake install 通过包管理器安装

ubuntu:

apt install libhiredis-dev

centos:

yum install hiredis-devel.x86_64

 安装完成之后,下载redis客户端:

下载/编译、安装客户端 

git clone https://github.com/sewenew/redis-plus-plus.gitcd redis-plus-plusmkdir buildcd buildcmake ..makemake installcd ..

 redis-plus-plus本体只能通过编译安装

centos

   centos需要安装一下cmake3:

yum install cmake3

 

然后在指定文件夹中使用git 命令来克隆:

​git clone https://github.com/sewenew/redis-plus-plus.git

 

cd进入redis-plus-plus:

 

mkdir build:创建build目录:这是一个习惯性做法,并非必须,目的是为了让编译产生的临时文件都放到build下,避免污染源码。cd build:进入build目录

        这个操作是生成makefile,也就是编译操作,里面的".."的意思是指向了要编译的目录,然后将此编译文件存放在build文件夹中。如果你是centos,就使用刚才安装的cmake3 ..

        如果出现下面的问题:

         可能的原因是你没有安装gcc:

解决方法如下:

1. 首先,确保已经安装了gcc和g++。如果没有安装,可以使用以下命令安装: sudo yum install gcc gcc-c++  

2. 安装cmake: sudo yum install cmake  

3. 如果问题仍然存在,尝试创建一个名为`CMakeCache.txt`的文件,将以下内容添加到文件中: CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++  

4. 保存文件后,再次尝试安装redis。如果仍然出现问题,请检查`/usr/bin/g++`是否存在。如果不存在,请使用以下命令查找g++的位置: which g++  

5. 将`CMakeCache.txt`文件中的`/usr/bin/g++`替换为实际的g++路径,然后再次尝试安装redis。

        cmake之后查看build中生成的文件:

        然后直接make进行编译:

        然后make install:

 

安装过程中可能遇到的问题

如果提示编译失败,或者是缺少必要的编译环境,例如gcc等,请自行安装。c++: fatal error: killed signalterminated program cclplus,如果你是轻量级服务器,那么请务必注意在出现此消息的时候,在build文件夹里面cmake的时候,禁用编译test文件,以减少系统的负担。如何禁用?参考官方文档:

When compiling redis-plus-plus, it also compiles a test program, which might take a while. However, you can disable building test with the following cmake option: -DREDIS_PLUS_PLUS_BUILD_TEST=OFF.

        cmake、cmake3阶段的命令改为下面的命令:

cmake -DCMAKE_PREFIX_PATH=/path/to/hiredis -DCMAKE_INSTALL_PREFIX=/path/to/install/redis-plus-plus -DREDIS_PLUS_PLUS_BUILD_TEST=OFF ..

 

文章版权声明:除非注明,否则均为 谢士广博客 原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog
评论列表 (暂无评论,6504人围观)

还没有评论,来说两句吧...

目录[+]