扬升资讯

养老基金是什么(举例说明什么是养老基金,以及特点)

8balincan|
27

大家好,今天给大家分享养老基金是什么,一起来看看吧。

晁元宁 阿里云云原生 2023-07-22 18:06 发表于浙江

01

Redis 新特性介绍

Cloud Native

1.1 背景

Redis 实际使用过程中会存在一些故障演练需求。例如:模拟触发所有 key 过期的极端故障场景、模拟主动触发 Redis 内存淘汰策略释放内存场景等等。

所以,根据以上故障演练需求,决定对 ChaosBlade 新增模拟 Redis 缓存过期实验和模拟 Redis 缓存内存限制实验,丰富 ChaosBlade 的混沌实验场景。

1.2 模拟Redis缓存过期实验

1.2.1 实验用途

模拟 Redis 缓存单个 key 缓存过期,触发缓存指定 key 过期的实验场景。模拟 Redis 缓存所有 key 缓存过期,触发缓存所有 key 过期的极端异常场景。

1.2.2 实现原理

通过使用 go-redis 包中的 Golang 接口修改 Redis 缓存 Key 的过期时间,来实现模拟 Redis 缓存过期实验。

1.2.3 使用示例

blade create redis cache-expire --addr 192.168.56.101:6379 --password 123456 --key test1 --expiry 1m{&34;:200,&34;:true,&34;:&34;}blade create redis cache-expire --addr 192.168.56.101:6379 --password 123456 --key test1 --option GT --expiry 1m{&34;:200,&34;:true,&34;:&34;}

1.2.4 官方文档

https://chao**lade.io/docs/experiment-types/host/redis/blade_create_redis_cache_expire

1.3 模拟 Redis 缓存内存限制实验

1.3.1 实验用途

通过修改 Redis 配置 maxmemory 的大小,模拟超出 Redis 缓存内存限制,从而触发 Redis 内存淘汰策略释放内存场景。

1.3.2 实现原理

通过使用 go-redis 包中的 Golang 接口修改 Redis maxmemory 配置,来实现模拟 Redis 缓存内存限制实验。

1.3.3 使用示例

blade create redis cache-limit --addr 192.168.56.101:6379 --password 123456 --size 256M{&34;:200,&34;:true,&34;:&34;}blade create redis cache-limit --addr 192.168.56.101:6379 --password 123456 --percent 50{&34;:200,&34;:true,&34;:&34;}

1.3.4 官方文档

https://chao**lade.io/docs/experiment-types/host/redis/blade_create_redis_cache_limit

02

开源贡献新人入门

Cloud Native

2.1 概述

本部分以两个新增 Redis 故障场景为例,帮助刚接触 ChaosBlade 的社区同学快速入门开源贡献。开源贡献新人入门前置条件为:了解混沌工程相关知识和掌握 Golang 开发。

2.2 贡献流程图

2.3 第一步:分析故障演练需求,确认新增原子**

确认新增原子**之前,首先要分析故障演练的需求价值。根据上述第一部分的背景介绍,我们了解到 Redis 实际使用过程中会存在模拟触发所有 key 过期的极端故障场景、模拟主动触发 Redis 内存淘汰策略释放内存场景等等故障演练需求。

所以,基于存在的故障演练需求价值,确认新增模拟 Redis 缓存过期实验和模拟 Redis 缓存内存限制实验。

2.4 第二步:Fork 项目&本地拉取代码并创建 dev 分支

2.5 第三步:正式开始新原子**开发

2.5.1 拉取 chao**lade-exec-middleware 项目代码

  • middleware 项目:
    • 包含 Nginx、Redis 等中间件相关实验核心代码。
  • 项目地址:
    • https://github/chao**lade-io/chao**lade-exec-middleware
2.5.2 新建 redis 目录

该目录放置 Redis 原子**核心代码

mkdir chao**lade-exec-middleware/exec/redis

2.5.3 新建 redis.go 文件

package redisimport (&34;)type RedisCommandSpec struct {spec.BaseExpModelCommandSpec}func (*RedisCommandSpec) Name() string {return &34;}func (*RedisCommandSpec) ShortDesc() string {return &34;}func (*RedisCommandSpec) LongDesc() string {return &34;}func NewRedisCommandSpec() spec.ExpModelCommandSpec {return &RedisCommandSpec{spec.BaseExpModelCommandSpec{ExpActions: []spec.ExpActionCommandSpec{NewCacheExpireActionSpec(),NewCacheLimitActionSpec(),},ExpFlags: []spec.ExpFlagSpec{},},}}2.5.4 Redis 原子**包含到 Model
  • model 目录位置:
    • chao**lade-exec-middleware/exec/model/ 目录
  • model 目录不同文件对应不同系统支持:
    • model_darwin.go 支持 Mac 系统
    • model_linux.go 支持 linux 系统
    • model_windows.go 支持 windows 系统
  • model 具体代码:

https://github/chao**lade-io/chao**lade-exec-middleware/tree/main/exec/model

package modelimport (&34;;&34;;&34;;)// GetAllExpModels returns the experiment model specs in the project.// Support for other project about chao**ladefunc GetAllExpModels() []spec.ExpModelCommandSpec {return []spec.ExpModelCommandSpec{nginx.NewNginxCommandSpec(),redis.NewRedisCommandSpec(),}2.5.5 Redis 原子**包含到编译文件
  • 具体文件:
    • 添加 Redis 到 chao**lade-exec-middleware/build/spec.go
  • 具体代码:

https://github/chao**lade-io/chao**lade-exec-middleware/blob/main/build/spec.go

...// getModels returns experiment models in the projectfunc getModels() *spec.Models {modelCommandSpecs := []spec.ExpModelCommandSpec{nginx.NewNginxCommandSpec(),redis.NewRedisCommandSpec(), // <== Redis相关}specModels := make([]*spec.Models, 0)for _, modeSpec := range modelCommandSpecs {flagSpecs := append(modeSpec.Flags(), model.GetSSHExpFlags()...)modeSpec.SetFlags(flagSpecs)specModel := util.ConvertSpecToModels(modeSpec, spec.ExpPrepareModel{}, &34;)specModels = append(specModels, specModel)}return util.MergeModels(specModels...)}...2.5.6 开发具体原子**
  • 缓存过期实验:

https://github/chao**lade-io/chao**lade-exec-middleware/blob/main/exec/redis/redis_cache_expire.go

  • 缓存内存限制实验:

https://github/chao**lade-io/chao**lade-exec-middleware/blob/main/exec/redis/redis_cache_limit.go

2.6 第四步:使用 Goland 本地调试,有 bug 或优化再次开发调试

2.6.1 搭建准备 Redis 服务
  • 参考相关文档:
    • https://redis.io/docs/getting-started/
2.6.2 使用 Goland Debug
  • 官方文档:
    • https://www.jetbrains/help/go/debugging-code.html

1) 打开 main.go 点击三角按钮,选择 Modify Run Configuration...

2) 修改 debug 配置:详细使用可以查看 Goland 官方文档

3) 执行 Debug *作:详细使用可以查看 Goland 官方文档

2.7 第五步:本地编译并替换测试环境旧编译文件

2.7.1 参考官方文档执行编译

1) 如果在 mac 系统上,编译当前系统的版本,请执行:

make build_darwin

2) 如果想在 mac 系统上,编译 linux 系统 x86 架构版本,请执行:

make build_linux

3) 如果想在 mac 系统上,编译 linux 系统 arm 架构版本,请执行:

make build_linux_arm

说明:其他系统编译说明参考官方文档

https://github/chao**lade-io/chao**lade/blob/master/README_CN.md

2.7.2 编译后文件存放在 target 目录中

2.7.3 测试环境替换为新编译文件

将测试服务器 chao**lade 目录以下文件替换为新版本:

  • chao**lade-1.7.2/**n/chaos_middleware
  • chao**lade-1.7.2/yaml/chao**lade-middleware-spec-1.7.2.yaml

2.8 第六步:测试环境测试直至通过

2.8.1 测试模拟缓存过期实验

1) 执行实验:

示例2:expire all keys only when the new expiry is greater than current oneblade create redis cache-expire --addr 192.168.56.101:6379 --password 123456 --option GT --expiry 1m

2) 验证实验结果:

34;test2& 实验后示例:set maxmemory to 256Mblade create redis cache-limit --addr 192.168.56.101:6379 --password 123456 --size 256M

2) 验证实验结果:

34;maxmemory&34;0& 实验后34;maxmemory&34;256000000& commitgit commit -s -m &34;# pushgit push origin dev2.9.2 登录 GitHub 使用 dev 分支创建和提交 PR2.9.3 提交 PR 后准备** chao**lade 文档贡献

https://chao**lade.io/docs/1.7.0/community/docs/

2.10 第八步:PR 审查直至审查通过

2.11 第九步:PR 合并至 main,新增原子**贡献成功

以上就是养老基金是什么的内容分享,希望对大家有用。