04, Redis deployment

1, get a mirror

Find Redis Mirror

docker search redis

The following information is returned Mirror:

NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   7020                [OK]                
bitnami/redis                    Bitnami Redis Docker Image                      114                                     [OK]
sameersbn/redis                                                                  75                                      [OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0 & 5.0               49                                      
kubeguide/redis-master           redis-master with "Hello World!"                29                                      
rediscommander/redis-commander   Alpine image for redis-commander - Redis man…   25                                      [OK]
redislabs/redis                  Clustered in-memory database engine compatib…   20                                      
arm32v7/redis                    Redis is an open source key-value store that…   15                                      
redislabs/redisearch             Redis With the RedisSearch module pre-loaded…   15                                      
webhippie/redis                  Docker images for Redis                         10                                      [OK]
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp…   10                                      
s7anley/redis-sentinel-docker    Redis Sentinel                                  8                                       [OK]
insready/redis-stat              Docker image for the real-time Redis monitor…   7                                       [OK]
arm64v8/redis                    Redis is an open source key-value store that…   6                                       
bitnami/redis-sentinel           Bitnami Docker Image for Redis Sentinel         5                                       [OK]
redislabs/redisgraph             A graph database module for Redis               5                                       [OK]
centos/redis-32-centos7          Redis in-memory data structure store, used a…   4                                       
circleci/redis                   CircleCI images for Redis                       2                                       [OK]
wodby/redis                      Redis container image with orchestration        2                                       [OK]
frodenas/redis                   A Docker Image for Redis                        2                                       [OK]
kilsoo75/redis-master            This image is for the redis master of SK Clo…   1                                       
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1                                       [OK]
runnable/redis-stunnel           stunnel to redis provided by linking contain…   1                                       [OK]
cflondonservices/redis           Docker image for running redis                  0                                       
xetamus/redis-resource           forked redis-resource                           0                                       [OK]

Download Redis Mirror

#获取最新的镜像
docker pull redis

2, view the downloaded image Redis

docker images redis

3, host to create a data directory

Establish Redis data in the directory / data, the instance name is here scloud_redis

mkdir -p /data/redis /data/redis/data /data/redis/data/scloud_redis /data/redis/config /data/redis/config/scloud_redis

4, Redis configuration file redis.conf

Redis Redis downloaded from the official website here to download the file to redis-5.0.5.tar.gz, unpack redis profile redis.conf, open the following configuration file comments. Copy the configuration file to the configuration directory scloud_redis Example: / data / redis / config / scloud_redis

#bind 127.0.0.1

5, start the Redis instance

Start Redis instance named scloud_redis of a container port number is 6379, root user password is abs # 1234

docker run \
    -p 6379:6379 \
    -v /data/redis/data/scloud_redis:/data:rw \
    -v /data/redis/config/scloud_redis/redis.conf:/etc/redis/redis.conf:rw \
    --name scloud_redis \
    -d redis \
    redis-server --appendonly yes

Command Description:

-p 6379:6379 : 将容器的6379端口映射到主机的6379端口
-v /data/redis/data/scloud_redis:/data : 将宿主机中的/data/redis/data/scloud_redis挂载到容器的/data
-v /data/redis/config/scloud_redis/redis.conf:/etc/redis/redis.conf : 使用宿主机中的redis.conf配置文件
redis-server --appendonly yes : 在容器执行redis-server启动命令,并打开redis持久化配置

6, redis increase port 6379 port clearance

iptables -I INPUT 1 -p tcp --dport 6379 -j ACCEPT -m comment --comment "scloud redis port"
service iptables save
systemctl restart iptables
iptables -L -n -v

7, connection, view a container

Mirroring performed using redis redis-cli command to connect to the container just started

docker exec -it 2c72def0298b redis-cli

returned messages:

# Server
redis_version:5.0.5
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:4d0898999c5f857
redis_mode:standalone
os:Linux 3.10.0-957.21.3.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:6.3.0
process_id:1
run_id:fbe3bab30f5bce965a3bd571fdc632d202a267c0
tcp_port:6379
uptime_in_seconds:924
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:683049
executable:/data/redis-server
......

Guess you like

Origin www.cnblogs.com/kennyxyz/p/11081222.html