Git Product home page Git Product logo

mac-docker-redis-cluster's Introduction

Mac上最简单明了的利用Docker搭建Redis集群

本文只是记录一下我在Mac上利用Docker搭建Redis集群成功后的步骤,期间走了许多的坑。有许多教程对于Mac用户不友好,搭建成功以后无法进行集群间的通信。

首先说明一下有多简单,如果你机器上已经有了Docker,那么就一个步骤就行。如果没有Docker那么在Docker下载下载一个就行。

接下来我们就开始进行Redis集群的搭建。

首先先从github。例如我的存放目录结构是如下

/Users/hupengfei/myDocker/newRedis-cluster

-rwxr-xr-x@ 1 hupengfei  staff   1.6K  4 19 14:01 Dockerfile
-rwxr-xr-x@ 1 hupengfei  staff   1.0K  3 31 14:28 LICENSE
-rwxr-xr-x@ 1 hupengfei  staff   8.8K  3 31 14:28 Makefile
-rwxr-xr-x@ 1 hupengfei  staff   4.8K  3 31 14:28 README.md
-rwxr-xr-x@ 1 hupengfei  staff   341B  4 22 11:43 docker-compose.yml
-rwxr-xr-x@ 1 hupengfei  staff   2.2K  4 19 13:55 docker-entrypoint.sh
-rwxr-xr-x@ 1 hupengfei  staff   506B  3 31 14:28 generate-supervisor-conf.sh
-rwxr-xr-x@ 1 hupengfei  staff   167B  4 19 16:47 redis-cluster.tmpl
-rwxr-xr-x@ 1 hupengfei  staff    65B  3 31 14:28 redis.tmpl
-rwxr-xr-x@ 1 hupengfei  staff   219B  3 31 14:28 sentinel.tmpl

那么就在newRedis-cluster此目录下执行命令docker-compose build,然后执行docker-compose up命令,你就会发现如下输出

 2019 03:50:25.179 * Background AOF rewrite finished successfully

就代表已经启动成功了,此时输入redis-cli -c -p 7001,进入其中一个节点,你就会发现已经启动成功了,在节点中输入cluster nodes可以查看到集群的信息。

此时可以进行测试一下,在里面存放不同的值,他会跳转到端口上面进行存放

127.0.0.1:7001> set hu1 1
OK
127.0.0.1:7001> set hu2 2
-> Redirected to slot [4983] located at 127.0.0.1:7000
OK
127.0.0.1:7000> set hu3 3
OK
127.0.0.1:7000> set hu4 4
-> Redirected to slot [13233] located at 127.0.0.1:7002
OK

此时集群就搭建成功了。此Git项目是参考https://github.com/Grokzen/docker-redis-cluster这个项目,只是根据Issues进行修改了一些东西使Mac用户能够更方便使用。

如果你想修改集群中redis的配置信息,可以修改里面的redis-cluster.tmpl文件。修改完以后用docker-compose build完以后再启动就好了。

mac-docker-redis-cluster's People

Contributors

modouxiansheng avatar hupengfei123 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.