docker redis 集群设置

redis-6.0rc3

创建外链文件

docker stop redis-master-1 redis-master-2 redis-master-3 redis-slave-1 redis-slave-2 redis-slave-3
docker rm redis-master-1 redis-master-2 redis-master-3 redis-slave-1 redis-slave-2 redis-slave-3

rm -rf /data/redis/redis-*

mkdir -p /data/redis/redis-master-1/data
mkdir -p /data/redis/redis-master-2/data
mkdir -p /data/redis/redis-master-3/data
mkdir -p /data/redis/redis-slave-1/data
mkdir -p /data/redis/redis-slave-2/data
mkdir -p /data/redis/redis-slave-3/data

mkdir -p /data/redis/redis-master-1/log
mkdir -p /data/redis/redis-master-2/log
mkdir -p /data/redis/redis-master-3/log
mkdir -p /data/redis/redis-slave-1/log
mkdir -p /data/redis/redis-slave-2/log
mkdir -p /data/redis/redis-slave-3/log

cp redis.conf /data/redis/redis-master-1/
cp redis.conf /data/redis/redis-master-2/
cp redis.conf /data/redis/redis-master-3/
cp redis.conf /data/redis/redis-slave-1/
cp redis.conf /data/redis/redis-slave-2/
cp redis.conf /data/redis/redis-slave-3/

创建6个节点

docker run -idt --name=redis-master-1 -v /data/redis/redis-master-1/redis.conf:/etc/redis/redis.conf -v /data/redis/redis-master-1/data:/data -v /data/redis/redis-master-3/log:/log --net=macvlan -h=redis-master-1 --ip=10.10.10.71 redis:latest redis-server /etc/redis/redis.conf
docker run -idt --name=redis-master-2 -v /data/redis/redis-master-2/redis.conf:/etc/redis/redis.conf -v /data/redis/redis-master-2/data:/data -v /data/redis/redis-master-3/log:/log --net=macvlan -h=redis-master-2 --ip=10.10.10.72 redis:latest redis-server /etc/redis/redis.conf
docker run -idt --name=redis-master-3 -v /data/redis/redis-master-3/redis.conf:/etc/redis/redis.conf -v /data/redis/redis-master-3/data:/data -v /data/redis/redis-master-3/log:/log --net=macvlan -h=redis-master-3 --ip=10.10.10.73 redis:latest redis-server /etc/redis/redis.conf

docker run -idt --name=redis-slave-1 -v /data/redis/redis-slave-1/redis.conf:/etc/redis/redis.conf -v /data/redis/redis-slave-1/data:/data -v /data/redis/redis-slave-1/log:/log --net=macvlan -h=redis-slave-1 --ip=10.10.10.81 redis:latest redis-server /etc/redis/redis.conf
docker run -idt --name=redis-slave-2 -v /data/redis/redis-slave-2/redis.conf:/etc/redis/redis.conf -v /data/redis/redis-slave-2/data:/data -v /data/redis/redis-slave-2/log:/log --net=macvlan -h=redis-slave-2 --ip=10.10.10.82 redis:latest redis-server /etc/redis/redis.conf
docker run -idt --name=redis-slave-3 -v /data/redis/redis-slave-3/redis.conf:/etc/redis/redis.conf -v /data/redis/redis-slave-3/data:/data -v /data/redis/redis-slave-3/log:/log --net=macvlan -h=redis-slave-3 --ip=10.10.10.83 redis:latest redis-server /etc/redis/redis.conf

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.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1
bind 0.0.0.0

# 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.
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

################################# TLS/SSL #####################################

# By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
# directive can be used to define TLS-listening ports. To enable TLS on the
# default port, use:
#
# port 0
# tls-port 6379

# Configure a X.509 certificate and private key to use for authenticating the
# server to connected clients, masters or cluster peers.  These files should be
# PEM formatted.
#
# tls-cert-file redis.crt 
# tls-key-file redis.key

# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange:
#
# tls-dh-params-file redis.dh

# Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
# clients and peers.  Redis requires an explicit configuration of at least one
# of these, and will not implicitly use the system wide configuration.
#
# tls-ca-cert-file ca.crt
# tls-ca-cert-dir /etc/ssl/certs

# By default, clients (including replica servers) on a TLS port are required
# to authenticate using valid client side certificates.
#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值