#数据库托管

YashanDB支持将某个单节点数据库或数据库集群托管到指定的集群内。

# 注意事项

  • 托管过程主要使用yasboot,请先了解该工具各命令选项含义及说明。
  • 对于遵照安装部署执行安装的数据库以及已完成托管的数据库,无需执行托管操作。

# 操作步骤

除特殊说明,以下步骤均在yasboot工具所在的环境上操作,且命令中的路径、用户、密码等需更换为实际值

  1. 生成服务器配置文件。

    通过执行如下命令生成服务器配置文件:

    $ ./bin/yasboot package config gen --cluster yashandb -u yashan -p password --ip ip1,ip2,...,ipn --install-path /var/database/yashan
    

    其中:

    -c,--cluster	生成的集群名称,这里可以任意取一个名称
    -u,--username	服务器ssh用户名
    -p,--password	服务器ssh登录密码
    -N,--no-password   如果用户配置了免密,请使用这个参数替代-p参数
    --ip			部署的ip地址,如果涉及到多个服务器,格式为:ip1,ip2,ip3
    --port			服务器ssh连接端口
    -i, --install-path	数据库安装路径(HOME目录),这里指定的路径是新版本的home目录,必须要是空目录
    -t, --yas-type		数据库部署的部署形态:
    * SE:单机部署
    * DE:分布式部署
    --db             单机db组及节点部署的节点规模,请根据实际主备情况调整此参数
    

    Note

    该命令会生成服务器hosts.toml和数据库yashandb.toml两个配置文件,将直接替换/home/yashan/intall目录下原有的hosts.toml及yashandb.toml文件,托管只需要hosts.toml服务器配置文件,yashandb.toml可以忽略。

  2. 部署主库,并将yasom和yasagent初始化。

    可通过执行如下命令进行初始化:

    $ ./bin/yasboot package install -i yashandb-22.2.0.9-linux-x86_64.tar.gz -t hosts.toml
    checking install package...
    install version: yashandb 22.2.0.9
    host0001 100% [====================================================================]    3s
    update host to yasom...
    

    其中:

    -i, --install-pkg  软件包文件本地路径
    -t, --toml 服务器配置文件,即hosts.toml
    
  3. 生成托管配置模板文件。

    可通过如下命令生成于目录中生成托管模板文件:

    $ ./bin/yasboot package config join-demo -t SE
    

    其中:

    -t, --type 托管集群的类型,SE表示单机,DE表示分布式
    
  4. 修改托管配置文件。

    如下为托管模板文件各参数描述,请根据实际情况修改模板文件中的参数值:

    cluster = "yashandb"  			--集群名称
    sys_password = "yasdb_123"  --数据库sys用户的密码
    yas_type = "SE"  			--部署形态
    
    [primary_config]
      manage_ip = "192.168.1.2"  								--主节点ip
      yasdb_home = "/opt/yasom/yashandb/yashandb"					--主节点的yasdb_home目录
      node_path = "/opt/yasom/yashandb/data/yashandb/db-1-1"		--主节点的yasdb_data目录
      node_id = "1-1:1"										--主节点的nodeid
    
    [[standby_config]]										--备节点按照主节点的示例修改
      manage_ip = "192.168.1.2"
      yasdb_home = "/opt/yasom/yashandb/yashandb"
      node_path = "/opt/yasom/yashandb/data/yashandb/db-1-2"
      node_id = "1-2:1"
    
    [[standby_config]]                    --备节点按照主节点的示例修改,没有就删除
      manage_ip = "192.168.1.2"
      yasdb_home = "/opt/yasom/yashandb/yashandb"
      node_path = "/opt/yasom/yashandb/data/yashandb/db-1-3"
      node_id = "1-3:1"
    
  5. 执行托管命令。

    通过执行如下命令进行托管操作:

    $ ./bin/yasboot cluster join -t SE --config join_demo.toml
    

    其中:

    -t, --type 托管集群的类型,SE表示单机,DE表示分布式
    -c, --config 托管配置文件
    

    命令执行结果如下所示:

    the cluster status is as follow:
    |key         |value
    |------------+------
    |clusterName |tp
    |version     |22.2.0.9
    
    the cluster status is as follow:
     hostid   | node_type | nodeid | pid   | instance_status | database_status | database_role | listen_address | data_path
    -------------------------------------------------------------------------------------------------------------------------------------------------
     host0001 | db        | 1-1:1  | 46689 | open            | normal          | primary       | 192.168.1.2:1688   | /data/yashan/yasdb_data/db-1-1
    ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------+------------------------------------
    Check success
    Are you sure you to add yasdb tp to yasom[yes/no]: yes
     type | uuid             | name             | hostid | index | status  | return_code | progress | cost
    -------------------------------------------------------------------------------------------------------
     task | e2007922a317a02c | JoinYasdbCluster | -      | tp    | SUCCESS | 0           | 100      | -
    ------+------------------+------------------+--------+-------+---------+-------------+----------+------
    task completed, status: SUCCESS
    
  6. 查看数据库状态。

    通过执行如下语句查看数据库状态:

    $ ./bin/yasboot cluster status -c yashandb -d
     hostid   | node_type | nodeid | pid   | instance_status | database_status | database_role | listen_address | data_path
    -----------------------------------------------------------------------------------------------------------------------------------------
     host0001 | db        | 1-1:1  | 46689 | open            | normal          | primary       | 192.168.1.2:1688   | /data/yashan/yasdb_data/db-1-1
    ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------+----------------------------
    
pdf-btn 下载文档
copy-btn 复制链接