docker-compose安装redis

基于docker-compose快速安装redis

目录

一、目录结构

1、docker-compose.yml

2、redis.conf

二、连接使用


一、目录结构

1、docker-compose.yml

version: '3'
services:redis:image: registry.cn-hangzhou.aliyuncs.com/zhengqing/redis:6.0.8                    # 镜像'redis:6.0.8'container_name: redis                                                             # 容器名为'redis'restart: unless-stopped                                                                   # 指定容器退出后的重启策略为始终重启,但是不考虑在Docker守护进程启动时就已经停止了的容器command: redis-server /etc/redis/redis.conf --requirepass hcses.com --appendonly no # 启动redis服务并添加密码为:123456,默认不开启redis-aof方式持久化配置
#    command: redis-server --requirepass 123456 --appendonly yes # 启动redis服务并添加密码为:123456,并开启redis持久化配置environment:                        # 设置环境变量,相当于docker run命令中的-eTZ: Asia/ShanghaiLANG: en_US.UTF-8volumes:                            # 数据卷挂载路径设置,将本机目录映射到容器目录- "./redis/data:/data"- "./redis/config/redis.conf:/etc/redis/redis.conf"  # `redis.conf`文件内容`http://download.redis.io/redis-stable/redis.conf`ports:                              # 映射端口- "6379:6379"

2、redis.conf

# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.################################## INCLUDES #################################### Include one or more other config files here.  This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
#
# Notice option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# include /path/to/local.conf
# include /path/to/other.conf################################## MODULES ###################################### Load modules at startup. If the server is not able to load modules
# it will abort. It is possible to use multiple loadmodule directives.
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so################################## NETWORK ###################################### By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 loopback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 注释允许外部访问redis
# bind 127.0.0.1# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
# 开启保护模式后,需要 bind ip 或 设置密码
protected-mode yes# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379# TCP listen() backlog.
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the Linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
tcp-backlog 511# Unix socket.
#
# Specify the path for the Unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 700# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300
daemonize nosupervised nopidfile /var/run/redis_6379.pidloglevel noticelogfile ""databases 16always-show-logo yes# 900秒内,如果超过1个key被修改,则发起快照保存
save 900 1
# 300秒内,如果超过10个key被修改,则发起快照保存
save 300 10
# 60秒内,如果1万个key被修改,则发起快照保存
save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbrdb-del-sync-files nodir ./replica-serve-stale-data yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-diskless-load disabledrepl-disable-tcp-nodelay noreplica-priority 100# 设置密码
# requirepass 123456lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush nolazyfree-lazy-user-del nooom-score-adj nooom-score-adj-values 0 200 800appendonly no# The name of the append only file (default: "appendonly.aof")appendfilename "appendonly.aof"# 每次操作都会立即写入aof文件中
# appendfsync always
# 每秒持久化一次(默认配置)
appendfsync everysec
# 不主动进行同步操作,默认30s一次
# appendfsync nono-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble yeslua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512
hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128
zset-max-ziplist-value 64hll-sparse-max-bytes 3000stream-node-max-bytes 4096
stream-node-max-entries 100activerehashing yesclient-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60hz 10dynamic-hz yesaof-rewrite-incremental-fsync yesrdb-save-incremental-fsync yesjemalloc-bg-thread yes

二、连接使用

为了方便使用,建议下载个Redis Desktop Manager 可视化工具。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/76965.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【性能测试】Jmeter —— jmeter计数器

jmeter计数器 如果需要引用的数据量较大,且要求不能重复或者需要递增,那么可以使用计数器来实现 如:新增功能,要求名称不能重复 1,新增计数器 计数器:允许用户创建一个在线程组之内都可以被引用的计数器…

van-list 下拉刷新 触底分页 触底分页事件只加载一次

我是 头部是筛选的条件,,更换不同的状态,显示不同的列表数据,比如 审批中数据是 对的,触底分页也是对的,如果我切换一个状态的话,总共是 15条数据,但是 切换了状态只显示第一页的数据…

8个免费的AI和LLM游乐场

推荐:使用 NSDT场景编辑器 快速搭建3D应用场景 在本文中,我们的目标是通过引入八个用户友好的平台来弥合这一差距,这些平台使任何人都可以免费测试和比较开源AI模型。此外,它们还提供多种更新型号,确保您及时了解最新进…

无涯教程-JavaScript - SLN函数

描述 SLN函数返回资产在一个期间内的直线折旧。 语法 SLN (cost, salvage, life)争论 Argument描述Required/OptionalCostThe initial cost of the asset.RequiredSalvage The value at the end of the depreciation (sometimes called the salvage value of the asset).Re…

win11本地连接没了怎么办

很多用户在使用win11系统时发现自己的网络连接没有了,遇到这种情况的话,我们应该怎么处理呢?我们可以尝试打开网络图标,下面就是小编整理出的教程,大家一起看看吧。 win11本地连接没了怎么办 方法一: 1、…

数据分享|R语言武汉流动人口趋势预测:灰色模型GM(1,1)、ARIMA时间序列、logistic逻辑回归模型...

全文链接:http://tecdat.cn/?p32496 人口流动与迁移,作为人类产生以来就存在的一种社会现象,伴随着人类文明的不断进步从未间断(点击文末“阅读原文”获取完整代码数据)。 相关视频 人力资源是社会文明进步、人民富裕…

Redis I/O多路复用机制

一、基础回顾 1.1 多路复用要解决什么问题 并发多客户端连接场景,在多路复用之前最简单和典型的方案就是同步阻塞网络IO模型。 这种模式的特点就是用一个进程来处理一个网络连接(一个用户请求),比如一段典型的示例代码如下。 直接调用 recv 函数从一个 socket 上…

去除pdf/word的水印艺术字

对于pdf中的水印如果无法去除水印,则先另存为word,然后再按下面办法处理即可: 查看宏,创建:删除艺术字 添加内容: Sub 删除艺术字()Dim sh As ShapeFor Each sh In ActiveDocument.ShapesIf sh.Type msoT…

HTML的段落中怎么样显示出标签要使用的尖括号<>?

很简单&#xff1a; 符号 < 用 < 替代&#xff1b; 符号 > 用 > 替代。 示例代码如下&#xff1a; <!DOCTYPE html> <html> <head><meta charset"UTF-8"><title>HTML中怎样打出尖括号</title> </head> <b…

Android Aidl跨进程通讯(三)--进阶使用

学更好的别人&#xff0c; 做更好的自己。 ——《微卡智享》 本文长度为2478字&#xff0c;预计阅读6分钟 前言 Android的AIDL使用和异常报错都已经介绍过了&#xff0c;今天这篇还是在原来的Demo基础上加入几个AIDL的进阶使用方法。 】 AIDL进阶使用 微卡智享 in,out,inout的使…

2022年全国研究生数学建模竞赛华为杯A题移动场景超分辨定位问题求解全过程文档及程序

2022年全国研究生数学建模竞赛华为杯 A题 移动场景超分辨定位问题 原题再现&#xff1a; 在日常家庭生活中&#xff0c;人们可能需要花费大量时间去寻找随意摆放在家中某些角落里的小物品。但如果给某些重要物品贴上电路标签&#xff0c;再利用诸如扫地机器人的全屋覆盖能力&…

docker入门

弱小和无知不是生存的障碍&#xff0c;傲慢才是。 Docker 学习 Docker概述 Docker为什么出现&#xff1f; 一款产品&#xff1a; 开发–上线 两套环境&#xff01;应用环境&#xff0c;应用配置&#xff01; 开发 — 运维。 问题&#xff1a;我在我的电脑上可以允许&#…

Vuex -访问(modules)模块中的 state mutations actions getters

文章目录 四大核心复习一、获取模块内的state数据1.目标&#xff1a;2.使用模块中的数据3.代码示例 二、获取模块内的getters数据1.目标&#xff1a;2.语法&#xff1a;3.代码演示 三、获取模块内的mutations方法1.目标&#xff1a;2.注意&#xff1a;3.调用方式&#xff1a;4.…

【实例项目:基于多设计模式下的日志系统(同步异步)】

本项目涉及的到所有源码见以下链接&#xff1a; https://gitee.com/ace-zhe/wz_log 一、项目简介 1.日志的概念&#xff08;白话版&#xff09; 日志类似于日记&#xff0c;通常是指对完成某件事情的过程中状态等的记录&#xff0c;而计算机中的日志是指日志数据&#xff0c…

考研英语笔记:程序员是否勤奋就看他的英语好不好

一位大佬朋友圈写道&#xff1a;看程序员是否勤奋就看他的英语好不好&#xff0c;智商高不高就看他算法好不好。 这句话我当时看到了很触动&#xff0c;默默的记在了心底。 对我来说&#xff0c;算法就免了&#xff0c;但学英语我一直在坚持。我不敢说我是优秀的程序员&#xf…

​消费盲返模式:一种让消费者和商家都受益的新型消费返利模式

您是否想过&#xff0c;如果您的消费能够带来意想不到的回报&#xff0c;您会不会更愿意购买商品或服务呢&#xff1f;您是否想过&#xff0c;如果您的商品或服务能够吸引更多的消费者&#xff0c;并让他们成为您的忠实客户&#xff0c;您会不会更有动力经营您的业务呢&#xf…

使用maven idea环境

目录 idea三种方式执行maven命令 工程导入 生命周期lifecycle 插件和目标 常用命令 创建模块工程后 idea三种方式执行maven命令 想在哪个工程模块上执行就点开哪一个 如果觉得双击完clean再双击install麻烦&#xff0c;可以 如果有需要还可以给命令后面加参数 ​​​ 第三种…

算法训练营day49|动态规划 part10:(LeetCode 121. 买卖股票的最佳时机、122.买卖股票的最佳时机II)

121. 买卖股票的最佳时机 题目链接&#x1f525; 给定一个数组 prices &#xff0c;它的第 i 个元素 prices[i] 表示一支给定股票第 i 天的价格。 你只能选择 某一天 买入这只股票&#xff0c;并选择在 未来的某一个不同的日子 卖出该股票。设计一个算法来计算你所能获取的最大…

【Redis专题】RedisCluster集群运维与核心原理剖析

目录 课程内容一、Redis集群架构模型二、Redis集群架构搭建&#xff08;单机搭建&#xff09;2.1 在服务器下新建各个节点的配置存放目录2.2 修改配置&#xff08;以redis-8001.conf为例&#xff09; 三、Java代码实战四、Redis集群原理分析4.1 槽位定位算法4.2 跳转重定位4.3 …

【MySQL】聊聊数据库高可用

对于任何一个互联网公司来说&#xff0c;必定涉及到存储系统&#xff0c;而一般主流的使用MySQL进行存储数据&#xff0c;但是如果只是部署一台数据库&#xff0c;数据丢失的话&#xff0c;其实没有办法进行有效的恢复&#xff0c;那么就会造成一定的损失。要么就是直接的损失&…