Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos6 uses docker to deploy redis master-slave database operation example

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article example describes how centos6 uses docker to deploy redis master-slave database operations. Share with you for your reference, the details are as follows:

Directory structure:

/ redis

/ Dockerfile

/ Readme

/ redis-3.2.8.tar.gz

/ start.sh

Dockerfile:

FROM centosMAINTAINER qiongtao.li hnatao@126.comADD. / redis-3.2.8.tar.gz / optADD. / start.sh / opt/start_redis.shRUN echo "Asia/shanghai" > / etc/timezone\ & & cp / usr/share/zoneinfo/Asia/Shanghai / etc/localtime\ & & yum-y install gcc make\ & & ln-s / opt/redis-3.2.8 / opt/redis\ & & cd / opt/redis & make & & make installEXPOSE 6379ENTRYPOINT ["sh" "/ opt/start_redis.sh"]

Start.sh

Role=$1port=6379password=Abc123redis_conf=/opt/redis/redis.confdir=/data/redislogfile=/data/redis/redis.logmkdir-p $dirsed-I "s | bind 127.0.0.1 | bind 0.0.0.0 | g" $redis_confsed-I "s | # requirepass foobared | requirepass ${password} | g" $redis_confsed-I "s | dir. / | dir ${dir} | g" $redis_confsed-I "s | logfile\"\ "| logfile ${logfile} | g" $redis_confif ["$role" = "slave"] Then echo "slave" sed-I "s | # slaveof | slaveof redis-master ${port} | g" $redis_conf sed-I "s | # masterauth | masterauth ${password} | g" $redis_confelse echo "master" firedis-server $redis_conf

Readme

Docker rm-f redis-master redis-slave-1 redis-slave-2docker rmi-f redisdocker build-t redis. Docker run-d-- name redis-master redisdocker run-d-- name redis-slave-1-- link redis-master:redis-master redis slavedocker run-d-name redis-slave-2-- link redis-master:redis-master redis slavedocker ps-adocker exec redis-master redis-cli-an Abc123 set name hnataodocker exec redis-master redis-cli-an Abc123 get namedocker exec redis-slave-1 redis-cli -an Abc123 get namedocker exec redis-slave-2 redis-cli-an Abc123 get namedocker exec redis-master grep-E "bind | dir | require | logfile | slaveof | masterauth" / opt/redis/redis.confdocker exec redis-slave-1 grep-E "bind | dir | require | logfile | slaveof | masterauth" / opt/redis/redis.confdocker exec redis-slave-2 grep-E "bind | dir | require | logfile | slaveof | masterauth" / opt/redis/redis.confdocker exec redis-master redis-cli-an Abc123 infodocker exec redis-slave-1 redis-cli-an Abc123 infodocker exec redis-slave-2 redis-cli-an Abc123 info

Test installation deployment

Cat Readme | while read line; do $line; done

I hope what is described in this article will be helpful to the use of Docker containers.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report