Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

#WeSpeakLinux Session

446 views

Published on

Slide Deck from inaugural We Speak Linux webinar.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

#WeSpeakLinux Session

  1. 1. Essential Linux for the SQL Server DBA Kellyn Pot’Vin-Gorman Technical Intelligence Manager, Delphix
  2. 2. Community Board President of Rocky Mountain Oracle User Group and for Denver SQL Server User Group and presenter at 45 technical events annually. Kellyn Pot’Vin-Gorman Deck of ACEs 2018 Idera ACE and Oracle ACE Alumnus and member of Oak Table Network, a group of Oracle scientists. Two Decades of Data Management Managing Oracle, SQL Server, MySQL, Sybase and big data. Current Technical Intelligence Manager for the Office of CMO for Delphix. http://dbakevlar.com @DBAKevlar https://linkedin/in/kel lynpotvin
  3. 3. So SQL Server Has Come to the World of Linux There are tools out there that have been the go-to success for Oracle DBAs since Linux adoption… These utilities provide the information we need to: • Manage the environment • Troubleshoot issues • Gather information • Report on usage
  4. 4. But You Need to Learn to Walk Before You Run.. 4
  5. 5. And it Should Never Be Like This… 5 Linux
  6. 6. History Lesson • 1991 project by Linux Torvalds from Finland to create free operating system kernel. • Based on C programming • Over 15 million lines of code in base kernel. • Almost was named Freax • Now all part of the GNU Project • Debian, Redhat, Oracle Linux, Ubuntu, Suse are all flavors of Linux. • Microsoft introduces SQL Server on Linux in version 2016 6
  7. 7. User, Groups and Penguins, Oh My! • Don’t do everything as ROOT, (aka super user) • Perform administrator tasks by using SUDO, (switch user domain owner) • Log in as with your own user ID and su, (switch user) to the application owner. • There is a UID, (User ID) for every user name. • Each user is assigned a group(s) for role hierarchy • A home directory will contain the following: • Profile, (RC) with environment variables, alias’ and other necessary configurations for the user environment. 7
  8. 8. RC and Profiles • RC file stands for Run Commands • Profile is similar, but set up as a secondary set of profile settings, including: • Shell to be used • Alias’ • Environment variables • Path information • File name begins with a “.” • View with command ls -la .bashrc .bash_rc .profile .profile_xx 8
  9. 9. Example of a profile #/! /usr/bin/sh EDITOR=nano sudo visudo export PATH = $PATH:. # export ORACLE_HOME=/u01/app/oracle/dbhome_1/db12c export SQL_HOME=/u01/app/mssql/140 export LANG=en.UTF-8 export JAVA_HOME=/usr/bin/java # alias info alias reload=’source ~/.bash_profile’ alias pre-‘open -a Preview’ alias cd.. =’cd ..’ 9
  10. 10. Creating Users • Useradd has different results than adduser, but both work. • Useradd will require you to: • Manually update the password with passwd <username> • Manually assign a group with usermod after creating a manual group with groupadd command • If you wish to add any pertinent information about the user, that must be added manually. A user should be created for every user logging in. Don’t share logins. Avoid non-audited, such as direct ROOT access. Grant SUDO with great care. Grant SU to only those that require it. 10
  11. 11. SU and SUDO • To switch to from existing user to become jsmith: $ su – jsmith • To execute a command as ROOT after being granted SUDO privileges $ sudo setsys.sh –y 11
  12. 12. Understanding File Permissions Where this can be confusing for some, is that we visibly identify the grants by their values, either as separate values or as totals. • Read,(r)= 4 • Write,(w)= 2 • Execute, (x)=1 • owner has 4+2+1=7 • group has 4+2+1=7 • other has 4+2+1=7 12
  13. 13. Changing Permissions • CHMOD= change modify $ chmod <filename> XXX $ chmod test.txt 764 • Owner- read, write, execute • Group- read, write • Other- read You must have permissions to update the permissions or must SU/SUDO to perform them: $ sudo chmod test.txt 764 13
  14. 14. Changing File Owner • CHOWN = change owner $ chown <newuser>:<group> <filename> $ chown jsmith:dba test.sh • You must have privileges or own the file to begin with to change the ownership. 14
  15. 15. Basics What Command Common Change Diretory cd cd, cd .. ,cd /directory path List or Directory information ls ls, ls –lf, ls –la Locate program find <program name> find java, find sql Locate which installation used which <program name> which mssql Current Directory pwd pwd Create Directory mkdir mkdir scripts mkdir /u01/apps/scripts Create File touch <filename>, vim <filename> touch test.sh Edit File vim <filename>, vi <filename> vim touch.sh Remove rm <filename> rm touch.sh 15
  16. 16. Processes • Ps command $ ps $ ps –ef To Kill a process, (BECAREFUL!) $ kill <PID> 16
  17. 17. Editors • VI/VIM makes you cool- old school • Nano • eMacs • Create a file easily by issuing the touch command $ touch <filename> 17
  18. 18. VI(M) Command line editor $ vi <filename> • Go down a line: j • Go up a line: k • Go to the right: l • Go to the left: h • Insert: i • Append: a • Append to the end of a line: a • Add a line and insert below your cursor: o 18 Add a line and insert ABOVE your cursor: <shft> o Undo: u Quit without saving: :q Quit without saving to a read only file: :q! Write to a file: :w Write to a read only file, (override): :w! Write to a file and quit: :wq Write to a read only file, (override) and quit: :wq!
  19. 19. Redirecting Data Output to a File • $ <command> > <filename> $ ls > filelist.txt $ ls >> filelist.txt • If run again with the “>>”, the results will be appended to the first file’s contents. 19
  20. 20. Running an Update on Linux • Updates and Installations are done most often via Yum, APT-GET or Zypper • Using APT-GET • Update from repository, (stored in $ apt-get update • Install updates, (may require SUDO) $ apt-get install 20
  21. 21. Adding Utilities is Done via Packages • Common Installers for Linux • YUM • APT-GET • ZYPPER Installing a package with APT-GET $ sudo apt-get install –y <pkgname> Viewing package information: $apt-cache pkgname <pkgname> Display package information: $apt-cache show <pkgname> 21
  22. 22. Cheat Sheets for Common Installers • Yum: https://access.redhat.com/articles/yum-cheat-sheet • Apt-Get https://blog.packagecloud.io/eng/2015/03/30/apt-cheat-sheet/ • Zypper: https://en.opensuse.org/images/1/17/Zypper-cheat-sheet-1.pdf 22
  23. 23. Mission Impossible • No Powershell • BASH, (Born again shell) • KSHELL, (Korn Shell) • CSHELL, (based off C) • Shell scripting is very similar in each of these languages and very different from Powershell. 23
  24. 24. Linux system-level diagnostics • CPU and Memory • Process • Network • Traces • Other useful Linux diagnostic utilities • Support recommended diagnostic tools • A great source of living technical information
  25. 25. Utilities to View Resource Usage • SAR • SADC/SADF • MPSTAT • VMSTAT • TOP 25
  26. 26. Common Arguments and Values • Some of the utilities aren’t standard and may need to be installed. • Yum and apt-get are your friend • You may require sudo, (super user) privileges to install • <command> -x(xx) • Arguments are cap sensitive, (as is everything in Unix world.) • <command> -x 5 5 • First how many second sleep, Second value is how many results to return • <command> -h • Provides help information about the utility or command 26
  27. 27. What is SAR? • System Activity Report • Provides information about • CPU • Memory and virtual memory • I/O • Network • Provided by the SYSSTAT package • What if it’s missing? • Install it as root: $yum -y install sysstat $apt-get install sysstat 27
  28. 28. sar Utility • CPU utilization: sar -u • %usr, %sys, %idle • %nice • Intervals of CPU: sar 1 3 • 3 times, every 1 second • CPU run queue report: sar -q • Runq-sz • plist-sz and load averages • Context switching activity: sar -w • cswch/s • Virtual memory swapping: sar -W • swpin/s, swpot/s • Virtual memory paging: sar -B • pgpgin/s, pgpgot/s
  29. 29. sar Utility $ sar -u 5 5 Linux 2.6.32-573.22.1.el6.x86_64 (linuxsource.delphix.local) 11/28/2017 _x86_64_ (2 CPU) 06:15:31 PM CPU %user %nice %system %iowait %steal %idle 06:15:36 PM all 0.20 0.00 0.20 48.58 0.00 51.01 06:15:41 PM all 0.30 0.00 0.20 47.98 0.10 51.41 06:15:46 PM all 0.30 0.00 0.20 46.92 0.00 52.58 06:15:51 PM all 0.20 0.00 0.20 47.77 0.00 51.82 06:15:56 PM all 0.20 0.00 0.20 47.78 0.10 51.72 Average: all 0.24 0.00 0.20 47.81 0.04 51.71
  30. 30. sar Utility $ sar -q 5 5 Linux 2.6.32-573.22.1.el6.x86_64 (linuxsource.delphix.local) 11/28/2017 _x86_64_ (2 CPU) 06:16:45 PM runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 06:16:50 PM 0 190 1.37 1.28 1.30 06:16:55 PM 0 190 1.34 1.28 1.29 06:17:00 PM 0 190 1.31 1.27 1.29 06:17:05 PM 0 190 1.36 1.29 1.30 06:17:10 PM 0 190 1.34 1.28 1.30 Average: 0 190 1.34 1.28 1.30
  31. 31. What is SADC/SADF? • sadc: back-end system activity data collector utility behind sar • Collects specified system data at configured intervals • Saves data to specified binary files • sadf: system activity data formatter • report on data collected by sadc/sar • output to be consumed by other programs like awk, MS-Excel, etc • Options for translating and displaying dates, numbers, text • Output to plain text or XML
  32. 32. mpstat utility Processor Level Statisitcs $ mpstat –P ALL Linux 2.6.32-573.22.1.el6.x86_64 (linuxsource.delphix.local) 11/28/2017 _x86_64_ (2 CPU) 06:18:10 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 06:18:10 PM all 1.42 0.00 0.19 8.01 0.00 0.00 0.02 0.00 90.36 06:18:10 PM 0 1.38 0.00 0.21 15.10 0.00 0.00 0.02 0.00 83.29 06:18:10 PM 1 1.45 0.00 0.17 0.94 0.00 0.00 0.02 0.00 97.42
  33. 33. vmstat Utility Virtual Memory Statistics vmstat 5 5 procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 2 28612 131668 255192 6766272 0 0 0 148 1 3 1 0 90 8 0 0 1 28612 234736 255204 6766424 0 0 24 1480 1485 2737 2 1 48 49 0 0 2 28612 234752 255208 6766536 0 0 0 1511 1365 2632 0 0 50 50 0 1 1 28612 234752 255208 6766664 0 0 0 1399 1353 2626 0 0 50 50 0 0 2 28612 218164 255216 6766784 0 0 18 1310 1337 2591 0 0 49 51 0
  34. 34. top Utility Tasks: 165 total, 1 running, 164 sleeping, 0 stopped, 0 zombie Cpu(s): 0.3%us, 0.2%sy, 0.0%ni, 53.5%id, 46.0%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 8057984k total, 7827928k used, 230056k free, 255324k buffers Swap: 311292k total, 28612k used, 282680k free, 6771660k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 9888 delphix 20 0 636m 43m 16m S 0.7 0.5 51:40.68 mssql 9892 delphix 20 0 636m 43m 16m D 0.7 0.5 51:18.86 mssql 9886 delphix 20 0 652m 43m 16m S 0.3 0.6 51:19.84 mssql 1 root 20 0 19232 976 820 S 0.0 0.0 0:26.11 delcli 2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd 3 root RT 0 0 0 0 S 0.0 0.0 0:09.92 migration/0
  35. 35. What is UPTIME? • uptime displays current time and up-time • Also displays the average number of processes in run-queue over the past 1 minute, 5 minutes, and 15 minutes (a.k.a. load average) 35
  36. 36. uptime and w Utilities $ uptime 18:20:41 up 41 days, 17 min, 1 user, load average: 1.17, 1.28, 1.30 • w displays same info plus info about logged-in UNIX users $ w 18:21:05 up 41 days, 17 min, 1 user, load average: 1.25, 1.29, 1.30 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT delphix pts/0 c-67-164-182-219 18:05 0.00s 0.02s 0.02s sshd: delphix [priv]
  37. 37. Process Diagnostics • ps • Process status • pmap • Process mapping • http://dbakevlar.com/2017/12/sql-server-2017-linux-processes/ • dstat • Disk, cpu and network monitoring • nmon • Color coded display of cpu, disk and memory statistics
  38. 38. ps Utility • SysV version with many versions and variations: $ ps -eaf % ps -aux # ps –eo opt[,opt…] • Provides info about individual processes • Status, PID, PPID, user, command text and parameters • Cumulative and recent CPU usage • Memory (virtual, resident)
  39. 39. ps Utility • An easy home-grown “top” command $ ps –eaf | sort –n | tail root 689 2 0 Oct18 ? 00:00:00 [ext4-dio-unwrit] root 7 2 0 Oct18 ? 00:00:12 [migration/1] root 723 2 0 Oct18 ? 00:01:34 [kauditd] root 781 2 0 Oct18 ? 00:00:18 [flush-253:0] root 8 2 0 Oct18 ? 00:00:00 [stopper/1] root 9 2 0 Oct18 ? 00:00:06 [ksoftirqd/1] root 99 2 0 Oct18 ? 00:00:00 [kdmremove] rpc 1101 1 0 Oct18 ? 00:00:01 rpcbind
  40. 40. ps Utility • Another home-grown “top” command • Also displays memory consumption in Kbytes $ ps -eo user,pid,pcpu,vsz,rss,comm | sort -n | tail root 689 0.0 0 0 ext4-dio-unwrit root 7 0.0 0 0 migration/1 root 723 0.0 0 0 kauditd root 781 0.0 0 0 flush-253:0 root 8 0.0 0 0 stopper/1 root 9 0.0 0 0 ksoftirqd/1 root 99 0.0 0 0 kdmremove rpc 1101 0.0 18980 588 rpcbind
  41. 41. ps Utility • Displaying environment variable values within a process $ ps -eaf | grep jar delphix 11313 1 0 Oct18 ? 00:23:10 /usr/java/jdk1.7.0_51/bin/java - Djava.util.logging.config.file=/u02/app/apache-tomcat-7.0.42/conf/logging.properties - Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager - Djava.endorsed.dirs=/u02/app/apache-tomcat-7.0.42/endorsed -classpath /u02/app/apache- tomcat-7.0.42/bin/bootstrap.jar:/u02/app/apache-tomcat-7.0.42/bin/tomcat-juli.jar - Dcatalina.base=/u02/app/apache-tomcat-7.0.42 -Dcatalina.home=/u02/app/apache-tomcat-7.0.42 - Djava.io.tmpdir=/u02/app/apache-tomcat-7.0.42/temp org.apache.catalina.startup.Bootstrap start $ ps eww 11313 PID TTY STAT TIME COMMAND 11313 ? Sl 23:10 /usr/java/jdk1.7.0_51/bin/java - Djava.util.logging.config.file=/u02/app/apache-tomcat-7.0.42/conf/logging.properties - Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager - Djava.endorsed.dirs=/u02/app/apache-tomcat-7.0.42/endorsed -classpath /u02/app/apache- tomcat-7.0.42/bin/bootstrap.jar:/u02/app/apache-tomcat-7.0.42/bin/tomcat-juli.jar - Dcatalina.base=/u02/app/apache-tomcat-7.0.42 -Dcatalina.home=/u02/app/apache-tomcat-7.0.42 - Djava.io.tmpdir=/u02/app/apache-tomcat-7.0.42/temp org.apache.catalina.startup.Bootstrap start SHELL=/bin/bash TERM=xterm USER=delphix PATH=/sbin:/usr/sbin:/bin:/usr/bin PWD=/ HOME=/home/delphix SHLVL=3 LOGNAME=delphix _=/usr/java/jdk1.7.0_51/bin/java
  42. 42. CPU/Memory Diagnostics • Use top and/or ps to identify process activity in Linux • By current CPU activity • By total CPU time consumed • By time started • By process name • By UNIX account • By process hierarchy • parent processes, child processes, etc.
  43. 43. pmap Utilities Example $ pmap -x 11313 11313: /usr/java/jdk1.7.0_51/bin/java -Djava.util.logging.config.file=/u02/app/apache-tomcat- 7.0.42/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager - Djava.endorsed.dirs=/u02/app/apache-tomcat-7.0.42/endorsed -classpath /u02/app/apache-tomcat- 7.0.42/bin/bootstrap.jar:/u02/app/apache-tomcat-7.0.42/bin/tomcat-juli.jar -Dcatalina.base=/u02/app/apache-tomcat- 7.0.42 -Dcatalina.home=/u02/app/apache-tomcat-7.0.42 -Djava.io.tmpdir=/u02/app/apache-tomcat-7.0.42/temp org.apache.cata Address Kbytes RSS Dirty Mode Mapping 0000000000400000 4 0 0 r-x-- java 0000000000600000 4 4 4 rw--- java … 00007f09de9a6000 4 0 0 r--s- commons-daemon.jar 00007f09de9a7000 4 0 0 r--s- bootstrap.jar 00007f09de9a8000 32 16 12 rw-s- 11313 00007f09de9b3000 4 4 4 r---- ld-2.12.so 00007f09de9b4000 4 4 4 rw--- ld-2.12.so 00007f09de9b5000 4 4 4 rw--- [ anon ] 00007fff04ccb000 84 32 32 rw--- [ stack ] 00007fff04df6000 4 4 0 r-x-- [ anon ] ffffffffff600000 4 0 0 r-x-- [ anon ] ---------------- ------ ------ ------ total kB 3294068 188964 186976
  44. 44. fuser/lsof Utilities • Displays list of UNIX processes with file handles $ fuser /u01/app/delphix/oradata/orcl/system01.dbf /u01/app/delphix/oradata/orcl/system01.dbf: 3801 9343 9349 9351 9353 9355 9357 9359 9911 10082 10084 22879 30148 $ ps -eaf | grep 9357 delphix 9357 1 0 Oct18 ? 00:00:19 ora_reco_orcl background $ ps –eaf | grep 3801 delphix 3801 1 0 Oct22 ? 00:24:20 oracleorcl (LOCAL=NO) $ ps –eaf | grep 30148 delphix 30148 1 0 Nov22 ? 00:02:04 ora_m002_orcl background
  45. 45. fuser/lsof Utilities • Displays list of UNIX processes using file-system $ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vg_linuxsource-lv_root 14600800 3135856 10720092 23% / tmpfs 4028992 0 4028992 0% /dev/shm /dev/xvda1 487652 132589 329463 29% /boot /dev/xvdf 30832636 28133056 1126716 97% /u01 /dev/xvdg 20511356 4213904 15248876 22% /u02 $ fuser /dev/xvdf /dev/xvdf: 727ctm 725ctm 723ctm 722tm 720ctom 633tom 623tom 462o 458o 456o 454o 452o 450o 448o 446o 444o
  46. 46. What is DSTAT? • Monitoring tool for CPU, disk and network activity • Displays ongoing values in interval until q(uit) • To Install: $ yum install dstat –y Or $ sudo apt-get install dstat 46
  47. 47. dstat Utility 47
  48. 48. dstat Utility • Dstat for one disk and only CPU info: $ dstat -cdl -D xvda1 48
  49. 49. dstat Utility • Monitor Disk Reads $ dstat -d 49
  50. 50. What is NMON? 50 • information dump creation related to cpu, memory, IO or network. • Install: $ yum install nmon –y • Use menu • q<enter> to quit or • <ctrl> c
  51. 51. nmon CPU • Click C <enter> 51
  52. 52. nmon memory • m<enter> 52
  53. 53. nmon NFS • NFS<enter> 53
  54. 54. fuser/lsof Utilities • Displays list of UNIX processes using file-system # lsof /var COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME syslogd 350 root 5w VREG 222,5 0 440818 /var/adm/messag syslogd 350 root 6w VREG 222,5 339098 6248 /var/log/syslog cron 353 root cwd VDIR 222,5 512 254550 /var -- atjobs
  55. 55. Network Diagnostics • ifconfig • Configure/display network interfaces $apt-get install -y net-tools • netstat/ss • Display cumulative network statistics • ping • Send ICMP echo packets to network hosts • traceroute • Trace the route of ICMP echo packets to network hosts • tcpdump/snoop
  56. 56. ifconfig Utility • Configures network interfaces • Configure new network interface: ifconfig … create inet … up • Display network interface status: ifconfig -a $ ifconfig -a eth0 Link encap:Ethernet HWaddr 06:8D:24:F2:82:3C inet addr:10.0.1.20 Bcast:10.0.1.255 Mask:255.255.255.0 inet6 addr: fe80::48d:24ff:fef2:823c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:9001 Metric:1 RX packets:29480071 errors:0 dropped:0 overruns:0 frame:0 TX packets:26850299 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4059464946 (3.7 GiB) TX bytes:9135825067 (8.5 GiB) Interrupt:153
  57. 57. What is NETSTAT? • Displays network connections, routing tables, interface statistics • Network connections (a.k.a. sockets): netstat • Cumulative networking statistics: netstat -s • Routing tables: netstat -r • STREAMS statistics (Solaris and AIX): netstat -m • Verbose mode: add “-v” switch
  58. 58. netstat Utility $ netstat Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 linuxsource:12129 linuxsource:ncube-lm ESTABLISHED tcp 0 64 linuxsource:ssh c-164-182-219.hsd1:50171 ESTABLISHED tcp 0 0 linuxsource:ncube-lm ip-10-0-1-10.delphix.:58424 ESTABLISHED tcp 0 0 linuxsource:ncube-lm landsharkengine.delph:63611 ESTABLISHED tcp 0 0 linuxsource:ncube-lm linuxsource:12129 ESTABLISHED udp 0 0 localhost:17493 localhost:17493 ESTABLISHED Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 12 [ ] DGRAM 8754 /dev/log unix 2 [ ] DGRAM 7377 @/org/kernel/udev/udevd unix 3 [ ] STREAM CONNECTED 9499 unix 2 [ ] DGRAM 9338 unix 2 [ ] DGRAM 8927
  59. 59. netstat Utility • Display network routing tables on the local host: $ netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 10.0.1.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 eth0 default 10.0.1.1 0.0.0.0 UG 0 0 0 eth0
  60. 60. What is SS? • SS stands for Socket Statistics • Works like NETSTAT • Gathers info from the kernel via NAD • To install: $apt-get install iproute2 60
  61. 61. ss Utility $ ss $ ss -ltp 61
  62. 62. ping Utility • Simple diagnostic test for network connectivity • Be aware that many network administrator block ICMP traffic for security reasons $apt-get install iputils.ping $ ping -c 4 www.amazon.com PING e15316.ci.akamaiedge.net (104.86.87.164) 56(84) bytes of data. 64 bytes from a104-86-87-164.deploy.static.akamaitechnologies.com (104.86.87.164): icmp_seq=1 ttl=50 time=1.81 ms 64 bytes from a104-86-87-164.deploy.static.akamaitechnologies.com (104.86.87.164): icmp_seq=2 ttl=50 time=1.83 ms 64 bytes from a104-86-87-164.deploy.static.akamaitechnologies.com (104.86.87.164): icmp_seq=3 ttl=50 time=1.99 ms 64 bytes from a104-86-87-164.deploy.static.akamaitechnologies.com (104.86.87.164): icmp_seq=4 ttl=50 time=1.85 ms --- e15316.ci.akamaiedge.net ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 1.812/1.874/1.994/0.082 ms
  63. 63. What is TRACEROUTE? • Display the route taken by ICMP packets to an IP host • If missing, install using: $yum install traceroute –y $apt-get install traceroute -y 63
  64. 64. traceroute Utility $ traceroute www.amazon.com traceroute to www.amazon.com (54.192.195.66), 30 hops max, 60 byte packets 1 216.182.225.134 (216.182.225.134) 16.379 ms 216.182.225.124 (216.182.225.124) 49.305 ms 216.182.225.134 (216.182.225.134) 16.347 ms 2 100.66.8.70 (100.66.8.70) 19.966 ms 100.66.8.6 (100.66.8.6) 19.962 ms 100.66.8.250 (100.66.8.250) 14.142 ms 3 100.66.10.46 (100.66.10.46) 21.317 ms 100.66.10.100 (100.66.10.100) 19.104 ms 100.66.11.150 (100.66.11.150) 14.317 ms 4 100.66.7.237 (100.66.7.237) 15.802 ms 100.66.7.183 (100.66.7.183) 16.916 ms 100.66.6.67 (100.66.6.67) 16.800 ms 5 100.66.4.199 (100.66.4.199) 19.609 ms 100.66.4.127 (100.66.4.127) 14.576 ms 100.66.4.151 (100.66.4.151) 11.455 ms 6 100.65.9.65 (100.65.9.65) 0.349 ms 100.65.9.33 (100.65.9.33) 5.948 ms 100.65.9.1 (100.65.9.1) 0.275 ms 7 205.251.244.243 (205.251.244.243) 1.378 ms 72.21.220.120 (72.21.220.120) 1.280 ms 1.333 ms 8 54.239.111.120 (54.239.111.120) 24.074 ms 23.301 ms 54.239.110.22 (54.239.110.22) 37.663 ms 9 54.239.111.183 (54.239.111.183) 1.415 ms 54.239.111.179 (54.239.111.179) 1.234 ms 1.280 ms 10 72.21.220.9 (72.21.220.9) 1.326 ms 1.348 ms 1.391 ms
  65. 65. What is TCPDUMP? • Dump/sniff traffic on a network • Another one that may be missing: $ yum install tcpdump –y $ apt-get install tcpdump 65
  66. 66. tcpdump/snoop Utilities $ tcpdump tcpdump: listening on hme0 18:56:08.427002 IP linuxsource.ssh > c-67-164-182-219.hsd1.co.comcast.net.50171: Flags [P.], seq 529952:530160, ack 3681, win 172, length 208 18:56:08.428001 IP linuxsource.ssh > c-67-164-182-219.hsd1.co.comcast.net.50171: Flags [P.], seq 530160:530368, ack 3681, win 172, length 208 18:56:08.429695 IP c-67-164-182-219.hsd1.co.comcast.net.50171 > linuxsource.ssh: Flags [.], ack 515360, win 256, length 0 18:56:08.429707 IP c-67-164-182-219.hsd1.co.comcast.net.50171 > linuxsource.ssh: Flags [.], ack 517984, win 252, length 0 18:56:08.429723 IP c-67-164-182-219.hsd1.co.comcast.net.50171 > linuxsource.ssh: Flags [P.], seq 3681:3745, ack 515568, win 255, length 64 ^C18:56:08.429925 IP linuxsource.ssh > c-67-164-182-219.hsd1.co.comcast.net.50171: Flags [P.], seq 530368:530960, ack 3745, win 172, length 592 2781 packets captured 2781 packets received by filter 0 packets dropped by kernel
  67. 67. Trace Utilities • Different utilities on different platforms, but for Linux: • strace • Attach to or run a process and then trace: • UNIX system calls executed • Signals received • Machine faults incurred • (optional) entry/exit trace of user level function calls
  68. 68. What is DTRACE? • Performance analysis and troubleshooting tool (http://dtrace.org ) • Not just user-level software (i.e. applications, databases and webservers) • also OS kernel and device drivers • provides a language, (i.e. “D”) for writing DTrace scripts and one-liners • Terrific case-study of I/O performance analysis using DTrace • https://blogs.oracle.com/BestPerf/entry/i_o_analysis_using_dtrace • Installation: $apt-get install systemtap-sdt-dev 68
  69. 69. dtrace Utility $ dtrace -n 'proc:::exec-success{printf("%d %s”,timestamp,curpsinfo- >pr_psargs);}’ dtrace: description 'proc:::exec-success ' matched 1 probe CPU ID FUNCTION:NAME 1 797 exec_common:exec-success 21935388676181394 man ls 0 797 exec_common:exec-success 21935388840101743 sh -c cd /usr/share/man; tbl /usr/sha 1 797 exec_common:exec-success 21935388858652639 col –x 0 797 exec_common:exec-success 21935388863714971 neqn /usr/share/lib/pub/eqnchar – 0 797 exec_common:exec-success 21935388867119787 tbl /usr/share/man/man1/ls.1 1 797 exec_common:exec-success 21935388881310626 nroff -u0 -Tlp -man –
  70. 70. file Utility “Finding Java” $ file /usr/bin/java /usr/bin/java: symbolic link to `/etc/alternatives/java’ $ file /etc/alternatives/java /etc/alternatives/java: symbolic link to `/usr/java/jdk1.7.0_51/jre/bin/java’ $ file /usr/java/jdk1.7.0_51/jre/bin/java /usr/java/jdk1.7.0_51/jre/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped $ file make_logs.sql make_logs.sql: ASCII C program text
  71. 71. What is FINDMNT? • A [somewhat] directory tree view of Linux • To Install: $ yum install findmnt –y $ apt-get install findmnt 71
  72. 72. findmnt Utility 72
  73. 73. findmnt Utility • findmnt -m 73
  74. 74. What is NCDU? • Quick utility to gather info on space usage in a directory • To install: $ yum install ncdu –y $ apt-get install ncdu Simply execute ncdu command in directory that you wish to gather detailed file/directory sizes on 74
  75. 75. ncdu Utility 75
  76. 76. Linux for the DBA Summary • Learn to walk before you run • Command line is essential • Utilities are your friends • A few will get you far, choose which ones provide you with what you need. • Build a knowledge of command line editing tools, such as VIM or Nano and Shell scripting to enhance utilities for full coverage. • Tough at first, but will become second nature- I promise! 76
  77. 77. Thank you! 77

×