Skip to content

Commit

Permalink
update some bug for release 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
githubname1024 committed Nov 11, 2022
1 parent 1aa6078 commit 9ccdadb
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 41 deletions.
33 changes: 32 additions & 1 deletion cachecloud-web/sql/3.0.sql
Expand Up @@ -759,6 +759,7 @@ CREATE TABLE `machine_info` (
`rack` varchar(128) COLLATE utf8_bin DEFAULT '' COMMENT '机器所在机架信息',
`is_allocating` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否在分配中,1是0否',
`disk` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '磁盘空间:G',
`dis_type` tinyint(4) DEFAULT 0 NOT NULL COMMENT '操作系统发行版本,0:centos;1:ubuntu',
PRIMARY KEY (`id`),
UNIQUE KEY `ip` (`ip`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='机器信息表' /* `compression`='tokudb_zlib' */;
Expand Down Expand Up @@ -1317,4 +1318,34 @@ CREATE TABLE `app_import` (
`app_build_task_id` bigint(20) DEFAULT NULL COMMENT '目标应用部署任务id',
`source_type` int(11) DEFAULT NULL COMMENT '源redis类型:7:cluster, 6:sentinel, 5:standalone',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- redis_module_config definition

CREATE TABLE `redis_module_config` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`config_key` varchar(128) NOT NULL COMMENT '配置名',
`config_value` varchar(512) NOT NULL COMMENT '配置值',
`info` varchar(512) NOT NULL COMMENT '配置说明',
`update_time` datetime NOT NULL COMMENT '更新时间',
`type` mediumint(9) NOT NULL COMMENT '类型:2.cluster节点特殊配置, 5:sentinel节点配置, 6:redis普通节点',
`status` tinyint(4) NOT NULL COMMENT '1有效,0无效',
`version_id` int(11) NOT NULL COMMENT 'Module version版本表主键id',
`refresh` tinyint(4) DEFAULT '0' COMMENT '是否可重置:0不可,1可重置',
`module_id` int(11) NOT NULL DEFAULT '7' COMMENT 'Module 信息表id',
`config_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '配置类型,0:加载和运行配置;1:加载时配置;2:运行时配置',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_configkey_type_version_id` (`config_key`,`type`,`version_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='redis模块配置表';


-- app_to_module definition

CREATE TABLE `app_to_module` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`app_id` bigint(20) NOT NULL COMMENT '应用id',
`module_id` int(11) NOT NULL COMMENT '模块info id',
`module_version_id` int(11) NOT NULL COMMENT '模块版本id',
PRIMARY KEY (`id`),
UNIQUE KEY `app_to_module_un` (`app_id`,`module_id`,`module_version_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='应用与模块关系表';
Expand Up @@ -113,6 +113,11 @@ public boolean startExistInstance(long appId, int instanceId) {
logger.info("{} is install :{}", host, redisResource.getName());
return false;
}
//校验是否需要推送module
if(TypeUtil.isRedisDataType(type)){
List<ModuleVersion> appToModuleList = appService.getAppToModuleList(appId);
redisCenter.checkAndDownloadModule(host, appToModuleList);
}
boolean isRun;
if (TypeUtil.isRedisType(type)) {
if (TypeUtil.isRedisSentinel(type)) {
Expand Down
Expand Up @@ -2,6 +2,7 @@

import com.alibaba.fastjson.JSONArray;
import com.sohu.cache.constant.AppCheckEnum;
import com.sohu.cache.constant.RedisConstant;
import com.sohu.cache.entity.MachineInfo;
import com.sohu.cache.entity.MachineStats;
import com.sohu.cache.redis.util.JedisUtil;
Expand All @@ -22,6 +23,7 @@
import redis.clients.jedis.Jedis;

import java.util.*;
import java.util.concurrent.TimeUnit;

import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE;

Expand Down Expand Up @@ -109,6 +111,8 @@ public List<String> getTaskSteps() {
taskStepList.add("deployCollection");
//14. 设置密码
taskStepList.add("setPasswd");
//14. rdb
taskStepList.add("checkFullSync");
//14. 装载组件
taskStepList.add("loadModule");
//14. 审核
Expand Down Expand Up @@ -436,6 +440,125 @@ public TaskFlowStatusEnum setPasswd() {
return TaskFlowStatusEnum.SUCCESS;
}

public TaskFlowStatusEnum checkFullSync(){
Map<RedisServerNode, Boolean> fullSyncSet = new HashMap<>();
Map<RedisServerNode, Boolean> slaveOnLoadingSet = new HashMap<>();
// 耗时
int totalSeconds = 0;
redisServerNodes.stream().filter(redisServerNode -> StringUtils.isBlank(redisServerNode.getMasterHost()) && redisServerNode.getMasterPort() == 0)
.forEach(redisServerNode -> fullSyncSet.put(redisServerNode, false));
redisServerNodes.stream().filter(redisServerNode -> StringUtils.isNotBlank(redisServerNode.getMasterHost()) && redisServerNode.getMasterPort() != 0)
.forEach(redisServerNode -> slaveOnLoadingSet.put(redisServerNode, false));
while (true) {
// 简单的计时器
long startTime = System.currentTimeMillis();
boolean syncFlag = true;
for (Map.Entry<RedisServerNode, Boolean> entry : fullSyncSet.entrySet()) {
if(entry.getValue().equals(false)){
syncFlag = false;
Jedis jedis = null;
try {
jedis = redisCenter.getJedis(appId, entry.getKey().getIp(), entry.getKey().getPort());
String statsInfo = jedis.info(RedisConstant.Stats.getValue());
if(StringUtils.isNotBlank(statsInfo)){
String[] split = statsInfo.split("\r\n");
for (String str : split){
if(StringUtils.isNotBlank(str) && str.contains("sync_full:")){
String[] pair = StringUtils.splitByWholeSeparator(str, ":");
Long aLong = Long.valueOf(pair[1]);
if(aLong > 0){
fullSyncSet.put(entry.getKey(), true);
break;
}
}
}
}
}catch (Exception e){
logger.error(marker, "check full sync, appId:{}, error:{}!", appId, e.getMessage());
}finally {
if (jedis != null) {
jedis.close();
}
}
}else{
continue;
}
}
if(syncFlag){
break;
}
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
logger.error(marker, e.getMessage(), e);
}
// 简单的计时器(秒)
long costTime = System.currentTimeMillis() - startTime;
totalSeconds += (costTime / 1000);
if (totalSeconds > TaskConstants.REDIS_SERVER_INSTALL_TIMEOUT) {
return TaskFlowStatusEnum.ABORT;
}
}

try {
TimeUnit.SECONDS.sleep(20);
} catch (InterruptedException e) {
logger.error(marker, "check full sync, appId:{}, error:{}!", appId, e.getMessage());
logger.error(marker, e.getMessage());
}
while (true) {
// 简单的计时器
long startTime = System.currentTimeMillis();
boolean loadingFlag = true;
for (Map.Entry<RedisServerNode, Boolean> entry : slaveOnLoadingSet.entrySet()) {
if (entry.getValue().equals(false)) {
loadingFlag = false;
Jedis jedis = null;
try {
jedis = redisCenter.getJedis(appId, entry.getKey().getIp(), entry.getKey().getPort());
String statsInfo = jedis.info(RedisConstant.Replication.getValue());
if (StringUtils.isNotBlank(statsInfo)) {
String[] split = statsInfo.split("\r\n");
for (String str : split) {
if (StringUtils.isNotBlank(str) && str.contains("master_sync_in_progress:")) {
String[] pair = StringUtils.splitByWholeSeparator(str, ":");
Long aLong = Long.valueOf(pair[1]);
if (aLong == 0) {
slaveOnLoadingSet.put(entry.getKey(), true);
break;
}
}
}
}
} catch (Exception e) {
logger.error(marker, "check not on sync progress, appId:{}, error:{}!", appId, e.getMessage());
} finally {
if (jedis != null) {
jedis.close();
}
}
} else {
continue;
}
}
if(loadingFlag){
break;
}
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
logger.error(marker, e.getMessage(), e);
}
// 简单的计时器(秒)
long costTime = System.currentTimeMillis() - startTime;
totalSeconds += (costTime / 1000);
if (totalSeconds > TaskConstants.REDIS_SERVER_INSTALL_TIMEOUT) {
return TaskFlowStatusEnum.ABORT;
}
}
return TaskFlowStatusEnum.SUCCESS;
}

public TaskFlowStatusEnum loadModule(){
if (!StringUtils.isEmpty(moduleInfo)) {
for (String versionId : moduleInfo.split(";")) {
Expand Down
16 changes: 0 additions & 16 deletions cachecloud-web/src/main/java/com/sohu/cache/util/ConstUtils.java
@@ -1,12 +1,8 @@
package com.sohu.cache.util;

import com.sohu.cache.web.enums.ModuleEnum;
import com.sohu.cache.web.enums.SshAuthTypeEnum;
import org.apache.commons.collections.map.HashedMap;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* cachecloud常量
Expand Down Expand Up @@ -150,18 +146,6 @@ public class ConstUtils {
* module info
*/
public static final String MODULE_BASE_PATH = "/opt/cachecloud/module/";
public static List<String> MODULE_LIST = new ArrayList<String>();
public static Map<String,Object> MODULE_MAP = new HashedMap();
static {
// 布隆过滤器 & redis search
MODULE_LIST.add(ModuleEnum.BLOOMFILTER_SO.getValue());
MODULE_LIST.add(ModuleEnum.REDISSEARCH_SO.getValue());
// 存redis moduleName & 模块文件名 一一对应关系
MODULE_MAP.put(ModuleEnum.BLOOMFILTER_SO.getValue(),ModuleEnum.BLOOMFILTER_NAME.getValue());
MODULE_MAP.put(ModuleEnum.REDISSEARCH_SO.getValue(),ModuleEnum.REDISSEARCH_NAME.getValue());
MODULE_MAP.put(ModuleEnum.BLOOMFILTER_NAME.getValue(),ModuleEnum.BLOOMFILTER_SO.getValue());
MODULE_MAP.put(ModuleEnum.REDISSEARCH_NAME.getValue(),ModuleEnum.REDISSEARCH_SO.getValue());
}

/**
* 管理员相关
Expand Down

This file was deleted.

Expand Up @@ -4,11 +4,11 @@

<img width="100%" src="../../img/function/server/cc-alert-all.png"/>

<img width="100%" src="../../img/function/server/cc-alter-special.png"/>
<img width="100%" src="../../img/function/server/cc-alert-special.png"/>

<img width="100%" src="../../img/function/server/cc-alter-add-common.png"/>
<img width="100%" src="../../img/function/server/cc-alert-add-common.png"/>

<img width="100%" src="../../img/function/server/cc-alter-add-app.png"/>
<img width="100%" src="../../img/function/server/cc-alert-add-app.png"/>

<img width="100%" src="../../img/function/server/cc-alter-add-instance.png"/>
<img width="100%" src="../../img/function/server/cc-alert-add-instance.png"/>

Expand Up @@ -17,10 +17,12 @@
<img src="../../img/function/operation/operation-app.png" width="100%">

<a name="cc1"/>

### 应用运维
点击”应用运维“操作,可管理应用实例、查看应用机器列表,应用详情和审批列表,修改应用密码等。

<a name="cc1-1"/>

#### 管理应用实例

**1. Redis Sentinel类型应用**
Expand Down Expand Up @@ -48,13 +50,15 @@ f. config/restart(修改配置/滚动重启)
<img src="../../img/function/server/app-operation-cluster.png" width="100%">

<a name="cc1-6"/>

#### 管理应用模块

查看机器集成模块情况,实例装载模块情况,安装模块,查看实例日志等。

<img src="../../img/function/server/app-module.png" width="100%">

<a name="cc1-2"/>

#### 应用机器列表

查看该应用分布机器的使用情况,包括内存使用率、已分配内存、cpu使用率等信息。
Expand All @@ -63,23 +67,27 @@ f. config/restart(修改配置/滚动重启)


<a name="cc1-3"/>

#### 应用详情和审批列表

<img src="../../img/function/server/app-detail.png" width="100%">

<a name="cc1-4"/>

#### 应用密码修改

<img src="../../img/function/server/app-redisPassword.png" width="100%">

<a name="cc1-5"/>

#### 应用拓扑诊断

提供对应用拓扑分布规范的检查功能,便于发现问题,做出调整。

<img src="../../img/function/server/topology.png" width="100%"/>

<a name="cc2"/>

#### 2.应用迁移

在CacheCloud后台的“应用运维”页面,选择要进行迁移的应用,点击“应用迁移”。 这种迁移方式不会更换应用的appId,通过主从节点的failover实现,是对客户端无感知迁移。注意:此操作通过failover实现节点切换,仅支持同redis版本/小版本应用的迁移升级。
Expand Down Expand Up @@ -121,11 +129,13 @@ f. config/restart(修改配置/滚动重启)
<img src="../../img/operate/appMigrate/app-migrate8.png" width="100%"/>

<a name="cc3"/>

#### 3.应用下线

下线当前应用,销毁所有存活节点。点击“应用下线”,跳转到应用下线任务流,可查看下线情况。

<a name="cc4"/>

#### 4.版本升级

升级应用的redis版本。详细操作可参考:[运维手册-Redis版本管理.应用版本升级](../access/redisVersion.md)

0 comments on commit 9ccdadb

Please sign in to comment.