欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

docker-compose安裝redis的方法步驟

 更新時間:2023年09月08日 09:36:19   作者:Roc-xb  
本文主要介紹了docker-compose安裝redis的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

基于docker-compose快速安裝redis

一、目錄結(jié)構(gòu)

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守護進程啟動時就已經(jīng)停止了的容器
    command: redis-server /etc/redis/redis.conf --requirepass hcses.com --appendonly no # 啟動redis服務(wù)并添加密碼為:123456,默認不開啟redis-aof方式持久化配置
#    command: redis-server --requirepass 123456 --appendonly yes # 啟動redis服務(wù)并添加密碼為:123456,并開啟redis持久化配置
    environment:                        # 設(shè)置環(huán)境變量,相當(dāng)于docker run命令中的-e
      TZ: Asia/Shanghai
      LANG: en_US.UTF-8
    volumes:                            # 數(shù)據(jù)卷掛載路徑設(shè)置,將本機目錄映射到容器目錄
      - "./redis/data:/data"
      - "./redis/config/redis.conf:/etc/redis/redis.conf"  # `redis.conf`文件內(nèi)容`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 或 設(shè)置密碼
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 no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 16
always-show-logo yes
# 900秒內(nèi),如果超過1個key被修改,則發(fā)起快照保存
save 900 1
# 300秒內(nèi),如果超過10個key被修改,則發(fā)起快照保存
save 300 10
# 60秒內(nèi),如果1萬個key被修改,則發(fā)起快照保存
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir ./
replica-serve-stale-data yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
# 設(shè)置密碼
# requirepass 123456
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
oom-score-adj no
oom-score-adj-values 0 200 800
appendonly no
# The name of the append only file (default: "appendonly.aof")
appendfilename "appendonly.aof"
# 每次操作都會立即寫入aof文件中
# appendfsync always
# 每秒持久化一次(默認配置)
appendfsync everysec
# 不主動進行同步操作,默認30s一次
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes

二、連接使用

為了方便使用,建議下載個Redis Desktop Manager 可視化工具。

 到此這篇關(guān)于docker-compose安裝redis的方法步驟的文章就介紹到這了,更多相關(guān)docker-compose安裝redis內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 使用dockercompose搭建springboot-mysql-nginx應(yīng)用

    使用dockercompose搭建springboot-mysql-nginx應(yīng)用

    這篇文章主要介紹了使用dockercompose搭建springboot-mysql-nginx應(yīng)用,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-03-03
  • 詳解如何進入、退出docker容器的方法

    詳解如何進入、退出docker容器的方法

    這篇文章主要介紹了詳解如何進入、退出docker容器的方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • 兩臺互通的服務(wù)器使用Docker部署一主兩從MySQL8.0.35的方法

    兩臺互通的服務(wù)器使用Docker部署一主兩從MySQL8.0.35的方法

    本文主要介紹了在兩臺服務(wù)器上使用Docker部署一主兩從的MySQL?8.0.35架構(gòu),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2025-03-03
  • Docker兩個容器互相請求接口的實現(xiàn)

    Docker兩個容器互相請求接口的實現(xiàn)

    在Docker中,容器通過Docker網(wǎng)絡(luò)進行相互通信,本文就來介紹一下Docker兩個容器互相請求接口的實現(xiàn),感興趣的可以了解一下,感興趣的可以了解一下
    2023-11-11
  • 使用Docker搭建Redis主從復(fù)制的集群

    使用Docker搭建Redis主從復(fù)制的集群

    這篇文章主要介紹了使用Docker搭建Redis主從復(fù)制的集群,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-07-07
  • Docker容器中運行nginx

    Docker容器中運行nginx

    本文介紹了從docker hub拉取官方nginx鏡像并自定義部分配置,綁定端口運行的過程。希望小伙伴們能夠從中得到些知識
    2017-03-03
  • Docker學(xué)習(xí)之常用的基礎(chǔ)命令總結(jié)

    Docker學(xué)習(xí)之常用的基礎(chǔ)命令總結(jié)

    這篇文章給大家整理了一些Docker常用的基礎(chǔ)命令,對大家日常使用Docker還是很有幫助,通過這些命令可以有效的提高大家的工作效率,有需要的朋友們下面來一起看看吧。
    2016-10-10
  • DockerHub 鏡像倉庫的使用詳解

    DockerHub 鏡像倉庫的使用詳解

    這篇文章主要介紹了DockerHub 鏡像倉庫的使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 使用Docker搭建MySQL主從數(shù)據(jù)庫的方法步驟

    使用Docker搭建MySQL主從數(shù)據(jù)庫的方法步驟

    本文主要介紹了使用Docker搭建MySQL主從數(shù)據(jù)庫的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-01-01
  • Gitlab-runner+Docker實現(xiàn)自動部署SpringBoot項目

    Gitlab-runner+Docker實現(xiàn)自動部署SpringBoot項目

    這篇文章主要介紹了Gitlab-runner+Docker自動部署SpringBoot項目,我們的主要流程就是通過Gitlab管理代碼,然后利用Gitlab自帶的Gitlab?CI/CD功能與GitlabRunner進行注冊綁定,需要的朋友可以參考下
    2022-04-04

最新評論