3.1 KiB
3.1 KiB
RedisClipSync 内网部署方案(v1.1.0)
本文档对应 v1.1.0,适用于「主机统一打包 -> 分发到多台从机 -> 从机一键安装并开机自启」场景。
1. 目标与范围
- 目标:降低内网批量部署成本,避免每台从机重复构建。
- 范围:Linux 从机部署(systemd 管理),主机负责生成发布包。
- 默认安装目录:
/opt/redis-clip-sync。
2. 架构与角色
- 主机(MASTER):生成发布包并分发。
- 从机(SLAVE):接收发布包,改配置后执行安装脚本。
- Redis:内网统一服务,主从均连接此 Redis。
3. 前置条件
- 主机:已安装 Java 8+、Maven 3.x。
- 从机:已安装 Java 8+、systemd、sudo。
- 网络:从机可访问 Redis
host:port。 - 安全:
crypto.enabled=true,主从crypto.key使用同一把 32-byte Base64 密钥。
4. 主机发布流程
在项目根目录执行:
chmod +x linux/build-slave-release.sh
./linux/build-slave-release.sh
执行完成后会生成:
- 目录:
dist/redis-clip-sync-slave-<version>/ - 压缩包:
dist/redis-clip-sync-slave-<version>.tar.gz
发布包包含:
bin/install-slave.sh:安装 + 注册 systemd + enable --nowbin/start.sh|stop.sh|status.sh|logs.sh:本地运维脚本lib/redis-clip-sync.jarconf/config.properties(从机模板)systemd/redis-clip-sync.service.tpl
5. 从机安装流程
5.1 解压发布包
tar -xzf redis-clip-sync-slave-<version>.tar.gz
cd redis-clip-sync-slave-<version>
5.2 修改从机配置
编辑 conf/config.properties,至少修改:
redis.hostslave.listen.channelslave.idcrypto.key- (按需)
redis.password
5.3 执行安装
sudo ./bin/install-slave.sh
安装脚本会执行:
- 复制程序到
/opt/redis-clip-sync - 渲染并写入
/etc/systemd/system/redis-clip-sync.service systemctl daemon-reloadsystemctl enable --now redis-clip-sync
6. 运维命令
systemctl status redis-clip-sync
systemctl restart redis-clip-sync
journalctl -u redis-clip-sync -f
7. 一键验收命令
在从机执行:
bash -c 'set -e; systemctl is-enabled redis-clip-sync >/dev/null; systemctl is-active redis-clip-sync >/dev/null; test -f /opt/redis-clip-sync/lib/redis-clip-sync.jar; test -f /opt/redis-clip-sync/conf/config.properties; echo "[PASS] redis-clip-sync deployed and running"'
输出 [PASS] ... 表示安装、开机自启、运行状态和关键文件均通过。
8. 回滚与卸载
如需快速回滚:
sudo systemctl disable --now redis-clip-sync
sudo rm -f /etc/systemd/system/redis-clip-sync.service
sudo systemctl daemon-reload
如需同时删除安装目录:
sudo rm -rf /opt/redis-clip-sync
9. 常见问题
- 服务启动失败:先看
journalctl -u redis-clip-sync -n 200 --no-pager。 - Redis 不通:检查
redis.host/redis.port、防火墙、密码。 - 无法解密:确认主从
crypto.enabled与crypto.key完全一致。 - TTL 不生效:确认从机角色为
SLAVE且slave.log.ttl.seconds>0。