Redis cluster

Posted 黑客不黑撒

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis cluster相关的知识,希望对你有一定的参考价值。

[[email protected] cloudcc]# cat Dockerfile

#pull down centos image

FROM centos

 

MAINTAINER [email protected]

 

#设置时间差

RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone

 

#基本工具安装

RUN yum install -y passwd openssl openssh-server openssh-clients vim wget curl net-tools gcc

 

#配置ssh

RUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ‘‘

RUN ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ‘‘

RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key  -N ‘‘

RUN echo "root:123qwe" | chpasswd

 

#define entry point which will be run first when the container starts up

#CMD ["/usr/sbin/sshd", "-D"]

ENTRYPOINT /usr/sbin/sshd -D

 

#docker build -t redis:1.0 .

 

[[email protected] Java]# docker run -d redis:1.0

docker inspect --format=‘{{.NetworkSettings.IPAddress}}‘ f9d7ff771c22 #查看容器ip

[[email protected] Java]# scp redis.conf redis-3.2.9.tar.gz 172.17.0.2:/home

ssh 172.172.0.60 #password:123qwe

[[email protected] ~]# cd /home/

[[email protected] home]# mkdir Java

[[email protected] home]# mv redis.conf redis-3.2.9.tar.gz Java

[[email protected] home]# cd Java/

[[email protected] Java]# tar -xaf redis-3.2.9.tar.gz

[[email protected] Java]# cd redis-3.2.9

[[email protected] redis-3.2.9]# make

[[email protected] redis-3.2.9]# rm -rf redis.conf

[[email protected] redis-3.2.9]# mv ../redis.conf .

[[email protected] redis-3.2.9]# src/redis-server redis.conf

[[email protected] redis-3.2.9]# src/redis-cli -a 123qwe

 

 

redis.conf

# 后台运行

daemonize yes

 

# 配置远程访问

# bind 127.0.0.1

protected-mode no

 

#配置访问密码

requirepass 123qwe

 

 

[[email protected] redis-3.2.9]# exit

[[email protected] Java]# docker ps

[[email protected] Java]# docker stop 18639389ab71

[[email protected] Java]# docker commit 18639389ab71 redis:1.1

[[email protected] Java]# docker rm 18639389ab71

 

docker network create --subnet=172.172.0.0/16 docker-ice

docker run -d --name redis-60 --net docker-ice --ip 172.172.0.60 --privileged=true -d -v /home/Data:/home/Data redis:1.1

docker run -d --name redis-61 --net docker-ice --ip 172.172.0.61 --privileged=true -d -v /home/Data:/home/Data redis:1.1

docker run -d --name redis-62 --net docker-ice --ip 172.172.0.62 --privileged=true -d -v /home/Data:/home/Data redis:1.1

docker run -d --name redis-63 --net docker-ice --ip 172.172.0.63 --privileged=true -d -v /home/Data:/home/Data redis:1.1

docker run -d --name redis-64 --net docker-ice --ip 172.172.0.64 --privileged=true -d -v /home/Data:/home/Data redis:1.1

docker run -d --name redis-65 --net docker-ice --ip 172.172.0.65 --privileged=true -d -v /home/Data:/home/Data redis:1.1

docker run -d --name redis-66 --net docker-ice --ip 172.172.0.66 --privileged=true -d -v /home/Data:/home/Data redis:1.1

 

./redis-cli -h 172.172.0.60 -a 123qwe

docker inspect --format=‘{{.NetworkSettings.IPAddress}}‘ f9d7ff771c22 #查看容器ip

 

以上是关于Redis cluster的主要内容,如果未能解决你的问题,请参考以下文章

Command to destroy cluster

Kubernetes核心模块

Kubernetes核心模块

Kubernetes —— 核心模块

使用令牌通过服务帐户登录GKE

Linux学习之路-集群及LVS24---20180213