Skip to content

Commit

Permalink
docker-redis单机部署支持
Browse files Browse the repository at this point in the history
  • Loading branch information
72178299 committed Mar 6, 2024
1 parent 7a9d1d3 commit 07d7239
Show file tree
Hide file tree
Showing 25 changed files with 290 additions and 45 deletions.
76 changes: 76 additions & 0 deletions docker/docker-compose-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,82 @@
version: "3"

services:
redis-cluster:
image: redis
command: redis-cli --cluster create 172.22.225.9:6371 172.22.225.9:6372 172.22.225.9:6373 172.22.225.9:6374 172.22.225.9:6375 172.22.225.9:6376 --cluster-replicas 1 --cluster-yes
depends_on:
- redis-6371
- redis-6372
- redis-6373
- redis-6374
- redis-6375
- redis-6376
redis-6371: # 服务名称
image: redis # 创建容器时所需的镜像
container_name: redis-6371 # 容器名称
restart: always # 容器总是重新启动
ports:
- "6371:6371"
- "16371:16371"
volumes: # 数据卷,目录挂载
- ./redis/redis1/redis1.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis1/data:/data
command: redis-server /usr/local/etc/redis/redis.conf # 覆盖容器启动后默认执行的命令

redis-6372:
image: redis
container_name: redis-6372
ports:
- "6372:6372"
- "16372:16372"
volumes:
- ./redis/redis2/redis2.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis2/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6373:
image: redis
container_name: redis-6373
ports:
- "6373:6373"
- "16373:16373"
volumes:
- ./redis/redis3/redis3.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis3/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6374:
image: redis
container_name: redis-6374
ports:
- "6374:6374"
- "16374:16374"
volumes:
- ./redis/redis4/redis4.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis4/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6375:
image: redis
container_name: redis-6375
ports:
- "6375:6375"
- "16375:16375"
volumes:
- ./redis/redis5/redis5.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis5/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6376:
image: redis
container_name: redis-6376
ports:
- "6376:6376"
- "16376:16376"
volumes:
- ./redis/redis6/redis6.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis6/data:/data
command: redis-server /usr/local/etc/redis/redis.conf
moonbox-mysql:
platform: linux/amd64
container_name: moonbox-mysql
Expand Down
76 changes: 76 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,82 @@
version: "3"

services:
redis-cluster:
image: redis
command: redis-cli --cluster create 172.22.225.9:6371 172.22.225.9:6372 172.22.225.9:6373 172.22.225.9:6374 172.22.225.9:6375 172.22.225.9:6376 --cluster-replicas 1 --cluster-yes
depends_on:
- redis-6371
- redis-6372
- redis-6373
- redis-6374
- redis-6375
- redis-6376
redis-6371: # 服务名称
image: redis # 创建容器时所需的镜像
container_name: redis-6371 # 容器名称
restart: always # 容器总是重新启动
ports:
- "6371:6371"
- "16371:16371"
volumes: # 数据卷,目录挂载
- ./redis/redis1/redis1.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis1/data:/data
command: redis-server /usr/local/etc/redis/redis.conf # 覆盖容器启动后默认执行的命令

redis-6372:
image: redis
container_name: redis-6372
ports:
- "6372:6372"
- "16372:16372"
volumes:
- ./redis/redis2/redis2.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis2/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6373:
image: redis
container_name: redis-6373
ports:
- "6373:6373"
- "16373:16373"
volumes:
- ./redis/redis3/redis3.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis3/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6374:
image: redis
container_name: redis-6374
ports:
- "6374:6374"
- "16374:16374"
volumes:
- ./redis/redis4/redis4.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis4/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6375:
image: redis
container_name: redis-6375
ports:
- "6375:6375"
- "16375:16375"
volumes:
- ./redis/redis5/redis5.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis5/data:/data
command: redis-server /usr/local/etc/redis/redis.conf

redis-6376:
image: redis
container_name: redis-6376
ports:
- "6376:6376"
- "16376:16376"
volumes:
- ./redis/redis6/redis6.conf:/usr/local/etc/redis/redis.conf
- ./redis/redis6/data:/data
command: redis-server /usr/local/etc/redis/redis.conf
moonbox-mysql:
container_name: moonbox-mysql
build:
Expand Down
4 changes: 4 additions & 0 deletions docker/redis/redis1/data/nodes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2c71ee68db63234165e93d1619ff02a1641eb2f8 172.22.225.9:6372@16372,,tls-port=0,shard-id=a4b1bdfa0c58a6fbcd97d8a843d46286dc365e8f master - 0 1709196638000 2 connected 5461-10922
3926e4b60debec1282741e15953a74a6c4d3eb2a 172.22.225.9:6371@16371,,tls-port=0,shard-id=dad52cafaa52b017aedb5bedc18b1dbc459ff13d myself,master - 0 1709196638000 1 connected 0-5460
e8fcf70df6cfd3838303d18d8e88f20f372120eb 172.22.225.9:6373@16373,,tls-port=0,shard-id=0e55c09c228fd825377ca07f972e371d7e2e5913 master - 1709196638126 1709196638030 6 disconnected 10923-16383
vars currentEpoch 6 lastVoteEpoch 0
10 changes: 10 additions & 0 deletions docker/redis/redis1/redis1.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port 6371
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip 172.22.225.9
cluster-announce-port 6371
cluster-announce-bus-port 16371
4 changes: 4 additions & 0 deletions docker/redis/redis2/data/nodes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
e8fcf70df6cfd3838303d18d8e88f20f372120eb 172.22.225.9:6373@16373,,tls-port=0,shard-id=0e55c09c228fd825377ca07f972e371d7e2e5913 master - 1709196637740 1709196637645 6 disconnected 10923-16383
2c71ee68db63234165e93d1619ff02a1641eb2f8 172.22.225.9:6372@16372,,tls-port=0,shard-id=a4b1bdfa0c58a6fbcd97d8a843d46286dc365e8f myself,master - 0 1709196638000 2 connected 5461-10922
3926e4b60debec1282741e15953a74a6c4d3eb2a 172.22.225.9:6371@16371,,tls-port=0,shard-id=dad52cafaa52b017aedb5bedc18b1dbc459ff13d master - 0 1709196638146 1 connected 0-5460
vars currentEpoch 6 lastVoteEpoch 0
10 changes: 10 additions & 0 deletions docker/redis/redis2/redis2.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port 6372
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip 172.22.225.9
cluster-announce-port 6372
cluster-announce-bus-port 16372
4 changes: 4 additions & 0 deletions docker/redis/redis3/data/nodes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
3926e4b60debec1282741e15953a74a6c4d3eb2a 172.22.225.9:6371@16371,,tls-port=0,shard-id=dad52cafaa52b017aedb5bedc18b1dbc459ff13d master - 0 1709196411483 1 connected 0-5460
e8fcf70df6cfd3838303d18d8e88f20f372120eb 172.22.225.9:6373@16373,,tls-port=0,shard-id=0e55c09c228fd825377ca07f972e371d7e2e5913 myself,master - 0 1709196402000 3 connected 10923-16383
2c71ee68db63234165e93d1619ff02a1641eb2f8 172.22.225.9:6372@16372,,tls-port=0,shard-id=a4b1bdfa0c58a6fbcd97d8a843d46286dc365e8f master - 1709196403317 1709196402321 2 connected 5461-10922
vars currentEpoch 6 lastVoteEpoch 0
10 changes: 10 additions & 0 deletions docker/redis/redis3/redis3.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port 6373
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip 172.22.225.9
cluster-announce-port 6373
cluster-announce-bus-port 16373
4 changes: 4 additions & 0 deletions docker/redis/redis4/data/nodes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2c71ee68db63234165e93d1619ff02a1641eb2f8 172.22.225.9:6372@16372,,tls-port=0,shard-id=a4b1bdfa0c58a6fbcd97d8a843d46286dc365e8f master - 0 1709196486419 2 connected 5461-10922
e8fcf70df6cfd3838303d18d8e88f20f372120eb 172.22.225.9:6374@16374,,tls-port=0,shard-id=0e55c09c228fd825377ca07f972e371d7e2e5913 myself,master - 0 1709196486000 4 connected
3926e4b60debec1282741e15953a74a6c4d3eb2a 172.22.225.9:6371@16371,,tls-port=0,shard-id=dad52cafaa52b017aedb5bedc18b1dbc459ff13d master - 1709196486410 1709196486324 1 connected 0-5460
vars currentEpoch 6 lastVoteEpoch 0
10 changes: 10 additions & 0 deletions docker/redis/redis4/redis4.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port 6374
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip 172.22.225.9
cluster-announce-port 6374
cluster-announce-bus-port 16374
4 changes: 4 additions & 0 deletions docker/redis/redis5/data/nodes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2c71ee68db63234165e93d1619ff02a1641eb2f8 172.22.225.9:6372@16372,,tls-port=0,shard-id=a4b1bdfa0c58a6fbcd97d8a843d46286dc365e8f master - 0 1709196516484 2 connected 5461-10922
3926e4b60debec1282741e15953a74a6c4d3eb2a 172.22.225.9:6371@16371,,tls-port=0,shard-id=dad52cafaa52b017aedb5bedc18b1dbc459ff13d master - 1709196516477 1709196516385 1 connected 0-5460
e8fcf70df6cfd3838303d18d8e88f20f372120eb 172.22.225.9:6375@16375,,tls-port=0,shard-id=0e55c09c228fd825377ca07f972e371d7e2e5913 myself,master - 0 1709196516000 5 connected
vars currentEpoch 6 lastVoteEpoch 0
10 changes: 10 additions & 0 deletions docker/redis/redis5/redis5.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port 6375
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip 172.22.225.9
cluster-announce-port 6375
cluster-announce-bus-port 16375
4 changes: 4 additions & 0 deletions docker/redis/redis6/data/nodes.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
2c71ee68db63234165e93d1619ff02a1641eb2f8 172.22.225.9:6372@16372,,tls-port=0,shard-id=a4b1bdfa0c58a6fbcd97d8a843d46286dc365e8f master - 0 1709196437505 2 connected 5461-10922
e8fcf70df6cfd3838303d18d8e88f20f372120eb 172.22.225.9:6376@16376,,tls-port=0,shard-id=0e55c09c228fd825377ca07f972e371d7e2e5913 myself,master - 0 1709196437000 6 connected
3926e4b60debec1282741e15953a74a6c4d3eb2a 172.22.225.9:6371@16371,,tls-port=0,shard-id=dad52cafaa52b017aedb5bedc18b1dbc459ff13d master - 0 1709196437504 1 connected 0-5460
vars currentEpoch 6 lastVoteEpoch 0
10 changes: 10 additions & 0 deletions docker/redis/redis6/redis6.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
port 6376
protected-mode no
daemonize no
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-announce-ip 172.22.225.9
cluster-announce-port 6376
cluster-announce-bus-port 16376
17 changes: 17 additions & 0 deletions moonbox-common/moonbox-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.11</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand All @@ -24,6 +30,11 @@
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-databind.version}</version>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
Expand All @@ -38,5 +49,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.vivo.internet.moonbox.redis.util;
package com.alibaba.jvm.sandbox.repeater.plugin.util;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.vivo.internet.moonbox.redis.util;
package com.alibaba.jvm.sandbox.repeater.plugin.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.vivo.internet.moonbox.common.api.serialize.SerializeException;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -48,9 +47,9 @@ public class JacksonUtils {
*
* @param object 要序列化的对象
* @return 序列化后的字符串
* @throws SerializeException 序列化异常
* @throws Exception 序列化异常
*/
public static String serialize(Object object) throws SerializeException {
public static String serialize(Object object) throws Exception {
return serialize(object, true);
}

Expand All @@ -60,14 +59,14 @@ public static String serialize(Object object) throws SerializeException {
* @param object 需要序列化的对象
* @param pretty 是否需要格式化输出
* @return 序列化后的JSON字符串
* @throws SerializeException 序列化异常
* @throws Exception 序列化异常
*/
public static String serialize(Object object, boolean pretty) throws SerializeException {
public static String serialize(Object object, boolean pretty) throws Exception {
try {
return pretty ? mapper.writerWithDefaultPrettyPrinter().writeValueAsString(object) : mapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
log.error("jackSonUtil-serialize failed,object:{}, pretty:{}", object, pretty, e);
throw new SerializeException("jackson-serialize-error", e);
throw new Exception("jackson-serialize-error", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.vivo.internet.moonbox.redis.util;
package com.alibaba.jvm.sandbox.repeater.plugin.util;

import com.google.common.base.Strings;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.JavaType;
import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.vivo.internet.moonbox.redis.util;
package com.alibaba.jvm.sandbox.repeater.plugin.util;


import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import com.vivo.internet.moonbox.redis.util.JacksonUtils;
import com.alibaba.jvm.sandbox.repeater.plugin.util.JacksonUtils;

import com.alibaba.fastjson.JSON;
import com.vivo.internet.moonbox.common.api.dto.MoonBoxResult;
Expand Down Expand Up @@ -91,7 +91,7 @@ public MoonBoxResult<String> saveRecord(String body) {
.getRequestSerialized(), Object[].class);
try{
entity.setRequest(JacksonUtils.serialize(objects));
} catch (SerializeException e) {
} catch (Exception e) {
log.error("deserialize request body failed, body:{}.",wrapper.getEntranceInvocation().getRequestSerialized(), e);
}

Expand Down
Loading

0 comments on commit 07d7239

Please sign in to comment.