东方通 TongRDS V2 配置与开机自启指南及 Spring Boot 集成

发布于:2024-10-15 ⋅ 阅读:(292) ⋅ 点赞:(0)

东方通 TongRDS V2 配置与开机自启指南及 Spring Boot 集成


本文详细介绍了如何配置和管理东方通 TongRDS V2,这是一个兼容 Redis 协议的高性能缓存系统。首先,通过修改 cfg.xml 配置文件来启用密码保护,确保安全性。然后,提供了如何在 Spring Boot 项目中连接 TongRDS 的示例配置。接着,文章展示了如何通过 systemd 配置 RdsCenter 和 RdsNode 服务实现开机自动启动,并详细讲解了各个服务的启停与日志检查。最后,用户可以通过端口检查命令确保服务正常运行。这篇指南适合需要在国产信创环境下部署和管理 TongRDS 的开发者与运维人员。

预备课

Docker 安装与配置:从入门到部署

Docker 安装与配置 Redis 实践指南

一 简述

TongRDS V2 是一个高性能的缓存系统,兼容 Redis 协议。它支持分布式部署,能够处理大规模数据和高并发访问,提供类似 Redis 的键值对存储和数据操作方式。TongRDS V2 保留了 Redis 的核心特性,如快速读写、数据持久化等,同时通过优化提升了系统的可扩展性和稳定性,非常适合对性能要求高的缓存场景。当前测试环境:

操作系统 CPU 架构
麒麟 V10 c86

二 配置 cfg.xml

通过修改 pmemdb/etc/cfg.xml 文件中的配置,启用密码访问功能。

1 启用密码访问
<?xml version="2.0" encoding="UTF-8"?>
<Server>
    <Common>
       <!-- 运行时模式,默认为debug -->
       <RuntimeModel>debug</RuntimeModel>
       <!-- 数据转储次数,默认10 -->
       <DataDump>${Server.Common.DataDump:10}</DataDump>
       <!-- 是否追加数据转储,默认false -->
       <DataDumpAppending>${Server.Common.DataDumpAppending:false}</DataDumpAppending>
       <!-- 启动等待时间,默认5秒 -->
       <StartWaiting>${Server.Common.StartWaiting:5}</StartWaiting>
       <!-- 服务类型,默认WebSession -->
       <Service>${Server.Common.Service:WebSession}</Service>
       <!-- 最大键长度,默认1m -->
       <MaxKeyLength>${Server.Common.MaxKeyLength:1m}</MaxKeyLength>
       <!-- 最大值长度,默认10m -->
       <MaxValueLength>${Server.Common.MaxValueLength:10m}</MaxValueLength>
    </Common>
    <Log>
       <!-- 日志级别可以是 nothing, error, warn, info, debug, dump -->
       <!-- 默认是 error -->
       <Level>${Server.Log.Level:error}</Level>
       <!-- 日志保留天数,默认30天 -->
       <BackDates>${Server.Log.BackDates:30}</BackDates>
    </Log>
    <Listen>
      <!-- 监听端口,默认6200 -->
      <Port>6200</Port>
      <!-- 线程数,默认8 -->
      <Threads>8</Threads>

      <!-- 最大连接数,默认1000 -->
      <MaxConnections>${Server.Listen.MaxConnections:1000}</MaxConnections>

      <!-- backlog值,默认1024 -->
      <Backlog>1024</Backlog>

      <!-- 安全模式:0 = telnet,1 = SSL,2 = password,3 = SSL + password,默认是1 -->
      <Secure>${Server.Listen.Secure:2}</Secure>
      <!-- 连接密码,默认32位随机字符串 -->
      <Password>${Server.Listen.Password:一串默认长度的32位字符串}</Password>
      <!-- Redis的明文密码选项,默认true -->
      <RedisPlainPassword>true</RedisPlainPassword>
      <!-- Redis服务端口,默认6379 -->
      <RedisPort>6379</RedisPort>
      <!-- Redis密码,可填写你喜欢的明文密码 -->
      <RedisPassword>这里填写你喜欢的明文密码</RedisPassword>
    </Listen>
    <!-- 可访问的Tables数,默认1 -->
    <Tables>1</Tables>
    <TableTemplate>
      <!-- 块数,默认4 -->
      <Blocks>${Server.TableTemplate.Blocks:4}</Blocks>
      <!-- 行数,默认0 -->
      <Rows>${Server.TableTemplate.Rows:0}</Rows>
      <!-- 键格式,默认bytes2,最大长度100 -->
      <Key>bytes2, 100</Key>
      <!-- 值格式,默认variable,最大长度0 -->
      <Value>variable, 0</Value>
      <!-- 索引数,默认0 -->
      <Indexes>0</Indexes>
      <Sync>
        <!-- 列表同步次数,默认1 -->
        <ListNumbers>${Server.TableTemplate.Sync.ListNumbers:1}</ListNumbers>
        <!-- 列表长度,默认10000 -->
        <ListLength>${Server.TableTemplate.Sync.ListLength:10000}</ListLength>
      </Sync>
    </TableTemplate>
</Server>
2 Spring Boot 连接 TongRDS

在 Spring Boot 项目中,TongRDS 与 Redis 的连接配置方式相同,可以复用相同的连接方法。

spring:
  redis:
    database: 0
    host: 192.168.0.1
    port: 6379
    password: 你的密码

三 配置 TongRDS 开机自启

1 配置 RdsCenter

参考 /pcenter/bin 中的 RdsCenter.service 配置修改。

1)设置 RdsCenter.service 执行权限
vim /etc/systemd/system/RdsCenter.service
sudo chmod +x /etc/systemd/system/RdsCenter.service
2)新增 RdsCenter.service
[Unit]
Description=RDS Center Service

[Service]
Type=simple
ExecStart=/home/yourpath/pcenter/bin/StartCenter.sh
ExecStop=/bin/kill -SIGTERM $MAINPID
TimeoutSec=6
RestartSec=1
Restart=always

[Install]
WantedBy=multi-user.target 

移动文件 RdsCenter.service

cp RdsCenter.service /etc/systemd/system/
# 修改为可执行权限
chmod +x /etc/systemd/system/RdsCenter.service
3)启动 RdsCenter 服务
sudo systemctl daemon-reload
sudo systemctl enable RdsCenter
sudo systemctl start RdsCenter
sudo systemctl stop RdsCenter
sudo systemctl status RdsCenter
2 配置 RdsNode

参考 pmemdb/bin 中的 RdsNode.service 配置修改。

1)设置 RdsNode.service 执行权限
vim /etc/systemd/system/RdsNode.service
sudo chmod +x /etc/systemd/system/RdsNode.service
2)新增 RdsNode.service
[Unit]
Description=RDS Node Service
After=RdsCenter.service

[Service]
Type=simple
ExecStart=/home/yourpath/pmemdb/bin/StartServer.sh
ExecStop=/bin/kill -SIGTERM $MAINPID
TimeoutSec=15
RestartSec=3
Restart=always

[Install]
WantedBy=multi-user.target

移动文件 RdsCenter.service

cp RdsNode.service /etc/systemd/system/
# 修改为可执行权限
chmod +x /etc/systemd/system/RdsNode.service
3 启动 RdsNode 服务
sudo systemctl daemon-reload
sudo systemctl enable RdsNode
sudo systemctl start RdsNode
sudo systemctl stop RdsNode
sudo systemctl status RdsNode

四 检查日志

使用 journalctl 检查更详细的日志输出,以便诊断问题的根本原因:

sudo journalctl -u RdsCenter.service -b -n 50
sudo journalctl -u RdsNode.service -b -n 50

五 其他启动方式

1 启动 RDS 服务节点
# 启动 RDS 服务节点,使用 pmemdb/bin 目录下的 StartServer.sh 脚本
./StartServer.sh
# 停止 RDS 服务节点,使用 pmemdb/bin 目录下执行 StopServer.sh 脚本
./StopServer.sh
# 以后台服务形式启动
nohup ./StartServer.sh > /dev/null 2>&1 &
2 启动中心节点
# 启动中心节点,使用 pcenter/bin 目录下的 StartCenter.sh 脚本
./StartCenter.sh
# 停止中心节点,使用 pcenter/bin 目录下执行 StopCenter.sh 脚本。
./StopCenter.sh
# 以后台服务形式启动
nohup ./StartCenter.sh > /dev/null 2>&1 &

六 查看端口

TongRDS 启动时使用的端口较多,请检查端口配置,以便于设置防火墙规则。

netstat -lnpt

网站公告

今日签到

点亮在社区的每一天
去签到