主机名 |
ip(私网) |
ip(外网) |
实例名 |
服务端口 |
心跳端口 |
守护监听端口 |
守护进程端口 |
dm-dw1 |
192.168.1.25 |
192.168.2.25 |
DMWAT |
5236 |
5238 |
5237 |
5239 |
dm-dw2 |
192.168.1.26 |
192.168.2.26 |
DMWAT2 |
5236 |
5238 |
5237 |
5239 |
dm-mon |
192.168.1.27 |
5239 |
192.168.1.25 dm-dw1 192.168.1.26 dm-dw2 192.168.1.27 dm-mon 192.168.2.25 dm-dw1-pub 192.168.2.26 dm-dw2-pub |
服务端口:对外提供数据库服务的端口
心跳端口:用于数据同步的端口
守护监听端口:数据守护监听数据库的端口
守护进程端口:datawatch收集数据守护信息的端口
#虚拟机无操作,仅修改了时区 timedatectl set-timezone Asia/Shanghai |
所有数据库节点均需要安装数据库软件
单实例静默安装示范
#组 groupadd dinstall #用户 useradd -g dinstall dmdba #目录 mkdir -p /opt/dm8 chown dmdba:dinstall /opt/dm8 #介质挂载 mount dm8_20210818_x86_rh6_64_ent_8.4.2.18_pack14.iso /mnt cd /mnt #安装 [dmdba@dm-mon mnt]$ ./DMInstall.bin -i Please select the installer's language (E/e:English C/c:Chinese) [E/e]: Extract install files.......... core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 31096 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 4096 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited The max number of open files is too little, suggest to set 65536 or more to number of open files. Welcome to DM DBMS Installer Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:n Installation Type: 1 Typical 2 Server 3 Client 4 Custom Please Input the number of the Installation Type [1 Typical]: Require Space: 1178M Please Input the install path [/home/dmdba/dmdbms]:/opt/dm8 No write permission! Please Input the install path [/home/dmdba/dmdbms]:/opt/dm8 Available Space:47G Please Confirm the install path(/opt/dm8)? (Y/y:Yes N/n:No) [Y/y]:y Pre-Installation Summary Installation Location: /opt/dm8 Require Space: 1178M Available Space: 47G Version Information: Expire Date: Installation Type: Typical Confirm to Install? (Y/y:Yes N/n:No): Confirm to Install? (Y/y:Yes N/n:No):y 2022-08-26 16:24:15 [INFO] Installing DM DBMS... 2022-08-26 16:24:15 [INFO] Installing BASE Module... 2022-08-26 16:24:17 [INFO] Installing SERVER Module... 2022-08-26 16:24:18 [INFO] Installing CLIENT Module... 2022-08-26 16:24:19 [INFO] Installing DRIVERS Module... 2022-08-26 16:24:19 [INFO] Installing MANUAL Module... 2022-08-26 16:24:19 [INFO] Installing SERVICE Module... 2022-08-26 16:24:20 [INFO] Move log file to log directory. 2022-08-26 16:24:20 [INFO] Installed DM DBMS completely. Please execute the commands by root: /opt/dm8/script/root/root_installer.sh End [dmdba@dm-mon mnt]$ exit logout [root@dm-mon soft]# /opt/dm8/script/root/root_installer.sh Move /opt/dm8/bin/dm_svc.conf to /etc Modify the files' mode of DM Server Create the DmAPService service Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service. Finished to create the service (DmAPService) Start the DmAPService service #环境变量 vi /home/dmdba/.bash_profile export PATH=$PATH:$DM_HOME/bin #增加上面环境变量 |
#初始化数据库 dminit PATH=/opt/dm8/data DB_NAME=dmwat INSTANCE_NAME=dmwat PORT_NUM=5236 PAGE_SIZE=32 EXTENT_SIZE=32 CHARSET=1 CASE_SENSITIVE=0 LENGTH_IN_CHAR=0 BLANK_PAD_MODE=1 #初次启动 dmserver /opt/dm8/data/dmwat/dm.ini ……. ctrl+c 退出 #配置服务后,可以用DmService 管理 DmServicedmwat start |
#登录,静默安装可以用以下方式登录 disql sysdba #切换到mount alter database mount; #添加归档路径 alter database add archivelog 'DEST=/opt/dm8/data/dmwat/arch,TYPE=local,FILE_SIZE=128,space_limit=0'; #开启归档 alter database archivelog; #开启数据库 alter database open; #查询归档状态 SQL> select arch_mode from v$database; LINEID arch_mode ---------- --------- 1 Y |
#关闭数据库 DmServicedmwat stop #备份数据库 RMAN> backup database '/opt/dm8/data/dmwat/dm.ini' full; backup database '/opt/dm8/data/dmwat/dm.ini' full; file dm.key not found, use default license! Database mode = 0, oguid = 0 Normal of FAST Normal of DEFAULT Normal of RECYCLE Normal of KEEP Normal of ROLL EP[0]'s cur_lsn[29710], file_lsn[29710] Processing backupset /opt/dm8/data/dmwat/bak/DB_dmwat_FULL_20220826_153412_280474 [Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00] backup successfully! time used: 00:00:01.358 RMAN> |
#配置服务 /opt/dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dm8/data/dmwat/dm.ini -p dmwat [root@dm-dw1 yum.repos.d]# /opt/dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dm8/data/dmwat/dm.ini -p dmwat Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedmwat.service to /usr/lib/systemd/system/DmServicedmwat.service. Finished to create the service (DmServicedmwat) [root@dm-dw1 yum.repos.d]# systemctl enable DmServicedmwat.service [root@dm-dw1 yum.repos.d]# systemctl status DmServicedmwat.service ● DmServicedmwat.service - Dameng Database Service(DmServicedmwat). Loaded: loaded (/usr/lib/systemd/system/DmServicedmwat.service; enabled; vendor preset: disabled) Active: inactive (dead) [root@dm-dw1 yum.repos.d]# systemctl start DmServicedmwat.service [root@dm-dw1 yum.repos.d]# systemctl status DmServicedmwat.service ● DmServicedmwat.service - Dameng Database Service(DmServicedmwat). Loaded: loaded (/usr/lib/systemd/system/DmServicedmwat.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-08-26 15:21:24 CST; 9s ago Process: 2021 ExecStart=/opt/dm8/bin/DmServicedmwat start (code=exited, status=0/SUCCESS) Main PID: 2045 (dmserver) CGroup: /system.slice/DmServicedmwat.service └─2045 /opt/dm8/bin/dmserver /opt/dm8/data/dmwat/dm.ini -noconsol... Aug 26 15:21:09 dm-dw1.novalocal systemd[1]: Starting Dameng Database Servi.... Aug 26 15:21:24 dm-dw1.novalocal DmServicedmwat[2021]: [36B blob data] Aug 26 15:21:24 dm-dw1.novalocal systemd[1]: Started Dameng Database Servic.... Hint: Some lines were ellipsized, use -l to show in full. [root@dm-dw1 yum.repos.d]# systemctl disable DmServicedmwat.service |
dminit PATH=/opt/dm8/data DB_NAME=dmwat INSTANCE_NAME=dmwat2 PORT_NUM=5236 PAGE_SIZE=32 EXTENT_SIZE=32 CHARSET=1 CASE_SENSITIVE=0 LENGTH_IN_CHAR=0 BLANK_PAD_MODE=1 |
#拷贝备份 [dmdba@dm-dw1 bak]$ scp -r DB_dmwat_FULL_20220826_153412_280474 dm-dw2:/home/dmdba dmdba@dm-dw2's password: DB_dmwat_FULL_20220826_153412_280474.bak 100% 16MB 63.2MB/s 00:00 DB_dmwat_FULL_20220826_153412_280474.meta 100% 77KB 16.4MB/s 00:00 #回复数据库 dmrman restore database '/opt/dm8/data/dmwat/dm.ini' from backupset '/home/dmdba/DB_dmwat_FULL_20220826_153412_280474'; recover database '/opt/dm8/data/dmwat/dm.ini' from backupset '/home/dmdba/DB_dmwat_FULL_20220826_153412_280474'; recover database '/opt/dm8/data/dmwat/dm.ini' update db_magic; |
#配置服务 /opt/dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dm8/data/dmwat/dm.ini -p dmwat #disable服务 [root@dm-dw1 yum.repos.d]# systemctl disable DmServicedmwat.service |
主备均修改
vi /opt/dm8/data/dmwat/dm.ini |
主库
INSTANCE_NAME =DMWAT MAL_INI =1 ARCH_INI =1 PORT_NUM =5236 ALTER_MODE_STATUS =0 ENABLE_OFFLINE_TS =2 |
备库
INSTANCE_NAME =DMWAT2 MAL_INI =1 ARCH_INI =1 PORT_NUM =5236 ALTER_MODE_STATUS =0 ENABLE_OFFLINE_TS =2 |
主备均修改,主备一致
vi /opt/dm8/data/dmwat/dmmal.ini |
主备一致
[MAL_INST1] MAL_INST_NAME = DMWAT MAL_HOST = 192.168.1.25 MAL_PORT = 5238 MAL_DW_PORT = 5239 MAL_INST_HOST = 192.168.2.25 MAL_INST_PORT = 5236 MAL_INST_DW_PORT = 5237 [MAL_INST2] MAL_INST_NAME = DMWAT2 MAL_HOST = 192.168.1.26 MAL_PORT = 5238 MAL_DW_PORT = 5239 MAL_INST_HOST = 192.168.2.26 MAL_INST_PORT = 5236 MAL_INST_DW_PORT = 5237 |
主备均修改
vi /opt/dm8/data/dmwat/dmarch.ini |
主库
#DaMeng Database Archive Configuration file #this is comments [ARCHIVE_LOCAL1] ARCH_TYPE = LOCAL ARCH_DEST = /opt/dm8/data/dmwat/arch ARCH_FILE_SIZE = 128 ARCH_SPACE_LIMIT = 0 ARCH_FLUSH_BUF_SIZE = 0 [ARCHIVE_REALTIME] ARCH_TYPE = REALTIME ARCH_DEST = DMWAT2 |
备库
#DaMeng Database Archive Configuration file #this is comments [ARCHIVE_LOCAL1] ARCH_TYPE = LOCAL ARCH_DEST = /opt/dm8/data/dmwat/arch ARCH_FILE_SIZE = 128 ARCH_SPACE_LIMIT = 0 ARCH_FLUSH_BUF_SIZE = 0 [ARCHIVE_REALTIME] ARCH_TYPE = REALTIME ARCH_DEST = DMWAT |
启动数据库到mount
#主库 DmServicedmwat start mount #备库 DmServicedmwat start mount |
主库
[dmdba@dm-dw1 dmwat]$ disql sysdba Server[LOCALHOST:5236]:mode is normal, state is mount login used time : 3.867(ms) disql V8 SQL> sp_set_oguid(3721886); DMSQL executed successfully used time: 18.406(ms). Execute id is 0. SQL>alter database parimary; |
备库
[dmdba@dm-dw2 ~]$ disql sysdba Server[LOCALHOST:5236]:mode is normal, state is mount login used time : 4.093(ms) disql V8 SQL> SQL> sp_set_oguid(3721886); DMSQL executed successfully used time: 19.548(ms). Execute id is 0. SQL> alter database standby; SQL> |
主备修改dmwatch.ini,主备一致
vi /opt/dm8/data/dmwat/dmwatch.ini |
主备一致
[GRP1] DW_TYPE = GLOBAL DW_MODE = MANUAL DW_ERROR_TIME = 10 INST_RECOVER_TIME = 60 INST_ERROR_TIME = 10 INST_OGUID = 3721886 INST_INI = /opt/dm8/data/dmwat/dm.ini INST_AUTO_RESTART = 1 INST_STARTUP_CMD = /opt/dm8/bin/dmserver RLOG_SEND_THRESHOLD = 0 RLOG_APPLY_THRESHOLD = 0 |
设置oguid,sp_set_oguid(3721886) 一致 |
主备库均配置该服务,由该服务来启停数据库
#主备一致 /opt/dm8/script/root/dm_service_installer.sh -t dmwatcher -watcher_ini /opt/dm8/data/dmwat/dmwatcher.ini -p mon |
在dm-mon上配置
配置监控台参数
[dmdba@dm-mon data]$ mkdir -p /opt/dm8/data/dmmon [dmdba@dm-mon data]$ cd /opt/dm8/data/dmmon [dmdba@dm-mon mon]$ vi dmmonitor.ini |
参数配置
MON_DW_CONFIRM = 1 MON_LOG_PATH = /opt/dm8/log MON_LOG_INTERVAL = 60 MON_LOG_FILE_SIZE = 32 MON_LOG_SPACE_LIMIT = 0 [GRP1] MON_INST_OGUID = 3721886 MON_DW_IP = 192.168.1.25:5239 MON_DW_IP = 192.168.1.26:5239 |
与设置oguid,sp_set_oguid(3721886) 一致 |
使用dmmonitor监控
[dmdba@dm-mon data]$ dmmonitor /opt/dm8/data/dmmon/dmmonitor.ini [monitor] 2022-08-26 16:49:43: DMMONITOR[4.0] V8 [monitor] 2022-08-26 16:49:43: DMMONITOR[4.0] IS READY. Input command illegal, please input help to get the help information! Input command illegal, please input help to get the help information! [monitor] 2022-08-26 16:54:38: Received message from(DMWAT2) [monitor] 2022-08-26 16:54:46: Received message from(DMWAT) |
关闭主备库
#先关闭数据库 DmServicedmwat stop |
启动watcher服务
#启动datawatch服务 systemctl start DmWatcherServicemon |
监控台命令,dm-mon上
[dmdba@dm-mon data]$ dmmonitor /opt/dm8/data/dmmon/dmmonitor.ini [monitor] 2022-08-26 16:49:43: DMMONITOR[4.0] V8 [monitor] 2022-08-26 16:49:43: DMMONITOR[4.0] IS READY. Input command illegal, please input help to get the help information! Input command illegal, please input help to get the help information! [monitor] 2022-08-26 16:54:38: Received message from(DMWAT2) [monitor] 2022-08-26 16:54:46: Received message from(DMWAT) show global info 2022-08-26 16:57:19 #================================================================================# GROUP OGUID MON_CONFIRM MODE MPP_FLAG GRP1 3721886 TRUE MANUAL FALSE < DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT 192.168.1.25 5239 2022-08-26 16:57:18 GLOBAL VALID OPEN DMWAT OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT 192.168.1.26 5239 2022-08-26 16:57:18 GLOBAL VALID OPEN DMWAT2 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID #================================================================================# ####该界面可随时退出,只是个监控界面输出 |
建表验证
##主库 SQL> create table wzy(x int); executed successfully used time: 20.814(ms). Execute id is 304. SQL> insert into wzy values(123); affect rows 1 used time: 1.402(ms). Execute id is 305. SQL> commit; executed successfully used time: 3.339(ms). Execute id is 306. SQL> select mode$ from v$instance; LINEID mode$ ---------- ------- 1 PRIMARY ##备库 SQL> select * from wzy; LINEID x ---------- ----------- 1 123 used time: 3.325(ms). Execute id is 1. SQL> insert into wzy values(321); insert into wzy values(321); [-2018]:Error in line: 1 Try to insert/update/delete table table is not temporary or contains lob on standby mode. used time: 0.624(ms). Execute id is 0. SQL> select mode$ from v$instance; LINEID mode$ ---------- ------- 1 STANDBY ------ |