linux下达梦数据库启动_linux 平台 达梦DM 7 数据库 启动与关闭
在之前的博客我們了解了Linux 平臺下DM7的安裝,如下:
在本篇博客里我們了解一下DM7的啟動和關閉。
1 背景知識說明
1.1 DM DB的啟動過程
DM的啟動主要按如下三個步驟進行:
1.讀取配置文件(.ini)
2.讀取控制文件(dm.ctl)
3.讀取重做日志文件(.log) 和 數據文件(*.DBF)
https://www.cndba.cn/dave/article/3566
1.2 DM DB的狀態
DM 數據庫包含以下幾種狀態:
配置狀態(MOUNT):不允許訪問數據庫對象,只能進行控制文件維護、歸檔配置、數據庫模式修改等操作;
打開狀態(OPEN):不能進行控制文件維護、歸檔配置等操作,可以訪問數據庫對象,對外提供正常的數據庫服務;
掛起狀態(SUSPEND):與 OPEN 狀態的唯一區別就是,限制磁盤寫入功能;一旦修改了數據頁,觸發 REDO 日志、數據頁刷盤,當前用戶將被掛起。
OPEN 狀態與 MOUNT 和 SUSPEND 能相互轉換,但是 MOUNT 和 SUSPEND 之間不能相互轉換。
1.3 DM DB的模式
DM 數據庫包含以下幾種模式:
普通模式(NORMAL):用戶可以正常訪問數據庫,操作沒有限制;
主庫模式(PRIMARY):用戶可以正常訪問數據庫,所有對數據庫對象的修改強制生成 REDO 日志,在歸檔有效時,發送 REDO 日志到備庫;
備庫模式(STANDBY):接收主庫發送過來的 REDO 日志并重做。數據對用戶只讀。
三種模式只能在 MOUNT 狀態下設置,模式之間可以相互轉換。
對于新初始化的庫,首次啟動不允許使用 mount 方式,需要先正常啟動并正常退出,然后才允許 mount 方式啟動。
一般情況下,數據庫為 NORMAL 模式,如果不指定 MOUNT 狀態啟動,則自動啟動到 OPEN 狀態。
在需要對數據庫配置時(如配置數據守護、數據復制),服務器需要指定 MOUNT 狀態啟動。當數據庫模式為非 NORMAL 模式(PRIMARY、STANDBY 模式),無論是否指定啟動狀態,服務器啟動時自動啟動到 MOUNT 狀態。
1.4 DM DB的三種啟動和關閉方式
啟動和關閉DM DB有三種方式:
1.4.1 DM服務查看器
Windows可以通過菜單目錄查看。 Linux 平臺需要運行/dm/dmdbms/tool/dmservice.sh 啟動。 如下圖:
1.4.2 系統服務
在實例安裝結束之后會創建,在操作系統直接對實例服務進行操作。Windows 則是直接在服務窗口進行。https://www.cndba.cn/dave/article/3566https://www.cndba.cn/dave/article/3566
啟動:systemctl start DmServicedave.service
關閉:systemctl stop DmServicedave.service
我這里的測試平臺是Linux7, Linux 6和 7 的在服務這塊有一點區別:
在Linux 6中,服務是放在/etc/rc.d/init.d目錄下,會有一個”DmService+實例名”的文件服務文件,啟動和關閉是執行service “DmServer+實例名” stop|start。
在Linux 7中,服務文件存放在/usr/lib/systemd/system目錄下,名稱改成:DmServicedave.service。
1.4.3 命令行模式
命令行模式使用dmserver命令來啟動和關閉實例。該命令在DM_HOME/bin目錄下。 https://www.cndba.cn/dave/article/3566
命令行方式啟動參數如下:
dmserver [ini_file_path] [-noconsole] [mount]
說明:
1. Dmserver 命令行啟動參數可指定 dm.ini 文件的路徑,非控制臺方式啟動及指定數據庫是否以 MOUNT 狀態啟動。
2. Dmserver 啟動時可不指定任何參數,默認使用當前目錄下的 dm.ini 文件,如果當前目錄不存在 dm.ini 文件,則無法啟動;
3. Dmserver 啟動時可以指定-noconsole 參數。如果以此方式啟動,則無法通過在控制臺中輸入服務器命令。
當不確定啟動參數的使用方法時,可以使用 help 參數,將打印出格式、參數說明和使用示例。使用方法如下:
dmserver help
當以控制臺方式啟動 Dmserver 時,用戶可以在控制臺輸入一些命令,服務器將在控制臺打印出相關信息或執行相關操作。
1.4.4 命令行方式和其他兩種方式的區別
命令行方式默認也是將數據庫啟動到open狀態,但也可以在啟動時指定啟動到mount狀態,從而可以維護開文件、進程歸檔配置、數據庫普通模式或主備機模式切換等操作。 在進行備份恢復時也常用命令行模式啟動。https://www.cndba.cn/dave/article/3566
https://www.cndba.cn/dave/article/3566
2 操作示例
2.1 查看DM DB的狀態
DB的狀態通過DM服務查看器可以直接看到,也可以通過查看系統服務狀態來查看,如下:https://www.cndba.cn/dave/article/3566
[dave@www.cndba.cn system]$ systemctl status DmServicedave
● DmServicedave.service - DM database instance service
Loaded: loaded (/usr/lib/systemd/system/DmServicedave.service; enabled; vendor preset: disabled)
Active: active (exited) since Fri 2029-02-23 01:37:37 CST; 10h ago
Process: 24621 ExecStart=/dm/dmdbms/bin/DmServicedave start (code=exited, status=0/SUCCESS)
Main PID: 24621 (code=exited, status=0/SUCCESS)
Tasks: 0
CGroup: /system.slice/DmServicedave.service
[dave@www.cndba.cn system]$
通過disql來查看:
[dave@www.cndba.cn ~]$ disql SYSDBA/SYSDBA
Server[LOCALHOST:5236]:mode is normal, state is open
login used time: 14.097(ms)
disql V7.6.0.145-Build(2019.03.20-104220)ENT
SQL> select status$ from v$database;
LINEID STATUS$
---------- -----------
1 4
used time: 8.850(ms). Execute id is 2197.
SQL>
這里是用數字來表示狀態的,這里一共有6種狀態,如下:
1:啟動;2:啟動,redo 完成;3:MOUNT;4:打開;5:掛起;6:關閉
2.2 使用系統服務來啟動和關閉DM 實例
[root@dm1 ~]# systemctl stop DmServicedave
[root@dm1 ~]# systemctl status DmServicedave
● DmServicedave.service - DM database instance service
Loaded: loaded (/usr/lib/systemd/system/DmServicedave.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2029-02-23 12:34:40 CST; 7s ago
Process: 2561 ExecStop=/dm/dmdbms/bin/DmServicedave stop (code=exited, status=0/SUCCESS)
Process: 741 ExecStart=/dm/dmdbms/bin/DmServicedave start (code=exited, status=0/SUCCESS)
Main PID: 741 (code=exited, status=0/SUCCESS)
Feb 23 12:26:16 dm1 systemd[1]: Starting DM database instance service...
Feb 23 12:26:16 dm1 su[824]: (to dmdba) root on none
Feb 23 12:26:19 dm1 DmServicedave[741]: Starting DmServicedave: Last login: Fri Feb 23 12:10:04 CST 2029 on pts/6
Feb 23 12:26:34 dm1 DmServicedave[741]: [11B blob data]
Feb 23 12:26:34 dm1 systemd[1]: Started DM database instance service.
Feb 23 12:34:35 dm1 systemd[1]: Stopping DM database instance service...
Feb 23 12:34:40 dm1 DmServicedave[2561]: [35B blob data]
Feb 23 12:34:40 dm1 systemd[1]: Stopped DM database instance service.
[root@dm1 ~]# systemctl start DmServicedave
[root@dm1 ~]# systemctl status DmServicedave
● DmServicedave.service - DM database instance service
Loaded: loaded (/usr/lib/systemd/system/DmServicedave.service; enabled; vendor preset: disabled)
Active: active (exited) since Fri 2029-02-23 12:35:12 CST; 1s ago
Process: 2561 ExecStop=/dm/dmdbms/bin/DmServicedave stop (code=exited, status=0/SUCCESS)
Process: 2621 ExecStart=/dm/dmdbms/bin/DmServicedave start (code=exited, status=0/SUCCESS)
Main PID: 2621 (code=exited, status=0/SUCCESS)
Feb 23 12:34:57 dm1 systemd[1]: Starting DM database instance service...
Feb 23 12:34:57 dm1 su[2641]: (to dmdba) root on none
Feb 23 12:34:57 dm1 DmServicedave[2621]: Starting DmServicedave: Last login: Fri Feb 23 12:28:13 CST 2029 on pts/1
Feb 23 12:35:12 dm1 DmServicedave[2621]: [11B blob data]
Feb 23 12:35:12 dm1 systemd[1]: Started DM database instance service.
[root@dm1 ~]#
[root@dm1 ~]# ps -ef|grep dm.ini
dmdba 2662 1 0 12:34 ? 00:00:00 /dm/dmdbms/bin/dmserver /dm/dmdbms/data/cndba/dm.ini -noconsole
root 2765 2026 0 12:36 pts/0 00:00:00 grep --color=auto dm.ini
[root@dm1 ~]#
2.3 使用命令行管理DB
前面提到命令行直接使用命令操作。 dmserver 啟動命令行窗口一直在,啟動后直接輸入exit即表示關閉實例。如果加上-noconsole選項,則不接受任何指令,可以直接按Ctrl+c 來終止程序并停止數據庫。
[dave@www.cndba.cn ~]$ /dm/dmdbms/bin/dmserver /dm/dmdbms/data/cndba/dm.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 V7.6.0.145-Build(2019.03.20-104220)ENT startup...
License will expire on 2029-03-09
ckpt lsn: 61183
ndct db load finished
ndct fill fast pool finished
set EP[0]'s pseg state to inactive
iid page's trxid = 2600
NEXT TRX ID = 2601
pseg recv finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
nsvr_process_before_open begin.
nsvr_process_before_open success.
SYSTEM IS READY.
#輸入其他指令,可以通過dmserver help 查看:
lock
----------------- object lock info ---------------
addr objid mode trx wait
>> 0 object locks.
------------------- tid lock info ----------------
addr objid mode trx wait
>> 0 object locks.
-----------------outer object lock info (dbms_lock)---------------
addr objid mode sess wait_sess
#輸入exit 關閉實例
exit
Server is stopping...
listener closed and all sessions disconnected
purge undo records in usegs...OK
full check point starting...
generate force checkpoint, rlog free space, used space is (536457216, 405504)
ckpt_lsn, ckpt_fil, ckpt_off are set as (66044, 0, 10398720)
checkpoint: 3878 pages flushed.
checkpoint finished, rlog free space, used space is (536600064, 262656)
full check point end.
shutdown audit subsystem...OK
shutdown schedule subsystem...OK
shutdown timer successfully.
pre-shutdown MAL subsystem...OK
shutdown worker threads subsystem...OK
shutdown local parallel threads pool successfully.
shutdown replication subsystem...OK
shutdown sequence cache subsystem...OK
wait for mtsk link worker to exit..OK
shutdown mpp session subsystem...OK
wait for rapply is all over... OK
rapply worker threads exit successfully.
pre ending task & worker threads...OK
shutdown dblink subsystem...OK
shutdown session subsystem...OK
shutdown rollback segments purging subsystem...OK
shutdown rps subsystem...OK
shutdown transaction subsystem...OK
shutdown locking subsystem...OK
shutdown dbms_lock subsystem...OK
ending tsk and worker threads...OK
ckpt2_exec_immediately begin.
ckpt_lsn, ckpt_fil, ckpt_off are set as (66048, 0, 10661376)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536680448, 182272)
ckpt_lsn, ckpt_fil, ckpt_off are set as (70401, 0, 10843648)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536862208, 512)
ckpt_lsn, ckpt_fil, ckpt_off are set as (70401, 0, 10844160)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536862720, 0)
ckpt_lsn, ckpt_fil, ckpt_off are set as (70401, 0, 10844160)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536862720, 0)
shutdown archive subsystem...OK
shutdown redo log subsystem...OK
shutdown MAL subsystem...OK
shutdown message compress subsystem successfully.
shutdown task subsystem...OK
shutdown trace subsystem...OK
shutdown svr_log subsystem...OK
shutdown plan cache subsystem...OK
shutdown file subsystem...OK
shutdown database dictionary subsystem...OK
shutdown mac cache subsystem...OK
shutdown dynamic login cache subsystem...OK
shutdown ifun/bifun/sfun/afun cache subsystem...OK
shutdown crypt subsystem...OK
shutdown pipe subsystem...OK
shutdown compress component...OK
shutdown slave redo subsystem...OK
shutdown kernel buffer subsystem...OK
shutdown SQL capture subsystem...OK
shutdown control file system...OK
shutdown dtype subsystem...OK
shutdown huge buffer and memory pools...OK
close lsnr socket
DM Database Server shutdown successfully.
[dave@www.cndba.cn ~]$
#啟動到mount狀態:
[dave@www.cndba.cn ~]$ dmserver /dm/dmdbms/data/cndba/dm.ini -noconsole mount
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 V7.6.0.145-Build(2019.03.20-104220)ENT startup...
License will expire on 2029-03-09
ckpt lsn: 126426
ndct db load finished
ndct fill fast pool finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
SYSTEM IS READY.
以服務模式啟動DB實例且不接收指令:
https://www.cndba.cn/dave/article/3566
/dm/dmdbms/bin/dmserver /dm/dmdbms/data/cndba/dm.ini -noconsolehttps://www.cndba.cn/dave/article/3566
使用命令行的方式啟動DB缺點很明顯,窗口必須一致存在,嘗試將將命令放到后臺執行:
https://www.cndba.cn/dave/article/3566
/dm/dmdbms/bin/dmserver /dm/dmdbms/data/cndba/dm.ini -noconsole &
實際測試發現一個問題,通過系統service 啟動的實例,狀態可以在DM service viewer中正確識別,但用命令行啟動的實例,狀態無法在系統服務和DM 服務查看中正確顯示,也無法進行操作,也就是說,命令行啟動的實例,只能通過命令行來關閉。 不過這個并不影響,可以直接使用linux 的fg命令將后臺進程調到前臺,在正常操作即可。 不建議直接在操作系統級別kill 進程。
#使用命令行啟動后系統服務無法獲取正確的狀態:
[root@dm1 ~]# systemctl status DmServicedave
● DmServicedave.service - DM database instance service
Loaded: loaded (/usr/lib/systemd/system/DmServicedave.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Fri 2029-02-23 12:38:36 CST; 42min ago
Process: 2788 ExecStop=/dm/dmdbms/bin/DmServicedave stop (code=exited, status=0/SUCCESS)
Process: 2621 ExecStart=/dm/dmdbms/bin/DmServicedave start (code=exited, status=0/SUCCESS)
Main PID: 2621 (code=exited, status=0/SUCCESS)
Feb 23 12:34:57 dm1 systemd[1]: Starting DM database instance service...
Feb 23 12:34:57 dm1 su[2641]: (to dmdba) root on none
Feb 23 12:34:57 dm1 DmServicedave[2621]: Starting DmServicedave: Last login: Fri Feb 23 12:28:13 CST 2029 on pts/1
Feb 23 12:35:12 dm1 DmServicedave[2621]: [11B blob data]
Feb 23 12:35:12 dm1 systemd[1]: Started DM database instance service.
Feb 23 12:38:26 dm1 systemd[1]: Stopping DM database instance service...
Feb 23 12:38:36 dm1 DmServicedave[2788]: [35B blob data]
Feb 23 12:38:36 dm1 systemd[1]: Stopped DM database instance service.
[root@dm1 ~]#
#后臺啟動實例,并使用fg命令調用到前臺:
[dave@www.cndba.cn ~]$ dmserver /dm/dmdbms/data/cndba/dm.ini -noconsole &
[1] 5435
[dave@www.cndba.cn ~]$ 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 V7.6.0.145-Build(2019.03.20-104220)ENT startup...
License will expire on 2029-03-09
ckpt lsn: 117208
ndct db load finished
ndct fill fast pool finished
set EP[0]'s pseg state to inactive
iid page's trxid = 2621
NEXT TRX ID = 2622
pseg recv finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
nsvr_process_before_open begin.
nsvr_process_before_open success.
SYSTEM IS READY.
#將命令調用到前臺
[dave@www.cndba.cn ~]$ jobs -l
[1]+ 5435 Running dmserver /dm/dmdbms/data/cndba/dm.ini -noconsole &
[dave@www.cndba.cn ~]$ fg 1
dmserver /dm/dmdbms/data/cndba/dm.ini -noconsole
exit
^CServer is stopping...
listener closed and all sessions disconnected
purge undo records in usegs...OK
full check point starting...
generate force checkpoint, rlog free space, used space is (536457216, 405504)
ckpt_lsn, ckpt_fil, ckpt_off are set as (122069, 0, 14882304)
checkpoint: 3232 pages flushed.
checkpoint finished, rlog free space, used space is (536602624, 260096)
full check point end.
shutdown audit subsystem...OK
shutdown schedule subsystem...OK
shutdown timer successfully.
pre-shutdown MAL subsystem...OK
shutdown worker threads subsystem...OK
shutdown local parallel threads pool successfully.
shutdown replication subsystem...OK
shutdown sequence cache subsystem...OK
wait for mtsk link worker to exit..OK
shutdown mpp session subsystem...OK
wait for rapply is all over... OK
rapply worker threads exit successfully.
pre ending task & worker threads...OK
shutdown dblink subsystem...OK
shutdown session subsystem...OK
shutdown rollback segments purging subsystem...OK
shutdown rps subsystem...OK
shutdown transaction subsystem...OK
shutdown locking subsystem...OK
shutdown dbms_lock subsystem...OK
ending tsk and worker threads...OK
ckpt2_exec_immediately begin.
ckpt_lsn, ckpt_fil, ckpt_off are set as (122073, 0, 15142400)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536680448, 182272)
ckpt_lsn, ckpt_fil, ckpt_off are set as (126426, 0, 15324672)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536862208, 512)
ckpt_lsn, ckpt_fil, ckpt_off are set as (126426, 0, 15325184)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536862720, 0)
ckpt_lsn, ckpt_fil, ckpt_off are set as (126426, 0, 15325184)
checkpoint: 0 pages flushed.
checkpoint finished, rlog free space, used space is (536862720, 0)
shutdown archive subsystem...OK
shutdown redo log subsystem...OK
shutdown MAL subsystem...OK
shutdown message compress subsystem successfully.
shutdown task subsystem...OK
shutdown trace subsystem...OK
shutdown svr_log subsystem...OK
shutdown plan cache subsystem...OK
shutdown file subsystem...OK
shutdown database dictionary subsystem...OK
shutdown mac cache subsystem...OK
shutdown dynamic login cache subsystem...OK
shutdown ifun/bifun/sfun/afun cache subsystem...OK
shutdown crypt subsystem...OK
shutdown pipe subsystem...OK
shutdown compress component...OK
shutdown slave redo subsystem...OK
shutdown kernel buffer subsystem...OK
shutdown SQL capture subsystem...OK
shutdown control file system...OK
shutdown dtype subsystem...OK
shutdown huge buffer and memory pools...OK
close lsnr socket
DM Database Server shutdown successfully.
[dave@www.cndba.cn ~]$
2.4 切換實例狀態
SQL> select status$ from v$database;
Server[LOCALHOST:5236]:mode is normal, state is open
connected
LINEID STATUS$
---------- -----------
1 4
used time: 7.105(ms). Execute id is 3.
SQL> alter database mount;
executed successfully
used time: 00:00:01.878. Execute id is 0.
SQL> select status$ from v$database;
LINEID STATUS$
---------- -----------
1 3
used time: 2.155(ms). Execute id is 4.
SQL>
其他修改選項可以參考官方手冊:
ALTER DATABASE ;
::=
RESIZE LOGFILE TO |
ADD LOGFILE {,}|
RENAME LOGFILE {,} TO {,}|
MOUNT |
SUSPEND |
OPEN [FORCE] |
NORMAL |
PRIMARY|
STANDBY |
ARCHIVELOG |
NOARCHIVELOG |
ARCHIVELOG |
ARCHIVELOG CURRENT
::= SIZE
::= 'DEST = ,TYPE = '
::=
LOCAL [] |
REALTIME|
SYNC |
ASYNC ,TIMER_NAME = |
REMOTE ,ARCH_INCOMING_PATH = []|
TIMELY
::=[,FILE_SIZE = ][,SPACE_LIMIT = ]
版權聲明:本文為博主原創文章,未經博主允許不得轉載。
總結
以上是生活随笔為你收集整理的linux下达梦数据库启动_linux 平台 达梦DM 7 数据库 启动与关闭的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 通过配置文件登陆有密码的mysql不需要
- 下一篇: 7-10外连接查询