Redis cluster

[root@service 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 .


[root@kafka Java]# docker run -d redis:1.0

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

[root@kafka Java]# scp redis.conf redis-3.2.9.tar.gz 172.17.0.2:/home

ssh 172.172.0.60 #password:123qwe

[root@18639389ab71 ~]# cd /home/

[root@18639389ab71 home]# mkdir Java

[root@18639389ab71 home]# mv redis.conf redis-3.2.9.tar.gz Java

[root@18639389ab71 home]# cd Java/

[root@18639389ab71 Java]# tar -xaf redis-3.2.9.tar.gz

[root@18639389ab71 Java]# cd redis-3.2.9

[root@18639389ab71 redis-3.2.9]# make

[root@18639389ab71 redis-3.2.9]# rm -rf redis.conf

[root@18639389ab71 redis-3.2.9]# mv ../redis.conf .

[root@18639389ab71 redis-3.2.9]# src/redis-server redis.conf

[root@18639389ab71 redis-3.2.9]# src/redis-cli -a 123qwe



redis.conf

#后台运行

daemonize yes


#配置远程访问

# bind 127.0.0.1

protected-mode no


#配置访问密码

requirepass 123qwe



[root@18639389ab71 redis-3.2.9]# exit

[root@kafka Java]# docker ps

[root@kafka Java]# docker stop 18639389ab71

[root@kafka Java]# docker commit 18639389ab71 redis:1.1

[root@kafka 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)