İndir

580 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
580
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

İndir

  1. 1. Tips for database administrators Gus Bj örklund (gus@progress.com) Wizard, Progress Software Corporation
  2. 2. Ask questions as we go if I am not being clear about something. Warning: there is a mistake somewhere in these slides.
  3. 3. Topics <ul><li>Tip Nr. 0x00 </li></ul><ul><li>… </li></ul><ul><li>Tip Nr. 0x16 </li></ul>numbered for easy reference
  4. 4. Tip Number 0x00 If it is not broken, don’t fix it !
  5. 5. Tip Number 0x01 If you do fix something, test your fix !
  6. 6. Tip Number 0x02 Read the man pages
  7. 7. Read the man pages <ul><li>man man </li></ul><ul><li>man [ -s section ] name </li></ul><ul><li>Read the man pages! </li></ul>
  8. 8. Tip Number 0x03 SSH is your friend! Like Linux, great software from Finland
  9. 9. SSH <ul><li>SSH replaces telnet, rlogin, rcp, rsh, etc. </li></ul><ul><li>All connections are encrypted </li></ul><ul><li>Use for remote access over Internet </li></ul>
  10. 10. SSH <ul><li>Don’t need username, password login </li></ul><ul><ul><li>Can also use certificates for authentication </li></ul></ul><ul><li>Can send output of </li></ul><ul><ul><li>local commands to remote host </li></ul></ul><ul><ul><li>remote commands to local host </li></ul></ul><ul><li>Can do secure file transfer </li></ul><ul><ul><li>scp and sftp </li></ul></ul><ul><li>Can tunnel other protocols (e.g. X windows) </li></ul>
  11. 11. Simple remote command execution gus@dirac:gus $ ssh bespin ls gus@bespin's password: 101arkt 90ajdk.txt GSI Mail News a.out a7 adb.man gus@dirac:gus $ Nothing much to see here
  12. 12. Remote command output to local host gus@dirac:gus $ ssh bespin &quot;ls; echo DONE” >ls.dat gus@bespin's password: gus@dirac:gus $ cat ls.dat 101arkt 90ajdk.txt GSI Mail News a.out a7 adb.man DONE gus@dirac:gus $ Output of remote commands written to local file
  13. 13. Local output piped to remote host gus@dirac:gus $ cd 4gl; tar -cf - *.p | ssh bespin &quot;cd foo; tar -xf -&quot; gus@bespin's password: gus@dirac:4gl $ Backup files in a local directory to a remote directory
  14. 14. Remote backup piped to local file gus@dirac:4gl $ ssh bespin &quot;cd pdr; tar -cvf - .&quot; >backup.tar gus@bespin's password: a ./ 0K a ./Makefile 1K a ./pdrcache.c 131K a ./pdrproc.c 23K a ./pdrtrig.c 175K a ./dsmcon.c 94K a ./dsmrec.c 17K a ./dsmseq.c 15K gus@dirac:4gl $ Backup files in a remote directory to a local directory
  15. 15. Turning off sshd password authentication in the file: /etc/ssh/sshd_config, do this: # Protocol 1,2 Protocol 2 . . . # Authentication: PasswordAuthentication no then save changes. restart daemon: # service sshd restart
  16. 16. Enabling SSH certificate authentication gus@dirac:gus $ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/gus/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/gus/.ssh/id_rsa. Your public key has been saved in /Users/gus/.ssh/id_rsa.pub. The key fingerprint is: 3f:a9:2c:a6:74:5e:36:59:39:7f:ed:3f:5d:e3:a6:ee [email_address] gus@dirac:gus $ gus@dirac:gus $ ssh-copy-id -i id_rsa gus@bespin gus@dirac:gus $
  17. 17. Enabling SSH certificate authentication 2 gus@dirac:gus $ cat /Users/gus/.ssh/id_rsa.pub. ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEApwswruyeETRbQ/T7ZHdNxtXIC5J41XpnJwWND4HB3WTuXPLx/Qf2S83Y3VPSgGoc+9YqmLOc/hfs/gQry+TQC9jGIPVYtW/E5PPvhh/HxTIKVc0eYMmpKlxFCjfcv0KyDcAwnd7r/wczPqw2TpurzZcXfA0c2upqufJZbnweXZtDrcs7bUwdQXskrqDj1EDBxACuH1/omZa2M/PdfFzyrRtbRMeyrfIWAfoL5RNOFsPYYOxWJxfp11tuSF7OiBUQtcbXAfS8cdHsQkJNNzSZqM6B69LvK28mlHZ8m2b5+cXICA27aUyDZfsSlMLR6rl+Ao3UByL8G+ZQBLUmhMsuRQ== gus@dirac.bedford.progress.com gus@dirac:gus $
  18. 18. More about SSH www.openssh.com http://www.ietf.org/rfc/rfc4251.txt
  19. 19. Tip Number 0x04 Windows can do SSH too
  20. 20. SSH for Windows Client: use Putty http://www.chiark.greenend.org.uk/~sgtatham/putty/ Server: get Cygwin http://www.cygwin.com
  21. 21. Tip Number 0x05 After-image journalling is your friend!
  22. 22. After Imaging <ul><li>Do you use after-image journalling? </li></ul><ul><ul><li>YOU SHOULD </li></ul></ul><ul><li>AI records </li></ul><ul><ul><li>all database changes after a backup </li></ul></ul><ul><li>Intended for </li></ul><ul><ul><li>disaster recovery </li></ul></ul><ul><ul><li>hot standby on another machine </li></ul></ul>
  23. 23. AI Basics <ul><li>Add AI extents to database </li></ul><ul><li>Back up the database </li></ul><ul><li>Enable after-imaging </li></ul><ul><li>Archive ai extents as they become full </li></ul><ul><ul><li>10.1 has an automatic archiver </li></ul></ul><ul><li>OpenEdge DBA guide has details </li></ul>
  24. 24. AI basics 2 <ul><li>A failure occurs and you lose your database ….. </li></ul><ul><li>Fix the failure </li></ul><ul><ul><li>replace disk, memory, machine, etc. </li></ul></ul><ul><li>Restore the backup copy of your database </li></ul><ul><li>Roll forward all ai extents you archived </li></ul><ul><ul><li>You do know where you put them, don’t you? </li></ul></ul><ul><ul><li>I hope they weren’t on the failed disk </li></ul></ul><ul><li>When roll forward done, start database </li></ul><ul><li>Now you are back to where you were </li></ul>
  25. 25. Tip Number 0x06 Specify scratch space for index rebuild
  26. 26. Index rebuild scratch space Command line looks like this: proutil dbname -C idxbuild table customer -SS dbname.srt -TB 31 -TM 32 -B 1000 Scratch space spec file (dbname.srt) looks like this: 300 /user2/db1/first/ 400 /user3/junk/ 0 /user4/last/ note multiple drives in this example
  27. 27. Tip Number 0x07 Tools you should know about
  28. 28. Tools <ul><li>uptime </li></ul><ul><li>find </li></ul><ul><li>top </li></ul><ul><li>lsof </li></ul><ul><li>ifconfig </li></ul><ul><li>vmstat </li></ul><ul><li>iostat </li></ul><ul><li>netstat </li></ul><ul><li>bzip2 </li></ul>
  29. 29. Tools: uptime $ uptime 11:26am up 17 day(s), 9:16, 163 users, load average: 3.09, 3.36, 3.76 $
  30. 30. Tools: top gus@dirac:gus $ top -l 1 Processes: 65 total, 3 running, 62 sleeping... 183 threads 10:51:24 Load Avg: 0.04, 0.06, 0.07 CPU usage: 11.1% user, 44.4% sys, 44.4% idle SharedLibs: num = 170, resident = 37.0M code, 5.30M data, 6.44M LinkEdit MemRegions: num = 6460, resident = 166M + 16.3M private, 164M shared PhysMem: 161M wired, 758M active, 879M inactive, 1.76G used, 248M free VM: 9.47G + 102M 230499(0) pageins, 16746(0) pageouts PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE 606 top 0.0% 0:00.05 1 17 19 276K 684K 748K 26.9M 586 bash 0.0% 0:00.02 1 14 16 224K 1.05M 844K 27.1M 585 login 0.0% 0:00.01 1 16 40 172K 768K 636K 26.9M 583 Terminal 0.0% 0:01.56 5 130 197 2.64M 11.9M 8.93M 364M 563 TextEdit 0.0% 0:00.23 1 67 149 2.05M 8.94M 5.80M 355M 558 TeXShop 0.0% 0:03.18 2 109 238 4.49M 20.2M 25.6M 365M 467 firefox-bi 0.0% 1:31.55 6 96 389 48.1M 29.4M 67.4M 428M
  31. 31. Tools:find <ul><li>find files modified more than 30 days ago </li></ul><ul><ul><li>find . -mtime +30 -print </li></ul></ul><ul><li>delete files modified more than 30 days ago </li></ul><ul><ul><li>find . -mtime +30 -exec rm {} ; </li></ul></ul><ul><li>find files bigger than 16k </li></ul><ul><ul><li>find . -size +16384c -print </li></ul></ul><ul><ul><li>find . -size +32 -print </li></ul></ul><ul><li>delete files bigger than 16k </li></ul><ul><ul><li>find . -size +16384c -print | xargs -i rm ; Read the man page for lots more! </li></ul></ul>
  32. 32. Tools:lsof _progres 26240 bleicher /usr/lib/librt.so.1 _progres 26240 bleicher /usr/lib/libsocket.so.1 _progres 26240 bleicher /usr/lib/libintl.so.1 _progres 26240 bleicher /usr/lib/ld.so.1 _progres 26240 bleicher /usr/lib/libdl.so.1 . . . _progres 26240 bleicher /tools/solaris/dlc100b/promsgs _progres 26240 bleicher /tools/solaris/dlc100b/bin/_progres ftp://vic.cc.purdue.edu/pub/
  33. 33. Tools:ifconfig 1-bespin-gus-> /usr/sbin/ifconfig -a lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST, IPv4> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST, IPv4> mtu 1500 index 2 inet 172.16.7.168 netmask ffff0000 broadcast 172.16.255.255
  34. 34. Tools:ifconfig gus@dirac:gus $ ifconfig en0 en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 tunnel inet --> inet6 fe80::217:f2ff:fecc:b686%en0 prefixlen 64 scopeid 0x4 inet 172.16.114.99 netmask 0xffff0000 broadcast 172.16.255.255 ether 00:17:f2:cc:b6:86 media: autoselect (1000baseT <full-duplex,flow-control>) status: active supported media: autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex>10baseT/UTP <full-duplex,hw-loopback> 10baseT/UTP <full-duplex flow-control> 100baseT<half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback> 100baseTX <full-duplex,flow-control> 1000baseT <full-duplex> 1000baseT <full-duplex,hw-loopback> 1000baseT <full-duplex,flow-control> none vlan: 0 parent interface: <none> bond interfaces: <none>
  35. 35. Tools:netstat 1-bespin-gus-> netstat TCP: IPv4 Local Address Remote Address Swind Send-Q Rwind Recv-Q State -------------------- -------------------- ----- ------ ----- ------ ------- bespin.1023 rdlserv.nfsd 26280 0 49640 116 ESTABLISHED bespin.32880 bespin.6015 49152 0 49152 0 ESTABLISHED bespin.32879 bespin.6014 49152 0 49152 0 ESTABLISHED bespin.6014 bespin.32879 49152 0 49152 0 ESTABLISHED bespin.6015 bespin.32880 49152 0 49152 0 CLOSE_WAIT . . .
  36. 36. Tools: netstat -s gus@dirac:4gl $ netstat -s tcp: 794419 packets sent 37468 data packets (22991001 bytes) 51 data packets (11242 bytes) retransmitted 0 resends initiated by MTU discovery 430311 ack-only packets (196294 delayed) 0 URG only packets 0 window probe packets 322074 window update packets 4516 control packets 1308690 packets received 33675 acks (for 22967429 bytes) 2270 duplicate acks 0 acks for unsent data 1248341 packets (1521010141 bytes) received in-sequence 385 completely duplicate packets (343882 bytes) 0 old duplicate packets 41 packets with some dup. data (28512 bytes duped) 33202 out-of-order packets (38094369 bytes) 1 packet (376 bytes) of data after window
  37. 37. vmstat vmstat 3 50 procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- r b swpd free buff cache si so bi bo in cs us sy id wa 0 7 3656 226920 16528 5294120 0 0 360 636 281 823 4 4 49 42 0 6 3656 205504 16584 5302288 0 0 2688 903 1066 4675 7 6 11 75 2 0 3656 186088 16584 5310512 0 0 2656 684 1010 4687 6 6 8 80 22 28 3656 165196 16600 5319748 0 0 2887 871 1096 4623 8 6 8 78 0 94 3656 138524 16648 5331008 0 0 3909 815 1292 3455 8 6 6 79 . . .
  38. 38. iostat gus@dirac:gus $ iostat 5 5 disk0 cpu KB/t tps MB/s us sy id 18.07 4 0.07 7 3 90 0.00 0 0.00 2 1 97 0.00 0 0.00 4 1 95 0.00 0 0.00 2 2 96 0.00 0 0.00 3 1 95
  39. 39. Tools:bzip2 $ ls -l tips_for_dbas_00.ppt -rw-r--r-- 1 gus staff 644096 Apr 23 09:18 tips_for_dbas_00.ppt $ bzip2 tips_for_dbas_00.ppt $ ls -l tips_for_dbas_00.ppt.bz2 -rw-r--r-- 1 gus staff 246356 Apr 23 09:18 tips_for_dbas_00.ppt.bz2
  40. 40. Tools: Windows tabbed console
  41. 41. Tools: windows tabbed console http://sourceforge.net/projects/console/
  42. 42. Tools: More Windoze Stuff http://www.microsoft.com/technet/sysinternals Some useful stuff you can get there: Handle: who has what files open Process Monitor: lots of information about processes and disk activity Autorun: what programs get started automatically Regmon: monitors registry activity Tcpview: shows all active TCP and UDP endpoints PsTools: list processes, system info, who is logged on Zoomit: zoom in on parts of screen Lots more
  43. 43. Tools: Still More Windoze Stuff http://www.baremetalsoft.com/baretail
  44. 44. Tools: Solaris pldd List the dynamic libraries linked into each process pfiles Report fstat(2) and fcntl(2) information for all open files in each process. pmap print information about the address space of a process plimit get or set the resource limits of running processes pargs print process arguments, environment variables preap force a defunct process to be reaped by its parent pkginfo list what packages are installed
  45. 45. Tools: AIX svmon svmon -G -I size inuse free pin virtual memory 1048576 425275 623301 66521 159191 pg space 262144 31995 work pers clnt pin 46041 0 0 in use 129600 275195 0 PageSize PoolSize inuse pgsp pin virtual s 4 KB - 404795 31995 46041 159191 L 16 MB 5 0 0 5 0 List top 15 memory consumers svmon -Pt15 | perl -e ’while(<>){print if($.==2||$&&&!$s++);$.=0 if(/^-+$/)}’
  46. 46. Tools: AIX vmstat vmstat -v 1048576 memory pages 1002054 lruable pages 478136 free pages 1 memory pools 95342 pinned pages 80.1 maxpin percentage 10.0 minperm percentage 50.0 maxperm percentage 36.1 numperm percentage 362570 file pages . . . Use vmo command to adjust minperm, maxperm, numperm as needed http://users.ca.astound.net/baspence/AIXtip/AIX5_Initial_Tuning.htm
  47. 47. Tip Number 0x08 Windows scripting
  48. 48. Windows scripting <ul><li>Cygwin </li></ul><ul><ul><li>provides lots of Unix tools and a shell for Windows. Also SSH server </li></ul></ul><ul><ul><li>Download from: www. cygwin .com </li></ul></ul><ul><li>Windows Services for UNIX Version 3.5 </li></ul><ul><ul><li>From Micro$oft, but free </li></ul></ul><ul><ul><li>Lots of goodies: Korn, C, bash shells, 350 UNIX commands, NFS, NFS gateway, telent, telnetd </li></ul></ul><ul><ul><li>Download from http: //technet . microsoft .com/en-us/interopmigration/bb380242. aspx </li></ul></ul><ul><li>UWIN </li></ul><ul><ul><li>http://www.research.att.com/sw/tools/uwin/ </li></ul></ul>Windows .bat scripts are brain damaged
  49. 49. Tip Number 0x09 how to turn off Windows indexing service
  50. 50. Stop Windows indexing service <ul><li>Go to the Start menu, pick run. </li></ul><ul><ul><li>Type services.msc, click OK. </li></ul></ul><ul><ul><li>Services dialog will show. </li></ul></ul><ul><li>Right-click on indexing service to show properties dialog, </li></ul><ul><li>if service running, click stop. </li></ul><ul><li>select disabled. </li></ul><ul><li>click apply </li></ul><ul><li>close. </li></ul>
  51. 51. Tip Number 0x0a What not to do
  52. 52. What Not To Do
  53. 53. Tip Number 0x0b How to telnet to Windows
  54. 54. Enable Windows telnet login by name/passwd <ul><li>NTLM authentication by default </li></ul><ul><li>To fix: </li></ul><ul><ul><li>run TLNTADMN </li></ul></ul><ul><ul><li>take menu pick no 3 (display/change …) </li></ul></ul><ul><ul><li>pick 7 (NTLM) </li></ul></ul><ul><ul><li>set value to 1 </li></ul></ul><ul><ul><li>take menu pick no 4 (restart service) </li></ul></ul><ul><li>BUT: don’t use telnet </li></ul>enables you to telnet into a Windows machine
  55. 55. Tip Number 0x0c scripting Progress backup
  56. 56. Scripting backup bkupdev=&quot;${DB_bkupdir}/${DB_name}.bkup&quot; rm -f ${bkupdev}* 2>&1 # echo &quot;Backing up database $DB_dir/$DB_name to $bkupdev&quot; # $DLC/bin/probkup online $DB_dir/$DB_name ${bkupdev}01 -vs 250000 -bf 40 <<EOF ${bkupdev}02 ${bkupdev}03 . . . ${bkupdev}12 ${bkupdev}_overflow EOF # source: PEG, from Jared Middleton
  57. 57. Tip Number 0x0d scripting promon
  58. 58. Scripting promon $DLC/bin/promon $DBNAME > promon.log <<- &quot; EOF &quot; 2> /dev/null R&D 5 1 9999 p 3 2 x EOF Set page size, capture list of IO operations by process
  59. 59. Tip Number 0x0e scripting after imaging
  60. 60. Scripting ai archiving EXTENT_NAME=`_rfutil $DB_DIR/$DB -C aimage extent full` # EXTENT_DATE=`date +%Y%m%d-%H%M%S` # like this: 20070516-140856, but change to suit tar -czvf /anotherdisk/aiarchives/$EXTENT_DATE $EXTENT_NAME md5 -q /anotherdisk/aiarchives/$EXTENT_DATE $EXTENT_NAME >/anotherdisk/aiarchives/$EXTENT_DATE $EXTENT_NAME.md5 rfutil $DB_DIR/$DB -C aimage extent empty $EXTENT_NAME or: use ssh to send archived extents to another machine
  61. 61. Tip Number 0x0f How much space is being used by storage areas?
  62. 62. How much space is being used? for each _AreaStatus where ( not _AreaStatus-Areaname matches &quot;*After Image Area*&quot; ) no-lock: display _AreaStatus-Areanum format &quot;>>>&quot; column-label &quot;Num&quot; _AreaStatus-Areaname format &quot;x(20)&quot; column-label &quot;Area Name&quot; _AreaStatus-Totblocks column-label &quot;Tot blocks&quot; _AreaStatus-Hiwater column-label &quot;High water mark&quot; _AreaStatus-Hiwater / _AreaStatus-Totblocks * 100 column-label &quot;% use&quot; _AreaStatus-Extents format &quot;>>>&quot; column-label &quot;Num Extents&quot; . end. from PEG: Dmitri Levin
  63. 63. Tip Number 0x10 List tables by storage area
  64. 64. List tables by storage area for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _File where (_File._File-Number = _Storageobject._Object-number) and (_File._File-Number > 0) break by _File._File-name: display _Area._Area-name _File._File-name. end.
  65. 65. Listing of tables by storage area Area-name File-Name Schema Area agedar Schema Area agedar Schema Area customer Schema Area customer Schema Area item Schema Area item Schema Area monthly Schema Area monthly Why are the areas listed twice ?
  66. 66. List tables by storage area for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _File where (_File._File-Number = _Storageobject._Object-number) and (_File._File-Number > 0) break by _File._File-name: display _Area._Area-name _File._File-name. end.
  67. 67. List tables by storage area 2 for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _File where (_File._File-Number = _Storageobject._Object-number) and (_File._File-Number > 0) and (_StorageObject._Object-type eq 1) break by _File._File-name: display _Area._Area-name _File._File-name. end.
  68. 68. Tip Number 0x11 List indices by storage area and table
  69. 69. List indexes by storage area and table for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _Index where (_Index._Idx-num = _Storageobject._Object-number) and (_StorageObject._Object-type eq 2) : find _File of _Index. if (_File._File-number > 0) then display _Area._Area-name _File._File-name _Index._Index-name. end.
  70. 70. Tip Number 0x12 Learn to use vi
  71. 71. vi cheat sheet
  72. 72. Tip Number 0x13 Tom Bascom’s protop
  73. 73. protop <ul><li>Tom Bascom’s Open Source Progress 4GL VST-based performance monitoring program </li></ul><ul><li>A “promon ++” written in the 4GL </li></ul><ul><li>Displays tons of useful information </li></ul><ul><li>Study source code to learn how it is done </li></ul><ul><li>Download from </li></ul><ul><ul><li>http://www.greenfieldtech.com/articles/protop.shtml </li></ul></ul>
  74. 74. Tip Number 0x14 Adam Backman’s DBA scripts
  75. 75. Adam Backman’s dba scripts <ul><li>Available on PEG: http://www.peg.com/utilities.html </li></ul><ul><li>Been around awhile, but very good </li></ul><ul><li>Stuff they do: </li></ul><ul><ul><li>backup </li></ul></ul><ul><ul><li>check ai status </li></ul></ul><ul><ul><li>check db status </li></ul></ul><ul><ul><li>look for blocked clients </li></ul></ul><ul><ul><li>more … </li></ul></ul><ul><li>Study code to learn how it is done </li></ul>
  76. 76. Tip Number 0x15 Where to get more tips
  77. 77. Where to learn more <ul><li>OpenEdge Database Administration Guide </li></ul><ul><li>“ OpenEdge RDBMS Performance Tuning Made Simple ” on PSDN or PEG </li></ul><ul><li>PSDN: www.psdn.progress.com </li></ul><ul><li>Classes (not the only ones) </li></ul><ul><ul><li>Bravepoint: bravepoint.com </li></ul></ul><ul><ul><li>White Star Software: wss.com </li></ul></ul><ul><ul><li>Progress DBA classes </li></ul></ul><ul><ul><ul><li>http://www.progress.com/openedge/services/education/index.ssp </li></ul></ul></ul><ul><li>PSC Tech Support Knowledge Center </li></ul>
  78. 78. Tip Number 0x16 Join the PEG www.peg.com Ask questions there
  79. 79. Questions ?

×