0% found this document useful (0 votes)
43 views254 pages

DevOps Pre Requisites v2 1

The document outlines common challenges faced by beginners in DevOps, including issues with lab setup, VM connectivity, and navigating Linux CLI. It is designed for individuals from various backgrounds who wish to start their journey in DevOps or cloud computing. The course features visual learning, demos, hands-on labs, and community support to aid learners in overcoming these challenges.

Uploaded by

Adiba Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views254 pages

DevOps Pre Requisites v2 1

The document outlines common challenges faced by beginners in DevOps, including issues with lab setup, VM connectivity, and navigating Linux CLI. It is designed for individuals from various backgrounds who wish to start their journey in DevOps or cloud computing. The course features visual learning, demos, hands-on labs, and community support to aid learners in overcoming these challenges.

Uploaded by

Adiba Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 254

Getting Started

www.kodekloud.com
Common Challenges

• Issues with setting up a basic lab


• Issues with connecting to VMs
• Trouble with navigating Linux CLI
• No experience working with text editors
• Errors during installation of application/dependencies
• Applications – Java, Python, NodeJS
• Web Servers – Apache, NGINX
• Databases – MySQL, MongoDB
• Issues with networking between VMs
• Trouble navigating JSON or YAML files
DevOps Pre-Requisite
Who is this course for?

• ANYONE who wants to start DevOps or Cloud Journey


• Non-IT Background or No Computer Science Degree
• College Students
• Developers trying to learn the basics of Operations
• Operations trying to learn the basics of Development
• Working in IT without a CS Degree
Course Features

VISUAL LEARNING DEMOS HANDS-ON LABS COMMUNITY SUPPORT


Why DevOps
Why DevOps
www.kodekloud.com
just enough

LINUX
Why Linux?

14
https://insights.stackoverflow.com/survey/2019
Why Linux?

2013 - Docker was born


2016– Docker for Windows was born

https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html

Kubernetes Documentation
Linux Basics

• Linux CLI
• VI Editor
• Package Management
• Service Management

*Allowed multiple selections


Linux Basics Course www.kodekloud.com
just enough

LINUX
Shell Types
echo $SHELL Bourne Shell (Sh Shell)
/bin/bash

C Shell (csh or tcsh)

Z Shell (zsh)

Bourne again Shell (bash)


Basic Commands
echo Hi
Print to screen
Hi

ls
List files & folders
File.txt my_dir1 file2.conf

cd my_dir1
Change directory

pwd
Present Working Directory
/home/my_dir1

mkdir new_directory Make Directory

cd new_directory; mkdir www; pwd


Multiple commands
/home/my_dir1/new_directory
Commands - Directories
/tmp/asia/india/bangalore
mkdir /tmp/asia
mkdir /tmp/asia/india
mkdir /tmp/asia/india/bangalore Make Directory Hierarchy

mkdir –p /tmp/asia/india/bangalore

rm –r /tmp/my_dir1 Remove Directory

cp –r my_dir1 /tmp/my_dir1 Copy Directory


Commands - Files
touch new_file.txt
Create a new file (no contents)
Hi

cat > new_file.txt


Add contents to file
This is some sample contents
CTLR + D

cat new_file.txt
View contents of file
This is some sample contents

cp new_file.txt copy_file.txt Copy File

mv new_file.txt sample_file.txt Move (Rename) File

rm new_file.txt Remove (Delete) File


User Accounts
whoami
matthew
matthew

id
uid=1001(matthew) gid=1001(matthew) groups=1001(matthew)

su aparna
Password:

ssh [email protected]

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

wget http://www.some-site.com/some-file.txt -O some-file.txt


some-file.txt
Check OS Version
ls /etc/*release*
/etc/centos-release /etc/os-release /etc/system-release
/etc/centos-release-upstream /etc/redhat-release /etc/system-release-cpe

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 –e telnet.rpm Uninstall Package

rpm –q telnet.rpm Query 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

yum remove ansible

yum --showduplicates list ansible


Available Packages
ansible.noarch 2.4.2.0-2.el7 extras
ansible.noarch 2.9.6-1.el7 epel

yum install ansible-2.4.2.0


Services
Services
service httpd start Start HTTPD service
Or
systemctl start httpd Start HTTPD service

systemctl stop httpd Stop HTTPD service

systemctl status httpd Check HTTPD service Status

Configure HTTPD to start at


systemctl enable httpd startup

Configure HTTPD to not start at


systemctl disable httpd startup
Services
/usr/bin/python3 /opt/code/my_app.py systemctl start my_app
* Serving Flask app "my_app" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment. systemctl stop my_app
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

/etc/systemd/system
curl http://localhost:5000
Hello, World!
Services
/etc/systemd/system

/usr/bin/python3 /opt/code/my_app.py my_app.service


* Serving Flask app "my_app" (lazy loading)
* Environment: production [Service]
WARNING: This is a development server. Do not use it in a production deployment. ExecStart=
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

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

Apr 07 09:01:39 systemd[1]: Started my_app.service. [Install]


Apr 07 09:01:39 python3[5038]: * Serving Flask app "my_app" (lazy loading) WantedBy=multi-user.target
Apr 07 09:01:39 python3[5038]: * Environment: production
Apr 07 09:01:39 python3[5038]: WARNING: This is a development server. Do not use it in a produ...ent.
Apr 07 09:01:39 python3[5038]: Use a production WSGI server instead.
Apr 07 09:01:39 python3[5038]: * Debug mode: off
Apr 07 09:01:39 python3[5038]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) systemctl daemon-reload
Hint: Some lines were ellipsized, use -l to show in full.

systemctl start my_app

systemctl stop my_app


curl http://localhost:5000
Hello, World!
systemctl enable 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) [Unit]
Active: active (running) since Tue 2020-04-07 09:01:39 UTC; 2s ago Description=My python web application
Main PID: 5038 (python3)
CGroup: /system.slice/my_app.service
└─5038 /usr/bin/python3 /tmp/app/my_app.py
[Service]
ExecStart= /usr/bin/python3 /opt/code/my_app.py
Apr 07 09:01:39 systemd[1]: Started my_app.service.
Apr 07 09:01:39 python3[5038]: * Serving Flask app "my_app" (lazy loading) ExecStartPre=/opt/code/configure_db.sh
Apr 07 09:01:39 python3[5038]: * Environment: production
Apr 07 09:01:39 python3[5038]: WARNING: This is a development server. Do not use it in a produ...ent. ExecStartPost=/opt/code/email_status.sh
Apr 07 09:01:39 python3[5038]: Use a production WSGI server instead.
Apr 07 09:01:39 python3[5038]: * Debug mode: off Restart=always
Apr 07 09:01:39 python3[5038]: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Hint: Some lines were ellipsized, use -l to show in full.
[Install]
WantedBy=multi-user.target

curl http://localhost:5000 systemctl daemon-reload


Hello, World!

systemctl start my_app


Service Unit File - Docker
/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[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

Copy & Paste yy p

Scroll Up/Down CTRL +u CTRL +d


VI Editor - Command Mode

Command :

Save :w :w filename

Quit (Discard) :q

Save + Quit :wq


VI Editor - Command Mode

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

Hypervisor Host Operating System

Baremetal (Server) Baremetal (Server)


Virtualization S/W

• 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

Terminal Remote Desktop


Putty

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

Terminal Remote Desktop


host> ssh 192.168.1.10 Putty

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

guest> ip addr add 192.168.1.10/24 dev eth0

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)

guest> service sshd start


Networking
Objectives
• Networking in VirtualBox
• Networking Adapters
• NAT
• Bridge
• Host Only
• Internet Connectivity

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

192.168.1.6 3: wlp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fa


wlp0s2 1000
link/ether dc:fb:48:dd:4b:4f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.6/24 brd 192.16810.255 scope global enp0s3
192.168.1.15
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

NAT Host-Only Bridge


Network Network Network
192.168.5.0 192.168.5.0

192.168.5.2 192.168.5.2 192.168.5.2

Possible Possible with IP Forwarding Possible


Internet Connectivity
Port Forwarding
Network Address
Translation (NAT)

80 80
5000 8080
22 2222

host> ssh 192.168.1.10

host> ssh 127.0.0.1 –p 2222


Port Forwarding
VirtualBox Networking

Requirement Solution

VMs must be able to reach the internet/other systems in the network NAT

VMs must be visible in the external network Bridged

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 Host 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

Yes Yes No No NAT Network

No Yes Yes No Host Network

Yes Yes Yes No Host Network +


NAT
Yes Yes Yes Yes Bridged
Vagrant

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>]

-v, --version Print the version and exit.


-h, --help Print this help.

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

Docker Ansible CI/CD

Kubernetes Chef Jenkins

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

• Who is this for?


• Non-Developers

• Different types of programming languages


• Python
• NodeJS
• Java
• Building and Deploying them
• Troubleshooting Applications
• Labs
Programming Languages

• JavaScript –
NodeJS
• Python
• Java

https://insights.stackoverflow.com/survey/2019#technology
Types

Compiled Interpreted

C C++
Compiled
MyClass.java

1. Develop Source Code public class MyClass {


public static void main(String[] args) {
System.out.println("Hello World");
}
}

2. Compile javac MyClass.java


MyClass.class

3. Run java MyClass


Hello World
Interpreted
main.py

1. Develop Source Code


def print_message():
print("Hello World")

if name == ' main ':


print_message()

2. Run python main.py


Hello World
Code
main.py Machine Code

01101000 10111100 10000001


def print_message(): 01100100 01011100 00010111
print("Hello World") 00001010 00001110 11111010
10110001 01101000 10111100
Compiler 10000001 01100100 01011100
if name == ' main ': 00010111 00001010 00001110
print_message() 11111010 10110001 10110001

Human Readable Machine Readable


Source Code Machine Code
Code

main.py main.pyc Machine Code


Hello World 01101000 10111100 10000001
def print_message(): 1 0 LOAD_NAME 0 (dig)
print("Hello World")
01100100 01011100 00010111
3 LOAD_NAME 1 (print) 00001010 00001110 11111010
6 LOAD_CONST 0 ('Hello World') 10110001 01101000 10111100
if name == ' main ': Compiler --> 12 CALL_FUNCTION 1 (1 positional,0 keyword) 10000001 01100100 01011100
print_message() 15 PRINT_EXPR Interpreter 00010111 00001010 00001110
16 LOAD_CONST 1 (None)
11111010 10110001 10110001
19 RETURN_VALUE

Human Readable Intermediary Machine Readable


Source Code Byte Code Machine Code
Virtual Machine

main.pyc Machine Code


Hello World 01101000 10111100 10000001
1 0 LOAD_NAME 0 (dig) 01100100 01011100 00010111
3 LOAD_NAME 1 (print) 00001010 00001110 11111010
6 LOAD_CONST 0 ('Hello World') 10110001 01101000 10111100
Compiler --> 12 CALL_FUNCTION 1 (1 positional,0 keyword) 10000001 01100100 01011100
15 PRINT_EXPR Interpreter 00010111 00001010 00001110
16 LOAD_CONST 1 (None)
11111010 10110001 10110001
19 RETURN_VALUE
Python VM

Intermediary Machine Readable


Byte Code Machine Code

python main.py
Hello World
Packages/Modules/Libraries

• Filesystems
• Math
• Operating system
• HTTP
• Security
• Networking
Build

• Compile
• Run Tests
• Package
• Delivery

• Check build procedure for different types of applications:


• Python
• Java
• NodeJS
just enough

NETWORKING
Networking Pre-Requisites

• Switching
• Routing
• Default Gateway
• DNS Configurations on Linux
just enough

Introduction
About Java

• Free Version Date


13 2019
• Open-source 12 2019
• Huge Community 11 2018
10 2018
9 2017
8 2014
7 2011
6 2006
5 2004
Install Java

wget https://download.java.net....
openjdk-13.0.2_linux-x64_bin.tar.gz

tar –xvf openjdk-13.0.2_linux-x64_bin.tar.gz


/opt/jdk-13/bin/java -version Version Name
13 13
jdk-13.0.2/bin/java -version 12 12

openjdk version "13.0.2" 2020-01-14 11 11


OpenJDK Runtime Environment (build 13.0.2+8) 10 10
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode,
sharing) 9 9
8 1.8
java -version 7 1.7
openjdk version "1.8.0_242" 6 1.6
OpenJDK Runtime Environment (build 1.8.0_242-b08) 5 1.5
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed
mode)
https://jdk.java.net/13/
Java Development Kit (JDK)

Develop Build Run

jdb javac JRE

javadoc jar (Java Runtime Environment)

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

Java Development Kit (JDK)


JRE
Develop Build Run
(Java Runtime Environment)
jdb javac
javadoc jar
java
After v9

Java Development Kit (JDK)


Develop Build Run

jdb javac JRE


javadoc jar
(Java Runtime Environment)
java
just enough

Build
Compile
MyClass.java

1. Develop Source Code public class MyClass {


public static void main(String[] args) {
System.out.println("Hello World");
}
}

2. Compile javac MyClass.java


MyClass.class

3. Run java MyClass


Hello World
Compile
MyClass.java Machine Code
public class MyClass { 01101000 10111100 10000001
public static void main(String[] args) { 01100100 01011100 00010111
System.out.println("Hello World"); 00001010 00001110 11111010
}
Compiler 10110001 01101000 10111100
}
10000001 01100100 01011100
00010111 00001010 00001110
11111010 10110001 10110001

Human Readable Machine Readable


Source Code Machine Code
Java Virtual Machine

MyClass.class Machine Code


MyClass.java
0: iconst_2 01101000 10111100 10000001
public class MyClass {
public static void main(String[] args) 1: istore_1 01100100 01011100 00010111
{ System.out.println("Hello World");
}
2: iload_1 00001010 00001110 11111010
} 3: sipush 1000 10110001 01101000 10111100
Compiler 6: if_icmpge 44 10000001 01100100 01011100
9: iconst_2 00010111 00001010 00001110
10: istore_2 11111010 10110001 10110001
11: iload_2
12: iload_1 JVM
13: if_icmpge 31

Human Readable Intermediary Machine Readable


Source Code Byte Code Machine Code

javac MyClass.java java MyClass


MyClass.class Hello World
Package
MyClass.class

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 1 Service1.class Manifest-Version: 1.0


Created-By: 1.8.0_242 (Private Build)
Dependency 2 Service2.class Main-Class: MyClass

Dependency 3
Utility.class

Tools.class
Image 1
Java Archive Web Archive
Image 2 HTML 1 (JAR) (WAR)
HTML 2

jar cf MyApp.jar MyClass.class Service1.class Service2.class ...


MyApp.jar

java -jar MyApp.jar


Hello World
Document

javadoc –d doc MyClass.java


Build Process

Develop Compile Package Document

javac MyClass.java

jar cf MyClass.jar ..

javadoc MyClass.java
Build Process
Build Tools

• Maven # Build Steps


• Gradle
• ANT 1.Compile

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

• Free Node.js 13.x


• Open source
• Cross Platform Compatible Node.js 12.x
Node.js 11.x
Node.js 10.x
Node.js 9.x
Node.js 8.x
Node.js 7.x
Node.js 6.x
Node.js 5.x
Node.js 4.x
Node.js 0.12.x
Node.js 0.10.x
Install NodeJS

curl -sL https://rpm.nodesource.com/setup_13.x | bash -

yum install nodejs


NodeJS Commands
node -v
V13.10.1

node add.js add.js


Addition : 15 // Returns addition of two numbers
let add = function (a, b) {
return a+b;
};

const a = 10, b = 5;

console.log("Addition : "+ add(a,b));


just enough
Node Package Manager (NPM)

• Files
• Web Servers
• Databases
• Security
• Many More

https://www.npmjs.com/
NPM Commands
npm -v
6.13.7

npm search file


NAME | DESCRIPTION | AUTHOR | DATE
file | Higher level path… | =aconbere | 2014-02-21
File | HTML5 FileAPI… | =coolaj86 =narf | 2014-10-24
dotenv | Loads environment… | =~jcblw… | 2019-10-16
fs-extra | fs-extra contains… | =jprichardson… | 2019-06-28
file-loader | A file loader… | =d3viant0ne… | 2020-02-19

npm install file node_modules


+ [email protected]
added 1 package from 1 contributor and audited 1 package in 1.072s
file
found 0 vulnerabilities LICENSE
README.md
package.json
lib
package.json
NPM Commands
{
"author": {
"name": "Anders Conbere",
"email": "[email protected]"
},
"bundleDependencies": false,
"devDependencies": {
"mocha": "1.9.x"
},
"directories": {
"lib": "lib"
},
"homepage": "https://github.com/aconbere/node-file-utils#readme",
"license": "MIT",
"main": "./lib/file",
"name": "file",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/aconbere/node-file-utils.git" node_modules
},
"tags": [
"file",
file
"path", LICENSE
"fs",
"walk"
],
README.md
"version": "0.2.2"
} package.json
lib
NPM Commands
npm install file
+ [email protected]
added 1 package from 1 contributor and audited 1 package in 1.072s
found 0 vulnerabilities

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

Built-In Modules External Modules


fs To handle filesystem express Fast, unopinionated, minimalist web
http To host an HTTP server framework
os To work with the Operating System react To create user interfaces
events To handle events debug To debug applications
tls To implement TLS and SSL async To work with asynchronous JS
url To Parse URL Strings lodash To work with arrays, objects, strings etc

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 – (2000 – 2010)


• Python3 – (2008 to Present)
Install
yum install python2 yum install python36

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

python2 main.py main.py

Hello World
def print_message():
print("Hello World")

if name == ' main ':


print_message()
just enough
Python Package Manager (pip)
python2 -V python3 -V
Python 2.7.16 Python 3.6.8

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)

pip install flask


Python Package Manager (pip)
pip install flask

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

pip show flask


Name: Flask usr
Version: 1.1.1 main.py
Summary: A simple framework for building complex lib
from flask import Flask, request
web applications.
Home-page: https://palletsprojects.com/p/flask/ python2.7
Author: Armin Ronacher app = Flask( name )
site-packages
Author-email: [email protected]
License: BSD-3-Clause @app.route('/') Python3.6
Location: /usr/lib64/python2.7/site-packages
Requires: Werkzeug, click, Jinja2, itsdangerous def hello(): site-packages
return 'Hello,
lib64 World'
python2 -c "import sys; print(sys.path)"
python2.7
'/usr/lib/python27.zip', '/usr/lib64/python2.7',
'/usr/lib64/python2.7/plat-linux2', site-packages
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old', Flask-1.1.1.dist-info
'/usr/lib64/python2.7/lib-dynload', python3.6
'/usr/lib64/python2.7/site-packages',
'/usr/lib/python2.7/site-packages' site-packages
Requirements
requirements.txt
pip install flask
Flask==0.10.1
pip install jinja2 Jinja2==2.7.3

pip install markupsafe MarkupSafe==0.23

pip install Werkzeug Werkzeug==0.9.6

pip install requests requests==2.3.0

pip install gunicorn gunicorn==18.0

pip install flask jinja2 markupsafe pip install –r requirements.txt


Upgrade/Uninstall Package

pip install flask --upgrade


Installing collected packages: click, flask
Attempting uninstall: flask
Found existing installation: Flask 0.10.1
Uninstalling Flask-0.10.1:
Successfully uninstalled Flask-0.10.1
Successfully installed click-7.1.1 flask-1.1.1

pip uninstall flask


Found existing installation: Flask 1.1.1
Uninstalling Flask-1.1.1:
Would remove:
/home/vagrant/.local/bin/flask
/home/vagrant/.local/lib/python3.5/site-
packages/Flask-1.1.1.dist-info/*
/home/vagrant/.local/lib/python3.5/site-
packages/flask/*
Proceed (y/n)? y
Successfully uninstalled Flask-1.1.1
Other Package Managers

• easy_install easy_install install app

</>

app.py setuptools app.egg

• wheels pip install app.whl

</>

app.py setuptools app.whl


Servers
Why?
Q. Please use the scale below to describe your organization’s plans for moving
each of the following types of applications to the cloud

166
Application Types

Desktop Mobile Web Analytics Problem Solving

167
Standalone vs Client-Server

Server

Standalone Desktop Desktop Client


Client-Server

Web Client

Chat
Desktop Client Server

Mobile Client
Servers

Chat Web Application DB Email Backup


Server Server Server Server Server Server

Photo by Gareth Halfacree


Servers

Web Application
Server Server
Servers

AppW
liceabtion
Server
Servers

Web Application DB
Server Server Server
just enough

Web Frameworks &


Web Servers
Web Frameworks

https://insights.stackoverflow.com/survey/2019
Web Frameworks
REQUEST
https://www.shop-app.com

Web
Server

HTML CSS JavaScript REJSAPVOANSE Python NodeJS


Web Frameworks
app.js DemoApplication.java
$(document).ready(function() { package com.example.demo;
$.get( "/products", function (data, status) {
// <code hidden>
displayProducts( data )
} ); @SpringBootApplication
}); @RestController
public class DemoApplication {

public static void main(String[] args) {


SpringApplication.run(DemoApplication.class, args);
}

@GetMapping("/products")
public String[] getProducts() {
return getProductList();
}
}

HTML CSS JavaScript JAVA Python NodeJS

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();
}
}

HTML CSS JavaScript JAVA Python NodeJS

Application Code
Web Server
DemoApplication.java
package com.example.demo;

// <code hidden>

@SpringBootApplication
@RestController
public class DemoApplication {

public static void main(String[] args) {


SpringApplication.run(DemoApplication.class, args);
}

@GetMapping("/products")
public String[] getProducts() { Web
return getProductList();
} Server
}

HTML CSS JavaScript JAVA Python NodeJS

Application Code
Web Server
DemoApplication.java
package com.example.demo;

// <code hidden>

@SpringBootApplication
@RestController
public class DemoApplication {

public static void main(String[] args) { HTML CSS JavaScript


SpringApplication.run(DemoApplication.class, args);
}
JAVA Python NodeJS
@GetMapping("/products")
public String[] getProducts() { Web
return getProductList();
} Server Application Code
}

8080 80 8000
Web Server
DemoApplication.java
package com.example.demo;

// <code hidden> HTML Python JavaScript


@SpringBootApplication Application 2 Code
@RestController
public class DemoApplication {

public static void main(String[] args) { HTML CSS JavaScript


SpringApplication.run(DemoApplication.class, args);
}
JAVA Python NodeJS
@GetMapping("/products")
public String[] getProducts() { Web
return getProductList(); Application Code
} Server
}

HTML NodeJS JavaScript

Application 3 Code
Static vs Dynamic Websites
just enough

APACHE WEB SERVER


Apache Web Server

• Open source
• Web Server
Install Apache Web Server
yum install httpd

service httpd start


Web
Server
service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2020-03-22 12:01:42 UTC; 56s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 4253 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"

firewall-cmd --permanent --add-service=http


View Logs
cat /var/log/httpd/access_log
::1 - - [22/Mar/2020:13:00:38 +0000] "GET / HTTP/1.1" 403 4897 "-" "curl/7.29.0"

cat /var/log/httpd/error_log Web


[Sun Mar 22 12:01:42.409565 2020] [core:notice] [pid 4253] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
Server
[Sun Mar 22 12:01:42.411052 2020] [suexec:notice] [pid 4253] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[Sun Mar 22 12:01:42.418732 2020] [lbmethod_heartbeat:notice] [pid 4253] AH02282: No slotmem from mod_heartmonitor
[Sun Mar 22 12:01:42.420272 2020] [mpm_prefork:notice] [pid 4253] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Sun Mar 22 12:01:42.420283 2020] [core:notice] [pid 4253] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Mar 22 13:00:38.040460 2020] [autoindex:error] [pid 4257] [client ::1:41654] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found, and
server-generated directory index forbidden by Options directive
[Sun Mar 22 13:16:36.345183 2020] [autoindex:error] [pid 4258] [client 10.0.2.2:54103] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found,
and server-generated directory index forbidden by Options directive
[Mon Mar 23 01:17:39.060209 2020] [autoindex:error] [pid 4256] [client 10.0.2.2:61535] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found,
and server-generated directory index forbidden by Options directive
[Mon Mar 23 01:20:14.131909 2020] [autoindex:error] [pid 4619] [client 10.0.2.2:61553] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found,
and server-generated directory index forbidden by Options directive
[Mon Mar 23 01:20:15.074959 2020] [autoindex:error] [pid 4255] [client 10.0.2.2:61558] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found,
and server-generated directory index forbidden by Options directive
Config File
/etc/httpd/conf/httpd.conf
#
# Listen: Allows you to bind Apache to specific IP addresses a nd/or
http://localhost:80
# ports, instead of the default. See also the <VirtualHost>
# directive.
# Web
# Change this to Listen on specific IP addresses as shown belo w to Server
# prevent Apache from glomming onto all bound IP addresses. 80
#
#Listen 12.34.56.78:80 Default HTTP Port - 80
Listen 80

#
# 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> HTML


ServerName www.oranges.com http://www.oranges.com CSS
DocumentRoot /var/www/oranges
</VirtualHost> JavaScript
Server: www.oranges.com
Document Root: /var/www/oranges
VirtualHost

service httpd restart Document Root


/var/www/html
#
#ServerName www.example.com:80
ServerName www.houses.com:80
Config File
/etc/httpd/conf/houses.conf

<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

tar xvf 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

HTML CSS JavaScript JAVA

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

HTML CSS JavaScript JAVA

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 = Flask( name )

@app.route('/')
my-application def hello():
LICENSE return 'Hello, World!'

README.md if name ==' main ':


requirements.txt pip install –r requirements.txt app.run()
main.py
utils python main.py
tests * Serving Flask app "main" (lazy loading)
config * Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
routes Use a production WSGI server instead.
services * Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
db
core
Production Deployme nt
from flask import Flask
main.py

app = Flask( name )


• Gunicorn @app.route('/')
• uWSGI def hello():
return 'Hello, World!'
• Gevent if name ==' main ':
• Twisted Web app.run()

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

pm2 start app.js

pm2 start app.js –i 4


https://github.com/Unitech/pm2
IP Addresses and Ports
From a Web Application
Perspective
FAQ
• What IP Address and Port should I use?
• localhost vs 127.0.0.1 vs IP Address
• Why can’t I connect to my server?
• HTTP or HTTPS?
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 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3

10.0.2.16 3: wlp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fa


wlp0s2 1000
link/ether dc:fb:48:dd:4b:4f brd ff:ff:ff:ff:ff:ff
inet 10.0.2.16/24 brd 10.0.2.255 scope global enp0s3
10.0.2.15
enp0s3

221
Ports

main.py
from flask import Flask

app = Flask( name )


?
10.0.2.16 @app.route('/')
wlp0s2 def hello():
return 'Hello, World!'
?
10.0.2.15
if name ==' main ':
enp0s3
app.run()
app.run(port=8000)
app.run(port=8000
app.run(port=8000,,,host='10.0.2.15')
host=‘127.0.0.1’)
host='0.0.0.0 ')

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

10.0.2.16 3: wlp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc


wlp0s2 1000
link/ether dc:fb:48:dd:4b:4f brd ff:ff:ff:ff:ff:ff
inet 10.0.2.16/24 brd 10.0.2.255 scope global enp0s3
10.0.2.15
enp0s3

223
Ports

127.0.0.1 ip addr show


lo 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state U
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

10.0.2.16 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc


wlp0s2 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
10.0.2.15
enp0s3 3: wlp0s2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
1000
link/ether dc:fb:48:dd:4b:4f brd ff:ff:ff:ff:ff:ff
inet 10.0.2.16/24 brd 10.0.2.255 scope global enp0s3

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 Age Location Salary Grade


John Doe 45 New York 5000
Dave Smith 34 New York 4000
Aryan Kumar 10 New York A
Lauren Rob 13 Bangalore C
Lily Oliver 15 Bangalore B
NoSQL
Key Value Key Value
Name John Doe Name Dave Smith
Age 45 Age 34
Location New York Location New York
Salary 5000 Salary 4000

Key Value Key Value Key Value


Name Aryan Kumar Name Lauren Rob Name Lily Oliver

Age 10 Age 13 Age 15

Location New York Location Bangalore Location Bangalore

Grade A Grade C Grade B


NoSQL
Key Value
Key Value
Name Dave Smith
Name John Doe
Age 34
Age 45
Location New York
Location New York
Salary 4000
Salary 5000
Organization ACME
Key Value Key Value Key Value
Name Aryan Kumar Name Lauren Rob Name Lily Oliver
Age 10 Age 13 Age 15
Location New York Location Bangalore Location Bangalore
Grade A Grade C Grade B
NoSQL
{ {
"name": "John Doe", "name": "Dave Smith",
"age": 45, "age": 34,
"location": "New York", "location": "New York",
"salary": 5000 "salary": 4000,
"organization": "ACME"
} }

{ { {
"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 } }

Dave Smith 34 New York 4000 { {


"name": "Aryan Kumar", "name": "Lauren Rob",
Aryan Kumar 10 New York A "age": 10, "age": 13,
"location": "New York", "location": "Bangalore",
"Grade": "A" "Grade": "C"
Lauren Rob 13 Bangalore C } }

Lily Oliver 15 Bangalore Row B


{
"name": "Lily Oliver",
"age": 15,
"location": "Bangalore",
"Grade": "B"
} Document
SQL vs NoSQL
SELECT * from persons where age > 10 db.persons.find( { age: { $gt: 10 } } )

Name Age Location Salary Grade { {


"name": "John Doe", "name": "Dave Smith",
"age": 45, "age": 34,
John Doe 45 New York 5000 "location": "New York", "location": "New York",
"salary": 5000 "salary": 4000,
Dave Smith 34 New York 4000 "organization": "ACME"
} }
Aryan Kumar 10 New York A
{ {
Lauren Rob 13 Bangalore C "name": "Lily Oliver", "name": "Lauren Rob",
"age": 15, "age": 13,
"location": "Bangalore", "location": "Bangalore",
Lily Oliver 15 Bangalore B "Grade": "B" "Grade": "C"
} }
SQL vs NoSQL
just enough
MySQL

• 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

rpm -ivh mysql80-community-release-el7-3.noarch.rpm

yum install mysql-server

service mysqld start

service mysqld status


Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-03-19 17:57:44 UTC; 1min 12s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 4135 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 4211 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─4211 /usr/sbin/mysqld

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'

mysql –u root -pg/io%pFlE77m


mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.19

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

mysql> SHOW DATABASES;


+ +
| Database |
+ +
| information_schema |
| mysql |
| performance_schema |
| sys |
+ +
4 rows in set (0.00 sec)

mysql> CREATE DATABASE school;


Validate

mysql> USE school; mysql> INSERT INTO persons values


( "John Doe", 45, "New York");

mysql> CREATE TABLE persons mysql> SELECT * FROM persons;


( +----------+------+----------+
Name varchar(255), | name | age | location |
+ + + +
Age int, | John Doe | 45 | New York |
Location varchar(255) +----------+------+----------+
1 row in set (0.00 sec)
);

mysql> SHOW TABLES;


+ +
| Tables_in school |
+ +
| persons |
+ +
1 row in set (0.00 sec)
Create User
mysql –u root -pg/io%pFlE77m

mysql> CREATE USER 'john'@'localhost' IDENTIFIED BY 'MyNewPass4!';

user password

'username'@'host'
Create User
mysql –u root -pg/io%pFlE77m

mysql> CREATE USER 'john'@'localhost' IDENTIFIED BY 'MyNewPass4!';

mysql> CREATE USER 'john' @'192.168.1.10'


user IDENTIFIED BY 'MyNewPass4!';
password

'username'@'host'

mysql –u john -pMyNewPass4! mysql –u john -pMyNewPass4!

192.168.1.10
Create User
mysql –u root -pg/io%pFlE77m

mysql> CREATE USER 'john'@'localhost' IDENTIFIED BY 'MyNewPass4!';

mysql> CREATE USER 'john'@'192.168.1.10' IDENTIFIED BY 'MyNewPass4!';

mysql> CREATE USER 'john'@'%' IDENTIFIED BY 'MyNewPass4!';

mysql –u john -pMyNewPass4! mysql –u john -pMyNewPass4!

192.168.1.10
Privileges

mysql> GRANT <PERMISSION> ON <DB.TABLE> TO 'john'@'%';

mysql> GRANT SElECT ON school.persons TO 'john'@'%';

mysql> GRANT SElECT, UPDATE ON school.persons TO 'john'@'%';

mysql> GRANT SElECT, UPDATE ON school.* TO 'john'@'%'; Privileges


ALL PRIVILEGES Grant all access
mysql> GRANT ALL PRIVILEGES ON *.* TO 'john'@'%'; CREATE Create databases
DROP Delete databases
mysql> SHOW GRANTS FOR 'john'@'localhost';
DELETE Delete rows from table
+ +
| Grants for john@localhost
+
|
+
INSERT Insert rows into table
| GRANT USAGE ON *.* TO `john`@`localhost` |
| GRANT SELECT ON `school`.`persons` TO `john`@`localhost` | SELECT Read/Query tables
+ +
2 rows in set (0.00 sec) UPDATE Update rows in table
just enough
MySQL

• 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

Database Database Database

MongoDB Server
Install
Install
Install

yum install mongodb-org

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Start DB Service
systemctl start mongod

systemctl status mongod


● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-03-21 18:43:53 UTC; 1min 46s ago
Docs: https://docs.mongodb.org/manual
Process: 4224 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
Process: 4222 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 4220 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 4219 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Main PID: 4227 (mongod)
CGroup: /system.slice/mongod.service
└─4227 /usr/bin/mongod -f /etc/mongod.conf

You might also like