搭建達夢DSC叢集

阿毛dd發表於2020-11-12

架構介紹

DMDSC 叢集是一個多例項、單資料庫的系統。 多個資料庫例項可以同時訪問、修改同一個資料庫的資料。 使用者可以登入叢集中的任意一個資料庫例項,獲得完整的資料庫服務。資料檔案、控制檔案在叢集系統中只有一份,不論有幾個節點,這些節點都平等地使用這些檔案。各個節點有自己獨立的聯機日誌和歸檔日誌。 這些檔案就儲存在共享儲存上
在這裡插入圖片描述

1.系統配置(centos7)

1.1.劃盤

磁碟規劃

磁碟組名稱作用大小
DCR存放叢集配置資訊100M
VOTE仲裁盤資訊100M
DATA儲存資料檔案40G
LOG存放日誌檔案5G
[root@dameng1 soft]# fdisk -l | grep sd
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4812799     2098176   82  Linux swap / Solaris
/dev/sda3         4812800   209715199   102451200   83  Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors.

1)輸入 fdisk /dev/sdb
2) 依次輸入 n > p > 1 > 回車> +100M > 回車,完成第一塊磁碟劃分
3) 依次輸入 n > p > 2 > 回車> +100M > 回車,完成第二塊磁碟劃分
4) 依次輸入 n > p > 3 > 回車> +40G > 回車,完成第三塊磁碟劃分
5) 依次輸入 n > p > 4 > 回車> 回車> 回車,完成第四塊磁碟劃分

[root@dameng1 soft]# fdisk -l | grep sd
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4812799     2098176   82  Linux swap / Solaris
/dev/sda3         4812800   209715199   102451200   83  Linux
Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors
/dev/sdb1            2048      206847      102400   83  Linux
/dev/sdb2          206848      411647      102400   83  Linux
/dev/sdb3          411648     4605951     2097152   83  Linux
/dev/sdb4         4605952    83886079    39640064   83  Linux
  1. 編輯vi /etc/udev/rules.d/60-raw.rules 檔案,增加以下語句:
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdb3", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdb4", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="raw[1-4]", OWNER="dmdba", GROUP="dinstall", MODE="660"

注意:官方給的盤許可權為root:root , 安裝是沒有問題的,但是後面使用過程中啟動會報許可權不足,需要修改為dmdba。
重啟載入udev或者
/sbin/udevadm trigger --type=devices --action=change /sbin/udevadm control --reload

1.2.建立dcr配置檔案dmdcr_cfg.ini

vi /dm/data/dmdcr_cfg.ini
DCR_N_GRP = 3
DCR_VTD_PATH = /dev/raw/raw2
DCR_OGUID = 63635
[GRP]
DCR_GRP_TYPE = CSS
DCR_GRP_NAME = GRP_CSS
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_CSS]
DCR_EP_NAME = CSS0
DCR_EP_HOST = 192.168.71.131
DCR_EP_PORT = 9341
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 192.168.71.132
DCR_EP_PORT = 9343
[GRP]
DCR_GRP_TYPE = ASM
DCR_GRP_NAME = GRP_ASM
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_ASM]
DCR_EP_NAME = ASM0
DCR_EP_SHM_KEY = 93360
DCR_EP_SHM_SIZE = 10
DCR_EP_HOST = 192.168.71.131
DCR_EP_PORT = 9349
DCR_EP_ASM_LOAD_PATH = /dev/raw
[GRP_ASM]
DCR_EP_NAME = ASM1
DCR_EP_SHM_KEY = 93361
DCR_EP_SHM_SIZE = 10
DCR_EP_HOST = 192.168.71.132
DCR_EP_PORT = 9351
DCR_EP_ASM_LOAD_PATH = /dev/raw
[GRP]
DCR_GRP_TYPE = DB
DCR_GRP_NAME = GRP_DSC
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_DSC]
DCR_EP_NAME = DSC0
DCR_EP_SEQNO = 0
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741
[GRP_DSC]
DCR_EP_NAME = DSC1
DCR_EP_SEQNO = 1
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9742

1.3.建立asm磁碟

[root@dameng1 ~]# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm/dmdbms/bin"         
[root@dameng1 ~]# /dm/dmdbms/bin/dmasmcmd   
DMASMCMD V8
ASM>create dcrdisk '/dev/raw/raw1' 'dcr'
[Trace]The ASM initialize dcrdisk /dev/raw/raw1 to name DMASMdcr
Used time: 14.098(ms).
ASM>create votedisk '/dev/raw/raw2' 'vote'
[Trace]The ASM initialize votedisk /dev/raw/raw2 to name DMASMvote
Used time: 18.603(ms).
ASM>create asmdisk '/dev/raw/raw3' 'LOG0'
[Trace]The ASM initialize asmdisk /dev/raw/raw3 to name DMASMLOG0
Used time: 13.575(ms).
ASM>create asmdisk '/dev/raw/raw4' 'DATA0'
[Trace]The ASM initialize asmdisk /dev/raw/raw4 to name DMASMDATA0
Used time: 0.717(ms).
ASM>init dcrdisk '/dev/raw/raw1' from '/dm/data/dmdcr_cfg.ini'identified by 'dameng'
[Trace]DG 126 allocate 4 extents for file 0xfe000002.
Used time: 67.942(ms).
ASM>init votedisk '/dev/raw/raw2' from '/dm/data/dmdcr_cfg.ini'
[Trace]DG 125 allocate 4 extents for file 0xfd000002.
Used time: 43.126(ms).
ASM>

1.4.準備叢集配置檔案(兩節點一樣)

DMASM 的兩個節點分別配置 dmdcr.ini, dmdcr_path 相同, dmasvrmal.ini 檔案內容也相同, dmdcr_seqo 分別為 0 和 1。

1.4.1.MAL 配置檔案

建立dmasvrmal.ini 檔案

[root@dameng1 ~]# cd /dm/data/
[root@dameng1 data]# vi dmasvrmal.ini
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741
[GRP_DSC]
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 192.168.71.131
MAL_PORT = 7236
[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 192.168.71.132
MAL_PORT = 7237

1.4.2.dmdcr.ini 配置檔案(2節點DMDCR_SEQNO改成1,路徑的dsc0改成dsc1)

[root@dameng1 data]# vi dmdcr.ini
DMDCR_PATH = /dev/raw/raw1
DMDCR_MAL_PATH =/dm/data/dmasvrmal.ini
DMDCR_SEQNO = 0
#ASM 重啟引數,命令列方式啟動
DMDCR_ASM_RESTART_INTERVAL = 0
DMDCR_ASM_STARTUP_CMD = /dm/dmdbms/bin/dmasmsvr dcr_ini=/dm/data/dmdcr.ini
#DB 重啟引數,命令列方式啟動
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD = /dm/dmdbms/bin/dmserver path=/dm/data/dsc1_config/dm.ini dcr_ini=/dm/data/dmdcr.ini

1.5.手工啟動 DMCSS、DMASM 服務程式

在兩個節點先後分別啟動 dmcss、dmasmsvr 程式。
先按順序手動啟動 dmcss 命令:

[root@dameng1 bin]# ./dmcss DCR_INI=/dm/data/dmdcr.ini 

再按順序手動啟動 dmasmsvr 命令:

[root@dameng1 bin]# ./dmasmsvr DCR_INI=/home/data/dmdcr.ini

1.6.建立ASM磁碟組

[root@dameng1 ~]# cd /dm/dmdbms/bin
[root@dameng1 bin]# ./dmasmtool DCR_INI=/dm/data/dmdcr.ini  
DMASMTOOL V8
#建立日誌磁碟組
ASM>create diskgroup 'DMLOG' asmdisk '/dev/raw/raw3'
Used time: 8.782(ms).
#建立資料磁碟組
ASM>create diskgroup 'DMDATA' asmdisk '/dev/raw/raw4'
Used time: 8.412(ms).

1.7.註冊叢集服務

1) 分別在2個節點註冊DMCSS和DMASM服務
以root使用者執行
節點DSC1:

#DMCSS:
[root@dameng1 bin]# /dm/dmdbms/script/root/dm_service_installer.sh -t dmcss -dcr_ini /dm/data/dmdcr.ini -p dsc1
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServicedsc1.service to /usr/lib/systemd/system/DmCSSServicedsc1.service.
建立服務(DmCSSServicedsc1)完成

#DMASM

[root@dameng1 bin]# /dm/dmdbms/script/root/dm_service_installer.sh -t dmasmsvr -dcr_ini /dm/data/dmdcr.ini -p dsc1 -y DmCSSServicedsc1
Created symlink from /etc/systemd/system/multi-user.target.wants/DmASMSvrServicedsc1.service to /usr/lib/systemd/system/DmASMSvrServicedsc1.service.
建立服務(DmASMSvrServicedsc1)完成

節點DSC2:
#DMCSS:

[root@dameng2 data]# /dm/dmdbms/script/root/dm_service_installer.sh -t dmcss -dcr_ini /dm/data/dmdcr.ini -p dsc2
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServicedsc2.service to /usr/lib/systemd/system/DmCSSServicedsc2.service.
建立服務(DmCSSServicedsc2)完成

#DMASM

[root@dameng2 data]# /dm/dmdbms/script/root/dm_service_installer.sh -t dmasmsvr -dcr_ini /dm/data/dmdcr.ini -p dsc2 -y DmCSSServicedsc2 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmASMSvrServicedsc2.service to /usr/lib/systemd/system/DmASMSvrServicedsc2.service.
建立服務(DmASMSvrServicedsc2)完成

2) 啟動DMCSS和DMASM 服務
節點1:

[root@dameng1 bin]# systemctl start DmCSSServicedsc1.service

節點2:

[root@dameng2 bin]# systemctl start DmCSSServicedsc2.service

節點1

[root@dameng1 bin]# systemctl start DmASMSvrServicedsc1.service 

節點2:

[root@dameng2 bin]# systemctl start DmASMSvrServicedsc2.service

2.建立資料庫

1)準備配置檔案dminit.ini

[root@dameng1 data]# vi /dm/data/dminit.ini
db_name = dsc
system_path = +DMDATA/data
system = +DMDATA/data/dsc/system.dbf
system_size = 128
roll = +DMDATA/data/dsc/roll.dbf
roll_size = 128
main = +DMDATA/data/dsc/main.dbf
main_size = 128
ctl_path = +DMDATA/data/dsc/dm.ctl
ctl_size = 8
log_size = 256
dcr_path = /dev/raw/raw1 #dcr 磁碟路徑,目前不支援 asm,只能是裸裝置
dcr_seqno = 0
auto_overwrite = 1
[DSC0] #inst_name 跟 dmdcr_cfg.ini 中 DB 型別 group 中 DCR_EP_NAME 對應
config_path = /dm/data/dsc0_config
port_num = 5236
mal_host = 192.168.71.131
mal_port = 9340
log_path = +DMLOG/log/dsc0_log01.log
log_path = +DMLOG/log/dsc0_log02.log
[DSC1] #inst_name 跟 dmdcr_cfg.ini 中 DB 型別 group 中 DCR_EP_NAME 對應
config_path = /dm/data/dsc1_config
port_num = 5236
mal_host = 192.168.71.132
mal_port = 9341
log_path = +DMLOG/log/dsc1_log01.log
log_path = +DMLOG/log/dsc1_log02.log
[root@dameng1 data]# ll
total 16
-rw-r--r--. 1 root root 150 Nov  6 07:16 dmasvrmal.ini
-rw-r--r--. 1 root root 961 Nov  6 07:22 dmdcr_cfg.ini
-rw-r--r--. 1 root root 408 Nov  6 07:25 dmdcr.ini
-rw-r--r--. 1 root root 868 Nov  6 07:40 dminit.ini
[root@dameng1 data]# chown -R dmdba.dinstall *
  1. 建立資料庫
[root@dameng1 bin]# su - dmdba
[dmdba@dameng1 ~]$ cd /dm/dmdbms/bin
[dmdba@dameng1 bin]$ ./dminit control=/dm/data/dminit.ini  
initdb V8
db version: 0x7000a
file dm.key not found, use default license!
License will expire on 2021-06-24
 log file path: +DMLOG/log/dsc0_log01.log
 log file path: +DMLOG/log/dsc0_log02.log
 log file path: +DMLOG/log/dsc1_log01.log
 log file path: +DMLOG/log/dsc1_log02.log
write to dir [+DMDATA/data/dsc].
create dm database success. 2020-11-06 07:41:20
  1. 啟動資料庫
[dmdba@dameng1 bin]$ ./dmserver /dm/data/dsc0_config/dm.ini dcr_ini=/dm/data/dmdcr.ini      
file dm.key not found, use default license!
version info: develop
Use normal os_malloc instead of HugeTLB
Use normal os_malloc instead of HugeTLB
DM Database Server x64 V8 1-1-88-20.06.24-123627-ENT  startup...
Database mode = 0, oguid = 0
License will expire on 2021-06-24

將dsc1_config傳到節點2

[dmdba@dameng1 ~]$ cd /dm/data/
[dmdba@dameng1 data]$ ll
total 16
-rw-r--r--. 1 dmdba dinstall 150 Nov  6 07:16 dmasvrmal.ini
-rw-r--r--. 1 dmdba dinstall 961 Nov  6 07:22 dmdcr_cfg.ini
-rw-r--r--. 1 dmdba dinstall 408 Nov  6 07:25 dmdcr.ini
-rw-r--r--. 1 dmdba dinstall 868 Nov  6 07:40 dminit.ini
drwxr-xr-x. 2 dmdba dinstall  87 Nov  6 07:41 dsc0_config
drwxr-xr-x. 2 dmdba dinstall  55 Nov  6 07:41 dsc1_config
[dmdba@dameng1 data]$ scp -r dsc1_config dmdba@192.168.83.132:/dm/data/
The authenticity of host '192.168.83.132 (192.168.83.132)' can't be established.
ECDSA key fingerprint is SHA256:8QOkseBMwz+jNPE42wK9fd4sNg09PwBgtx1+iONLHgY.
ECDSA key fingerprint is MD5:d1:99:6f:c5:eb:bc:9d:39:8f:d8:c3:89:4e:3f:12:dd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.83.132' (ECDSA) to the list of known hosts.
dmdba@192.168.83.132's password: 
dmmal.ini                                                                                                                                                                 100%  208   354.6KB/s   00:00    
dm.ini                                                                                                                                                                    100%   48KB   2.1MB/s   00:00    
sqllog.ini                                                                                                                                                                100%  479   938.1KB/s   00:00    
[dmdba@dameng1 data]$ 
  1. 註冊資料庫服務
    在2個節點分別註冊DM 資料庫服務:
[root@dameng1 bin]# /dm//dmdbms/script/root/dm_service_installer.sh -t dmserver -dm_ini /dm/data/dsc0_config/dm.ini -dcr_ini /dm/data/dmdcr.ini -p dsc1 -y DmASMSvrServicedsc1                     
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedsc1.service to /usr/lib/systemd/system/DmServicedsc1.service.
建立服務(DmServicedsc1)完成
[root@dameng2 data]# /dm//dmdbms/script/root/dm_service_installer.sh -t dmserver -dm_ini /dm/data/dsc1_config/dm.ini -dcr_ini /dm/data/dmdcr.ini -p dsc2 -y DmASMSvrServicedsc2 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedsc2.service to /usr/lib/systemd/system/DmServicedsc2.service.
建立服務(DmServicedsc2)完成
  1. 啟動資料庫
[root@dameng1 bin]# systemctl start DmServicedsc1
[root@dameng2 data]# systemctl start DmServicedsc2

3.連線資料庫測試

1)配置dm_svc.conf檔案

[root@dameng1 bin]# vim /etc/dm_svc.conf
dsc=(192.168.83.131:5236,192.168.83.132:5236)
SWITCH_TIME=(3)
SWITCH_INTERVAL=(100)
TIME_ZONE=(480)
LANGUAGE=(cn)

2)使用連線串連線

[root@dameng1 bin]# ./disql SYSDBA/SYSDBA@dsc

伺服器[192.168.83.131:5236]:處於普通開啟狀態
登入使用時間: 17.727(毫秒)
disql V8
SQL> 
SQL> select * from v$dsc_ep_info;

行號     EP_NAME EP_SEQNO    EP_GUID              EP_TIMESTAMP         EP_MODE      EP_STATUS
---------- ------- ----------- -------------------- -------------------- ------------ ---------
1          DSC0    0           323073163            323073660            Control Node OK
2          DSC1    1           323085767            323086196            Normal Node  OK

已用時間: 2.187(毫秒). 執行號:503.
SQL> 

相關文章