數(shù)據(jù)庫系統(tǒng)管理及設備操作課件_第1頁
數(shù)據(jù)庫系統(tǒng)管理及設備操作課件_第2頁
數(shù)據(jù)庫系統(tǒng)管理及設備操作課件_第3頁
數(shù)據(jù)庫系統(tǒng)管理及設備操作課件_第4頁
數(shù)據(jù)庫系統(tǒng)管理及設備操作課件_第5頁
已閱讀5頁,還剩50頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、數(shù)據(jù)庫系統(tǒng)管理數(shù)據(jù)庫系統(tǒng)管理: Adaptive Server Enterprise 12.5設設 備備尹海寧尹海寧 高級顧問高級顧問Sybase Software (China) Shanghai1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 1單元概要單元概要Adaptive Server通過一個稱為設備的機制來分配數(shù)據(jù)庫資源。在創(chuàng)建數(shù)據(jù)庫之前,它所在的設備必須先初始化。目標目標完成本單元學習后,應該能夠:n初始化和刪除設備;n把設備變?yōu)槿笔≡O備;n鏡像設備;n創(chuàng)建和修改設備后備份 master 數(shù)據(jù)庫。199

2、9 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 2單元提要單元提要n創(chuàng)建和刪除設備創(chuàng)建和刪除設備n缺省設備n鏡像設備n備份 master 數(shù)據(jù)庫1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 3設設 備備n數(shù)據(jù)庫設備是一個物理資源,用它來存放數(shù)據(jù)庫中的對象。l術語“設備”并不需要指一個獨立的物理設備。s它可為一片磁盤, 例如一個磁盤分區(qū)。s它可為操作系統(tǒng)的一個文件。1999 Sybase, Inc. and its subsidiaries.

3、 All rights reserved.6 - 4設備類型設備類型n安裝設lmaster設備s該設備初始時存放 master, model, tempdb, 和 sybsystemdb系統(tǒng)數(shù)據(jù)庫。 s除了master 數(shù)據(jù)庫外,所有其它數(shù)據(jù)庫都可移出或擴展出 master 設備。l設備, 它存放 sybsystemprocs 數(shù)據(jù)庫。n用戶定義數(shù)據(jù)庫設備l這些設備存放用戶數(shù)據(jù)庫。l這些設備可存放除 master 外的其它系統(tǒng)數(shù)據(jù)庫。n轉儲設備l這些設備存放數(shù)據(jù)庫和日志的備份。1999 Sybase, Inc. and its subsidiaries. All rights reserved

4、.6 - 5物理硬盤類型物理硬盤類型n可從兩種物理存儲類型創(chuàng)建一個設備:l裸盤分區(qū);l操作系統(tǒng)文件。n最合適的選擇依賴于:l使用的 ASE 版本;lASE 運行的平臺。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 6n裸分區(qū)l服務器在磁盤初始化時就預分配了空間,這樣創(chuàng)建數(shù)據(jù)庫時就不容易失敗。n操作系統(tǒng)文件l服務器在磁盤初始化時不預分配空間。s由于沒有預分配空間,在創(chuàng)建數(shù)據(jù)庫時可能由于空間不夠而失敗。物理硬盤話題物理硬盤話題: ASE 11.9.2 和以前版本和以前版本1999 Sybase, Inc. and i

5、ts subsidiaries. All rights reserved.6 - 7物理硬盤話題物理硬盤話題: ASE 11.9.2 和以前版本和以前版本l在 UNIX上, 設備的完整性無法保證。s寫到文件的數(shù)據(jù)要先寫到 UNIX 文件系統(tǒng)緩沖區(qū)。s在一些失敗情況下,服務器不能保證恢復緩沖區(qū)中數(shù)據(jù)。n所以, 在 UNIX 上推薦使用裸設備。l在 NT 上沒有物理磁盤類型建議。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 8物理硬盤話題物理硬盤話題: ASE 12.5n裸分區(qū)l服務器在磁盤初始化時就預分配了空間,這

6、樣創(chuàng)建數(shù)據(jù)庫時就不容易失敗。n操作系統(tǒng)文件l服務器在磁盤初始化時就預分配了空間,這樣創(chuàng)建數(shù)據(jù)庫時就不容易失敗。l寫盤操作在兩個平臺上都保證。l性能通常較好。s文件系統(tǒng)設備能夠使用文件大緩存。s查詢文件系統(tǒng)設備通常性能好。u所需頁即使不能在 Sybase 緩存中也可能在文件系統(tǒng)緩存中找到。l文件系統(tǒng)容易管理。n所以, 推薦使用文件系統(tǒng)。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 9初始化設備初始化設備n設備初始化是設備準備存儲并使服務器知道它的過程。l設備在使用前必須初始化。n一旦設備完成初始化后,就能用于存儲:

7、l數(shù)據(jù)庫;l指定數(shù)據(jù)庫對象;l數(shù)據(jù)庫事務日志。n設備初始化使用 disk init 命令。l把指定的物理磁盤設備或操作系統(tǒng)文件映射到一個數(shù)據(jù)庫設備名。l新設備列在 master.sysdevices 中。l該設備準備存放數(shù)據(jù)庫。l只有系統(tǒng)管理員能執(zhí)行 disk init。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 10分配單元分配單元ndisk init 將數(shù)據(jù)庫設備分成分配單元。l每個分配單元由256個2K的頁組成。(等于1/2MB 內(nèi)存容量)l每一分配單元的首頁是分配頁。s即便在分配單元上,此頁仍包含有關數(shù)

8、據(jù)庫的信息。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 11disk init語法語法n語法:disk initname = logical_device_name,physname = physical_name,vdevno = virtual_device_number,size = number_of_pages,dsync = true | false nUNIX例子:disk initname = dev_dat_2,physname = /dev/rxyla,vdevno = 2, size =

9、51201999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 12disk init語法語法nNT例子:disk initname = dev_dat_2,physname = d:devicesuserdisk.dat,vdevno = 2, size = 51201999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 13虛擬設備號虛擬設備號n虛擬設備號是在 disk init 命令中賦給 vdevno 的值。n可使用從2到( number of

10、 devices 配置值 - 1)沒有使用的任何數(shù)字。lmaster device設備使用 vdevno 值為0。lsybprocsdev設備使用 vdevno 值為1。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 14選擇虛擬設備號nsp_helpdevice列出所有正在使用的 vdevno 號。n下面查詢返回正在使用 vdevno 的最大值:select max(low/16777216) from sysdevicesl每個設備最多有 16,777,216 個虛擬頁。smaster device設備使用 0

11、 到 16,777,216。ssybprocsdev device設備使用 16,777,217 到 33,554,431。s下個設備使用 33,554,432 到 50,331,647。lsysdevices表中的列 low 記錄了該設備使用的最低虛擬頁號。l所以 (low/16,777,216) 返回該設備的 vdevno 值。l這在創(chuàng)建設備的腳本中有用。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 15dsync子句子句ndsync子句決定如何向 UNIX 操作系統(tǒng)文件設備上寫數(shù)據(jù)。l當設為 TRUE 時:

12、s直接寫到磁盤上。s保證完全恢復。l當設為 FALSE 時:s寫盤要通過 UNIX 文件緩沖區(qū)。s不能保證完全恢復。n如果沒有指定 dsync 值, 該值設為 TRUE。n當使用 UNIX 裸設備和 NT 設備時,不考慮 dsync 值。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 16刪除設備刪除設備n語法:sp_dropdevice logical_device_namen例子:sp_dropdevice dev_dat_2n刪除設備。l當需要改變、修理或增加硬件時;l當需要改變設備大小時。s為了達到該目的,

13、刪除然后重建該設備。n一旦設備被刪除,它的 vdevno 值就釋放出來了。n在刪除設備前,必須先把該設備上所有的數(shù)據(jù)庫移開。nsp_dropdevice并不從操作系統(tǒng)中刪除設備文件(它必須手工刪除)。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 17查看設備信息查看設備信息n語法:sp_helpdevice logical_device_namel帶一個設備名, 它返回該設備信息;l不帶設備名,它返回所有設備信息。n例子:sp_helpdevice dev_dat_2device_namephysical_nam

14、edescription-dev_dat_2d:Sybaseuserdisk.datspecial, dsyncon, physicaldisk, 10.00MBstatus cntrltypedevice_number lowhigh- - -16386071174405121174456311999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 18sysdevices系統(tǒng)表系統(tǒng)表nsysdevices是記錄每個設備的系統(tǒng)表。l它只在 master 數(shù)據(jù)庫中。n例子:select * from sysdevices19

15、99 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 19開發(fā)習慣建議開發(fā)習慣建議n要確認命令 disk init 執(zhí)行成功。l確認有足夠的磁盤剩余空間。s在 UNIX 上, 執(zhí)行 df -k 命令。s在 Windows NT上,查看磁盤的屬性。n在 UNIX 上,確認 sybase 帳戶在該設備上有寫權限。n使用有意義的設備名。n創(chuàng)建和保存你的設備分配腳本。n將 sysdevices 系統(tǒng)表作一個硬拷貝。l該硬拷貝為物理設備與邏輯設備的映射。1999 Sybase, Inc. and its subsidiaries. A

16、ll rights reserved.6 - 20動手練習動手練習06A: 初始化設備初始化設備n除非特別指定, 否則每個方標語句都在自己的批中執(zhí)行。n轉到 master 數(shù)據(jù)庫:use mastern正在使用的虛擬設備號最大是多少?select max(low/16777216) from sysdevices_n初始化一個新設備。對應 vdevno 值,使用最大虛擬設備號加1:1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 21動手練習動手練習06A: 初始化設備初始化設備disk initname = dev

17、_dat_temp,physname = device_path_1,vdevno = ,size = 5120n確認設備已創(chuàng)建好:sp_helpdevice dev_dat_tempndisk init命令指定設備大小為 5120, 但 sp_helpdevice 報告設備大小為10MB。兩個數(shù)為什么不同? 1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 22動手練習動手練習06A: 初始化設備初始化設備_n正在使用的最大虛擬設備號是多少?select max(low/16777216) from sysdevi

18、cesn刪除已創(chuàng)建的設備:sp_dropdevice dev_dat_tempn正在使用的最大虛擬設備號是多少 ?select max(low/16777216) from sysdevices1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 23單元提要單元提要創(chuàng)建和刪除設備n缺省設備缺省設備n鏡像設備n備份master數(shù)據(jù)庫1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 24缺省設備缺省設備n當創(chuàng)建一個數(shù)據(jù)庫時, 可指定它所在的設備。

19、n缺省設備是當創(chuàng)建數(shù)據(jù)庫時沒有指定設備而該數(shù)據(jù)庫所在的設備。l可有多個缺省設備。s當有多個缺省設備時, 缺省設備按照邏輯設備名的字母次序使用。s第一個設備用滿后,然后使用第二個,依次類推。l可能沒有缺省設備。s如果沒有缺省設備而你創(chuàng)建數(shù)據(jù)庫時又沒有指定設備,則該命令失敗。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 25使設備變?yōu)槿笔≡O備使設備變?yōu)槿笔≡O備n語法:sp_diskdefault logical_device_name, defaulton | defaultoffn例子:sp_diskdefault

20、 dev_dat_2 defaulton1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 26master設設 備備nmaster設備是安裝過程中的缺省設備。l它包含 master, model, tempdb, 和 sybsystemdb 數(shù)據(jù)庫。nMaster 數(shù)據(jù)庫不能擴展到 master設備外。nSybase建議:l擴展 model, tempdb, 和 sybsystemdb 數(shù)據(jù)庫到 master 設備外。l將 master 設備變?yōu)榉侨笔≡O備。1999 Sybase, Inc. and its subs

21、idiaries. All rights reserved.6 - 27不能為缺省設備的設備不能為缺省設備的設備下面類型的設備可為缺省設備, 但 Sybase 建議不要把它們使用為缺省設備:nmaster設備;nsybsecurity設備 (如果安裝了的話);n任何只用作事務日志的設備;n高性能數(shù)據(jù)庫所使用的設備。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 28動手練習動手練習06B保護保護 master 設備設備除非特別指定, 否則每個方標中語句在自己的批中執(zhí)行。n轉到 master 數(shù)據(jù)庫:use mast

22、ern查看 master 設備的缺省狀態(tài):sp_helpdevice mastern將 master 設備變?yōu)榉侨笔≡O備:sp_diskdefault master, defaultoffn查看 master 設備的缺省狀態(tài)以確認修改:sp_helpdevice master1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 29單元提要單元提要創(chuàng)建和刪除設備缺省設備n鏡像設備鏡像設備n備份 master 數(shù)據(jù)庫1999 Sybase, Inc. and its subsidiaries. All rights res

23、erved.6 - 30磁盤鏡像磁盤鏡像n在介質(zhì)損壞情況下,磁盤鏡像提供不間斷恢復。l鏡像設備是“重復”的。l所有向設備的寫操作都被拷貝到另一個分離設備上。l如果一個硬盤壞了, 服務器在 error log 注出后繼續(xù)使用令外一個硬盤。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 31鏡像的優(yōu)點與缺點鏡像的優(yōu)點與缺點n優(yōu)點:l磁盤壞后不會停機;l確保全部、不間斷恢復。n缺點:l占用額外磁盤資源;l有用數(shù)據(jù)寫到兩塊磁盤上,因而會降低性能。n盡管會增加成本開銷, 仍然建議使用磁盤鏡像。1999 Sybase, Inc

24、. and its subsidiaries. All rights reserved.6 - 32鏡像設備時發(fā)生的動作鏡像設備時發(fā)生的動作1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 33鏡像一個設備鏡像一個設備n語法:disk mirrorname = logical_device_name,mirror = physical_device_name, writes = serial | noserialnUNIX例子:disk mirrorname = dev_dat_2,physname = /dev/r

25、xyld_mrrnNT例子:disk mirrorname = dev_dat_2,physname = d:devicesuserdiskmirror.dat1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 34用戶引發(fā)的鏡像取消用戶引發(fā)的鏡像取消n語法:disk unmirrorname = logical_device_name, side = primary” | secondary, mode = retain | removen例子:disk unmirrorname = dev_dat_2,mode =

26、 remove1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 35系統(tǒng)引發(fā)的鏡像取消系統(tǒng)引發(fā)的鏡像取消n在鏡像設備上的一個 I/O 錯誤會自動取消設備鏡像。n當 I/O 錯誤發(fā)生時:lAdaptive Server 繼續(xù)在非鏡像模式下運行;lsysdevices表中的狀態(tài)位指示非激活和哪一個設備處于工作狀態(tài);l出錯設備的 I/O 不起作用了;l在 master 數(shù)據(jù)庫中執(zhí)行 checkpoint ; l錯誤信息送到 error log 中;lwaitfor mirrorexit 進程被激活。1999 Sybase,

27、 Inc. and its subsidiaries. All rights reserved.6 - 36設備再鏡像設備再鏡像n語法:disk remirrorname = logical_device_name例子:disk remirrorname = dev_dat_2n該命令恢復被掛起設備的鏡像,將設備內(nèi)容拷貝到鏡像設備上。l在用戶引起或系統(tǒng)引起的取消鏡像后使用該命令。l在鏡像掛起期間寫到主設備的任何數(shù)據(jù)都要拷貝到第二塊設備上。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 37移動一個設備移動一個設備n

28、鏡像可用于將一個設備從一個位置移到另一個位置。l鏡像設備被移到新位置。s這將第一個設備拷貝到新位置。l取消主設備面的鏡像。s這樣就停止使用老位置設備,轉而使用新位置設備。n例子:disk mirrorname = dev_dat_2,physname = /dev/new_locationdisk unmirrorname = dev_dat_2,side = primary,mode = remove1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 38什么應該鏡像什么應該鏡像?n鏡像最有價值和最脆弱的設備。lma

29、ster 設備l日志設備l活動設備n理想狀態(tài), 應該鏡像所有數(shù)據(jù)庫設備。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 39查看鏡像設備信息查看鏡像設備信息nsp_helpdevice包含鏡像設備信息。n語法:sp_helpdevice logical_device_namen例子:sp_helpdevice dev_dat_2device_namephysical_namedescription.-dev_dat_2/dev/rxylaspecial, MIRROR ENABLED, mirror= /dev/r

30、xyld, serial writes, reads mirrored.1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 40鏡像規(guī)則鏡像規(guī)則n一個設備和它的鏡像組成一個邏輯設備,而不是兩個。n第二個物理設備容量必須大于等于主磁盤設備, 并且它應該在單獨一個物理硬盤上。l遵循特定平臺對鏡像設備的額外限制。n為了鏡像全部數(shù)據(jù)庫, 要鏡像該數(shù)據(jù)庫的每個設備。n在主盤不忙時作鏡像。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 41啟動時鏡像啟

31、動時鏡像Master設備設備n可在啟動時鏡像 master 設備。l如果主 master 設備有問題時, Adaptive Server 能夠使n在 UNIX 上,在啟動時鏡像 master 設備,編輯 RUNSERVER文件,加入鏡像設備的物理名。l例子:dataserver -ddevicename . -rmastermirror_devicename.1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 42啟動時鏡像啟動時鏡像Master設備設備n在 UNIX 或 NT 上,采用以下步驟利用 Sybase Ce

32、ntral 配置在啟動時鏡像 master 設備:1. 打開數(shù)據(jù)庫設備文件夾;2. 點擊 master 設備圖標;3. 選擇 Mirror 頁;4. 點擊 Mirrored Device 檢查框;5. 提供鏡像設備路徑。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 43單元提要單元提要創(chuàng)建和刪除設備缺省設備鏡像設備n備份備份 master 數(shù)據(jù)庫數(shù)據(jù)庫1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 44備份備份 master 數(shù)據(jù)庫數(shù)

33、據(jù)庫nMaster 數(shù)據(jù)庫中包含的系統(tǒng)表對服務器功能非常重要。在增加、修改和刪除前后備份 master 數(shù)據(jù)庫非常重要。u設備;u數(shù)據(jù)庫;u段;u用戶。n本節(jié)提供數(shù)據(jù)庫備份的簡單概要。l它包含能夠備份 master 數(shù)據(jù)庫的足夠信息。l備份和裝載數(shù)據(jù)庫的詳細信息在“備份數(shù)據(jù)庫”單元中詳細討論。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 45轉儲設備轉儲設備n一個數(shù)據(jù)庫備份,或“轉儲”是整個數(shù)據(jù)庫的一個物理備份。n數(shù)據(jù)庫備份存放到轉儲設備上。1999 Sybase, Inc. and its subsidiari

34、es. All rights reserved.6 - 46增加和刪除轉儲設備增加和刪除轉儲設備n簡化的增加語法:sp_addumpdevice tape | disk , logical_name, physical_namen例子:sp_addumpdevice tape, dump_master_db,/dev/nrmt4sp_addumpdevice disk, dump_pubs2_db,/usr/backups/disk.dumpn刪除語法:sp_dropdevice logical_namen例子:sp_dropdevice dump_master_dbsp_dropdevice

35、 dump_pubs2_db1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 47備份服務器備份服務器n所有 Adaptive Server 的備份都是由備份服務器完成的。l是一個基于 Open Server 的程序,與 Adaptive Server 運行在同一臺機器上。n做備份前必須先啟動備份服務器。l可使用 startserver 命令啟動備份服務器。l可使用 Sybase Central 命令啟動備份服務器。1999 Sybase, Inc. and its subsidiaries. All rights

36、reserved.6 - 48備份備份 master 數(shù)據(jù)庫數(shù)據(jù)庫n簡化語法:dump database masterto dump_device_namen例子:dump database masterto dump_master_dbn備份 master 數(shù)據(jù)庫時其它用戶可使用服務器。n在創(chuàng)建、修改或刪除設備前后應該備份 master 數(shù)據(jù)庫。1999 Sybase, Inc. and its subsidiaries. All rights reserved.6 - 49總總 結結n一個數(shù)據(jù)庫設備是存放該數(shù)據(jù)庫內(nèi)對象的物理資源。n設備必須初始化后才能使用。ldisk init命令用于初始化設備。l一旦設備初始化后,它就能存放數(shù)據(jù)庫、指定數(shù)據(jù)庫對象和數(shù)據(jù)庫事務日志。l要刪除一個

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論