f3 db2 backup, rec. o performance (ppt-fil)
TRANSCRIPT
DB2 Universal Database
Backup + Recovery + Performance
Bernt Castman
ISK/Kista okt 2001
THE IT AFTERMATH(after Sept 11 2001)
• Recovery, security, and privacy have taken on new meaning in the wake of the terrorist attacks earlier this month. Special coverage of how the attacks affected IT procedures, major Web sites, and networks at companies large and small - plus what changes to expect in the industry as a result -is available at http://www.techweb.com/hot_topics/us_attacked.
Vad är viktigast kring Databaser?• Installation?• GUI? The Control Center? • Java - möjligheter?• Backup och recovery av data JAA!!
– Strömavbrott– Applikationsprogramvara som går fel– dåliga, små diskar och dåligt, gammalt minne– Nätverksproblem– Avgörande: vilken tid det tar tills man är uppe
En enda transaktionskedja
• En check skall lösas in, transaktionskedja. – Utställarens konto skall belastas med summan– Om ovanstående deltransaktion kan göras skall
mottagarens konto utökas med summan minus ev. avgift …annars
• Vad kan hända?– Hela transaktionskedjan utförd– Ingen del görs– Första delen görs men inte den andra
Roll - back
Transaction Log Example 1
Log
Beg
in T
2B
egin
T2
LSN 12
5
14
Insert R
2In
sert R2
Insert R
4In
sert R4
16
16
R2
R4
Delete R
2D
elete R2
21 22
Ab
ort T
2A
bo
rt T2
21
R2
R4
19
Delete R
4D
elete R4
19
R2
R4
Done
Backup?
• Backup beskriver processen att ta en kopia av alla data i databasen och lagra dessa någonstans och på något sätt helt säkert– förvaras brandskyddat
– på något annat medium (tape, CD)
– på någon annan dators diskar i annan lokal
• Recovery är processen att få data tillbaka från denna säkra plats så att man kan fortsätta bearbetningen som om ingenting hänt
När och Hur?
• Off-Line– Statisk kopia som tas när databasen inte används.
Körningen kan ta ända fram till nästa användning av databasen
• On-Line– Kopia när användarna fortsätter att använda
databasen– Kan påverka prestanda, ge längre svarstider– Mycket svårare att göra recovery
Grunden för loggning
• En check skall lösas in, transaktionskedja. – Utställarens konto skall belastas med summan– Om ovanstående deltransaktion kan göras skall
mottagarens konto utökas med summan minus ev. avgift
• Vad kan hända?– Hela transaktionskedjan utförd– Ingen del görs– Första delen görs men inte den andra
Loggningsalternativ
• Before– före det att händelsen sker
• After– efter allt uppdaterande har skett
• logiskt• fysiskt
• Transaktionsloggning dvs som applikationer• Imageloggning dvs kopia av databasdel
Rollback
• Pågående transaktioner, dvs sådana som inte avslutats, kan återföras
• Databasen ser efter en rollback ut som den gjorde före transaktionerna
• Data till rollback hämtas från log-filer– när transaktionerna startas– när operationerna är avslutade var för sig– när alla transaktioner är kompletta
Roll Forward
• Köra transaktioner framåt från log-fil kallas Roll Forward
• Kan ibland vara enda alternativet men tar ofta väldigt lång tid. Endast realistiskt för del av en dag eller högst en-två dagar.
• Även om man skall återskapa en databas, som delvis är trasig, gör detta i en ny kopia. Man vet aldrig när man behöver den trasiga!
Backup & Restore SmartGuide
• I DB2 Control Center, klicka fram SAMPLE i vänsterfönstret
• Gå in i fönstret till figuren av SAMPLE och högerklicka
• Välj Backup med alternativet SmartGuide
• Restore sker på motsvarande sätt
Considerations
• Point of Recovery
• Frequency of Backups and Time Required
• Recovery Time Required
• Storage Considerations
• Keeping related data together
• Managing Log Files
Keeping Related Data Together
• As part of your database design, you will know the relationships that exist between tables. These relationships can be at the application level, where transactions update more than one table, or at the database level, where referential integrity exists between tables, or where triggers on one table affect another table. You should consider these relationships when developing a recovery plan.
Keeping Related Data Together
• You will want to back up related sets of data together. The sets of data can be established at either the table space or the database level. By keeping related sets of data together, you can recover to a point where all of the data is consistent. This is especially important if you want to be able to perform point-in-time roll-forward recovery on table spaces.
Recovery Performance
• Frequently updated databases: Log on separate device
• Online transaction processing: more I/O needed for the logs than store a row: separate physical disk
• logs on different disk from system paging
LOB columns
• If a table contains long field or large object (LOB) columns, you should consider placing this data into a separate table space. This will affect your storage space considerations as well as affect your plan for recovery. With a separate table space for long field and LOB data, and knowing the time required to back up long field and LOB data, you may decide to use a recovery plan that only infrequently saves a backup of this long field/LOB table space. You may also choose, when creating or altering a table to include LOB columns, not to log changes to that column. This will reduce the size of the log space required and the corresponding log archive space.
• Because the database logs can take a large
amount of storage, if you plan on using the roll-forward recovery method you must decide how to manage the archived logs. Your choices are the following:
– Dedicate enough space in the database log path directory to retain the logs.
– Manually copy the logs to a storage device or directory other than the database log path directory after they are no longer in the active set of logs.
– Use a user exit program to copy these logs to another storage device in your environment
Total System Performance• Det interna arbetet i DB2 är IBMs
hemlighet
• Vissa spår kan skönjas– Kör med mer eller mindre loggning– Ändra bufferthanteringen– Läs av och förstå Table Statistics och Index
Statistics– Högerklicka på SAMPLE och använd
Configure Performance SmartGuide
. Benchmark Testing
• Normally oriented towards the configuration parameters. However, the same basic technique can be used for tuning other factors that affect performance, such as:
SQL statements
Indexes
Table space configuration
Application code
Hardware configuration.
Problem Analysis
What do you mean by "slow response"? Is it ten percent slower than you expect it to be, or tens of times slower?
When did you notice the problems? Is it recent or has it always been there?
Do you know of other users who are complaining of the same problem? Are those complaining one or two individuals or a whole group?
(If a whole group of users are experiencing difficulties, are they connected to the same terminal controller?)
Are the problems you are experiencing related to a specific transaction or application program?
Do your problems appear during regular periods such as at lunch hour, or are they continuous?
How you manage disk storage affects performance
• How Storage is Divided: – How you divide a limited amount of storage between
indexes and data, among table spaces, and among buffer pools, determines to a large degree how each will perform in different situations.
• Wasted Storage: – Wasted storage in itself may not affect the performance of
the system that is using it, but it may represent a resource that could be used to improve performance elsewhere.
• Distributing Disk I/O– How well you balance the demand for disk I/O across
several disk storage devices, and controllers can affect how fast the database manager can retrieve information from disks.
• Running out of storage space– Reaching the limit of available storage can degrade
overall performance.
Hur förbättra tillgänglighet? High Availibility
• Hot Standby
• Mutual Takeover -Flera Fristående Processorer med gemensamma diskar
• F F P + separata diskar – High Availibility Cluster Multi-Processing (HACMP)
• Databas-spegling med flera fristående diskar
• Mutual Takeover with NFS Failover and DB2 Failover
Ultimate solution
• A site to be used in the event of an emergency
• A different machine on which to recover the database
• Off-site storage of database backups and archived logs.
Protecting Against Disk Failure
• With a RAID disk array, multiple disks are used and managed by a disk controller, complete with its own CPU
• A software disk array accomplishes much the same as a hardware disk array but the management of the disk traffic is done by either an operating system task or an application program running on the server.
•
Hardware ideas
• To reduce the impact of a transaction failure, try to ensure the following:
Uninterrupted power supplies.
Adequate disk space for database logs.
Reliable communication links among the database partition servers in a partitioned database environment.
Prestandaövervakning
Information om status för DB2 Universal Database och de data som kontrolleras av den.
Varningar om ovanliga situationer.
Kan användas för övervakning av:
Förekomster
Databaser
Tabeller
Tabellutrymmen
Anslutningar
Visar de objekt som övervakas genom att den ikon som visas bredvid objekt i objektträd för Styrcenter antingen är grön, gul eller röd.
• Med den information som inhämtas i prestandaövervakare kan du:
Upptäcka prestandaproblem
Optimera prestanda för databaser
Analysera prestandatrender
Analysera prestandan hos databastillämpningar
Förhindra problem från att uppstå
Fördefinierade övervakare
• Det finns övervakare: DISK_PERFORMANCE (en fördefinierad övervakare som levereras från IBM).
• I övervakaren DISK_PERFORMANCE övervakas in- och utdata. Den innehåller prestandavariabler med fokus på diskprestanda på databas- och tabellutrymmesnivå.
Mail från Mats Mohlin (4 sidor)
jag kör DB2 V7.1 där man i Control Center kan välja SHOW COMMAND för att spara undan detta (jag gör CUT/PASTE)Jag skapade en db create db testdb on D;Slog på logretain (via CC configure DB - logs )update db cfg for testdb using logretain recovery;Tog backup via CC sparade kommandotBACKUP DATABASE TESTDB TO D:\\backup WITH 2 BUFFERS BUFFER 1024 ;Backup successful. The timestamp for this backup image is : 19991123112353
Spapade tabell:create table test ( id int, c1 char(10) );
Insertade rader:insert into test values (01 , 'AAAAAAAAA1');insert into test values (02 , 'AAAAAAAAA2');insert into test values (03 , 'AAAAAAAAA3');insert into test values (04 , 'AAAAAAAAA4');
Tog ny backup via CC eller kommandoradBACKUP DATABASE TESTDB TO D:\\backup WITH 2 BUFFERS BUFFER 1024 ;
Backup successful. The timestamp for this backup image is : 19991123112644
insertade lite fler raderinsert into test values (11 , 'AAAAAAAA11');insert into test values (12 , 'AAAAAAAA12');insert into test values (13 , 'AAAAAAAA13');insert into test values (14 , 'AAAAAAAA14');
stoppade DB2;
kopierade undan alla logfiler i D:\DB2\NODE00000\SQL00001\SQLLOGDIRtill D:\tempDenna kopiering kan också göras löpande via userexits, det är nödvändigt att rädda log-filerna om disken skulle krascha
Jag gjorde sedan för (i filsystemet) erase av D:\DB2 och allt uder dvs hela databasenär förstörd pga t.ex diskfel
startade db2;
via Controlcenter gjorde jagDB create from backupJag angav via gui - var min backup låg D:\backup ( bara högsta nivån) - vad min backupdb hette TESTDB - Vid vilket datum 991123 min backup kom ifrån - Vilket tid min backup var ifrån 11:23 (Datum och tid framgår om man kollar i filsystemet om man glömt notera list history backup all for testdb; är också användbart dat hhmmss D:\backup\TESTDB.0\DB2\NODE0000\CATN0000\19991123\112353.001 - vad min nya db skulle heta TESTNEW - var mina loggar låg D:\temp (detta blir LOGPATH i nya TESTNEW kan bytas senare) - Angav rollforward to end of logs om Du inte gör detta kommer Du inte åt db utan måste via CC köra STOP ROLLFORWARD (anv om man har fler loggar att applicera)
Show SQL visade detta kommando
RESTORE DATABASE TESTDB FROM D:\\backup\\ TAKEN AT 19991123124225 TO E: INTO TESTNEW NEWLOGPATH D:\temp WITH 2 BUFFERS BUFFER 1024 WITHOUT PROMPTING ; ROLLFORWARD DATABASE TESTDB TO END OF LOGS AND STOP
Jag körde via CC och det gick bra Sedan tittade jag i tabellerna och alla nya rader var medconnect to testnew Database Connection Information Database server = DB2/NT 6.1.0 SQL authorization ID = SE59192 Local database alias = TESTNEWselect * from testID C1 ----------- ---------- 1 AAAAAAAAA1 2 AAAAAAAAA2 3 AAAAAAAAA3 4 AAAAAAAAA4 11 AAAAAAAA11 12 AAAAAAAA12 13 AAAAAAAA13 14 AAAAAAAA14 8 record(s) selected.
TPC
• The Transaction Processing Performance Council is an organization of 41 companies who define, develop, and support system performance benchmarks for various application environments. Current benchmarks are TPC-C, representing medium OLTP, and TPC-D , representing decision support environments.
All from TPC
• The TPC-H (Ad-hoc, decision support) benchmark represents decision support environments where users don't know which queries will be executed against a database system
• The TPC-R (Business Reporting, Decision Support) benchmark represents decision support environments where users run a standard set of queries against a database system
• TPC Benchmark™ W (TPC-W) is a transactional web benchmark. The workload is performed in a controlled internet commerce environment that simulates the activities of a business oriented transactional web server.
What is TPC-C benchmark
• In TPC-C, throughput is defined as how many New-Order transactions per minute a system generates while the system is executing four other transactions types (Payment, Order-Status, Delivery, Stock-Level) with certain user response times requirement, with the New-Order transaction response time set at 5 seconds
Cont..
• Therefore, for a 710 tpmC number, a system
• is generating 710 New-Order transactions per minute while fulfilling the rest of the TPC-C transaction mix workload.
$/tpmC ?
• All cost dimensions of an entire system environment the user might purchase, including terminals, communications equipment, software (transaction monitors and database software), computer system or host, backup storage, and three years maintenance cost.
How do I get more information beyond the TPC's results listing?
• First, you can obtain a Full Disclosure Report (approximately 100 pages) from our web site under Benchmark Results.
• In addition, you may choose to contact the vendor who may be able to supply additional performance and pricing information.