验证LUN保护组一致性脚本(MySQL)

由于自定义脚本非eReplication提供,脚本的正确性需要脚本提供方进行保证。在配置脚本前,请确认该脚本已通过测试验证。

验证和调试脚本时,测试过程中会重复冻结和解冻数据库,会影响现有业务,建议您新建一个非业务MySQL数据库进行验证。

部署Server组件

详情请参见软件包方式安装eReplication Server(Linux)

部署Agent组件

详情请参见安装eReplication Agent(保护各类应用系统时)。选用SUSE操作系统进行Agent组件安装。

Agent组件与Server组件不能够安装在同一个虚拟机上。

部署expect组件(非LVM场景下)

  1. 安装tcl组件

    安装过程中,除了以下三个步骤外,其他参数均选择默认参数即可。

    1. 使用浏览器,打开“https://www.activestate.com/activetcl/downloads”页面。选择Linux(x86_64)平台类型的8.6.7.0版本进行下载。

    2. 将软件包上传至部署虚拟机,执行install.sh命令进行安装。
    3. 安装过程中,需要接受License,输入“A”。显示如下:
      Accept License [yes] => 'A' >>A
    4. 当询问是否需要下载IDE时,输入“n”。显示如下
      Do you want to download a free trial of Komodo IDE? [Y/n] 
      n     
  2. 安装gcc组件。

    以SuSE操作系统为例,执行which gcc命令,查看是否已经存在gcc组件。

    • 已经存在gcc组件,则不需要再进行安装。
    • 没有安装,参考以下步骤进行安装:
      #添加zypper安装源 
      zipper as file://media/<path> iso 
      #搜索需要安装的软件包是否能够找到 
      zypper se gcc-c++ 
      zypper se gcc 
      #安装需要的软件包 
      zypper insall gcc-c++ 
      zypper install gcc     
  3. 编译安装expect组件。

    使用浏览器打开“https://sourceforge.net/projects/expect/files/Expect/5.45.4/”界面,下载expect5.45.4.tar.gz源码包。将文件上传到部署虚拟机,依次执行以下命令:

    ./configure --with-tclconfig=/opt/ActiveTcl-8.6/lib/ --with-tkconfig=/opt/ActiveTcl-8.6/lib/ 
    make 
    make install     
  4. 以“root”用户身份登录生产应用服务器。
  5. 将文件存放在“/home/rdadmin/Agent/sbin/thirdparty/”目录下,文件系统权限需要满足的要求如表1所示。配置详情介绍请参见表2
    表1 文件系统权限要求

    文件

    权限

    作用

    blanket.sh

    rdadmin: rdadmin 755

    阵列操作公共脚本,在mysqlstart.sh/mysqlstop.sh中引用,需要可执行权限。

    mysql.conf

    rdadmin: rdadmin 644

    mysql配置文件,不需要可执行权限。

    mysqlstart.sh

    rdadmin: rdadmin 755

    mysql启动脚本,在server保护流程中配置该文件,需要可执行权限。

    mysqlstop.sh

    rdadmin: rdadmin 755

    mysql停止脚本,在server保护流程中配置该文件,需要可执行权限。

    mysqlquery.sh

    rdadmin: rdadmin 755

    mysql查询冻结状态脚本,在server保护流程中配置该文件,需要可执行权限。

    mysqlfreeze.sh

    rdadmin: rdadmin 755

    mysql冻结数据库脚本,在server保护流程中配置该文件,需要可执行权限。

    mysqlthaw.sh

    rdadmin: rdadmin 755

    mysql解冻数据库脚本,在server保护流程中配置该文件,需要可执行权限。

    storage

    rdadmin: rdadmin 755

    封装阵列CLI命令下发的expect脚本,需要可执行权限。

    表2 配置项说明

    配置项

    配置说明

    MYSQL_USER

    Mysql数据库用户,默认为root用户,用于登录数据库执行冻结解冻等操作。

    MYSQL_PASSWORD

    Mysql数据库密码,用于登录数据库执行冻结解冻等操作。

    VG_NAME

    Mysql数据库使用的VG名称,用于挂载启动操作,未避免启动失败,请严格按照使用的VG名称配置。

    LV_NAME

    Mysql数据库使用的LV名称,用于挂载启动操作,未避免启动失败,请严格按照使用的LV名称配置。

    DATA_FILE_PATH

    Mysql数据库的数据目录。

    VOL_TYPE

    Mysql数据库使用的磁盘类型,0为简单卷,1为LVM。

    STORAGE_USER

    Mysql数据库使用的阵列用户名。

    STORAGE_PASSWORD

    Mysql数据库使用的阵列密码。

    STORAGE_LOCATION

    Mysql数据库使用的阵列IP。

    LUN_ID

    Mysql数据库使用的LUN ID。

    配置示例:

    • LVM场景下:
      MYSQL_USER=root 
      MYSQL_PASSWORD=Psaaword 
      VOL_TYPE=1 
      DATA_FILE_PATH=/var/lib/mysql 
       
      [Simple Volume] 
      STORAGE_USER= 
      STORAGE_PASSWORD= 
      STORAGE_LOCATION= 
      LUN_ID=100 
       
      [LVM] 
      VG_NAME=vg_mysql 
      LV_NAME=lv_mysql 
           
    • 非LVM场景下:
      MYSQL_USER=root 
      MYSQL_PASSWORD=Password 
      VOL_TYPE=0 
      DATA_FILE_PATH=/var/lib/mysql 
       
      [Simple Volume] 
      STORAGE_USER=admin 
      STORAGE_PASSWORD=Password 
      STORAGE_LOCATION=10.10.10.10 
      LUN_ID=100 
       
      [LVM] 
      VG_NAME= 
      LV_NAME=     
  6. 完成mysql.conf配置以后,需要检查一下内容:

冻结脚本(非Windows)

  1. 以“root”用户身份登录生产应用服务器。
  2. 执行cd /home/rdadmin/Agent/sbin/thirtparty命令,进入脚本存放路径。
  3. 执行sh mysqlfreeze.sh 命令,执行冻结脚本。
  4. 执行su - mysql命令,切换为MySQL用户。
  5. 执行mysql -uroot -p password命令,登录数据库。

     
    Warning: Using a password on the command line interface can be insecure. 
    Welcome to the MySQL monitor.  Commands end with ; or \g. 
    Your MySQL connection id is 309 
    Server version: 5.6.22 MySQL Community Server (GPL) 
     
    Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 
     
    Oracle is a registered trademark of Oracle Corporation and/or its 
    affiliates. Other names may be trademarks of their respective 
    owners. 
     
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.     

  6. 执行show processlist;命令,查看MySQL数据库冻结状态。

     
    mysql> show processlist; 
    +-----+------+-----------+------+---------+------+-------+------------------------+ 
    | Id  | User | Host      | db   | Command | Time | State | Info                   | 
    +-----+------+-----------+------+---------+------+-------+------------------------+ 
    | 334 | root | localhost | NULL | Query   |    0 | init  | select 1 and sleep(60) | 
    +-----+------+-----------+------+---------+------+-------+------------------------+ 
    1 row in set (0.00 sec) 
         

    “Info”显示为“select 1 and sleep(60)”表示MySQL数据库已经开启冻结模式,脚本执行成功。

解冻脚本(非Windows)

  1. 以“root”用户身份登录生产应用服务器。
  2. 执行cd /home/rdadmin/Agent/sbin/thirtparty命令,进入脚本存放路径。
  3. 执行sh mysqlfreeze.sh 命令,执行冻结脚本。
  4. 执行sh mysqlthaw.sh命令,执行解冻脚本。
  5. 执行su - mysql命令,切换为MySQL用户。
  6. 执行mysql -uroot -p password命令,登录数据库。

     
    Warning: Using a password on the command line interface can be insecure. 
    Welcome to the MySQL monitor.  Commands end with ; or \g. 
    Your MySQL connection id is 309 
    Server version: 5.6.22 MySQL Community Server (GPL) 
     
    Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 
     
    Oracle is a registered trademark of Oracle Corporation and/or its 
    affiliates. Other names may be trademarks of their respective 
    owners. 
     
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.     

  7. 执行show processlist;命令,验证脚本是否执行成功。

     
    mysql> show processlist; 
    +-----+------+-----------+------+---------+------+-------+------------------+ 
    | Id  | User | Host      | db   | Command | Time | State | Info             | 
    +-----+------+-----------+------+---------+------+-------+------------------+ 
    | 334 | root | localhost | NULL | Query   |    0 | init  |                  | 
    +-----+------+-----------+------+---------+------+-------+------------------+ 
    1 row in set (0.00 sec) 
         

查询冻结状态脚本(非Windows)

  1. 以“root”用户身份登录生产应用服务器。
  2. 执行cd /home/rdadmin/Agent/tmp/命令,进入tmp目录。
  3. 执行sh mysqlquery.sh命令查询冻结状态脚本。

     
    linux2:/home/rdadmin/Agent/sbin/thirdparty # cat ../../tmp/RST.txt  
    0 
    linux2:/home/rdadmin/Agent/sbin/thirdparty #     

    查看“RST.txt”结果文档,如果显示为“0”,表示MySQL数据库已经开启冻结状态。如果显示为“1”,表示MySQL数据库已关闭冻结状态。

启动脚本(非Windows)

  1. 以“root”用户身份登录生产应用服务器。
  2. 执行cd /home/rdadmin/Agent/sbin/thirtparty命令,进入脚本存放路径。
  3. 执行sh mysqlstart.sh命令,启动脚本。

    180611 18:28:33 mysqld_safe Logging to '/var/lib/mysql/mysql01.err'. 
    180611 18:28:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql     

  4. 执行service mysql status命令,查看脚本状态。

    SUCCESS! MySQL running (25995)     

停止脚本(非Windows)

  1. 以“root”用户身份登录生产应用服务器。
  2. 执行cd /home/rdadmin/Agent/sbin/thirtparty命令,进入脚本存放路径。
  3. 执行sh mysqlstop.sh命令,停止脚本。
  4. 执行service mysql status命令,查看脚本状态。

     ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists


版权所有 © 华为技术有限公司