常规安装

  1. 下载:地址https://dev.mysql.com/downloads/mysql/5.7.html#downloads
  2. 选择对应5.7的版本,下载并解压到指定目录 tar -xvf mysql-5.7.32-linux-glibc2.12-x86_64.tar(在进一步-zxvf解压后面的文件) 我安装在:/data/util/mysql/mysql57
  3. 创建mysql配置文件 vim /etc/my.cnf

    1. [mysqld]
    2. bind-address=0.0.0.0
    3. port=3306
    4. user=mysql
    5. #安装目录
    6. basedir=/data/util/mysql/mysql57
    7. #数据目录
    8. datadir=/data/util/mysql/mysqlData
    9. socket=/tmp/mysql.sock
    10. log-error=/data/util/mysql/mysqlData/mysql.err
    11. pid-file=/data/util/mysql/mysqlData/mysql.pid
    12. #character config
    13. character_set_server=utf8mb4
    14. symbolic-links=0
    15. explicit_defaults_for_timestamp=true
  4. 创建mysql用户组和用户并修改权限

    1. groupadd mysql
    2. useradd -r -g mysql mysql
    3. chown mysql:mysql -R /data/util/mysql/mysqlData/
  5. 进入mysql的bin目录 cd /data/util/mysql/mysql57/bin 初始化加载配置,

    1. ./mysqld --defaults-file=/etc/my.cnf --basedir=/data/util/mysql/mysql57 --datadir=/data/util/mysql/mysqlData --user=mysql --initialize

    此时便会在mysqlData文件夹中生成一堆文件
    image.png

  6. 查看密码 cat /data/util/mysql/mysqlData/mysql.err,将临时密码保存,后面在第一次登录修改密码的时候用的到

image.png

  1. 因为mysql的默认安装地址是/usr/local/mysql,而我们的目录是在/data/util/mysql/mysql57,所以需要对mysql的安装目录个数据目录进行一个修改,cd /data/util/mysql/mysql57/support-files 启动文件的配置。image.pngimage.png

  2. 先将mysql.server放置到/etc/init.d/mysql中

    1. cp /data/util/mysql/mysql57/support-files/mysql.server /etc/init.d/mysql
  3. 进入mysql的安装目录的bin目录启动

    1. service mysql start #stop是通知
  4. 启动成功后,对密码进行修改

    1. ./mysql -u root -p

    输完密码后看等否登录(show databases;看下是否有多个数据库名)
    备注:停止Mysql服务:进入/usr/bin 命令:./mysqladmin -uroot -p shutdown 输入密码 ```bash

SET PASSWORD = PASSWORD(‘123456’); ALTER USER ‘root’@’localhost’ PASSWORD EXPIRE NEVER; FLUSH PRIVILEGES;

use mysql #访问mysql库 update user set host = ‘%’ where user = ‘root’; #使root能再任何host访问 FLUSH PRIVILEGES;

如果是云服务器请在安全组开放其端口

  1. 参考链接地址:[https://blog.csdn.net/qq_37598011/article/details/93489404](https://blog.csdn.net/qq_37598011/article/details/93489404)
  2. <a name="FcBp1"></a>
  3. # docker-compose安装
  4. 1. 编写docker-compose.yml文件

version: ‘3.1’ services: mysql: image: mysql:5.7 #到dockerhub找到你要的镜像版本 container_name: mysql5.7 privileged: true #一定要设置为true,不然数据卷可能挂载不了,启动不起 ports:

  1. - 3306:3306
  2. environment:
  3. MYSQL_USER: admin
  4. MYSQL_PASSWORD: 123456
  5. MYSQL_ROOT_PASSWORD: xxxx #root用户的密码
  6. TZ: Asia/Shanghai
  7. command:
  8. --character-set-server=utf8mb4
  9. --collation-server=utf8mb4_general_ci
  10. --explicit_defaults_for_timestamp=true
  11. --lower_case_table_names=1
  12. --max_allowed_packet=128M
  13. --sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO"
  14. volumes:
  15. - ./data:/var/lib/mysql
  16. - ./conf/my.cnf:/etc/my.cnf
  17. restart: always

version: “3” services: mysql-master: image: mysql:5.7 container_name: mysql_master ports:

  1. - 3307:3306
  2. volumes:
  3. - ./volume/mysql-master:/var/lib/mysql
  4. - ./volume/etc/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
  5. environment:
  6. MYSQL_ROOT_PASSWORD: 123456
  7. MYSQL_USER: admin
  8. MYSQL_PASSWORD: 123456
  9. restart: unless-stopped
  1. 2. 编写完成后,后台方式启动 docker-compose up -d
  2. 2. docker ps 找到容器id docker exec -it id bash 进入容器内
  3. 2. 执行以下脚本

mysql -u root -p #以root用户登陆进去,创建admin用户

create user ‘admin’@’%’ identified by ‘123456’; grant all privileges on . to ‘admin’@’%’ identified by ‘123456’; flush privileges;

################# 新建用户后,使用admin登陆

mysql -u admin -p 能成功连接即可

  1. 查看数据存储位置:show GLOBAL VARIABLES LIKE '%datadir%' 默认存放位置 /var/lib/mysql/
  2. <a name="um00Y"></a>
  3. ### 时区问题
  4. ```bash
  5. mysql> show variables like "%time_zone%";
  6. +------------------+--------+
  7. | Variable_name | Value |
  8. +------------------+--------+
  9. | system_time_zone | UTC |
  10. | time_zone | SYSTEM |
  11. +------------------+--------+
  12. mysql> select now(); # 查看时间是否与现在一致,不一致的话记得修改mysqld.cnf追加配置
  1. [mysqld]
  2. pid-file = /var/run/mysqld/mysqld.pid
  3. socket = /var/run/mysqld/mysqld.sock
  4. datadir = /var/lib/mysql
  5. #log-error = /var/log/mysql/error.log
  6. # By default we only accept connections from localhost
  7. #bind-address = 127.0.0.1
  8. # Disabling symbolic-links is recommended to prevent assorted security risks
  9. symbolic-links=0
  10. #追加的
  11. default-storage-engine=INNODB
  12. character_set_server=utf8mb4
  13. innodb_default_row_format=DYNAMIC
  14. innodb_large_prefix=ON
  15. innodb_file_format=Barracuda
  16. innodb_log_file_size=2G
  17. sql_mode = NO_AUTO_VALUE_ON_ZERO
  18. # 时区+8个小时
  19. default-time_zone = '+8:00'

docker-compose安装主从数据库

  1. 编写compose文件,配置相应的cnf和创建对应的挂在目录。启动 docker-compose up -d

    1. version: "3"
    2. services:
    3. mysql-master:
    4. image: mysql:5.7
    5. container_name: mysql_master
    6. ports:
    7. - 3307:3306
    8. volumes:
    9. - ./volume/mysql-master:/var/lib/mysql
    10. - ./volume/conf/mysql-ms/mysqld-master.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
    11. environment:
    12. MYSQL_ROOT_PASSWORD: 123456
    13. MYSQL_DATABASE: BIG
    14. MYSQL_USER: admin
    15. MYSQL_PASSWORD: 123456
    16. restart: unless-stopped
    17. mysql-slave:
    18. image: mysql:5.7
    19. container_name: mysql_slave
    20. ports:
    21. - 3308:3306
    22. volumes:
    23. - ./volume/mysql-slave:/var/lib/mysql
    24. - ./volume/conf/mysql-ms/mysqld-slave.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf
    25. environment:
    26. MYSQL_ROOT_PASSWORD: 123456
    27. MYSQL_DATABASE: BIG
    28. MYSQL_USER: admin
    29. MYSQL_PASSWORD: 123456
    30. restart: unless-stopped

    mysqld-master.cnf

    1. [mysqld]
    2. #主数据库端ID号 唯一即可
    3. server_id = 1
    4. #开启二进制日志
    5. log-bin = mysql-bin
    6. #需要复制的数据库名,如果复制多个数据库,重复设置这个选项即可
    7. binlog-do-db = nacos
    8. binlog-do-db = xxl-job
    9. binlog-do-db = simone
    10. binlog-do-db = order
    11. binlog-do-db = user
    12. #将从服务器从主服务器收到的更新记入到从服务器自己的二进制日志文件中
    13. log-slave-updates
    14. #控制binlog的写入频率。每执行多少次事务写入一次(这个参数性能消耗很大,但可减小MySQL崩溃造成的损失)
    15. sync_binlog = 1
    16. #这个参数一般用在主主同步中,用来错开自增值, 防止键值冲突
    17. auto_increment_offset = 1
    18. #这个参数一般用在主主同步中,用来错开自增值, 防止键值冲突
    19. auto_increment_increment = 1
    20. #二进制日志自动删除的天数,默认值为0,表示“没有自动删除”,启动时和二进制日志循环时可能删除
    21. expire_logs_days = 7
    22. #将函数复制到slave
    23. log_bin_trust_function_creators = 1

    mysqld-slave.cnf

    1. [mysqld]
    2. # 从数据库端ID号 唯一即可
    3. server_id = 2
    4. #开启二进制日志
    5. log-bin = mysql-bin
    6. #将从服务器从主服务器收到的更新记入到从服务器自己的二进制日志文件中
    7. log-slave-updates
    8. sync_binlog = 0
    9. #log buffer将每秒一次地写入log file中,并且log file的flush(刷到磁盘)操作同时进行。该模式下在事务提交的时候,不会主动触发写入磁盘的操作
    10. innodb_flush_log_at_trx_commit = 0
    11. #指定slave要复制哪个库
    12. replicate-do-db = nacos
    13. replicate-do-db = xxl-job
    14. replicate-do-db = simone
    15. replicate-do-db = order
    16. replicate-do-db = user
    17. #MySQL主从复制的时候,当Master和Slave之间的网络中断,但是Master和Slave无法察觉的情况下(比如防火墙或者路由问题)。Slave会等待slave_net_timeout设置的秒数后,才能认为网络出现故障,然后才会重连并且追赶这段时间主库的数据
    18. slave-net-timeout = 60
    19. #将函数复制到slave
    20. log_bin_trust_function_creators = 1

    image.png

  2. 分别登陆主从数据库给admin赋权 ``` mysql -u admin -p #输入密码后登陆

mysql> grant all privileges on . to ‘admin’@’%’ identified by ‘123456’; Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)

  1. 3. 执行完成后,将我们148:3306的数据库和数据分别拷贝到新的数据库中。(148:3306是我们技术leader用的库,我自己的业务库自己维护),复制完成后,开始着手配置工作。
  2. ![image.png](https://cdn.nlark.com/yuque/0/2021/png/771792/1619143717614-3d831014-92c2-436c-b410-58c67ec5ed42.png#clientId=u73dcc51d-2d54-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=401&id=u4df1e1de&margin=%5Bobject%20Object%5D&name=image.png&originHeight=401&originWidth=329&originalType=binary&ratio=1&rotation=0&showTitle=false&size=15610&status=done&style=none&taskId=uca702ff6-0ea5-4841-a0d2-588ff2bd5a2&title=&width=329)
  3. 4. 获取mysql-masterbinlog开始主从复制的地址(连接上主库输入)

mysql> show master status; +—————————+—————+———————————————————+—————————+—————————-+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +—————————+—————+———————————————————+—————————+—————————-+ | mysql-bin.000005 | 154 | nacos_conf,xxl-job,simone,order,user | | | +—————————+—————+———————————————————+—————————+—————————-+ 1 row in set (0.00 sec)

  1. 5. 在从库上执行

mysql> reset slave; Query OK, 0 rows affected (0.00 sec)

mysql> change master to -> master_host=’192.168.1.148’, -> master_user=’root’, -> master_port=3307, -> master_password=’123456’, -> master_log_file=’mysql-bin.000005’, -> master_log_pos=154; Query OK, 0 rows affected, 2 warnings (0.04 sec)

mysql> start slave; Query OK, 0 rows affected (0.00 sec)

  1. ```
  2. mysql> show slave status\G; #查看从库的装填
  3. *************************** 1. row ***************************
  4. Slave_IO_State: Waiting for master to send event
  5. Master_Host: 192.168.1.148
  6. Master_User: root
  7. Master_Port: 3307
  8. Connect_Retry: 60
  9. Master_Log_File: mysql-bin.000005
  10. Read_Master_Log_Pos: 154
  11. Relay_Log_File: aa9cf29d7f05-relay-bin.000002
  12. Relay_Log_Pos: 320
  13. Relay_Master_Log_File: mysql-bin.000005
  14. Slave_IO_Running: Yes #执行io线程必须为yes
  15. Slave_SQL_Running: Yes #执行sql线程必须为yes
  16. Replicate_Do_DB: nacos_conf,xxl-job,simone,order,user
  17. Replicate_Ignore_DB:
  18. Replicate_Do_Table:
  19. Replicate_Ignore_Table:
  20. Replicate_Wild_Do_Table:
  21. Replicate_Wild_Ignore_Table:
  22. Last_Errno: 0
  23. Last_Error:
  24. Skip_Counter: 0
  25. Exec_Master_Log_Pos: 154
  26. Relay_Log_Space: 534
  27. Until_Condition: None
  28. Until_Log_File:
  29. Until_Log_Pos: 0
  30. Master_SSL_Allowed: No
  31. Master_SSL_CA_File:
  32. Master_SSL_CA_Path:
  33. Master_SSL_Cert:
  34. Master_SSL_Cipher:
  35. Master_SSL_Key:
  36. Seconds_Behind_Master: 0
  37. Master_SSL_Verify_Server_Cert: No
  38. Last_IO_Errno: 0
  39. Last_IO_Error:
  40. Last_SQL_Errno: 0
  41. Last_SQL_Error:
  42. Replicate_Ignore_Server_Ids:
  43. Master_Server_Id: 1
  44. Master_UUID: dcbc2673-a348-11eb-b069-0242c0a81003
  45. Master_Info_File: /var/lib/mysql/master.info
  46. SQL_Delay: 0
  47. SQL_Remaining_Delay: NULL
  48. Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
  49. Master_Retry_Count: 86400
  50. Master_Bind:
  51. Last_IO_Error_Timestamp:
  52. Last_SQL_Error_Timestamp:
  53. Master_SSL_Crl:
  54. Master_SSL_Crlpath:
  55. Retrieved_Gtid_Set:
  56. Executed_Gtid_Set:
  57. Auto_Position: 0
  58. Replicate_Rewrite_DB:
  59. Channel_Name:
  60. Master_TLS_Version:
  61. 1 row in set (0.00 sec)
  62. ERROR:
  63. No query specified

注意查看Slave_IO_Running | Slave_SQL_Running这两列必须为yes
本次用到的命令集合:

  1. create user 'admin'@'%' identified by '123456';
  2. grant all privileges on *.* to 'admin'@'%' identified by '123456';
  3. flush privileges;
  4. mysql -u admin -p
  5. mysql -u root -p
  6. grant replication slave on *.* to 'root'@'192.168.1.148' identified by '123456';
  7. stop slave;
  8. reset slave;
  9. change master to
  10. master_host='192.168.1.148',
  11. master_user='root',
  12. master_port=3307,
  13. master_password='123456',
  14. master_log_file='mysql-bin.000005',
  15. master_log_pos=154;
  16. start slave;
  17. show slave status\G;

至此,完成,后面每次修改、新增、删除(表/数据)都会同步到salve,以此来做备份。也可以用作主写从读来分摊主库的压力。

参考:
https://www.jianshu.com/p/40e8b7548f03
https://www.cnblogs.com/gl-developer/p/6170423.html

k8s

因为我目前开发环境是自己单节点部署了一台k8s,所以也就暂时没搞文件挂在比如NFS服务,直接类似于docker的方式挂在载宿主机上。ok直接进入部署的yml就好了

Deployment方式

Deployment

因为我这里使用了k8s中的密文传输,所以在此之前需要先建一个root账户的密码,与此同时再进行deploy之前也需要把对应宿主机conf的挂在文件放到指定位置,否则初始化容器的时候会报错说找不到对应文件

  1. apiVersion: apps/v1 #apiserver的版本
  2. kind: Deployment #副本控制器deployment,管理pod和RS
  3. metadata:
  4. namespace: prod
  5. name: mysql-master #deployment的名称,全局唯一
  6. spec:
  7. replicas: 1 #Pod副本期待数量
  8. selector:
  9. matchLabels: #定义RS的标签
  10. app: mysql-master #符合目标的Pod拥有此标签
  11. strategy: #定义升级的策略
  12. type: RollingUpdate #滚动升级,逐步替换的策略
  13. template: #根据此模板创建Pod的副本(实例)
  14. metadata:
  15. labels:
  16. app: mysql-master #Pod副本的标签,对应RS的Selector
  17. spec:
  18. containers: #Pod里容器的定义部分
  19. - name: mysql-master #容器的名称
  20. image: mysql:5.7 #容器对应的docker镜像
  21. volumeMounts: #容器内挂载点的定义部分
  22. - name: time-zone #容器内挂载点名称
  23. mountPath: /etc/localtime #容器内挂载点路径,可以是文件或目录
  24. - name: mysql-data
  25. mountPath: /var/lib/mysql #容器内mysql的数据目录
  26. - name: mysql-logs
  27. mountPath: /var/log/mysql #容器内mysql的日志目录
  28. - name: mysql-conf
  29. mountPath: /etc/mysql/mysql.conf.d/mysqld.cnf #mysql配置文件
  30. ports:
  31. - containerPort: 3306 #容器暴露的端口号
  32. env: #写入到容器内的环境容量
  33. - name: MYSQL_ROOT_PASSWORD #定义了一个mysql的root密码的变量
  34. #value: "123456" 我这里使用了k8s中的secret方式密文显示
  35. valueFrom:
  36. secretKeyRef:
  37. name: mysecret-mysql
  38. key: mysql-root-pwd
  39. volumes: #本地需要挂载到容器里的数据卷定义部分
  40. - name: time-zone #数据卷名称,需要与容器内挂载点名称一致
  41. hostPath:
  42. path: /etc/localtime #挂载到容器里的路径,将localtime文件挂载到容器里,可让容器使用本地的时区
  43. - name: mysql-data
  44. hostPath:
  45. path: /myvolume/mysql/master/data
  46. type: DirectoryOrCreate
  47. - name: mysql-logs
  48. hostPath:
  49. path: /myvolume/mysql/master/logs
  50. type: DirectoryOrCreate
  51. - name: mysql-conf
  52. hostPath:
  53. path: /myvolume/mysql/master/conf/mysqld.cnf
  54. type: FileOrCreate

service

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. labels:
  5. app: mysql-master
  6. name: mysql-master
  7. namespace: prod
  8. spec:
  9. type: NodePort
  10. ports:
  11. - port: 3306
  12. nodePort: 30010 #NodePort默认范围是30000-32767,会映射道容器的对应端口
  13. protocol: TCP
  14. targetPort: 3306
  15. selector:
  16. app: mysql-master

Secret

我这里选择base64进行加密,当然因为这是可逆的也会导致不安全,我这里只是做个演示

  1. # 配置secret
  2. echo -n "root" | base64 ---> cm9vdA==
  3. echo -n "123456" | base64 ---> MTIzNDU2
  4. apiVersion: v1
  5. kind: Secret
  6. metadata:
  7. name: mysecret-mysql
  8. namespace: prod
  9. type: Opaque
  10. data:
  11. mysql-user-name: cm9vdA==
  12. mysql-root-pwd: MTIzNDU2

StatefulSet方式(推荐)

statefulset

  1. apiVersion: apps/v1
  2. kind: StatefulSet
  3. metadata:
  4. name: mysql
  5. namespace: prod
  6. spec:
  7. serviceName: mysql-headless
  8. replicas: 1
  9. selector:
  10. matchLabels:
  11. app: mysql
  12. template:
  13. metadata:
  14. labels:
  15. app: mysql
  16. spec:
  17. containers:
  18. - name: mysql-container
  19. image: mysql:5.7
  20. ports:
  21. - containerPort: 3306
  22. volumeMounts:
  23. - name: time-zone
  24. mountPath: /etc/localtime
  25. - name: mysql-data
  26. mountPath: /var/lib/mysql
  27. - name: mysql-logs
  28. mountPath: /var/log/mysql
  29. - name: mysql-conf
  30. mountPath: /etc/mysql/mysql.conf.d/mysqld.cnf #mysql配置文件
  31. env: #写入到容器内的环境容量
  32. - name: MYSQL_ROOT_PASSWORD #定义了一个mysql的root密码的变量
  33. valueFrom:
  34. secretKeyRef:
  35. name: mysecret-mysql
  36. key: mysql-root-pwd
  37. volumes: #本地需要挂载到容器里的数据卷定义部分
  38. - name: time-zone #数据卷名称,需要与容器内挂载点名称一致
  39. hostPath:
  40. path: /etc/localtime #挂载到容器里的路径,将localtime文件挂载到容器里,可让容器使用本地的时区
  41. - name: mysql-data
  42. hostPath:
  43. path: /root/project-server/backend/mysql/mysql-master/volume/data
  44. type: DirectoryOrCreate
  45. - name: mysql-logs
  46. hostPath:
  47. path: /root/project-server/backend/mysql/mysql-master/volume/logs
  48. type: DirectoryOrCreate
  49. - name: mysql-conf
  50. hostPath:
  51. path: /root/project-server/backend/mysql/mysql-master/volume/conf/mysqld.cnf
  52. type: FileOrCreate

service

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. labels:
  5. app: mysql
  6. name: mysql-headless
  7. namespace: prod
  8. spec:
  9. type: NodePort
  10. ports:
  11. - port: 3306
  12. nodePort: 30001 #NodePort默认范围是30000-32767,会映射道容器的对应端口
  13. protocol: TCP
  14. targetPort: 3306
  15. selector:
  16. app: mysql

Secret

同上

CorbJob数据库备份

一般我们会部署mysql数据库集群以此来达到高可用,但是以防万一别人删库跑路,所以还是定时做个数据库备份最好,k8s为我们提供了定时任务的解决方案,我们直接拿来主义即可。
需要说到的就是因为我们这里需要mysqldump所有选择了mysql镜像来使用此命令,当然commond命令是在我们容器内部进行的所以需要将内部的mysql-xxx.sql挂在到我们宿主机的指定位置即可。

  1. apiVersion: batch/v1
  2. kind: CronJob
  3. metadata:
  4. name: mysql-backup
  5. namespace: default
  6. spec:
  7. schedule: "0 0 * * *"
  8. jobTemplate:
  9. spec:
  10. completions: 1
  11. template:
  12. metadata: {}
  13. spec:
  14. #parallelism: 1 #标志并行运行的Pod的个数,默认为1,可以理解为同时运行的Pod数量.
  15. containers:
  16. - name: mysql-backup
  17. imagePullPolicy: IfNotPresent
  18. image: mysql:5.7
  19. env:
  20. - name: MYSQL_BACKUP_USER
  21. value: root
  22. - name: MYSQL_BACKUP_USER_PASSWORD
  23. valueFrom:
  24. secretKeyRef:
  25. name: mysecret-mysql
  26. key: mysql-root-pwd
  27. #command: ['bash','/backup/backup.sh']
  28. command:
  29. - /bin/sh
  30. - -c
  31. - |
  32. set -ex
  33. pwd &&
  34. ls &&
  35. if [ ! -d "/myvolume/mysql-backup/" ];then
  36. mkdir -p /myvolume/mysql-backup/
  37. fi &&
  38. mysqldump --host=192.168.1.110 -P 30010 --user=$MYSQL_BACKUP_USER \
  39. --password=$MYSQL_BACKUP_USER_PASSWORD \
  40. --routines --databases order \
  41. > /myvolume/mysql-backup/mysql-`date +"%Y%m%d_%H_%M"`.sql
  42. volumeMounts: #容器内挂载点的定义部分
  43. - name: mysql-backup
  44. mountPath: /myvolume/mysql-backup/ #容器内目录不存在
  45. restartPolicy: OnFailure #Never
  46. volumes:
  47. - name: mysql-backup
  48. hostPath:
  49. path: /myvolume/mysql-backup/
  50. type: DirectoryOrCreate

定时任务博客参考:https://dylanyang.top/post/2020/07/10/%E4%BD%BF%E7%94%A8cronjob%E5%AE%9A%E6%97%B6%E5%A4%87%E4%BB%BDmysql%E6%95%B0%E6%8D%AE%E5%BA%93/https://segmentfault.com/a/1190000014966962 官方corn表达式规则参考:
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/