YashanDB数据库主备高可用架构实践( 三 )

  • -u和-p,指定创建的用户yashan和密码
  • --port指定SSH服务端口,一般为22
  • --install-path指定数据库安装路径,指定为/usr/local/yashandb/yasdb_home
  • --data-path指定数据存放目录,指定为/usr/local/yashandb/yasdb_data
  • --begin-port指定数据库监听端口,默认1688
  • --node指定主备节点总数量,1主1备设置为2
  • 4)上一步骤执行完毕后,当前目录下将生成yashandb.toml和hosts.toml两个配置文件,yashandb.toml为数据库集群的配置文件,hosts.toml为主机的配置文件 。根据需要调整配置项,比如RUN_LOG_FILE_PATH和SLOW_LOG_FILE_PATH 。
    cluster = "yashandb"create_simple_schema = falseuuid = "655eb2496767a825e8dda1d6c4da4d4e"yas_type = "SE"[[group]]group_type = "db"name = "dbg1"[group.config]CHARACTER_SET = "utf8"ISARCHIVELOG = trueREDO_FILE_NUM = 4REDO_FILE_SIZE = "128M"[group.create_sql][[group.node]]data_path = "/usr/local/yashandb/yasdb_data"hostid = "host0001"role = 1[group.node.config]LISTEN_ADDR = "192.168.112.121:1688"REPLICATION_ADDR = "192.168.112.121:1689"RUN_LOG_FILE_PATH = "/usr/local/yashandb/yasdb_home/yashandb/log/yashandb/db-1-1/run"RUN_LOG_LEVEL = "INFO"SLOW_LOG_FILE_PATH = "/usr/local/yashandb/yasdb_home/yashandb/log/yashandb/db-1-1/slow"[[group.node]]data_path = "/usr/local/yashandb/yasdb_data"hostid = "host0002"role = 2[group.node.config]LISTEN_ADDR = "192.168.112.122:1688"REPLICATION_ADDR = "192.168.112.122:1689"RUN_LOG_FILE_PATH = "/usr/local/yashandb/yasdb_home/yashandb/log/yashandb/db-1-2/run"RUN_LOG_LEVEL = "INFO"SLOW_LOG_FILE_PATH = "/usr/local/yashandb/yasdb_home/yashandb/log/yashandb/db-1-2/slow"2.2.2 执行安装使用以下命令执行安装
    #./bin/yasboot package install -t hosts.toml -i /usr/local/src/yashandb-personal-23.1.1.100-linux-x86_64.tar.gz -fchecking install package...install version: yashandb 23.1.1.100host0001 100% [====================================================================]6shost0002 100% [====================================================================]6supdate host to yasom...注:指定参数-f不强制校验环境是否满足部署条件 , 否则会提示:
    192.168.112.121ip:192.168.112.121 cpu cores is less than 2ip:192.168.112.121 memroy is less than 4096MB2.2.3 数据库部署1)执行部署命令
    $ ./bin/yasboot cluster deploy -t yashandb.toml type | uuid| name| hostid | index| status| return_code | progress | cost ------------------------------------------------------------------------------------------------------------ task | 3190567c61c193bc | DeployYasdbCluster | -| yashandb | SUCCESS | 0| 100| 59------+------------------+--------------------+--------+----------+---------+-------------+----------+------task completed, status: SUCCESS2)生效环境变量
    #部署命令成功执行后将会在$YASDB_HOME目录下的conf文件夹中生成<<集群名称>>.bashrc环境变量文件$ cd /usr/local/yashandb/yasdb_home/yashandb/23.1.1.100/conf# 如~/.bashrc中已存在YashanDB相关的环境变量,将其清除$ cat yashandb.bashrc >> ~/.bashrc$ source ~/.bashrc3)开机后启动命令
    yashoot process yasom start -c yashandbyasboot process yasagent start -c yashandbyasboot cluster start -c yashandb2.2.4 修改sys用户口令通过yasboot工具设置集群内所有节点sys用户的密码
    #./bin/yasboot cluster password set -n xxxx -c yashandbtype | uuid| name| hostid | index| status| return_code | progress | cost ---------------------------------------------------------------------------------------------------------- task | ce83dacc3c2e4246 | YasdbPasswordSet | -| yashandb | SUCCESS | 0| 100| 2------+------------------+------------------+--------+----------+---------+-------------+----------+------task completed, status: SUCCESS2.2.5 验证安装1)查看数据库状态
    $ ./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| 16119 | open| normal| primary| 192.168.112.121:1688 | /usr/local/yashandb/yasdb_data/db-1-1 ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------------+--------------------------------------- host0002 | db| 1-2:2| 15363 | open| normal| standby| 192.168.112.122:1688 | /usr/local/yashandb/yasdb_data/db-1-2 ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------------+---------------------------------------


    推荐阅读