Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Commands 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Task: 1st SEP

----------------------

* create AWS account


* create EC2 Instances (Ubuntu, Amazon)
* Install web-server, app-server, db-server
* deploy index.html files
* deploy smaple.war file

HA-Proxy Configuration
-------------------------------------

Step-1: create Three Servers


-----------------------------------------
1 - HA-Proxy (Ubuntu)
2 - Servers (Ubuntu, Amazon)

Step-2: get Server IP-Address and Host Names:


----------------------------------------------------------------------
# cat /etc/os-release
# whoami
# sudo su - ---> to swtich to root user

# hostname -i ---> to get ip-address


# ip addr (or) ip a
# ifconfig

# hostname ---> to get server name


# hostname -f ---> to get FQDN

# vi /etc/hosts
[press 'i' for insert ]
172.31.17.224 ip-172-31-17-224.us-east-2.compute.internal
172.31.17.146 ip-172-31-17-146.us-east-2.compute.internal
172.31.30.208 ip-172-31-30-208.us-east-2.compute.internal
[press 'Esc' key ]
[:wq ---> for write and quit ]
1
Page
Step-3: Install HA-Proxy :
-------------------------------------
Ubuntu / Debian :
* apt
* apt-get

Redhat / Amazon :
* yum
* rpm (Redhat Package Manager)

# apt-get update ---> to update repo


# apt-get install haproxy -y ---> to install haproxy
# haproxy -version

Step-4: Install Web-Server, App-Server, DB-Server :


--------------------------------------------------------------------------
Web-Server:
-----------------
* to deploy static web-pages (.html files)
* packages: apache2, httpd, nginx
* port: 80 (apache)
* path: /var/www/html

App-Server:
-----------------
* to deploy static and dynamic web-pages (.war files)

* packages: tomcat, web-logic, JBoss

* port: 8080 (tomcat)

* path: /var/lib/tomcat/webapps

DB-Server:
----------------
* to Manage Data (insert, update, delete, select...)

* packages: mysql-server, oracle, sql-server, db2, mariadb

* port: 3306 (mysql)


2
Page
Server-1: Ubuntu / Debian
--------------------------------------
* apt
* apt-get

# whoami
# sudo su - --> to switch for root user
# cat /etc/os-release
# apt-get update
# apt-get install openjdk-11-jdk -y --> to install java
# java -version
# which java
# apt-get install apache2 -y --> to install web-server
# apt-get install tomcat9 -y --> to install app-server
# apt-get install mysql-server -y --> to install db-server

# service apache2 start --> to start services


# service tomcat9 start
# service mysql start
# service apache2 status
# service apache2 stop --> to stop service
# apt-get install net-tools -y
# netstat -lntp --> to list ports

Server-2: Amazon / Redhat


--------------------------------------
* yum
* rpm (Rehdat Package Manager)

# whoami
# sudo su - --> to switch for root user
# cat /etc/os-release
# yum update -y
# yum install java -y --> to install java
# java -version
# which java
3

# yum install httpd -y --> to install web-server


Page

# yum install tomcat -y --> to install app-server


# yum install mariadb-server -y --> to install db-server

# systemctl start httpd


# systemctl start tomcat
# systemctl start mariadb
# systemctl enable httpd
# systemctl stop httpd --> to stop service
# netstat -lntp --> to list ports

# ps -ef ---> to list processes


# ps -ef | grep java
# ps -ef | grep mysql

Step-5: Deploy index.html file for Web-Server:


-------------------------------------------------------------------

# cd /var/www/html/
# ls
# rm index.html
# vi index.html
[press 'i' for insert ]
<h1> Hello from Web-Server-1 </h1>
<h1> Hello from Web-Server-1 </h1>
......
[press 'Esc' key ]
[:wq --> for write and quit ]

Browser ----> http://<public IP-Address>

Step-6: Deploy sample.war file for App-Server:


---------------------------------------------------------------
# cd /var/lib/tomcat/webapps
# wget https://tomcat.apache.org/tomcat-7.0-doc/appdev/sample/sample.war

Browser --> http://3.135.223.219:8080/sample


4
Page
Step-7: to Configure HA-Proxy :
----------------------------------------------
# vi /etc/haproxy/haproxy.cfg
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
balance roundrobin
default_backend servers
backend servers
server web1 172.31.17.146:80 check maxconn 32
server web2 172.31.30.208:80 check maxconn 32

# vi /etc/default/haproxy
ENABLED=1

# service haproxy restart

Browser ---> http://<HA-Proxy IP-Address>

# curl http://localhost
# while true; do curl http://localhost; sleep 1; done

Dev + Op
-----------------
Cloud : Data storage, Servers (or) Instances

Unix Servers (or) Distributions:


---------------------------------------------
* Solaris (Sun OS) , AIX (IBM), HP-UX (HP Corp), MAC (Apple)
* System-V (AT & T Bell Labs), LINUX (Linus Torvald),
* BSD Unix (Berkeley Software Distribution)

Linux Servers (or) Distributions:


5

-----------------------------------------------
Page

* Redhat, Ubuntu, Centos, Gentoo, Slackware, Fedora, Mandark


* SuSE, Debain, Amazon Linux, Berkeley Linux , Mint Linux,
* Oracle Entperlinux, Turbo Linux, ...

#1. VM-Ware
#2. Virtual Box
#3. Vagrant
#4. Cloud (AWS, Azure, IBM, Google cloud, Oracle cloud...)

AWS-EC2 Instance
----------------------------
* create a new AWS account
* select "services" --> "Compute"
* select "EC2" (Elastic Compute Cloud)
* select "Launch Instances"

Step-1: Name and tags --> Redhat

Step-2: Application and OS Images --> Redhat9

Step-3: Instance type --> t2.micro (1 core, 1 Gb RAM)

Step-4: Key pair --> create a New key-pair

Step-5: Firewall (security groups) --> allow SSH, HTTP, HTTPS

Step-6: Configure storage --> select 10 Gb

Step-7: Number of instances --> 1

Google ---> search "Git for Windows" ---> download & Install Git-Bash

Linux commands
---------------------------

$ cp ~/Downloads/DEVOPS.pem ~/Desktop/
$ ssh -i "DEVOPS.pem" ec2-user@ec2-compute.amazonaws.com
$ cat /etc/os-release
$ whoami
$ who
$ date
6
Page

You might also like