数据库名 |
实例名 |
PORT_NUM |
MAL_INST_DW_PORT |
MAL_HOST |
MAL_PORT |
MAL_DW_PORT |
备注 |
DMSERVER01 |
DMSERVER01 |
5237 |
45101 |
192.168.0.128 |
55101 |
65101 |
主库 |
DMSERVER02 |
DMSERVER02 |
5237 |
45121 |
192.168.0.140 |
55121 |
65121 |
从库 |
DMSERVER |
DMSERVER |
5236 |
45101 |
192.168.0.231 |
55101 |
65101 |
监听 |
创建数据库实例
一个数据库软件可以创建多个数据库实例,通过端口号区别,达梦默认端口号是 5236
可视化方式创建数据库实例:
[root@localhost ~]# echo $DISPLAY
:1.0
[root@localhost ~]# xhost +
access control disabled, clients can connect from any host
[dmdba@localhost ~]$ export DISPLAY=:1.0
[dmdba@localhost ~]$ xhost +
[dmdba@localhost dm8]$ cd /dm8/tool/
[dmdba@localhost tool]$ ./dbca.sh
数据库模板选择---直接下一步
配置数据库名、实例名、端口号,第一个实例默认,后续实例配置安装要求配置
配置数据库文件路径
设置数据库密码------用户名为SYSDBA,密码为设置的密码,密码设置最好是字母+数字组合,不能使用特殊字符,否则创建数据库实例后使用disql 无法识别特殊字符
为实验数据库SQL语句,配置测试数据库
数据库实例摘要:
root用户执行3条配置脚本
使用root用户权限复制上述3个命令执行
一定要将命令复制完整
[root@localhost 桌面]# mv /dm8/bin/DmServiceDMSERVER01.service /usr/lib/systemd/system/DmServiceDMSERVER01.service
将命令加入开机自启
[root@localhost 桌面]# systemctl enable DmServiceDMSERVER01.service
启动实例
[root@localhost 桌面]# systemctl start DmServiceDMSERVER01.service
root用户重启实例
[root@localhost 桌面]# systemctl restart DmServiceDMSERVER01.service
自此数据库实例创建完成
su - dmdba
主库备份
cd /dm8/bin
[dmdba@dm bin]$ ./DmServiceDMSERVER01 status
[dmdba@dm bin]$ ./DmServiceDMSERVER01(关闭实例)
[dmdba@dm bin]$ ./DmServiceDMSERVER02(从库关闭实例)
[dmdba@dm bin]$ mkdir /dm8/backup (备库同步建一个)
[dmdba@dm bin]$ ./dmrman
RMAM>BACKUP DATABASE '/dm8/data/DAMENG01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'
cd /dm8/backup/BACKUP_FILE_01
scp *.* 备库IP:/dm8/backup
备库数据还原切换到dmdba账户
cd /dm8/bin
./dmrman
RMAM>RESTORE DATABASE '/dm8/data/DAMENG02/dm.ini' FROM BACKUPSET '/dm8/backup'
RMAM>RECOVER DATABASE '/dm8/data/DAMENG02/dm.ini' FROM BACKUPSET '/dm8/backup'
RMAM>RECOVER DATABASE '/dm8/data/DAMENG02/dm.ini' UPDATE DB_MAGIC
修改配置文件从主库开始
primary(主库)
cd /dm8/data/DAMENG01/
vim dm.ini
----------
INSTANCE_NAME = DMSERVER01 # (主库实例名)
PORT_NUM = 5237
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64
vim dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSERVER01 #(主库实例名)
MAL_HOST = 192.168.0.128 #(主库ip)
MAL_PORT = 55101
MAL_INST_HOST = 192.168.0.128 #(主库ip)
MAL_INST_PORT = 5237
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSERVER02 #(备库实例名)
MAL_HOST = 192.168.0.140#(备库ip)
MAL_PORT = 55121
MAL_INST_HOST = 192.168.0.140#(备库ip)
MAL_INST_PORT = 5237
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
[dmdba@localhost DAMENG02]$ mkdir /dm8/arch
vim dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
vim dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dm8/data/DAMENG01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
启动主库
cd /dm8/bin
./dmserver /dm8/data/DAMENG01/dm.ini mount
启动后不用管,另开一个窗口进入数据库执行下面命令)
[dmdba@dm DAMENG01]$ cd /dm8/bin
[dmdba@dm bin]$ ./disql sysdba/dameng123@localhost:5237
SQL>SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',1);
SQL>sp_set_oguid(453331);
SQL>alter database primary;
SQL>SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',0);