首页 > 数据库 >编译安装Redis

编译安装Redis

时间:2024-01-20 21:55:51浏览次数:39  
标签:opt systemd service Redis redis server 编译 conf 安装

编译安装Redis

ubuntu 22.04.3

1. 下载redis源码包

redis官网

下载最新的稳定版本。 (7.2)

2.编译安装

redis.tar.gz解压到 linxu下的 /usr/local/src 下,用make命令编译。需要一下依赖

  • pkg-config
  • gcc

如果报错缺失 ccpkg-config, 则需要安装对应的依赖

sudo apt-get install pkg-config
sudo apt-get install gcc

将redis安装到指定的目录下:

make PREFIX=/opt/redis install

此时会在 /opt/redis/bin 下生成相关的启动程序

  • redis-server 服务
  • redis-cli 客户端
  • redis-benchmark 性能测试工具
  • redis-check-aof
  • redis-check-rdb

复制一份 redis.conf文件到 /opt/redis/conf

mkdir /opt/redis/conf
cp /usr/local/src/redis.conf /opt/redis/conf

3.启动程序

前台启动

./redis-server ../conf/redis.conf 

后台启动

方式一:nohup

nohup redis-server &

方式二: 配置后台启动

修改 redis.conf配置文件 中的 daemonize属性值改为 yes即可

./redis-server ../conf/redis.conf

4. 注册service服务

redis注册为linxu服务,可开机启动

在我们的源码文件夹 /usr/local/src/redis/utils下有对应的工具包。 通过脚本 install_server.sh来注册服务。是交互式的,通过端口来区分实例,不过在新版linxu服务器上,建议使用 systemd 来管理服务,所以redis上会提示:

Welcome to the redis service installer
This script will help you easily set up a running redis server

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!

可以通过修改安装的脚本来跳过校验, 注释下面的校验行就行了

#bail if this system is managed by systemd
_pid_1_exe="$(readlink -f /proc/1/exe)"
if [ "${_pid_1_exe##*/}" = systemd ]
then
        echo "This systems seems to use systemd."
        echo "Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!"
        exit 1
fi
unset _pid_1_exe

不过不建议采用以上的方案, 应遵循新的linux管理方式, 采用 systemd

5. 注册为systemd服务

systemd-redis_server.service 文件拷贝到 /etc/systemd/system

sudo cp systemd-redis_server.service /etc/systemd/system/redis_server.service

根据自己需求定制化。 如下:

# 修改redis.conf
# 改为后台启动
daemoninze yes
# pid文件存放位置
pidfile /opt/redis/redis_6379.pid
# 日志存放位置
logfile /opt/redis/redis.log
# redis数据存放位置
dir /opt/redis


#  修改 redis_server.service 文件的启动文件
# 启动
ExecStart=/opt/redis/bin/redis-server /opt/redis/conf/redis.conf
# 停止
ExecStop=/opt/redis/bin/redis-cli shutdown
# 因为上面redis的配置 daemon 是 yes, 所以这里必须采用 forking
Type=forking

标签:opt,systemd,service,Redis,redis,server,编译,conf,安装
From: https://www.cnblogs.com/dxpbaby/p/17977194

相关文章

  • WSL2+Ubuntu22.04+Vscode 虚拟环境安装
    1.WSL2+Ubuntu22.04+Vscode虚拟环境安装详细攻略WIN11+WSL2+Ubuntu22.04+CUDA+MINICONDA3+Pytorch安装踩坑总结,手把手教学,看不会你打我1.1先决配置1.2安装命令官网https://learn.microsoft.com/zh-cn/windows/wsl/basic-commandswsl--install--no-distributio......
  • Redis数据类型
    title:Redis数据类型date:2024-01-2017:01:46permalink:/pages/73a3c3/categories:-中间件-Redistags:-Redis数据类型Redis作为K-V类型的缓存中间件,其value一共有5中数据类型。string,set,list,sorted-set(zset),hash.数据类型查看方式可以通......
  • WSL2+Ubuntu22.04+Vscode 虚拟环境安装
    1.WSL2+Ubuntu22.04+Vscode虚拟环境安装详细攻略WIN11+WSL2+Ubuntu22.04+CUDA+MINICONDA3+Pytorch安装踩坑总结,手把手教学,看不会你打我1.1先决配置1.2安装命令官网https://learn.microsoft.com/zh-cn/windows/wsl/basic-commandswsl--install--no-distributio......
  • Ubuntu20.04静态编译Boost记录
    下载Boost源码地址:https://www.boost.org/users/history/version_1_72_0.html指定安装位置./bootstrap.sh--prefix=/usr/local/boost-1-72-0编译release版本的boost库./b2toolset=gcclink=staticruntime-link=staticthreading=multi开始编译sudo./b2install--......
  • 二进制免安装的方式,部署java1.8开发环境
    (1)配置Java环境#1.下载二进制压缩文件[root@servertools]#wgethttps://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.tar.gz#2.解压Java二进制文件[root@servertools]#tar-xvfjdk-18_linux-x64_bin.tar.gz#3.编写Java代码[root@server~]#catH......
  • C++编译全过程
    1.源文件.cpp2.预处理:将所有的#include头文件以及宏定义替换成其真正的内容(删除所有的注释、宏扩展、文件包含).i3.汇编:转换为汇编语言.s4.编译:转换为二进制机器码.o(目标文件)5.链接:链接过程将多个目标文件以及所需的库文件(.so等)链接成最终的可执行文件(executablefile)......
  • Arch旧式安装
    cpu架构X86_64主板支持UEFI工具准备1.ArchLinuxLivehttps://mirrors.aliyun.com/archlinux/iso/latest/archlinux-x86_64.iso?spm=a2c6h.25603864.0.0.578c6488N8teka2.写入工具https://github.com/pbatard/rufus/releases/download/v4.1/rufus-4.1.exe3.U盘随意基本安......
  • 第九天:软件编译安装过程
    一、利用编译工具,通常只需要三个大的步骤./configure(1)通过选项传递参数,指定安装路径、启用特性等;执行时会参考用户的指定以及Makefile.in文件生成Makefile(2)检查依赖到的外部环境,如依赖的软件包make根据Makefile文件,会检测依赖的环境,进行构建应用程序makeinstall复......
  • Ubuntu20.04安装部署Jenkins
     Jenkins要求Java8及更高版本,检查系统上是否安装了Javajava--version如果没有安装Java,执行如下命令,在您的系统上安装Javasudoaptinstall-yopenjdk-17-jre-headless再次验证Java版本安装Jenkins会启用JenkinsAPT软件源,导入源GPGkey,并且安装Jenkins软件包......
  • CDH6.3.2下安装部署Qualitis数据质量分析的计算服务Linkis1.3.2
    快速搭建Qualitis手册一、基础软件安装Gradle(4.6)MySQL(5.5+)JDK(1.8.0_141)Linkis(1.0.0+),必装Spark引擎。如何安装LinkisDataSphereStudio(1.0.0+)可选.如果你想使用工作流,必装DataSphereStudio如何安装DataSphereStudio?(1)安装Gradle(4.6)腾讯云镜像:http......