11月14日,YashanDB在“2024国产数据库创新生态大会”上正式发布YashanDB V23.3版本,定位为面向企业核心的通用数据库,具备1:1替代Oracle的能力。目前在用系统中oracle RAC存量还不少,需要国产数据库提供替换能力,并减少应用的修改。该版本已在官网全面开放下载,包含单机主备、共享集群、分布式多种产品形态 。
在四月份YCP考试时,用的是企业版本22.2 ,还没开放下载,也没法学习共享集群。现重新复习YashanDB的安装使用,
用的资源是VBOX下的openeuler两台虚拟机,YashanDB 23.2.4企业版。
学习个人版时已安装必须的软件包,系统参数已设置过,关闭了防火墙和selinux,配置用户root和yashan互信,不再重复记录。
操作系统版本
[root@yas2 ~]# cat /etc/os-release
NAME="openEuler"
VERSION="24.03 (LTS)"
ID="openEuler"
VERSION_ID="24.03"
PRETTY_NAME="openEuler 24.03 (LTS)"
ANSI_COLOR="0;31"
为系统添加共享磁盘,两块1G,分别用作 VOTE ,OCR,一块10G用作数据盘,加盘操作如下
重启虚拟机,确认两台机器上认到的共享盘UUID一致,第一台yas1
[root@yas1 udev]# /usr/lib/udev/scsi_id -g -u -d /dev/sdb
1ATA_VBOX_HARDDISK_VBf49fdfde-08b2987d
[root@yas1 udev]# /usr/lib/udev/scsi_id -g -u -d /dev/sdc
1ATA_VBOX_HARDDISK_VB42ee6ad4-7412f256
[root@yas1 udev]# /usr/lib/udev/scsi_id -g -u -d /dev/sdd
1ATA_VBOX_HARDDISK_VB863bac1f-366f29ff
第二台yas2
[root@yas2 udev]# /usr/lib/udev/scsi_id -g -u -d /dev/sdb
1ATA_VBOX_HARDDISK_VBf49fdfde-08b2987d
[root@yas2 udev]# /usr/lib/udev/scsi_id -g -u -d /dev/sdc
1ATA_VBOX_HARDDISK_VB42ee6ad4-7412f256
[root@yas2 udev]# /usr/lib/udev/scsi_id -g -u -d /dev/sdd
1ATA_VBOX_HARDDISK_VB863bac1f-366f29ff
为保证数据库性性能,调整进程的VMA上限
# sysctl -w vm.max_map_count=2000000
# echo "vm.max_map_count=2000000" >> /etc/sysctl.conf
绑定共享盘的别名
# cat /etc/udev/rules.d/yas.rules
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VBf49fdfde-08b2987d", SYMLINK+="yas/yasvote", OWNER="yashan", GROUP="YASDBA", MODE="0660"
KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB42ee6ad4-7412f256", SYMLINK+="yas/yasycr", OWNER="yashan", GROUP="YASDBA", MODE="0660"
KERNEL=="sd?1",BUS=="scsi", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="1ATA_VBOX_HARDDISK_VB863bac1f-366f29ff", SYMLINK+="yas/yasdata", OWNER="yashan", GROUP="YASDBA", MODE="0660"
激活udev并设置开机自启动
/sbin/udevadm control --reload-rules
systemctl status systemd-udevd.service
systemctl enable systemd-udevd.service
[root@yas1 rules.d]# ll /dev/yas*
lrwxrwxrwx 1 root root 3 Dec 11 12:38 /dev/yas/yasdata -> sdd
lrwxrwxrwx 1 root root 3 Dec 11 12:38 /dev/yas/yasvote -> sdb
lrwxrwxrwx 1 root root 3 Dec 11 12:38 /dev/yas/yasycr -> sdc
在两台服务器上分别执行以下命令,确认两台服务器上/dev/yas/yasdata、/dev/yas/yasvote和/dev/yas/yasycr对应的WWID是否一致。
对比两台服务器上的输出结果是否对应一致,简化只输出/dev/yas/yasycr
# /lib/udev/scsi_id --whitelisted --device=/dev/yas/yasdata
# /lib/udev/scsi_id --whitelisted --device=/dev/yas/yasvote
# /lib/udev/scsi_id --whitelisted --device=/dev/yas/yasycr
[root@yas2 ]# /lib/udev/scsi_id --whitelisted --device=/dev/yas/yasycr
1ATA VBOX HARDDISK VB42ee6ad4-7412f256
[root@yas1 ~]# /lib/udev/scsi_id --whitelisted --device=/dev/yas/yasycr
1ATA VBOX HARDDISK VB42ee6ad4-7412f256
下载安装,官方说发布的是23.3,这里的文件名是23.2.4
崖山安装包官方下载链接:https://download.yashandb.com/download
上传安装包到yashan用户目录下
mkdir install
cd install
tar xvf ../yashandb-23.2.4.100-linux-x86_64.tar.gz
....
[yashan@yas1 install]$ tree -L 1
.
├── admin
├── bin
├── conf
├── ext
├── gitmoduleversion.dat
├── hosts.toml
├── include
├── java
├── lib
├── LICENSE
├── om
├── plug-in
├── scripts
├── yashandb-23.2.4.100-linux-x86_64.tar.gz
├── yashandb.toml
└── yas.toml
11 directories, 6 files
生成安装配置文件,分别是hosts.toml,yashandb.toml
共享配置命令是package ce,单机是package se,分布式是package de ,–cluster 是集群名
[yashan@yas1 install]$ ./bin/yasboot package ce gen --cluster yashandb -u yashan -p admin@110 --ip 192.168.56.30,192.168.56.21 --port 22 --install-path /opt/yashan/yasdb_home --data-path /opt/yashan/yasdb_data --begin-port 2688 --node 2 --data /dev/yas/yasdata --vote /dev/yas/yasvote --ycr /dev/yas/yasycr
hostid | group | node_type | node_name | listen_addr | inter_connect | data_path
-------------------------------------------------------------------------------------------------------------
host0001 | ceg1 | ce | 1-1 | 192.168.56.30:2688 | 192.168.56.30:2689 | /opt/yashan/yasdb_data
----------+-------+-----------+-----------+--------------------+--------------------+------------------------
host0002 | ceg1 | ce | 1-2 | 192.168.56.21:2688 | 192.168.56.21:2689 | /opt/yashan/yasdb_data
----------+-------+-----------+-----------+--------------------+--------------------+------------------------
Generate config success
查看生成的配置文件,可以修改但不能删除行,cluster参数除非重装,否则修改不生效
[yashan@yas1 install]$ cat hosts.toml
uuid = "6759b2cf611e00a4b5a0c2b80b0ad41f"
cluster = "yashandb"
yas_type = "CE"
secret_key = "ed0233d93ea409a2"
add_yasdba = true
[om]
hostid = "host0001"
[om.config]
LISTEN_ADDR = "192.168.56.30:2675"
[[host]]
hostid = "host0001"
group = "yashan"
user = "yashan"
password = "admin@110"
ip = "192.168.56.30"
port = 22
path = "/opt/yashan/yasdb_home"
disks = ["/dev/yas/yasdata", "/dev/yas/yasvote", "/dev/yas/yasycr"]
[host.yasagent]
[host.yasagent.config]
LISTEN_ADDR = "192.168.56.30:2676"
[[host]]
hostid = "host0002"
group = "yashan"
user = "yashan"
password = "admin@110"
ip = "192.168.56.21"
port = 22
path = "/opt/yashan/yasdb_home"
disks = ["/dev/yas/yasdata", "/dev/yas/yasvote", "/dev/yas/yasycr"]
[host.yasagent]
[host.yasagent.config]
LISTEN_ADDR = "192.168.56.21:2676"
数据库实例参数
[yashan@yas1 install]$ cat yashandb.toml
cluster = "yashandb"
create_simple_schema = false
uuid = "6759b2cf611e00a4b5a0c2b80b0ad41f"
yas_type = "CE"
[[group]]
database_role = "primary"
group_type = "ce"
name = "ceg1"
[group.cedisk]
vote = "/dev/yas/yasvote"
ycr = "/dev/yas/yasycr"
[group.config]
CHARACTER_SET = "utf8"
ISARCHIVELOG = true
REDO_FILE_NUM = 4
REDO_FILE_SIZE = "128M"
[[group.diskgroup]]
au_size = "1M"
disk_size = ""
name = "DG0"
redundancy = "EXTERNAL"
yfs_force_create = false
[[group.diskgroup.failgroup]]
disk = ["/dev/yas/yasdata"]
name = "DG0_0"
[[group.node]]
data_path = "/opt/yashan/yasdb_data"
hostid = "host0001"
role = 1
[group.node.config]
CLUSTER_DATABASE = "TRUE"
CLUSTER_INTERCONNECT = "192.168.56.30:2689"
DATA_BUFFER_SIZE = "1G"
HA_ELECTION_TIMEOUT = 18
HA_HEARTBEAT_INTERVAL = 6
INTER_URL = "192.168.56.30:2788"
LISTEN_ADDR = "192.168.56.30:2688"
REDO_BUFFER_PARTS = 8
REDO_BUFFER_SIZE = "64M"
RUN_LOG_FILE_PATH = "/opt/yashan/yasdb_home/yashandb/23.2.4.100/log/yashandb/ce-1-1/run"
SHARE_POOL_SIZE = "1G"
SLOW_LOG_FILE_PATH = "/opt/yashan/yasdb_home/yashandb/23.2.4.100/log/yashandb/ce-1-1/slow"
SQL_POOL_PARTS = 8
[[group.node]]
data_path = "/opt/yashan/yasdb_data"
hostid = "host0002"
role = 2
[group.node.config]
CLUSTER_DATABASE = "TRUE"
CLUSTER_INTERCONNECT = "192.168.56.21:2689"
DATA_BUFFER_SIZE = "1G"
HA_ELECTION_TIMEOUT = 18
HA_HEARTBEAT_INTERVAL = 6
INTER_URL = "192.168.56.21:2788"
LISTEN_ADDR = "192.168.56.21:2688"
REDO_BUFFER_PARTS = 8
REDO_BUFFER_SIZE = "64M"
RUN_LOG_FILE_PATH = "/opt/yashan/yasdb_home/yashandb/23.2.4.100/log/yashandb/ce-1-2/run"
SHARE_POOL_SIZE = "1G"
SLOW_LOG_FILE_PATH = "/opt/yashan/yasdb_home/yashandb/23.2.4.100/log/yashandb/ce-1-2/slow"
SQL_POOL_PARTS = 8
[group.ycsconfig]
DISK_HB_KEEP_ALIVE = 30
LOG_LEVEL = "DEBUG"
LOG_NUMBER = 10
LOG_SIZE = "20M"
NETWORK_HB_TIMEOUT = 30
RESTART_INTERVAL = 30
RESTART_TIMES = 3
WAIT_STOP_FIN_TIME = 90
[group.yfsconfig]
SHM_POOL_SIZE = "2G"
SYS_AREA_SIZE = "1G"
YFS_PACKET_SIZE = "1M"
安装并部署数据库
[yashan@yas1 install]$ bin/yasboot package install -t hosts.toml -i ../yashandb-23.2.4.100-linux-x86_64.tar.gz
checking install package...
install version: yashandb 23.2.4.100
host0001 100% [====================================================================] 3s
host0002 100% [====================================================================] 3s
update host to yasom...
安装不成功时需要清理环境
[yashan@yas1 install]$ ./bin/yasboot cluster clean -c yashandb --purge
Are you sure you want to CLEAN cluster: [yashandb], AND ALL DATA WILL BE DELETED (-p/--purge is given)?
[yes/no]: yes
type | uuid | name | hostid | index | status | return_code | progress | cost
-----------------------------------------------------------------------------------------------------------
task | 07b73abc324692f8 | CleanYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 1
------+------------------+-------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@yas1 install]$ ./bin/yasboot cluster deploy -t yashandb.toml --yfs-force-create
type | uuid | name | hostid | index | status | return_code | progress | cost
------------------------------------------------------------------------------------------------------------
task | a1fa1e0dc35b1740 | DeployYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 109
------+------------------+--------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
查询集群状态,两个节点都是primary角色,即可以同时写入
[yashan@yas1 install]$ bin/yasboot cluster status -c yashandb -d
hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | data_path
-----------------------------------------------------------------------------------------------------------------------------------------------
host0001 | ce | 1-1:1 | 5487 | open | normal | primary | 192.168.56.30:2688 | /opt/yashan/yasdb_data/ce-1-1
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+-------------------------------
host0002 | ce | 1-2:2 | 5381 | open | normal | primary | 192.168.56.21:2688 | /opt/yashan/yasdb_data/ce-1-2
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+-------------------------------
修改数据库sys用户登录密码
[yashan@yas1 install]$ bin/yasboot cluster password set -n admin_110 -c yashandb
type | uuid | name | hostid | index | status | return_code | progress | cost
----------------------------------------------------------------------------------------------------------
task | e96a0ce1d309f6c8 | YasdbPasswordSet | - | yashandb | SUCCESS | 0 | 100 | 1
------+------------------+------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
连接数据库,确认数据文件、控制文件在共享存储DG0上
[yashan@yas1 install]$ yasql / as sysdba
YashanDB SQL Enterprise Edition Release 23.2.4.100 x86_64
Connected to:
YashanDB Server Enterprise Edition Release 23.2.4.100 x86_64 - X86 64bit Linux
SQL> select file_id,file_name from dba_data_files;
FILE_ID FILE_NAME
------------ ----------------------------------------------------------------
0 +DG0/dbfiles/system
1 +DG0/dbfiles/sysaux
2 +DG0/dbfiles/temp
3 +DG0/dbfiles/swap
4 +DG0/dbfiles/users
5 +DG0/dbfiles/undo1
6 +DG0/dbfiles/undo2
7 rows fetched.
SQL> show parameter CONTROL_FILES;
NAME VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
CONTROL_FILES ('+DG0/dbfiles/ctrlfile0', '+DG0/dbfiles/ctrlfile1', '+DG0/dbfiles/ctrlfile2')
1 row fetched.
每个节点有四个redo文件,每个大小256M
SQL> SELECT * FROM V$LOGFILE;
THREAD# ID NAME BLOCK_SIZE BLOCK_COUNT USED_BLOCKS SEQUENCE# STATUS
------- ------------ ---------------------------------------------------------------- ------------ --------------------- --------------------- ------------ ---------
1 0 +DG0/dbfiles/redo1 512 262144 41905 1 INACTIVE
1 1 +DG0/dbfiles/redo2 512 262144 1224 2 CURRENT
1 2 +DG0/dbfiles/redo3 512 262144 0 0 INACTIVE
1 3 +DG0/dbfiles/redo4 512 262144 0 0 INACTIVE
2 0 +DG0/dbfiles/redo5 512 262144 1 1 CURRENT
2 1 +DG0/dbfiles/redo6 512 262144 0 0 INACTIVE
2 2 +DG0/dbfiles/redo7 512 262144 0 0 INACTIVE
2 3 +DG0/dbfiles/redo8 512 262144 0 0 INACTIVE
8 rows fetched.
停止一个节点,
[yashan@yas1 install]$ yasboot node stop -n 1-1 -c yashandb
type | uuid | name | hostid | index | status | return_code | progress | cost
-----------------------------------------------------------------------------------------------------------
task | cd1be60b8a2a6d90 | StopYasdbNode | - | yashandb.1-1 | SUCCESS | 0 | 100 | 11
------+------------------+---------------+--------+--------------+---------+-------------+----------+------
task completed, status: SUCCESS
查询集群状态,节点1-1pid 为off ,只有切点1-2为open状态
[yashan@yas1 install]$ yasboot cluster status -c yashandb -d
hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | data_path
-----------------------------------------------------------------------------------------------------------------------------------------------
host0001 | ce | 1-1:1 | off | - | - | - | 192.168.56.30:2688 | /opt/yashan/yasdb_data/ce-1-1
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+-------------------------------
host0002 | ce | 1-2:2 | 6291 | open | normal | primary | 192.168.56.21:2688 | /opt/yashan/yasdb_data/ce-1-2
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+-------------------------------
[yashan@yas1 install]$ yasql test/admin_110@192.168.56.21:2688
YashanDB SQL Enterprise Edition Release 23.2.4.100 x86_64
Connected to:
YashanDB Server Enterprise Edition Release 23.2.4.100 x86_64 - X86 64bit Linux
[yashan@yas1 install]$ yasboot node start -c yashandb -n 1-1
type | uuid | name | hostid | index | status | return_code | progress | cost
------------------------------------------------------------------------------------------------------------
task | 2787e9d3f6732265 | StartYasdbNode | - | yashandb.1-1 | SUCCESS | 0 | 100 | 8
------+------------------+----------------+--------+--------------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@yas1 install]$ yasboot cluster status -c yashandb -d
hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | data_path
-----------------------------------------------------------------------------------------------------------------------------------------------
host0001 | ce | 1-1:1 | 9104 | open | normal | primary | 192.168.56.30:2688 | /opt/yashan/yasdb_data/ce-1-1
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+-------------------------------
host0002 | ce | 1-2:2 | 6291 | open | normal | primary | 192.168.56.21:2688 | /opt/yashan/yasdb_data/ce-1-2
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+-------------------------------
在共享存储模式下,单节点故障不影响业务的正常运行。