<>Redis Cluster deployment practice

# Create network card docker network create redis --subnet 172.38.0.0/16 # Create six through script redis to configure for
port in $(seq 1 6); \ do \ mkdir -p /mydata/redis/node-${port}/conf touch
/mydata/redis/node-${port}/conf/redis.conf cat << EOF >/mydata/redis/node-
${port}/conf/redis.conf port 6379 bind 0.0.0.0 cluster-enabled yes
cluster-config-file nodes.conf cluster-node-timeout 5000 cluster-announce-ip
172.38.0.1${port} cluster-announce-port 6379 cluster-announce-bus-port 16379
appendonly yes EOF done # Create node 1 - 6 docker run -p 6371:6379 -p 16371:16379
--name redis-1\ -v /mydata/redis/node-1/data:/data \ -v
/mydata/redis/node-1/conf/redis.conf:/etc/redis/redis.conf\ -d --net redis --ip
172.38.0.11 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf # Create node 6
docker run -p6376:6379 -p 16376:16379 --name redis-6 \ -v
/mydata/redis/node-6/data:/data\ -v
/mydata/redis/node-6/conf/redis.conf:/etc/redis/redis.conf\ -d --net redis --ip
172.38.0.16 redis:5.0.9-alpine3.11 redis-server /etc/redis/redis.conf # Create cluster [
root@iZ2zeg4ytp0whqtmxbsqiiZ ~]# docker exec -it redis-1 /bin/sh /data # ls
appendonly.aof nodes.conf /data# redis-cli --cluster create 172.38.0.11:6379
172.38.0.12:6379 172.38.0.13:6379 172.38.0.14:6379 172.38.0.15:6379
172.38.0.16:6379 --cluster-replicas 1 >>> Performing hash slots allocation on 6
nodes... Master[0] -> Slots 0 - 5460 Master[1] -> Slots 5461 - 10922 Master[2] -
> Slots 10923 - 16383 Adding replica 172.38.0.15:6379 to 172.38.0.11:6379
Adding replica172.38.0.16:6379 to 172.38.0.12:6379 Adding replica 172.38
.0.14:6379 to172.38.0.13:6379 M: 541b7d237b641ac2ffc94d17c6ab96b18b26a638 172.38
.0.11:6379 slots:[0-5460] (5461 slots) master M:
a89c1f1245b264e4a402a3cf99766bcb6138dbca172.38.0.12:6379 slots:[5461-10922] (
5462 slots) master M: 259e804d6df74e67a72e4206d7db691a300c775e 172.38.0.13:6379
slots:[10923-16383] (5461 slots) master S:
9b19170eea3ea1b92c58ad18c0b5522633a9e271172.38.0.14:6379 replicates
259e804d6df74e67a72e4206d7db691a300c775e S:
061a9d38f22910aaf0ba1dbd21bf1d8f57bcb7d5172.38.0.15:6379 replicates
541b7d237b641ac2ffc94d17c6ab96b18b26a638 S:
7a16b9bbb0615ec95fc978fa62fc054df60536f0172.38.0.16:6379 replicates
a89c1f1245b264e4a402a3cf99766bcb6138dbca Can Iset the above configuration? (type
'yes' to accept): yes >>> Nodes configuration updated >>> Assign a different
config epoch to each node>>> Sending CLUSTER MEET messages to join the cluster
Waitingfor the cluster to join ... >>> Performing Cluster Check (using node
172.38.0.11:6379) M: 541b7d237b641ac2ffc94d17c6ab96b18b26a638 172.38.0.11:6379
slots:[0-5460] (5461 slots) master 1 additional replica(s) M:
a89c1f1245b264e4a402a3cf99766bcb6138dbca172.38.0.12:6379 slots:[5461-10922] (
5462 slots) master 1 additional replica(s) S:
7a16b9bbb0615ec95fc978fa62fc054df60536f0172.38.0.16:6379 slots: (0 slots) slave
replicates a89c1f1245b264e4a402a3cf99766bcb6138dbca S:
061a9d38f22910aaf0ba1dbd21bf1d8f57bcb7d5172.38.0.15:6379 slots: (0 slots) slave
replicates 541b7d237b641ac2ffc94d17c6ab96b18b26a638 M:
259e804d6df74e67a72e4206d7db691a300c775e172.38.0.13:6379 slots:[10923-16383] (
5461 slots) master 1 additional replica(s) S:
9b19170eea3ea1b92c58ad18c0b5522633a9e271172.38.0.14:6379 slots: (0 slots) slave
replicates 259e804d6df74e67a72e4206d7db691a300c775e[OK] All nodes agree about
slots configuration.>>> Check for open slots... >>> Check slots coverage... [OK]
All16384 slots covered.
docker build redis Cluster complete !

<>Springboot Microservice packaging Docker image

*
structure springboot project

*
Packaged application

*
to write Dockerfile
FROM java:8 COPY *.jar /app.jar CMD ["--server.port=8080"] EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]
* Build image
* Publish run ! # Put it right jar Bao He Dockerfile Upload to linux [root@tianqinglong idea]# ll total 16140
-rw-r--r--1 root root 16519871 Aug 14 17:38 demo-0.0.1-SNAPSHOT.jar -rw-r--r--
1 root root 122 Aug 14 17:38 Dockerfile # Build image , Don't forget the last point [root@tianqinglong
idea]# docker build -t tianqinglong666 . Sending build context to Docker daemon
16.52MB Step 1/5 : FROM java:8 8: Pulling from library/java 5040bd298390: Pull
complete fce5728aad85: Pull complete 76610ec20bf5: Pull complete 60170fec2151:
Pull complete e98f73de8f0d: Pull complete 11f7af24ed9c: Pull complete
49e2d6393f32: Pull complete bb9cdec9c7f3: Pull complete Digest:
sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d Status:
Downloaded newer imagefor java:8 ---> d23bdf5b1b1b Step 2/5 : COPY *.jar
/app.jar ---> d4de8837ebf9 Step 3/5 : CMD ["--server.port=8080"] ---> Running in
e3abc66303f0 Removing intermediate container e3abc66303f0 ---> 131bb3917fea
Step4/5 : EXPOSE 8080 ---> Running in fa2f25977db7 Removing intermediate
container fa2f25977db7 ---> d98147377951 Step 5/5 : ENTRYPOINT ["java", "-jar",
"/app.jar"] ---> Running in e1885e23773b Removing intermediate container
e1885e23773b ---> afb6b5f28a32 Successfully built afb6b5f28a32 Successfully
tagged xiaofan666:latest# View mirror [root@tianqinglong idea]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE tianqinglong666 latest afb6b5f28a3214
seconds ago 660MB tomcat latest 2ae23eb477aa8 days ago 647MB redis 5.0
.9-alpine3.11 3661c84ee9d03 months ago 29.8MB java 8 d23bdf5b1b1b 3 years ago
643MB# Run container [root@tianqinglong idea]# docker run -d -P --name
tianqinglong-springboot-web tianqinglong666
fd9a353a80bfd61f6930c16cd92204532bfd734e003f3f9983b5128a27b0375e#
View the running container port ( Because we didn't specify it when we started ) [root@iZ2zeg4ytp0whqtmxbsqiiZ idea]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fd9a353a80bf
tianqinglong666"java -jar /app.jar …" 9 seconds ago Up 8 seconds 0.0.0.0:32779->
8080/tcp tianqinglong-springboot-web # Local access 1 [root@iZ2zeg4ytp0whqtmxbsqiiZ idea]
# curl localhost:32779 {"timestamp":"2020-08-14T09:42:57.371+00:00","status"
:404,"error":"Not Found","message":"","path":"/"} # Local access 2 [root@tianqinglong
idea]# [root@tianqinglong idea]# curl localhost:32779/hello hello, xiaofan #
remote access ( Open the security group on Alibaba cloud )

We used it later Docker after , What you interact with others is a mirror image !

Sprinkle flowers at the end Crazy God has issued an advanced version ~ Rush ~

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq