原文地址: http://blog.duhbb.com/2022/02/09/compile-and-install-redis-debian-and-add-to-systemd/

欢迎访问我的个人博客: http://blog.duhbb.com/

下载

wget https://download.redis.io/releases/redis-6.2.6.tar.gz

编译并安装

安装libsystemd-dev

apt-get install libsystemd-dev

编译并安装redis

make USE_SYSTEMD=yes install

如果交给systemd管理的话, 需要在编译的时候指定USE_SYSTEMD=yes.

如果报systemd的头文件没有找到的话, 需要先安装``.

报错如下:

fatal error: systemd/sd-daemon.h: No such file or directory

systemd的service文件

文件位置:

root@mydebian:~# cat /lib/systemd/system/redis.service

文件内容如下:

# example systemd service unit file for redis-server
#
# In order to use this as a template for providing a redis service in your
# environment, _at the very least_ make sure to adapt the redis configuration
# file you intend to use as needed (make sure to set "supervised systemd"), and
# to set sane TimeoutStartSec and TimeoutStopSec property values in the unit's
# "[Service]" section to fit your needs.
#
# Some properties, such as User= and Group=, are highly desirable for virtually
# all deployments of redis, but cannot be provided in a manner that fits all
# expectable environments. Some of these properties have been commented out in
# this example service unit file, but you are highly encouraged to set them to
# fit your needs.
#
# Please refer to systemd.unit(5), systemd.service(5), and systemd.exec(5) for
# more information. [Unit]
Description=Redis data structure server
Documentation=https://redis.io/documentation
#Before=your_application.service another_example_application.service
#AssertPathExists=/var/lib/redis
Wants=network-online.target
After=network-online.target [Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf --supervised systemd
ExecStop=/usr/local/bin/redis-cli -p 6379 shutdown
## Alternatively, have redis-server load a configuration file:
#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf
LimitNOFILE=10032
NoNewPrivileges=yes
#OOMScoreAdjust=-900
#PrivateTmp=yes
Type=notify
TimeoutStartSec=infinity
TimeoutStopSec=infinity
UMask=0077
#User=redis
#Group=redis
#WorkingDirectory=/var/lib/redis [Install]
WantedBy=multi-user.target
root@mydebian:~#

在redis.conf的配置文件中一定要设置:

daemonize no
supervised systemd

这是因为redis要和systemd交互.

下面是一份可供参考的redis配置文件:

bind * -::*
protected-mode no
port 8000
daemonize no
pidfile "/usr/local/redis/run/redis_8000.pid"
loglevel notice
logfile "/usr/local/redis/log/redis8000.log"
save 3600 1
save 300 100
save 60 10000
stop-writes-on-bgsave-error no
dbfilename "dump8000.rdb"
dir "/usr/local/redis-6.2.3/data"
requirepass "monkey"
maxclients 1000
maxmemory 24gb
appendonly yes
appendfilename "appendonly8000.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 1gb
aof-load-truncated yes
aof-use-rdb-preamble yes
supervised systemd

systemctl相关命令

systemctl daemon-reload         # 重新加载service文件
systemctl status redis.service # 查看redis服务的状态
systemctl enable redis.service # 加入到开机自启中

参考资料

原文地址: http://blog.duhbb.com/2022/02/09/compile-and-install-redis-debian-and-add-to-systemd/

欢迎访问我的个人博客: http://blog.duhbb.com/

debian下编译安装redis并加入到systemd启动管理的更多相关文章

  1. debian下编译安装poco

    系统环境: debian版本:Linux localhost.localdomain 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC ...

  2. 超详细 Linux 下编译安装Redis 以及php配套使用

    一.Linux 下安装Redis 下载地址:http://redis.io/download,下载最新文档版本. 把鼠标移到上图的绿色框上,就会显示下图提示:(直接右键复制链接就好) 本教程使用的旧版 ...

  3. Debian下编译安装驱动模块

    在Linux下,我们常有需要自己来编译安装驱动模块的情况,例如要安装显卡驱动,要安装无线驱动,有的时候某个程序的安装使用与需要安装相应的驱动模块.Debian Linux下的生活本已十分简单,使用ap ...

  4. Redhat5.8 环境下编译安装 Redis 并将其注册为系统服务

    系统环境: $ cat /etc/issueRed Hat Enterprise Linux Server release 5.8 (Tikanga)Kernel \r on an \m 1. 下载安 ...

  5. Linux Centos下编译安装Redis

    需要安装 tcl 8.5 wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz //直接下载 sudo tar xzvf tcl8 ...

  6. Linux下编译安装redis

    redis是开源,BSD许可,高级的key-value存储系统,可以用来存储字符串,哈希结构,链表,集合,因此,常用来提供数据结构服务. redis和memcached相比的独特之处: 1: redi ...

  7. 2020ubuntu1804server编译安装redis笔记(三)启动服务和使用redis

    第一篇笔记记录了ubuntu1804server编译安装redis5,接下来要配置redis5了 网址:https://www.cnblogs.com/qumogu/p/12435694.html 第 ...

  8. Centos 下编译安装Redis

    安装环境说明: 操作系统:Centos 6.5 -64bit 安装路径:/usr/local/redis 开始编译redis tar -zxvf redis-2.8.19.tar.gz cd redi ...

  9. Linux下编译安装redis,详细教程

    话不多说,直接开工 准备工作: 本人测试环境:Win10 虚拟机:VM Linux:CentOS5.5 (已搭建好LNMP环境) 软件包:redis-2.6.14.tar.gz (Linux下redi ...

随机推荐

  1. 【论文笔记】用反事实推断方法缓解标题党内容对推荐系统的影响 Click can be Cheating: Counterfactual Recommendation for Mitigating Clickbait Issue

    Click can be Cheating: Counterfactual Recommendation for Mitigating Clickbait Issue Authors: 王文杰,冯福利 ...

  2. 【jvm】09-full gc分析思路

    [jvm]09-full gc分析思路 欢迎关注b站账号/公众号[六边形战士夏宁],一个要把各项指标拉满的男人.该文章已在github目录收录. 屏幕前的大帅比和大漂亮如果有帮助到你的话请顺手点个赞. ...

  3. JavaScript交互式网页设计 • 【第2章 JavaScript函数与事件】

    全部章节   >>>> 本章目录 2.1 JavaScript 自定义函数 2.1.1 函数的定义 2.1.2 函数的调用 2.1.3 函数的参数 2.1.4 函数的返回值 2 ...

  4. Java程序设计基础笔记 • 【目录】

    持续更新中- 我的大学笔记>>> 章节 内容 实践练习 Java程序设计基础作业目录(作业笔记) 第1章 Java程序设计基础笔记 • [第1章 初识Java] 第2章 Java程序 ...

  5. Java高级程序设计笔记 • 【第2章 多线程(一)】

    全部章节   >>>> 本章目录 2.1 线程的概述 2.1.1 进程 2.1.2 多线程优势 2.1.3 Thread 类 2.1.4 实践练习 2.2 Runnable接口 ...

  6. [ vue ] quasar框架踩坑:在vue文件外导入路由,执行router.push('/')没有效果

    问题描述: 1. 如图所示的项目结构目录, axios.js 文件负责拦截全局请求和回复,我在拦截回复的代码中写了:如果服务器回复了一个401错误,则执行Router.push('/'),但是该方法失 ...

  7. systemd学习及使用

    什么是systemd? (译)systemd是linux系统的一组基础构件块.它提供了一个系统和服务的管理,它以PID 1 的形式运行并启动系统的其余部分.systemd 使用积极的并行化功能,使用s ...

  8. Scala语言介绍一

    为什么学习scala语言 Scala是基于JVM的语言,与java语言类似,java语言是基于JVM的面向对象的语言,Scala也是基于JVM,同时支持面向对象和面向函数的编程语言.Spark底层的源 ...

  9. 日K蜡烛图

    股票价格涨跌趋势,常用蜡烛图技术中的K线图来表示,分为按日的日K线.按周的周K线.按月的月K线等.以日K线为例,每天股票价格从开盘到收盘走完一天,对应一根蜡烛小图,要表示四个价格:开盘价格Open(早 ...

  10. 使用 Json Schema 定义 API

    本文地址:使用 Json Schema 定义 API 前面我们介绍了 Json Schema 的基本内容,这篇文章我们结合 jsonschema2pojo 工具深入分析如何使用 Json Schema ...