DevOps Pre Requisites v2 1
DevOps Pre Requisites v2 1
www.kodekloud.com
Common Challenges
LINUX
Why Linux?
14
https://insights.stackoverflow.com/survey/2019
Why Linux?
https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html
Kubernetes Documentation
Linux Basics
• Linux CLI
• VI Editor
• Package Management
• Service Management
LINUX
Shell Types
echo $SHELL Bourne Shell (Sh Shell)
/bin/bash
Z Shell (zsh)
ls
List files & folders
File.txt my_dir1 file2.conf
cd my_dir1
Change directory
pwd
Present Working Directory
/home/my_dir1
mkdir –p /tmp/asia/india/bangalore
cat new_file.txt
View contents of file
This is some sample contents
id
uid=1001(matthew) gid=1001(matthew) groups=1001(matthew)
su aparna
Password:
24
User Accounts
ls /root
ls: cannot open directory /root: Permission denied
matthew root
sudo ls /root SUDO
anaconda-ks.cfg initial-setup-ks.cfg /etc/sudoers
25
Download Files
curl http://www.some-site.com/some-file.txt -O
some-file.txt
cat /etc/*release*
CentOS Linux release 7.7.1908 (Core)
Derived from Red Hat Enterprise Linux 7.7 (Source)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
Package Managers
RPM (Red Hat Package Manager)
rpm –i telnet.rpm Install Package
?
?
? RPM
? telneta.rnpsm
ible
YUM
yum install ansible Install Package
/etc/yum.repos.d
PyYAML
YUM
python RPM
ansible
sshpass
YUM Repos
yum repolist
repo id repo name status
base/7/x86_64 CentOS-7 - Base 10097
extras/7/x86_64 CentOS-7 - Extras 341
mongodb-org-4.2/7 MongoDB Repository 25
mysql-connectors-community/x86_64 MySQL Connectors Community 141
mysql-tools-community/x86_64 MySQL Tools Community 105
mysql80-community/x86_64 MySQL 8.0 Community Server 161
updates/7/x86_64 CentOS-7 - Updates 1787
ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Media.repo mysql-community.repo
CentOS-CR.repo CentOS-Sources.repo mysql-community-source.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
CentOS-fasttrack.repo mongodb-org-4.2.repo
cat /etc/yum.repos.d/CentOS-Base.repo
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
YUM
yum list ansible
Installed Packages
ansible.noarch 2.9.6-1.el7 @epel
/etc/systemd/system
curl http://localhost:5000
Hello, World!
Services
/etc/systemd/system
systemctl daemon-reload
curl http://localhost:5000
Hello, World!
systemctl start my_app
Services
/etc/systemd/system
systemctl status my_app my_app.service
● my_app.service
Loaded: loaded (/etc/systemd/system/my_app.service; static; vendor preset: disabled) [Service]
Active: active (running) since Tue 2020-04-07 09:01:39 UTC; 2s ago ExecStart= /usr/bin/python3 /opt/code/my_app.py
Main PID: 5038 (python3)
CGroup: /system.slice/my_app.service
└─5038 /usr/bin/python3 /tmp/app/my_app.py
[Service]
Type=notify
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
[Install]
WantedBy=multi-user.target
VI Editor
Working with Files
cat > index.html
CTLR + D 44
Poem By: Meine Klaus, Schenker Rudolf
VI Editor
vi index.html
COMMAND INSERT
MODE MODE
esc i
VI Editor - Command Mode
K
>
Move Around
> J L
>
Delete x dd
Command :
Save :w :w filename
Quit (Discard) :q
Find /of n
Lab Setup
Virtualization S/W
Type 1
VM VM VM
Hypervisor
Baremetal (Server)
Virtualization S/W
Type 1 Type 2
VM VM VM
VM VM VM Hypervisor
• Commercial
• Install Anywhere –
• FREE
Windows, Linux
• OpenSource
• Snapshots & Clones
• Install Anywhere –
Windows, Linux, MAC • VMWare Player:
• Snapshots & Clones • Free
• Run Multiple VMs • Windows/Linux
• Networking • One VM at a time
• No Snapshots
• VMWare Fusion:
• Free
Oracle VirtualBox VMWare Workstation • Mac
• One VM at a time
• No Snapshots
Oracle VirtualBox
• Support:
•Windows, MAC OS X, Linux, Solaris
https://www.virtualbox.org/manual/ch01.html#
hostossupport
• Resource Requirements:
• CPU: x86 Intel or AMD
• Memory: 512 MB
• Disk space: 30 MB
• Recommended Resources:
• CPU: Dual or Quadcore
• Memory: 4 GB
• Disk Space: 100 GB
https://www.virtualbox.org/wiki/Downloads
The more the better
Oracle VirtualBox
Oracle VirtualBox
Oracle VirtualBox
Images
https://www.osboxes.org/
Oracle VirtualBox
Start
Connectivity
Frequently Asked Questions
• How do I connect to the VM?
• How do I SSH into my VM?
• Why can’t I access the server on my VM?
• What’s Port mapping?
63
Guest
Virtual Machine
Host
LAPTOP 64
65
Guest Guest
Windows
Virtual Machine Virtual Machine
Host LAPTOP 66
guest> service sshd status
Redirecting to /bin/systemctl status sshd.service Guest Guest
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-03-22 11:57:47 UTC; 1 day 18h ago
Docs: man:sshd(8)
man:sshd_config(5) Windows
Main PID: 2406 (sshd)
CGroup: /system.slice/sshd.service 192.168.1.10 192.168.1.11
└─2406 /usr/sbin/sshd -D -u0 Virtual Machine Virtual Machine
Host
LAPTOP 67
IP Address
guest> ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:8a:fe:e6 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 brd 192.168.1.255 scope global noprefixroute dynamic eth0
valid_lft 86387sec preferred_lft 86387sec
68
Start SSH service
guest> service sshd status
Redirecting to /bin/systemctl status sshd.service
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-03-25 09:29:51 UTC; 3h 53min ago
Docs: man:sshd(8)
man:sshd_config(5)
72
IP Address
ip addr show
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_f
1000
link/ether 02:0e:0c:9a:00:f0 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.5/24 brd 192.168.1.255 scope global enp0s3
73
VirtualBox Networking
Guest
Virtual Machine
74
??
LAN
192.168.1.10
192.168.1.0
Host Only 192.168.5.1
192.168.5.2 192.168.5.3
Host-Only
Network ifconfig
192.168.5.0 en9: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mt
LAN
ether 64:4b:f0:20:6a:6b
inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255
192.168
nd6 .1.10
options=201<PERFORMNUD,DAD>
status: active 192.168.1.0
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu
192.168.5.4 192.168.5.5 ether 0a:00:27:00:00:00
inet 192.168.5.1 netmask 0xffffff00 broadcast 192.168.5.255
Host Only 192.168.5.1
192.168.5.2 192.168.5.3
Host-Only
Network
192.168.5.0
LAN
192.168.1.10
192.168.1.0
192.168.5.4 192.168.5.5
Network Address Translation (NAT) Network
192.168.5.1
192.168.5.2 192.168.5.3
NAHTosNte-Otwnloyrk
19N2e.1tw68o.r5k.0
192.168.5.0
LAN From: To:
From: To: From: To: 192.168.1.11 192.168.1.10
192.168.5.2 192.168.1.11 192.168.1.10 192.168.1.10
192.168.5.2 192.168.1.11
192.168.1.0 Here’s your data..
Read DB
192.168.5.4 192.168.5.5
Network Address Translation (NAT)
192.168.5.1
192.168.5.2 192.168.5.3
NAT Network
192.168.5.0
LAN
192.168.1.10 192.168.1.11
192.168.1.0
192.168.5.4 192.168.5.5
192.168.1.26
192.168.1.25
Bridge Network
192.168.1.12 192.168.1.13
BRIDGE
Network
LAN
192.168.1.10 192.168.1.11
192.168.1.0
192.168.1.14 192.168.1.15
192.168.1.26
192.168.1.25
Bridge Network
192.168.1.12 192.168.1.13 192.168.1.14 192.168.1.15
BRIDGE
Network
LAN
192.168.1.10 192.168.1.11
192.168.1.0
192.168.1.26
192.168.1.25
Internet Connectivity
Network Address
Translation (NAT) Host-Only Network Bridged
192.168.5.1 192.168.5.1
80 80
5000 8080
22 2222
Requirement Solution
VMs must be able to reach the internet/other systems in the network NAT
VMs must NOT be visible in the external network and VMs must NOT be able to reach Host Network
internet/other systems in the network
VMs must be able to reach each other and the internet but NOT visible in the external Host Network + NAT
network NAT Network
VirtualBox Networking
VM can reach VMs can reach Host can reach VM Other systems in network Solution
internet/other systems each other (Without Port can reach VM
in the network forwarding)
Yes No No No NAT
vagrant up
1. Download
Bringing machine 'default' up with 'virtualbox' provider...
2. Create VM ==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
3. Create Networks ==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: centos2_default_1586895892002_53453
4. Configure Networking ==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
5. Configure Port Forwarding ==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
6. Boot up VM ==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
==> default: Machine booted and ready!
Getting started
https://www.vagrantup.com/
Vagrant Init
vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read the comments in the
Vagrantfile as well as documentation on `vagrantup.com` for more information on using
Vagrant.
ls centos/7
Vagrantfile
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos/7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'centos/7' version '1905.1' is up to date...
==> default: Setting the name of the VM: centos2_default_1586895892002_53453
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 (guest) => 2200 (host) (adapter 1)
==> default: Booting VM... https://app.vagrantup.com/boxes
==> default: Waiting for machine to boot. This may take a few minutes...
Vagrant Commands
vagrant
Usage: vagrant [options] <command> [<args>]
Common commands:
init initializes a new Vagrant environment by creating a Vagrantfile
up starts and provisions the vagrant environment
suspend suspends the machine
resume resume a suspended vagrant machine
halt stops the vagrant machine
destroy stops and deletes all traces of the vagrant machine
status outputs status of the vagrant machine
reload restarts vagrant machine, loads new Vagrantfile configuration
snapshot manages snapshots: saving, restoring, etc.
vagrant ssh
[vagrant@localhost ~]$
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.synced_folder "../data", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y apache2
SHELL
end
Vagrant Providers
• VirtualBox
• VMware
• Hyper-V
• Docker
• Custom
Review
Lab Linux Applications DB Security Networking Storage
DevOps Pre-Requisites
CKA Puppet
CKAD DevOps
What to test
Check Ignore
Facts Delivery/Speed
Explanation Noise
Code/Typos Pauses/Stops
Analogies/Examples Animation
Student/Expert
How to Review
just enough
Applications
Introduction
• JavaScript –
NodeJS
• Python
• Java
https://insights.stackoverflow.com/survey/2019#technology
Types
Compiled Interpreted
C C++
Compiled
MyClass.java
python main.py
Hello World
Packages/Modules/Libraries
• Filesystems
• Math
• Operating system
• HTTP
• Security
• Networking
Build
• Compile
• Run Tests
• Package
• Delivery
NETWORKING
Networking Pre-Requisites
• Switching
• Routing
• Default Gateway
• DNS Configurations on Linux
just enough
Introduction
About Java
wget https://download.java.net....
openjdk-13.0.2_linux-x64_bin.tar.gz
java
ls jdk-13.0.2/bin
jaotc javadoc jdeprscan jinfo jps jstatd rmiregistry
jar javap jdeps jjs jrunscript keytool serialver
jarsigner jcmd jfr jlink jshell pack200 unpack200
java jconsole jhsdb jmap jstack rmic
javac jdb jimage. jmod jstat rmid
Before v9
Build
Compile
MyClass.java
Dependency 1 Service1.class
Dependency 2 Service2.class
Dependency 3
Utility.class
Tools.class
Java Archive
(JAR)
Package
META-INF/MANIFEST.MF
MyClass.class
Dependency 3
Utility.class
Tools.class
Image 1
Java Archive Web Archive
Image 2 HTML 1 (JAR) (WAR)
HTML 2
javac MyClass.java
jar cf MyClass.jar ..
javadoc MyClass.java
Build Process
Build Tools
2. Package
3. Document
Gradle
https://github.com/arun-gupta/docker-java-sample
Summary
• Java
• Java Runtime Environment
• Java Development Kit
• Compiling a Java application
• Packaging a given application to JARs
• What are Build Tools?
just enough
JavaScript
https://enonic.com/blog/websites-past-and-present
NodeJS
const a = 10, b = 5;
• Files
• Web Servers
• Databases
• Security
• Many More
https://www.npmjs.com/
NPM Commands
npm -v
6.13.7
app.js my_application
var file = require("file");
node_modules
file.mkdirs("/tmp/dir1") file
LICENSE
README.md
node -e "console.log(module.paths)"
package.json
[ '/app/node_modules', '/node_modules' ]
lib
npm install file -g app.js
Common Modules
ls /usr/lib/node_modules/npm/node_modules/ ls /usr/lib/node_modules/
package.json
Application Dependencies
{
"name": "example-contentful-theExampleApp-js",
"version": "0.0.0",
"private": true,
"dependencies": {
"body-parser": "^1.18.2",
"contentful": "^6.0.0",
"cookie-parser": "~1.4.3",
"dotenv": "^5.0.0",
"execa": "^0.9.0",
"express": "^4.16.2",
"helmet": "^3.11.0",
"lodash": "^4.17.5",
"marked": "^0.3.16",
"morgan": "^1.9.1",
"pug": "~2.0.0-beta6"
}
}
just enough
Python
• Free
• Open source
• Cross Platform Compatible
Download
https://www.python.org/downloads/
Versions
python2 python3
Python 2.7.16 (default, Nov 17 2019, 00:07:27) Python 3.6.8 (default, Nov 21 2019, 19:31:34)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux2 [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type "help", "copyright", "credits" or "license" Type "help", "copyright", "credits" or "license"
for more information. for more information.
>>> exit() >>> exit()
python2 -V python3 -V
Python 2.7.16 Python 3.6.8
Python Commands
Hello World
def print_message():
print("Hello World")
pip2 -V pip3 -V
pip 9.0.3 from /usr/lib/python2.7/site-packages pip 9.0.3 from /usr/lib/python3.6/site-packages
(python 2.7) (python 3.6)
pip -V
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)
usr
lib
python2.7
site-packages
Python3.6
site-packages
lib64
python2.7
site-packages
Flask-1.1.1.dist-info
python3.6
site-packages
Python Package Manager (pip)
pip install flask
</>
</>
166
Application Types
167
Standalone vs Client-Server
Server
Web Client
Chat
Desktop Client Server
Mobile Client
Servers
Web Application
Server Server
Servers
AppW
liceabtion
Server
Servers
Web Application DB
Server Server Server
just enough
https://insights.stackoverflow.com/survey/2019
Web Frameworks
REQUEST
https://www.shop-app.com
Web
Server
@GetMapping("/products")
public String[] getProducts() {
return getProductList();
}
}
Application Code
Web Frameworks
DemoApplication.java demo.py demo.js
package com.example.demo; from flask import Flask const express = require('express')
// <code hidden> const app = express()
app = Flask( name )
@SpringBootApplication app.get('/products', (req, res) =>
@app.route(‘/products') res.send(getProductList()))
@RestController def hello():
public class DemoApplication { return getProductList()
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args); if name ==' main ':
} app.run()
@GetMapping("/products")
public String[] getProducts() {
return getProductList();
}
}
Application Code
Web Server
DemoApplication.java
package com.example.demo;
// <code hidden>
@SpringBootApplication
@RestController
public class DemoApplication {
@GetMapping("/products")
public String[] getProducts() { Web
return getProductList();
} Server
}
Application Code
Web Server
DemoApplication.java
package com.example.demo;
// <code hidden>
@SpringBootApplication
@RestController
public class DemoApplication {
8080 80 8000
Web Server
DemoApplication.java
package com.example.demo;
Application 3 Code
Static vs Dynamic Websites
just enough
• Open source
• Web Server
Install Apache Web Server
yum install httpd
#
# DocumentRoot: The dir ectory out of which you will serve your
# documents. By default , all requests are taken from this dire ctory, but
# symbolic links and aliases may be used to point to other locations.
Document Root
#
/var/www/html
DocumentRoot "/var/www/html”
#
#
DNS Name IP Address
#Listen 12.34.56.78:80
wwLwi.hsotuesnes.8c0om 192.168.1.10
Config File
#
/etc/hosts
# DocumentRoot: The directory out of which you will serve your
# documents.
# Host Database By defaul t, all requests are taken from this dire ctory, but
127.0.0.1 localhost
# symbolic
127.0.0.1
links and aliases mayhttp://l
www.houses.com
bewowcawused
lh.o to point to other loc ations.
hsotu:8se0s.com
o
#
DocumentRoot "/var/www/ html”
Web
Server
#
# ServerName gives the name and port that the server uses to identify 80
itself.
# This can often be det ermined automatically, but we recommend you Default HTTP Port - 80
specify
# it explicitly to prev ent problems during startup. HTML
# CSS
# If your host doesn't have a registered DNS name, enter its I P address
here. JavaScript
# Document Root
#ServerName www.example.com:80 /var/www/html
ServerName www.houses.com:80
#
#Listen 12.34.56.78:80
Listen 80 Config File
#
Web
# DocumentRoot: The directory out of which you will serve your
Server
# documents. By default, all requests are taken from this dire ctory, but
# symbolic links and aliases may be usedhttp://
tolwowcawpoint
lh.h
oo
stu:8se0s.com
to other loc ations.
# HTML
DocumentRoot "/var/www/html” CSS
# JavaScript
# ServerName gives the name and port that the server uses to identify Server: www.houses.com
Document Root: /var/www/houses
itself. VirtualHost
# This can often be determined automatically, but we recommend you
specify HTML
# it explicitly to prevent prob lems during startup.
#
http://www.oranges.com CSS
# If your host doesn't have a r egistered DNS name, enter its I P address JavaScript
here. Server: www.oranges.com
Document Root: /var/www/oranges
# VirtualHost
#ServerName www.example.com:80
Document Root
ServerName www.houses.com:80 /var/www/html
#
DNS#ServerName
Name IP Address
www.example.c om:80
wwSwe.hrovuesreNs.acmoem ww w1.9h2o.1u6s8e.1s..1c0om:80
www.oranges.com 192.168.1.10
Config File
/etc/hosts
Web
Server
# Host Database
127.0.0.1 localhost http://lwow
cawlh.h
oo
stu:8se0s.com
<VirtualHost
127.0.0.1
*:80>
www.houses.com
ServerName
127.0.0.1 www.houses.c om
www.oranges.com HTML
DocumentRoot /var/www/h ouses
</VirtualHost> CSS
JavaScript
Server: www.houses.com
Document Root: /var/www/houses
VirtualHost
<VirtualHost *:80>
Include conf/houses.conf ServerName www.houses.com
DocumentRoot /var/www/houses
Include conf/oranges.conf </VirtualHost>
/etc/httpd/conf/oranges.conf
<VirtualHost *:80>
ServerName www.oranges.com
DocumentRoot /var/www/oranges
</VirtualHost>
just enough
NGINX
just enough
APACHE TOMCAT
Install Apache Tomcat
yum install java-1.8.0-openjdk-devel
wget https://downloads.apache.org/tomcat/
tomcat-8/v8.5.53/bin/apache-tomcat-8.5.53.tar.gz
./apache-tomcat-8.5.53/bin/startup.sh
http://tomcat.apache.org/download-80.cgi
View Server
https://localhost:8080
Apache Tomcat Directory
ls –l apache-tomcat-8.5.53
-rw-r----- 1 19318 Mar 11 10:06 BUILDING.txt catalina-tasks.xml
-rw-r----- 1 5408 Mar 11 10:06 CONTRIBUTING.md catalina.bat
catalina.sh
-rw-r----- 1 57011 Mar 11 10:06 LICENSE
ciphers.bat
-rw-r----- 1 1726 Mar 11 10:06 NOTICE ciphers.sh
-rw-r----- 1 3255 Mar 11 10:06 README.md configtest.bat
-rw-r----- 1 7136 Mar 11 10:06 RELEASE-NOTES configtest.sh
-rw-r----- 1 16262 Mar 11 10:06 RUNNING.txt daemon.sh
drwxr-x--- 2 4096 Mar 18 10:17 bin digest.bat
digest.sh
drwx------ 2 4096 Mar 11 10:06 conf
setclasspath.bat
drwxr-x--- 2 4096 Mar 18 10:17 lib setclasspath.sh
drwxr-x--- 2 4096 Mar 11 10:03 logs shutdown.bat
drwxr-x--- 2 4096 Mar 18 10:17 temp shutdown.sh
drwxr-x--- 7 4096 Mar 11 10:04 webapps startup.bat
drwxr-x--- 2 4096 Mar 11 10:03 work startup.sh
tool-wrapper.bat
tool-wrapper.sh
version.bat
version.sh
Apache Tomcat Directory
ls –l apache-tomcat-8.5.53
-rw-r----- 1 19318 Mar 11 10:06 BUILDING.txt
-rw-r----- 1 5408 Mar 11 10:06 CONTRIBUTING.md catalina.policy
<!-- A "Connector" represents an endpoint
-rw-r----- 1 57011 Mar 11 10:06 LICENSE by which requests are received
catalina.properties and responses are returned. Documentation at :
-rw-r----- 1 1726 Mar 11 10:06 NOTICE
Java HTTP Connector: /docs/config/http.html
-rw-r----- 1 3255 Mar 11 10:06 README.md context.xml
Java AJP Connector: /docs/config/ajp.html
-rw-r----- 1 7136 Mar 11 10:06 RELEASE-NOTES jaspic-providers.xml APR (HTTP/AJP) Connector: /docs/apr.html
-rw-r----- 1 16262 Mar 11 10:06 RUNNING.txt -->
jaspic-providers.xsd
drwxr-x--- 2 4096 Mar 18 10:17 bin <Connector port="8080" protocol="HTTP/1.1"
drwx------ 2 4096 Mar 11 10:06 conf logging.properties connectionTimeout="20000"
redirectPort="8443" />
drwxr-x--- 2 4096 Mar 18 10:17 lib server.xml <!-- A "Connector" using the shared thread pool-->
drwxr-x--- 2 4096 Mar 11 10:03 logs tomcat-users.xml <!--
drwxr-x--- 2 4096 Mar 18 10:17 temp <Connector executor="tomcatThreadPool"
drwxr-x--- 7 4096 Mar 11 10:04 webapps tomcat-users.xsd
port="8080" protocol="HTTP/1.1"
drwxr-x--- 2 4096 Mar 11 10:03 work web.xml connectionTimeout="20000"
redirectPort="8443" />
Apache Tomcat Directory
ls –l apache-tomcat-8.5.53
-rw-r----- 1 19318 Mar 11 10:06 BUILDING.txt
-rw-r----- 1 5408 Mar 11 10:06 CONTRIBUTING.md
-rw-r----- 1 57011 Mar 11 10:06 LICENSE
-rw-r----- 1 1726 Mar 11 10:06 NOTICE
-rw-r----- 1 3255 Mar 11 10:06 README.md
-rw-r----- 1 7136 Mar 11 10:06 RELEASE-NOTES
-rw-r----- 1 16262 Mar 11 10:06 RUNNING.txt
drwxr-x--- 2 4096 Mar 18 10:17 bin
drwx------ 2 4096 Mar 11 10:06 conf catalina.2020-03-18.log
drwxr-x--- 2 4096 Mar 18 10:17 lib catalina.out
host-manager.2020-03-18.log
drwxr-x--- 2 4096 Mar 11 10:03 logs localhost.2020-03-18.log
drwxr-x--- 2 4096 Mar 18 10:17 temp localhost_access_log.2020-03-18.txt
drwxr-x--- 7 4096 Mar 11 10:04 webapps manager.2020-03-18.log
drwxr-x--- 2 4096 Mar 11 10:03 work
Apache Tomcat Directory
ls –l apache-tomcat-8.5.53 jar –cvf app.war *
-rw-r----- 1 19318 Mar 11 10:06 BUILDING.txt
-rw-r----- 1 5408 Mar 11 10:06 CONTRIBUTING.md
-rw-r----- 1 57011 Mar 11 10:06 LICENSE mvn package
-rw-r----- 1 1726 Mar 11 10:06 NOTICE
-rw-r----- 1 3255 Mar 11 10:06 README.md
-rw-r----- 1 7136 Mar 11 10:06 RELEASE-NOTES gradle build
-rw-r----- 1 16262 Mar 11 10:06 RUNNING.txt
drwxr-x--- 2 4096 Mar 18 10:17 bin
drwx------ 2 4096 Mar 11 10:06 conf
drwxr-x--- 2 4096 Mar 18 10:17 lib
drwxr-x--- 2 4096 Mar 11 10:03 logs
drwxr-x--- 2 4096 Mar 18 10:17 temp
drwxr-x--- 7 4096 Mar 11 10:04 webapps
drwxr-x--- 2 4096 Mar 11 10:03 work
app.war
Application Code
Web Frameworks
ls –l apache-tomcat-8.5.53 jar –cvf app.war *
-rw-r----- 1 19318 Mar 11 10:06 BUILDING.txt
-rw-r----- 1 5408 Mar 11 10:06 CONTRIBUTING.md
-rw-r----- 1 57011 Mar 11 10:06 LICENSE mvn package
-rw-r----- 1 1726 Mar 11 10:06 NOTICE
-rw-r----- 1 3255 Mar 11 10:06 README.md
-rw-r----- 1 7136 Mar 11 10:06 RELEASE-NOTES gradle build
-rw-r----- 1 16262 Mar 11 10:06 RUNNING.txt
drwxr-x--- 2 4096 Mar 18 10:17 bin
drwx------ 2 4096 Mar 11 10:06 conf
drwxr-x--- 2 4096 Mar 18 10:17 lib
drwxr-x--- 2 4096 Mar 11 10:03 logs
META-INF
drwxr-x--- 2 4096 Mar 18 10:17 temp WEB-INF
drwxr-x--- 7 4096 Mar 11 10:04 webapps hello.jsp
drwxr-x--- 2 4096 Mar 11 10:03 work images
app.war index.html
Application Code
Verify
cat ~/apache-tomcat-8.5.53/logs/catalina.out
18-Mar-2020 10:43:32.769 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application
directory [/home/vagrant/apache-tomcat-8.5.53/webapps/ROOT] has finished in [13] ms
18-Mar-2020 10:43:32.769 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application
directory [/home/vagrant/apache-tomcat-8.5.53/webapps/manager]
18-Mar-2020 10:43:32.783 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application
directory [/home/vagrant/apache-tomcat-8.5.53/webapps/manager] has finished in [14] ms
18-Mar-2020 10:43:32.784 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
18-Mar-2020 10:43:32.789 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 407 ms
18-Mar-2020 11:21:23.503 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive
[/home/vagrant/apache-tomcat-8.5.53/webapps/app.war]
18-Mar-2020 11:21:23.560 INFO [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive
[/home/vagrant/apache-tomcat-8.5.53/webapps/app.war] has finished in [57] ms
View Sample Application
https://localhost:8080/app
just enough
Web Frameworks
https://insights.stackoverflow.com/survey/2019
Project Structure main.py
from flask import Flask
@app.route('/')
my-application def hello():
LICENSE return 'Hello, World!'
gunicorn main:app -w 2
[2020-03-10 09:53:29 +0000] [2916] [INFO] Starting gunicorn 20.0.4
[2020-03-10 09:53:29 +0000] [2916] [INFO] Listening at: http://127.0.0.1:8000 (2916)
[2020-03-10 09:53:29 +0000] [2916] [INFO] Using worker: sync
[2020-03-10 09:53:29 +0000] [2919] [INFO] Booting worker with pid: 2919
[2020-03-10 09:53:29 +0000] [2921] [INFO] Booting worker with pid: 2921
https://flask.palletsprojects.com/en/1.1.x/deploying/wsgi-standalone/
just enough
Express.js
Project Structure
app.js
my-application const express = require('express')
const app = express()
LICENSE
app.get('/products', (req, res) =>
res.send(getProductList()))
README.md
app.use(express.static(path.join( dirname, 'public')));
package.json
app.listen(3000);
app.js
public
tests
config
routes
services
db
core
Project Structure
package.json
{
"name": "my-application",
my-application npm install "version": "0.0.0",
"private": true,
LICENSE
"dependencies": {
README.md node app.js "dotenv": "^5.0.0",
"execa": "^0.9.0",
package.json "express": "^4.16.2"
app.js npm run start :dev },
"scripts": {
public "debug": "node debug app.js",
tests "start": "NODE_ENV=production node app.js",
config "start:dev": "NODE_ENV=dev node app.js",
routes "test:e2e": "node tests/run-e2e-test.js",
"test:unit": "jest tests/unit",
services
"test:unit:watch": "jest tests/unit --watch"
db }
core }
Project Structure
http://localhost:3000
my-application npm install
LICENSE
README.md node app.js
package.json
app.js npm run start :dev
public
tests
supervisord
config
routes
forever
services
db
pm2
core
pm2
ip addr show
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_f
1000
link/ether 02:0e:0c:9a:00:f0 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3
221
Ports
main.py
from flask import Flask
http://10.0.2.15:8000
http://10.0.2.16:8000
222
Ports
ip addr show
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
1000
link/ether 02:0e:0c:9a:00:f0 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3
223
Ports
http://127.0.0.1:8000
http://localhost:8000
224
Ports
127.0.0.1 127.0.0.1
lo lo
10.0.2.16
wlp0s2
10.0.2.15
enp0s3
http://127.0.0.1:8000 http://127.0.0.1:8000
http://localhost:8000 http://localhost:8000
225
Databases
Databases
• MySQL
• MongoDB SQL
• Redis SQL
SQL
SQL
NoSQL
Key-Value
SQL
SQL
NoSQL
NoSQL
NoSQL
NoSQL
NoSQL
https://insights.stackoverflow.com/survey/2019#technology
SQL
Tabular/Relational Databases
{ { {
"name": "Aryan Kumar", "name": "Lily Oliver", "name": "Lauren Rob",
"age": 10, "age": 15, "age": 13,
"location": "New York", "location": "Bangalore", "location": "Bangalore",
"Grade": "A" "Grade": "B" "Grade": "C"
} } }
SQL vs NoSQL
SELECT * from persons where AGE > 10 db.persons.find( { age:Co{llectti:on10 } } )
$g
{ {
"name": "John Doe", "name": "Dave Smith",
Table "age": 45, "age": 34,
"location": "New York", "location": "New York",
Name Age Location Salary Grade "salary": 5000 "salary": 4000,
"organization": "ACME"
John Doe 45 New York 5000 } }
• Open source
• Fast
• Reliable
• SQL
Community Commercial
https://www.mysql.com/products/
Install
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
https://dev.mysql.com/doc/refman/8.0/en/linux-installation-yum-repo.html
Validate
cat /var/log/mysqld.log
2020-03-19T17:57:37.375709Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.19) initializing of server in progress as process 4162
2020-03-19T17:57:39.467035Z 5 [Note] A temporary password is generated for root@localhost: g/io%pFlE77m
2020-03-19T17:57:41.582829Z 0 [System] [MY-010116]A[Stem
rvpeor]ra/urysrp/asbssinw/omrdysiqslgde(nmeyrsaqteldd8fo.0r.1ro9o)ts@
talrotcinaglhaossp
t:rgo/cieos%
s p4F2l1E17 7m
2020-03-19T17:57:43.812826Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-03-19T17:57:44.021160Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL
Community Server - GPL.
2020-03-19T17:57:44.245102Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-03-19T18:04:21.190127Z 8 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release.
Please use caching_sha2_password instead'
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Validate
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
mysql_secure_installation
user password
'username'@'host'
Create User
mysql –u root -pg/io%pFlE77m
'username'@'host'
192.168.1.10
Create User
mysql –u root -pg/io%pFlE77m
192.168.1.10
Privileges
• Open source
• NoSQL
• Scalable
• High Performance
Community Enterprise
https://www.mongodb.com/what-is-mongodb
MongoDB
{ {
"name": "John Doe", "name": "Dave Smith",
"age": 45, "age": 34,
"location": "New York", "location": "New York",
"salary": 5000 "salary": 4000,
"organization": "ACME"
} Document }
{ { {
"name": "Aryan Kumar", "name": "Lily Oliver", "name": "Lauren Rob",
"age": 10, "age": 15, "age": 13,
"location": "New York", "location": "Bangalore", "location": "Bangalore",
"Grade": "A" "Grade": "B" "Grade": "C"
} } }
Collection
MongoDB
{ {
"name": "John Doe", "name": "Dave Smith", {
"age": 45, "age": 34, "name": "Aryan Kumar",
"location": "New York", "location": "New York", "age": 10,
"salary": 5000 "salary": 4000, "location": "New York",
"organization": "ACME" "Grade": "A"
} Document } }
{
"name": "Lauren Rob",
"age": 13,
{ { { "location": "Bangalore",
"name": "Aryan Kumar", "name": "Lily Oliver", "name": "Lauren Rob", "Grade": "C"
"age": 10, "age": 15, "age": 13, }
"location": "New York", "location": "Bangalore", "location": "Bangalore",
"Grade": "A" "Grade": "B" "Grade": "C"
} } } {
"name": "Lily Oliver",
"age": 15,
Collection "location": "Bangalore",
"Grade": "B"
}
{
"name": "Lauren Rob",
{ { { "age": 13,
"name": "Aryan Kumar", "name": "Lily Oliver", "name": "Lauren Rob", "location": "Bangalore",
"age": 10, "age": 15, "age": 13, "Grade": "C"
"location": "New York", "location": "Bangalore", "location": "Bangalore", }
"Grade": "A" "Grade": "B" "Grade": "C"
} } }
Collection Collection
Database
MongoDB
MongoDB Server
Install
Install
Install
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Start DB Service
systemctl start mongod