#分布式部署
执行安装部署前,请以yashan用户登录192.168.1.2服务器,并进入/home/yashan/install安装目录。
$ cd /home/yashan/install
# 典型规格安装
典型规格为3主机,1个MN组,2个CN,1个DN组(DN组和MN组均为1主2备)。
# Step1: 生成部署文件
执行yasboot package命令生成配置文件,命令详细参数可查阅yasboot。
其中,--cluster指定为要部署的数据库集群名称,该名称也将作为集群中所有节点上初始创建数据库的名称(database name),--port指定SSH服务端口,--install-path指定数据库安装路径,--data-path指定数据存放目录,--begin-port指定第一个CN节点上数据库监听端口,--mn/cn/dn分别指定MN节点/CN节点/DN组-节点数量。
$ ./bin/yasboot package de gen --cluster yashandb -u yashan -p password --ip 192.168.1.2,192.168.1.3,192.168.1.4 --port 22 --install-path /data/yashan/yasdb_home --data-path /data/yashan/yasdb_data --begin-port 1688 --mn 3 --cn 2 --dn 1-3
- 上一步骤执行完毕后,当前目录下将生成yashandb.toml和hosts.toml两个配置文件,yashandb.toml为数据库集群的配置文件,hosts.toml为主机的配置文件,可手动修改,但不建议删除文件中任何行,否则可能导致后续安装过程报错,或者所搭建的环境后续无法进行扩展配置。
-rw-------. 1 yashan yashan 444 Aug 31 16:27 hosts.toml
-rw-------. 1 yashan yashan 708 Aug 31 16:27 yashandb.toml
# 以下内容以实际展示结果为准
cluster = "yashandb" # 安装后修改也不会生效,除非重新安装
create_simple_schema = false # 为true部署完会执行示例的sql,若改为true需要在deploy时指定sys-password参数
deploy_mode = "MINI" # 分布式的部署模式
uuid = "64f1568f4f6b033e58a015a833f0ad9e" # 系统自动生成,不建议修改
yas_type = "DE" # 部署模式,安装后修改也不会生效,除非重新安装
[[group]]
group_type = "mn" # 节点组类型,安装后修改也不会生效,除非重新安装
name = "mng1" # 节点组名称,安装后修改也不会生效,除非重新安装
[group.config] # 可配置所有建库参数,不配置时采用默认值
CHARACTER_SET = "utf8"
ISARCHIVELOG = true
REDO_FILE_NUM = 4
REDO_FILE_SIZE = "128M"
[[group.node]] # 节点配置
data_path = "/data/yashan/yasdb_data" # 为DATA目录,安装后修改也不会生效,除非重新安装
hostid = "host0001" # 节点所在主机标识,安装后修改也不会生效,除非重新安装
role = 1 # 数据库主备角色,安装后修改也不会生效,除非重新安装
[group.node.config] # 可配置所有数据库参数,不配置时采用默认值,安装后修改也不会生效,除非重新安装
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.2:1679"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.2:1678"
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.2:1680"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/mn-1-1/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/mn-1-1/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0002"
role = 2
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.3:1679"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.3:1678"
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.3:1680"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/mn-1-2/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/mn-1-2/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0003"
role = 2
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.4:1679"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.4:1678"
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.4:1680"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/mn-1-3/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/mn-1-3/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
[[group]]
group_type = "cn"
name = "cng1"
[group.config]
CHARACTER_SET = "utf8"
ISARCHIVELOG = true
REDO_FILE_NUM = 4
REDO_FILE_SIZE = "128M"
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0002"
role = 1
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.3:1689"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.3:1688"
MAX_PARALLEL_WORKERS = 128
MAX_REACTOR_CHANNELS = 1
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.3:1690"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/cn-2-1/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/cn-2-1/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
WORK_AREA_HEAP_SIZE = "2M"
WORK_AREA_POOL_SIZE = "128M"
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0003"
role = 1
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.4:1689"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.4:1688"
MAX_PARALLEL_WORKERS = 128
MAX_REACTOR_CHANNELS = 1
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.4:1690"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/cn-2-2/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/cn-2-2/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
WORK_AREA_HEAP_SIZE = "2M"
WORK_AREA_POOL_SIZE = "128M"
[[group]]
group_type = "dn"
name = "dng1"
[group.config]
CHARACTER_SET = "utf8"
ISARCHIVELOG = true
REDO_FILE_NUM = 4
REDO_FILE_SIZE = "128M"
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0003"
role = 1
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.4:1699"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.4:1698"
MAX_PARALLEL_WORKERS = 512
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.4:1700"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/dn-3-1/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/dn-3-1/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
WORK_AREA_HEAP_SIZE = "2M"
WORK_AREA_POOL_SIZE = "128M"
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0001"
role = 2
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.2:1699"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.2:1698"
MAX_PARALLEL_WORKERS = 512
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.2:1700"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/dn-3-2/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/dn-3-2/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
WORK_AREA_HEAP_SIZE = "2M"
WORK_AREA_POOL_SIZE = "128M"
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0002"
role = 2
[group.node.config]
DATA_BUFFER_SIZE = "256M"
DB_BLOCK_SIZE = "8K"
DDL_LOCK_TIMEOUT = 60
DEFAULT_TABLE_TYPE = "LSC"
DICTIONARY_CACHE_SIZE = 20
DIN_ADDR = "192.168.1.3:1699"
DSTB_POOL_SIZE = 10
LARGE_POOL_SIZE = "32M"
LISTEN_ADDR = "192.168.1.3:1698"
MAX_PARALLEL_WORKERS = 512
MAX_SESSIONS = 1024
OPEN_CURSORS = 310
REDO_BUFFER_SIZE = "8M"
REPLICATION_ADDR = "192.168.1.3:1700"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/dn-3-3/run"
RUN_LOG_LEVEL = "DEBUG"
SHARE_POOL_SIZE = "256M"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.0.2/log/yashandb/dn-3-3/slow"
SQL_POOL_SIZE = 45
TRANSACTION_LOCK_TIMEOUT = 300
UNDO_RETENTION = 300
WORK_AREA_HEAP_SIZE = "2M"
WORK_AREA_POOL_SIZE = "128M"
请参考数据库配置调优和自身环境配置调整上述参数。如所安装环境为高可用的Raft集群(自动选举),还需参考高可用。
# Step2: 执行安装
$ ./bin/yasboot package install -t hosts.toml -i yashandb-23.1.0.2-linux-x86_64.tar.gz
# Step3: 数据库部署
- 执行部署命令。
$ ./bin/yasboot cluster deploy -t yashandb.toml
- 生效环境变量(此步骤需以yashan用户登录到每个节点上执行)。
# 部署命令成功执行后将会在$YASDB_HOME目录下的conf文件夹中生成<<集群名称>>.bashrc环境变量文件
$ cd /data/yashan/yasdb_home/yashandb/23.1.0.2/conf
# 如~/.bashrc中已存在YashanDB相关的环境变量,将其清除
$ cat yashandb.bashrc >> ~/.bashrc
$ source ~/.bashrc
# Step4: 设置sys用户口令
YashanDB不提供系统初始口令,请通过yasboot工具设置集群内所有节点sys用户的密码。
$ ./bin/yasboot cluster password set -n newpasswd -c yashandb
# Step5:验证安装是否成功
- 执行查看数据库状态命令。
$ ./bin/yasboot cluster status -c yashandb -d
hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | data_path
-------------------------------------------------------------------------------------------------------------------------------------------------
host0001 | mn | 1-1:1 | 56961 | open | normal | primary | 192.168.1.2:1678 | /data/yashan/yasdb_data/mn-1-1
+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
| dn | 3-2:7 | 57029 | open | normal | standby | 192.168.1.2:1698 | /data/yashan/yasdb_data/dn-3-2
----------+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
host0002 | mn | 1-2:2 | 57024 | open | normal | standby | 192.168.1.3:1678 | /data/yashan/yasdb_data/mn-1-2
+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
| cn | 2-1:4 | 57024 | open | normal | primary | 192.168.1.3:1688 | /data/yashan/yasdb_data/cn-2-1
+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
| dn | 3-3:8 | 57016 | open | normal | standby | 192.168.1.3:1698 | /data/yashan/yasdb_data/dn-3-3
----------+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
host0003 | mn | 1-3:3 | 57021 | open | normal | standby | 192.168.1.4:1678 | /data/yashan/yasdb_data/mn-1-3
+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
| cn | 2-2:5 | 57021 | open | normal | primary | 192.168.1.4:1688 | /data/yashan/yasdb_data/cn-2-2
+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
| dn | 3-1:6 | 57021 | open | normal | primary | 192.168.1.4:1698 | /data/yashan/yasdb_data/dn-3-1
----------+-----------+--------+-------+-----------------+-----------------+---------------+--------------------+--------------------------------
- 使用yasboot工具连接数据库,查看实例状态。
$ ./bin/yasboot sql -d sys/password@192.168.1.3:1688
SQL> SELECT STATUS FROM V$INSTANCE;
STATUS
-------------
OPEN
SQL> SELECT database_name FROM v$database;
DATABASE_NAME
----------------------------------------------------------------
yashandb
如连接报错,或执行SQL语句报错,请根据错误提示信息检查安装步骤,或咨询我们的技术支持。
# Step6:创建数据库用户(可选)
使用yasql工具连接数据库并创建sales用户。
$ ./bin/yasql sys/password@192.168.1.3:1688
SQL> CREATE USER sales IDENTIFIED BY sales;
SQL> GRANT CONNECT TO SALES;