2. If you require assistance
during the session, type
your inquiry into the
question pane on the right
side.
Maximize your screen with
the zoom button on the
top of the presentation
window.
Please fill in the short
evaluation following the
session. It will appear in
your web browser.
Technical Assistance
3. Thank You to Our Presenting Sponsors
Supporting Sponsor
Quest helps IT Professionals simplify administration
tasks so they can focus on the evolving needs of their
businesses. Combined with its commitment to help
companies protect today’s investment while planning
for the future, Quest continues to deliver the most
comprehensive solutions to monitor, manage, protect
and replicate database environments
Empower users with new insights through familiar tools
while balancing the need for IT to monitor and
manage user created content. Deliver access to all data
types across structured and unstructured sources.
IDERA designs powerful software with one
goal in mind – to solve customers’ most complex
challenges with easy-to-use solutions. IDERA’s award-
winning SQL Server database solutions and multi-
platform database, application and cloud monitoring
tools ensure your business never slows down.
SentryOne empowers Microsoft data professionals to
achieve breakthrough performance across physical,
virtual and cloud environments. We develop solutions
to monitor, diagnose, and optimize SQL Server
performance, including Plan Explorer, the query-tuning
tool with more than 100,000 downloads.
4. Attend PASS Summit to Grow Your Career
The Community
PASS Summit is the largest conference for technical professionals who
leverage the Microsoft Data Platform.
November 6-9 | Seattle, WA
PASSsummit.com
Connect with a global network of 250,000+ data professionals
5. B Speaker
Speaker numerous technical conferences for Oracle, Big Data, DevOps
Testing and SQL Server
Kellyn Pot’vin-Gorman
Member of the Oak Table Network
dbakevlar.com
@DBAKevlar
linkedin.com/in/kellynpotvin
Oracle ACE Director alumnus
Technical Intelligence Manager at Delphix
7. So SQL Server Has Come to the World of Linux
There’s a lot to learn about Linux…
Learning how to:
• Navigate
• Manage
• Gather information
• Monitor
9. History Lesson
• 1991 project by Linus Torvalds from Finland to create free operating
system kernel.
• Based on C programming
• 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 2017 beta
9
10. Accessing a Linux Host
• Most Common Tools
• Putty, (free download)
• Terminal, (MAC)
• Docker or VM image with terminal via Linux console.
• SSH, (Secure Shell)
ssh OSUsername@<hostname or IP address>
10
11. 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.
11
12. 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
12
13. Example of a profile
#/! /usr/bin/sh
EDITOR=nano
# EDITOR=vi
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 ..’
13
14. 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.
14
15. 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
15
16. 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
16
17. 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
17
18. 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.
18
19. 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 ** rmdir
19
21. Editors
• VI/VIM makes you cool- old school
• Nano
• eMacs
• Create a file easily by issuing the touch command
$ touch <filename>
21
22. 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
22
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!
23. 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.
23
24. 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
24
25. 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>
25
26. 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
26
27. Mission Impossible
• Initial Powershell for Linux:
https://github.com/PowerShell/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.
27
28. Linux system-level diagnostics
• CPU and Memory
• Process
• Network
• Other useful Linux diagnostic utilities
• Support recommended diagnostic tools
• A great source of living technical information
30. 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
30
31. 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
31
32. 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
33. 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
35. 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
41. 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)
41
42. 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]
43. 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
44. Process Diagnostics
• top
• Display “top” resource-consuming processes and totals
• Ctrl + C to exit ongoing refresh
• ps
• Process status
• pmap
• Process mapping
• dstat
• Disk, cpu and network monitoring
46. 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)
50. 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.
53. 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
53
54. 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)
61. 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
61
63. 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!
63
64. Ready to Get Started?
Microsoft Azure account will have you on Linux in minutes.
A Linux VM or Docker Image with access to an outside network to perform
installations of tools and/or software as needed.
• Docker for Windows
• Docker for Mac
• VMWare or VirtualBox