tag:blogger.com,1999:blog-27399027301610480052024-03-18T08:31:33.557+05:30Linux NotesAnup D.Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.comBlogger38125tag:blogger.com,1999:blog-2739902730161048005.post-21558051187177805802023-12-28T11:58:00.003+05:302023-12-28T11:58:11.122+05:30Enable SSH in Azure Webapp Container<p style="text-align: center;"><b><span style="font-size: large;"> Enable SSH in Azure Webapp Container</span></b></p><p style="text-align: justify;"><b><span style="font-size: large;"><br /></span></b></p><p style="text-align: justify;"><span> This article will help you enable ssh in Azure Webapp container.</span><br /></p><p style="text-align: justify;"><span>- Create a file called "init.sh" at the same location where your Dockerfile is and add below content to it.</span></p><div style="background-color: #fffffe; font-family: Consolas, "Courier New", monospace; line-height: 16px; white-space: pre;"><div><span style="color: #e00000;"><span style="font-size: medium;">#!/bin/bash</span></span></div><div><span style="font-size: medium;"><span style="color: blue;">set</span> <span style="color: red;">-e</span></span></div><span style="font-size: medium;"><br /></span><div><span style="font-size: medium;"><span style="color: teal;">echo</span> <span style="color: #a31515;">"Starting SSH ..."</span></span></div><div><span style="font-size: medium;"><span style="color: teal;">service</span> <span style="color: teal;">ssh</span> <span style="color: teal;">start</span></span></div><span style="font-size: medium;"><br /></span><div><span style="font-size: medium;">exec <span style="color: #a31515;">"$@"</span></span></div><span style="font-size: 12px;"><br /></span></div><div style="background-color: #fffffe; font-family: Consolas, "Courier New", monospace; line-height: 16px; white-space: pre;">- Create a file called "sshd_config", this file will have basic SSH configuration and port for SSH</div><div style="background-color: #fffffe; font-family: Consolas, "Courier New", monospace; line-height: 16px; white-space: pre;">and add below content.</div><div style="background-color: #fffffe; font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 16px; white-space: pre;"><br /></div><div style="background-color: #fffffe; line-height: 16px;"><span style="font-family: Consolas, Courier New, monospace;"><span style="font-size: 12px; white-space: pre;">Port 2222
ListenAddress 0.0.0.0
LoginGraceTime 180
X11Forwarding yes
Ciphers aes128-cbc,3des-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr
MACs hmac-sha1,hmac-sha1-96
StrictModes yes
SyslogFacility DAEMON
PasswordAuthentication yes
PermitEmptyPasswords no
PermitRootLogin yes
Subsystem sftp internal-sftp</span></span></div><div style="background-color: #fffffe; font-family: Consolas, "Courier New", monospace; font-size: 12px; line-height: 16px; white-space: pre;"><br /></div><p style="text-align: justify;">- Install OpenSSH service, add below lines in Dockerfile.</p><div style="background-color: #fffffe; font-family: Consolas, "Courier New", monospace; line-height: 16px; white-space: pre;"><div><span style="color: #007200;"><span style="font-size: medium;"># Install and Run SSH</span></span></div><div><span style="font-size: medium;"><span style="color: blue;">ENV</span> <span style="color: #001188;">SSH_PASSWD</span> <span style="color: #a31515;">"root:Docker!"</span></span></div><div><span style="font-size: medium;"><span style="color: blue;">RUN</span> apt-get update</span></div><div><span style="font-size: medium;"><span style="color: blue;">RUN</span> apt-get install -y dialog \</span></div><div><span style="font-size: medium;"> && apt-get update \</span></div><div><span style="font-size: medium;"> && apt-get install -y openssh-server \</span></div><div><span style="font-size: medium;"> && echo <span style="color: #a31515;">"</span><span style="color: #001188;">$SSH_PASSWD</span><span style="color: #a31515;">"</span> | chpasswd</span></div><span style="font-size: medium;"><br /></span><div><span style="font-size: medium;"><span style="color: blue;">COPY</span> ./sshd_config /etc/ssh/</span></div><div><span style="font-size: medium;"><span style="color: blue;">COPY</span> ./init.sh /usr/local/bin/</span></div><div><span style="font-size: medium;"><span style="color: blue;">RUN</span> chmod u+x /usr/local/bin/init.sh</span></div><div><span style="font-size: medium;"><span style="color: blue;">ENTRYPOINT</span> [<span style="color: #a31515;">"init.sh"</span>]</span></div><div style="font-size: 12px;"><br /></div><div>- Build Docker image and deploy it on Azure webapp, to validate SSH navigate to Azure Portal.</div><div style="font-size: 12px;"><br /></div><div style="font-size: 12px;"><br /></div><div style="font-size: 12px;"><span style="background-color: white; font-family: Raleway, Arial; font-size: 14px;">Login into your </span><strong data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Azure Portal</strong><span style="background-color: white; font-family: Raleway, Arial; font-size: 14px;">–> Navigate to </span><strong data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">App services</strong><span style="background-color: white; font-family: Raleway, Arial; font-size: 14px;">–> Enter into your </span><strong style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">deployed App service</strong><span style="background-color: white; font-family: Raleway, Arial; font-size: 14px;">–> </span></div><div style="font-size: 12px;"><span style="background-color: white; font-family: Raleway, Arial; font-size: 14px;">Click on </span><strong data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">SSH</strong><span style="background-color: white; font-family: Raleway, Arial; font-size: 14px;">(from the side pane)–> Click on </span><strong data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Go</strong></div><div style="font-size: 12px;"><strong data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><br /></strong></div><div style="font-size: 12px;"><span data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><div class="separator" style="clear: both; font-weight: bold; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEijxozYu-JTfWw7oX336EwhFQRgkMZZfrYnQuAqcxEyJt4arcKA0PKGRto9Q1VQupZIOaKYTHNsW5ErWCV5ubRP2_KZIoeFFYCP4hT23pLnmMzQ2vzSrUpr4mkwW9QClOPMHriJiqPhX7EyXBg3PopzmfOSF1rhkXBmgn3ZXyzuyeCRYWku1WqkpfZyyBJ0" style="margin-left: 1em; margin-right: 1em;"><img data-original-height="293" data-original-width="553" height="213" src="https://blogger.googleusercontent.com/img/a/AVvXsEijxozYu-JTfWw7oX336EwhFQRgkMZZfrYnQuAqcxEyJt4arcKA0PKGRto9Q1VQupZIOaKYTHNsW5ErWCV5ubRP2_KZIoeFFYCP4hT23pLnmMzQ2vzSrUpr4mkwW9QClOPMHriJiqPhX7EyXBg3PopzmfOSF1rhkXBmgn3ZXyzuyeCRYWku1WqkpfZyyBJ0=w400-h213" width="400" /></a></div><b><br /></b>It will open another tab in browser and login to container.</span></div><div style="font-size: 12px;"><span data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><br /></span></div><div style="font-size: 12px;"><span data-renderer-mark="true" style="background-color: white; border: 0px; box-sizing: border-box; font-family: Raleway, Arial; font-feature-settings: inherit; font-kerning: inherit; font-optical-sizing: inherit; font-size: 14px; font-stretch: inherit; font-variant-alternates: inherit; font-variant-east-asian: inherit; font-variant-numeric: inherit; font-variant-position: inherit; font-variation-settings: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgwvVdFMogBlRQMdZo3hJmphUimCmsqC66aSbtUZiJOk6991Uj2Dlz2o_Hrg_5MDLU5CEcwnnJuCk2PcBwKMXqRfirUHJkfnmmXG-3MPAFQ3mlIdQsOdAxCmMLOw7nhFjMBH0n6Q89sUgmVW7GZBbSeCO2hroy_hOP-Kqw8APBg18-1vczJ-KbJPNQCl9Bx" style="margin-left: 1em; margin-right: 1em;"><img data-original-height="521" data-original-width="815" height="256" src="https://blogger.googleusercontent.com/img/a/AVvXsEgwvVdFMogBlRQMdZo3hJmphUimCmsqC66aSbtUZiJOk6991Uj2Dlz2o_Hrg_5MDLU5CEcwnnJuCk2PcBwKMXqRfirUHJkfnmmXG-3MPAFQ3mlIdQsOdAxCmMLOw7nhFjMBH0n6Q89sUgmVW7GZBbSeCO2hroy_hOP-Kqw8APBg18-1vczJ-KbJPNQCl9Bx=w400-h256" width="400" /></a></div><br /><br /></div><br /><br /></span></div></div>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-85371462380829612222023-07-21T07:05:00.004+05:302023-07-21T07:06:06.457+05:30Github Action workflow to deploy flask application on Google Kubernetes Engine (GKE)<p style="text-align: center;"><b><span style="font-size: large;"> Deploy application on GKE using Github Actions</span></b></p><p style="text-align: center;"><b><span style="font-size: large;"><br /></span></b></p><p style="text-align: justify;"><span style="font-size: large;">Follow the below steps to setup Github Actions workflow.</span></p><p style="text-align: justify;"><span style="text-align: left;"><span style="font-size: large;">Prerequisite</span></span><span style="font-size: large;">:</span></p><p style="text-align: justify;"><span style="font-size: large;">- Create service account in GCP and generate key file.</span></p><p style="text-align: justify;"><span style="font-size: large;">- Convert key file into base64 format and using the output to create secret variable in github repo.</span></p><p style="text-align: justify;"><span style="font-size: large;">Steps:</span></p><p style="text-align: justify;"><span style="font-size: large;">- In your github repo create .github/workflow directory</span></p><p style="text-align: justify;"><span style="font-size: large;">- Under workflow directory create a file called deploy.yml and paste below code into it.</span></p><p style="text-align: justify;"><span style="font-size: x-small;">name: Build-Deploy</span></p><p style="text-align: justify;"><span style="font-size: x-small;">on:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> push:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> branches: [ "anup_gke" ]</span></p><p style="text-align: justify;"><span style="font-size: x-small;">env:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> PROJECT_ID: <google-project-id> # ${{ secrets.GKE_PROJECT }}</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> GKE_CLUSTER: <GKE-Cluster-name> # TODO: update to cluster name</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> GKE_ZONE: us-central1-a # TODO: update to cluster zone</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> DEPLOYMENT_NAME: gke-test # TODO: update to deployment name</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> IMAGE_FLASK: <image name></span></p><p style="text-align: justify;"><span style="font-size: x-small;"> IMAGE_NGINX: <image name></span></p><p style="text-align: justify;"><span style="font-size: x-small;">jobs:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> build-deploy-gke:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> name: Login, Build, Publish, and Deploy</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> runs-on: ubuntu-latest</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> steps:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: Checkout</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> uses: actions/checkout@v3</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - id: 'auth'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> name: Google Authentication</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> uses: 'google-github-actions/auth@v1'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> with:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> credentials_json: '${{ secrets.GKE_SA_KEY }}'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> # Setup gcloud CLI</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - uses: google-github-actions/setup-gcloud@v1</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> name: Setup gcloud CLI</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> # Configure Docker to use the gcloud command-line tool as a credential</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> # helper for authentication</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: 'Configure Docker to use the gcloud command-line tool'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> run: |-</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> gcloud --quiet auth configure-docker</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> # Build the Docker image for mvp-flask</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: Build Docker Image of mvp-flask</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> run: |-</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> cd source/mvp-flask</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> docker build -t gcr.io/$PROJECT_ID/$IMAGE_FLASK:$GITHUB_RUN_ID .</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> # Build the Docker image for mvp-nginx</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: Build Docker Image of mvp-nginx</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> run: |-</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> cd source/nginx</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> docker build -t gcr.io/$PROJECT_ID/$IMAGE_NGINX:$GITHUB_RUN_ID .</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: Push docker images to GCR</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> run: |-</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> docker push gcr.io/$PROJECT_ID/$IMAGE_FLASK:$GITHUB_RUN_ID</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> docker push gcr.io/$PROJECT_ID/$IMAGE_NGINX:$GITHUB_RUN_ID</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: 'Get GKE Credentails'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> id: 'get-credentials'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> uses: 'google-github-actions/get-gke-credentials@v1'</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> with:</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> cluster_name: ${{ env.GKE_CLUSTER }}</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> location: ${{ env.GKE_ZONE }}</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: Deploy Docker Image on GKE Cluster</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> run: |-</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> kubectl set image deployment.apps/mvp-flask flask=gcr.io/<google-project-id>/</span><span style="font-size: small;">$IMAGE_FLASK</span><span style="font-size: x-small;">:$GITHUB_RUN_ID</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> kubectl set image deployment.apps/mvp-nginx nginx=gcr.io/</span><span style="font-size: small;"><google-project-id></span><span style="font-size: x-small;">/</span><span style="font-size: small;">$IMAGE_NGINX</span><span style="font-size: x-small;">:$GITHUB_RUN_ID</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> - name: command</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> run: |-</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> kubectl get all</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> echo "###"</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> kubectl describe deployment.apps/mvp-flask</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> echo "###"</span></p><p style="text-align: justify;"><span style="font-size: x-small;"> kubectl describe deployment.apps/mvp-nginx</span></p>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-64792856146306559262022-08-30T18:35:00.001+05:302022-08-30T18:35:48.463+05:30 Nginx location Regex Expression<p style="text-align: center;"> <span style="font-size: large;">Nginx Regex Expression</span></p><p style="text-align: center;"><span style="font-size: large;"><br /></span></p><p style="text-align: justify;"><span style="font-size: medium;">Nginx location block allow you to route request to particular location in file system or particular url.</span></p><p style="text-align: justify;"><span style="font-size: medium;">Below example is to show how to route domain name and number to domain.com:port.</span></p><p style="text-align: justify;"><br /></p><p style="text-align: justify;"><span style="font-size: medium;">server {</span></p><p style="text-align: justify;"><span style="font-size: medium;"> listen 80;</span></p><p style="text-align: justify;"><span style="font-size: medium;"> server_name anup.co.in;</span></p><p style="text-align: justify;"><span style="font-size: medium;"> root /usr/share/nginx/html;</span></p><p style="text-align: justify;"><span style="font-size: medium;"> location ~ "<b>/app/lck/([a-z0-9\-\.]+)/([0-9]+)</b>" {</span></p><p style="text-align: justify;"><span style="font-size: medium;"> return 301 http://$1:$2;</span></p><p style="text-align: justify;"><span style="font-size: medium;"> }</span></p><p style="text-align: justify;"></p><p style="text-align: justify;"><span style="font-size: medium;">}</span></p><p style="text-align: justify;"><span style="font-size: medium;"><br /></span></p><p style="text-align: justify;"><span> Above highlighted part will redirect as follows -</span><br /></p><p style="text-align: justify;"><span>http://anup.co.in/app/lck/google.com/8080 --> http://google.com:8080</span></p>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-61562809781457406872022-03-11T10:15:00.005+05:302022-03-11T10:18:06.965+05:30How to run Docker inside Docker using Dockerfile<p style="text-align: center;"><b><span style="font-size: large;"> How to run Docker inside Docker using Dockerfile</span></b></p><p style="text-align: center;"><b><span style="font-size: large;"><br /></span></b></p><p style="text-align: justify;"><span style="font-size: medium;">In some cases we want to run docker command inside docker container, we can do that by mapping docker.sock volume while running container. The other option is to use your Dockerfile.</span></p><p style="text-align: justify;">1] Here is Dockerfile -</p><p style="text-align: left;"><span style="background-color: white;">FROM ubuntu:18.04</span></p><p style="text-align: left;"><span style="background-color: white;">#Install Docker</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get update</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install apt-transport-https</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install ca-certificates</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install curl</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install gnupg2</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install software-properties-common</span></p><p style="text-align: left;"><span style="background-color: white;">ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn</span></p><p style="text-align: left;"><span style="background-color: white;">RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT)</span></p><p style="text-align: left;"><span style="background-color: white;">RUN add-apt-repository --yes "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get update</span></p><p style="text-align: left;"><span style="background-color: white;">RUN echo "deb http://security.ubuntu.com/ubuntu xenial-security main" >> /etc/apt/sources.list; apt-get update</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install build-essential</span></p><p style="text-align: left;"><span style="background-color: white;">RUN apt-get -y install docker-ce docker-ce-cli containerd.io</span></p><p style="text-align: left;"><span style="background-color: white;">CMD ["tail", "-f", "/dev/null"]</span></p><div style="text-align: justify;"><br /></div><div style="text-align: justify;">2] Build docker image.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"># docker build -t docker-in-docker:latest .</div><div style="text-align: justify;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhZ6W7vqvy_XlwafXZVNYI_le9-XAmrxP2BBHxe7gOxfAJQx2vfRPUDJ16Dzuio_7FX_oTADbghe0mS8xbLtsXYVbJ6VawfaJqRaZO084ThdpkQ4cYgdq0KbagiaU66zQUvruXCfEp-G8R58nd7jHBcctXLRxAq1l1Ic7jpcZv2yEhUbmP8RiGxxy-p8g=s1041" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="972" data-original-width="1041" height="374" src="https://blogger.googleusercontent.com/img/a/AVvXsEhZ6W7vqvy_XlwafXZVNYI_le9-XAmrxP2BBHxe7gOxfAJQx2vfRPUDJ16Dzuio_7FX_oTADbghe0mS8xbLtsXYVbJ6VawfaJqRaZO084ThdpkQ4cYgdq0KbagiaU66zQUvruXCfEp-G8R58nd7jHBcctXLRxAq1l1Ic7jpcZv2yEhUbmP8RiGxxy-p8g=w400-h374" width="400" /></a></div><br /><div style="text-align: justify;"><br /></div><div style="text-align: justify;">3] Run docker container from above docker image.</div><div style="text-align: justify;"># docker run -d --name dockerINdocker docker-in-docker:latest</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">4] Enter into docker container and confirm docker version as per below image.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEi6upezzZuibGRizHt5kYrKR1Q5SDYOcZ7yuFothtit9LK4xgCa3-kVILCTOIuhY8JsRRdFGAzYSu7g3-_YL2ln6QSXfU8u13DDZBJJoudakwrLBNIsTxdqR99wt-2OQPiO5rNXoRzSC1ZEiqyJNGOrc2nRmDbDDAYII6BJQngLyghhalk93r_J-zksnw" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="125" data-original-width="690" height="73" src="https://blogger.googleusercontent.com/img/a/AVvXsEi6upezzZuibGRizHt5kYrKR1Q5SDYOcZ7yuFothtit9LK4xgCa3-kVILCTOIuhY8JsRRdFGAzYSu7g3-_YL2ln6QSXfU8u13DDZBJJoudakwrLBNIsTxdqR99wt-2OQPiO5rNXoRzSC1ZEiqyJNGOrc2nRmDbDDAYII6BJQngLyghhalk93r_J-zksnw=w400-h73" width="400" /></a></div><br /><br /></div>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-46260878794778895242021-08-24T14:40:00.005+05:302021-08-24T14:40:36.209+05:30Download large file from Google Drive using wget on terminal<p style="text-align: center;"><b><span style="font-size: medium;"> Download large file from Google Drive using wget on terminal</span></b></p><p style="text-align: center;"><b><span style="font-size: medium;"><br /></span></b></p><p style="text-align: justify;"><span style="font-size: medium;"><b> </b>To download large file from Google Drive use following steps.<br /></span></p><p style="text-align: justify;"><span style="font-size: medium;"><br /></span></p><p style="text-align: justify;"><span style="font-size: medium;">1] Share file publicly and Copy share URL.</span></p><p style="text-align: justify;"><span style="font-size: medium;">Example share URL - </span></p><p style="text-align: justify;"><span style="text-align: left;"><span style="font-size: medium;">https://drive.google.com/file/d/1tcthANUPNgyho7X-5HPDuUAiEfTfw5/view?usp=sharing</span></span></p><p style="text-align: justify;"><span style="text-align: left;"><span style="font-size: medium;"><br /></span></span></p><p style="text-align: justify;"><span style="text-align: left;"><span style="font-size: medium;">2] Extract Field ID from above share URL as below.</span></span></p><p style="text-align: justify;"><span style="font-size: large; text-align: left;">https://drive.google.com/file/d/<b>1tcthANUPNgyho7X-5HPDuUAiEfTfw5</b>/view?usp=sharing</span></p><p style="text-align: justify;"><span style="font-size: large; text-align: left;">Field ID is - </span><b style="font-size: large; text-align: left;">1tcthANUPNgyho7X-5HPDuUAiEfTfw5</b></p><p style="text-align: justify;"><b style="font-size: large; text-align: left;"><br /></b></p><p style="text-align: justify;">3] Go to terminal and paste following command.</p><p style="text-align: justify;">wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=<b>FIELDID</b>' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=<b>FIELDID</b>" -O <b>FILENAME</b> && rm -rf /tmp/cookies.txt</p><p style="text-align: justify;"><br /></p><p style="text-align: justify;">Here, Replace <b>FIELDID </b>and<b> FILENAME </b>as per your file.</p><p style="text-align: justify;"><br /></p><p style="text-align: justify;">Let me know how it goes.</p>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-42286006494027010242021-03-31T15:58:00.004+05:302021-03-31T15:58:33.785+05:30Nginx Cookbook<p style="text-align: center;"><b><span style="font-size: x-large;"> Nginx Cookbook</span></b></p><p style="text-align: justify;"><b>1] Wildcard for Nginx location</b></p><p style="text-align: justify;">I have multiple API running on server to access them through I have to add multiple location block as below.</p><p style="text-align: justify;">My goal is to add single location block for all API's.</p><p style="text-align: justify;"><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">server {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> listen 80;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> server_name <a href="http://www.">www.</a></span><a href="http://anup.co.in">anup.co.in</a><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location / {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location /getHighscores {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/getHighscores<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location /auth/google {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/auth/google<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location /auth/google/redirect {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/auth/google/redirect<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location /auth/login/success {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/auth/login/success<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location /auth/login/failed {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/auth/login/failed<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location /auth/logout {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/auth/logout<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">}</span></p><p style="text-align: justify;"><b>Solution:</b></p><p style="text-align: justify;"><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">server {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> listen 80;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> server_name <a href="http://www.anup.co.in">www.anup.co.in</a></span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location / {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> location ~ ^/(.*)$ {</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> proxy_pass </span>http://localhost:3000/$1<span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">;</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;"> }</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">
</span><span style="background-color: white; color: #333333; font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; text-align: start; white-space: pre-wrap;">}</span></p>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-11806012083272774092020-08-11T17:29:00.003+05:302020-08-11T17:32:56.186+05:30Azure DevOps Pipeline Runtime parameter Task Condition<p style="text-align: center;"><b> Azure DevOps Pipeline Runtime parameter Task Condition</b></p><p style="text-align: center;"><b><br /></b></p><p style="text-align: justify;"><b> </b>This guide explains you how to use Azure DevOps pipeline to pass runtime boolean values and run tasks only if condition is true else skip the task.<br /></p><p style="text-align: justify;"><br /></p><p style="text-align: justify;">- Add following lines at the beginning of your pipeline YAML file</p><p style="text-align: justify;"><br /></p><div style="background-color: #fffffe; font-family: consolas, "courier new", monospace; line-height: 19px; white-space: pre;"><div style="font-size: 14px;"><span style="color: teal;">parameters</span>:</div><div style="font-size: 14px;">- <span style="color: teal;">name</span>: <span style="color: #0451a5;">installNewRelic</span></div><div style="font-size: 14px;"> <span style="color: teal;">type</span>: <span style="color: #0451a5;">boolean</span></div><div style="font-size: 14px;"> <span style="color: teal;">default</span>: <span style="color: blue;">false</span></div><div style="font-size: 14px;"><span style="color: blue;"><br /></span></div><div style="font-size: 14px;"><span style="color: blue;"><div style="color: black; font-family: Consolas, "Courier New", monospace; line-height: 19px;"><div><span style="color: teal;">trigger</span>:</div><div> <span style="color: teal;">branches</span>:</div><div> <span style="color: teal;">include</span>:</div><div> - <span style="color: #0451a5;">qa</span></div><div> <span style="color: teal;">paths</span>:</div><div> <span style="color: teal;">include</span>:</div><div> - <span style="color: #0451a5;">'*'</span></div><div> <span style="color: teal;">exclude</span>:</div><div> - <span style="color: #0451a5;">'docs/*'</span></div><div> - <span style="color: #0451a5;">'*.md'</span></div><br /><div><span style="color: teal;">pr</span>:</div><div> <span style="color: teal;">branches</span>:</div><div> <span style="color: teal;">include</span>:</div><div> - <span style="color: #0451a5;">qa</span></div><br /><div><span style="color: teal;">variables</span>:</div><div><div style="line-height: 19px;"><div> <span style="color: teal;">drupalroot</span>: <span style="color: #0451a5;">'/usr/share/nginx/html'</span></div><div> <span style="color: teal;">docroot</span>: <span style="color: #0451a5;">'/usr/share/nginx/html/docroot'</span></div><div><div style="line-height: 19px;"><span style="color: teal;"> newrelic_cmd</span>: <span style="color: #0451a5;">'docker run --entrypoint /bin/mv $(containerRegistry)/$(imageRepository):latest'</span></div></div></div></div></div></span></div><div style="font-size: 14px;"><span style="color: blue;"><br /></span></div><div><div style="line-height: 19px;"><div style="font-size: 14px;"><span style="color: teal;">stages</span>:</div><div style="font-size: 14px;">- <span style="color: teal;">stage</span>: <span style="color: #0451a5;">ReleaseToQA</span></div><div style="font-size: 14px;"> <span style="color: teal;">condition</span>: <span style="color: #0451a5;">and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/qa'))</span></div><div style="font-size: 14px;"> <span style="color: teal;">displayName</span>: <span style="color: #0451a5;">Release to QA</span></div><div style="font-size: 14px;"> <span style="color: teal;">jobs</span>:</div><div style="font-size: 14px;"> - <span style="color: teal;">job</span>: <span style="color: #0451a5;">Release</span></div><div style="font-size: 14px;"> <span style="color: teal;">displayName</span>: <span style="color: #0451a5;">Release</span></div><div style="font-size: 14px;"> - <span style="color: teal;">deployment</span>: <span style="color: #0451a5;">DeployToQA</span></div><div style="font-size: 14px;"> <span style="color: teal;">environment</span>: <span style="color: #0451a5;">$(webAppNameQA)</span></div><div style="font-size: 14px;"> <span style="color: teal;">strategy</span>:</div><div style="font-size: 14px;"> <span style="color: teal;">runOnce</span>:</div><div style="font-size: 14px;"> <span style="color: teal;">deploy</span>:</div><div style="font-size: 14px;"> <span style="color: teal;">steps</span>:</div><div style="font-size: 14px;"><span> </span><span> ...</span><br /></div><div style="font-size: 14px;"><span> Other Tasks</span></div><div style="font-size: 14px;"><span> ...</span></div><div style="font-size: 14px;"><span> # Below Task will only be executed if condition is true, default value is </span></div><div style="font-size: 14px;"><span> # false in parameter. </span>When you click on run pipeline it will ask you the </div><div style="font-size: 14px;"> # parameter value i.e. installNewRelic if you select then condition becomes</div><div style="font-size: 14px;"> # true and below task will executed else it will be skipped.</div><div style="font-size: 14px;"> # Refer the screenshot below</div><div><span><span style="font-size: 14px;"> </span><span style="font-size: x-small;"> </span></span><span style="font-size: x-small;">- <span style="color: teal;">task</span>: <span style="color: #0451a5;">Bash@3</span></span></div><div style="line-height: 19px;"><div><span style="font-size: x-small;"> <span style="color: teal;">displayName</span>: <span style="color: #0451a5;">'Place newrelic.ini from /usr/share/nginx/html/docroot/profiles/'</span></span></div><div><span style="font-size: x-small;"> <b><span style="color: teal;">condition</span>: <span style="color: #0451a5;">and(succeeded(), eq('${{ parameters.installNewRelic }}', true)) </span></b></span></div><div><span style="font-size: x-small;"> <span style="color: teal;">inputs</span>:</span></div><div><span style="font-size: x-small;"> <span style="color: teal;">targetType</span>: <span style="color: #0451a5;">'inline'</span></span></div><div><span style="font-size: x-small;"> <span style="color: teal;">script</span>: |</span></div><div><span style="color: #0451a5; font-size: x-small;"> $(newrelic_cmd) $(docroot)/profiles/corp-qa-newrelic.ini /etc/php/7.3/mods-available/newrelic.ini</span></div><div><span style="color: #0451a5; font-size: x-small;"><br /></span></div><div><span style="color: #0451a5;"><br /></span></div><div style="font-size: 14px;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09v8gp4hMtJGDkygtgf5YCeL6-LjK1xwfpEH3S0zTW3vszeMTyzfd_Lri_qsVg88z91fExtnpdLtidvtIq_vugsmwgYJQuLQwumxhC-Fim5ur2KFt9ApaLRv-azW1fVF6N2rcpwi49dQt/s521/azure-run-pipeline.JPG" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="480" data-original-width="521" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09v8gp4hMtJGDkygtgf5YCeL6-LjK1xwfpEH3S0zTW3vszeMTyzfd_Lri_qsVg88z91fExtnpdLtidvtIq_vugsmwgYJQuLQwumxhC-Fim5ur2KFt9ApaLRv-azW1fVF6N2rcpwi49dQt/s0/azure-run-pipeline.JPG" /></a></div><span style="color: #0451a5;"><br /></span></div><div style="font-size: 14px;"><span style="color: #0451a5;"><br /></span></div><div style="font-size: 14px;"><span style="color: #0451a5;"><br /></span></div></div></div></div></div>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com1tag:blogger.com,1999:blog-2739902730161048005.post-55245726989006685972019-08-03T20:18:00.002+05:302019-08-03T20:18:46.140+05:30Create VPC Subnet Security Group EC2 ELB using Python Boto3 <div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">This script assumes basic knowledge of AWS, Boto3 & Python.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
GIT URL - <a href="https://github.com/anupdubbewar/aws-python-boto3/blob/master/aws-python-boto3" style="background-color: transparent;">https://github.com/anupdubbewar/aws-python-boto3/blob/master/aws-python-boto3</a></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">Prerequisites:</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
</div>
<ul>
<li><span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">AWS Account</span></li>
<li><span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">IAM Role with Access & Secret Key</span></li>
<li><span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">Boto3 Installed & Configured</span></li>
</ul>
<br />
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">- Install AWS CLI & Python Boto3 Library in Python using pip, which is package management tool written in Python.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># pip install awscli boto3</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">- Create user in AWS from AWS console and get the Secret Access Key & Access ID to access AWS services programatically.</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># aws configure</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">- Run script using python command </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># python <script-name>.py</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<br /></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">import boto3</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">import time</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">ec2 = boto3.resource('ec2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">client = boto3.client('ec2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Create VPC</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">response = client.create_vpc(CidrBlock='172.16.0.0/16',InstanceTenancy='default')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Assign tags to VPC</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">client.create_tags(Resources=[response['Vpc']['VpcId']],Tags=[{'Key': 'Name','Value': 'my-drupal-vpc',}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('***** VPC Created with ID*********',response['Vpc']['VpcId'])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">vpc_id = response['Vpc']['VpcId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Creating Internet Gateway for Drupal Web Instance subnets and attaching to VPC</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">ig = ec2.create_internet_gateway()</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">client.attach_internet_gateway(InternetGatewayId = ig.id, VpcId=vpc_id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">routetable1_response = client.create_route_table(VpcId=vpc_id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def create_tag_for_route_table(route_table_number, route_table_name):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> tag = client.create_tags(Resources=[route_table_number['RouteTable']['RouteTableId']],Tags=[{'Key': 'Name','Value': route_table_name}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> return tag</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tag_for_route_table(routetable1_response,'drupal-rt1')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Route Table 1 Created - ',routetable1_response['RouteTable']['RouteTableId'])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table1 = ec2.RouteTable(routetable1_response['RouteTable']['RouteTableId'])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Attach internet gateway to Routetable drupal-rt1 for web instances in subnet 1 and 3</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table1.create_route(DestinationCidrBlock='0.0.0.0/0', GatewayId=ig.id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Attach internet gateway to Routetable drupal-rt1 for web instances in subnet 1 and 3</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table1.create_route(DestinationCidrBlock='0.0.0.0/0', GatewayId=ig.id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def create_subnet(cidr, vpc_id, azname):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> subnet_response = client.create_subnet(CidrBlock=cidr, VpcId=vpc_id, AvailabilityZone=azname)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> return subnet_response</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def create_tag(subnet_number,subnet_name):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> client.create_tags(Resources=[subnet_number['Subnet']['SubnetId']], Tags=[{'Key': 'Name', 'Value': subnet_name}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def modify_subnet_attribute(subnet_name):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> client.modify_subnet_attribute(MapPublicIpOnLaunch={'Value': True,}, SubnetId=subnet_name)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Creating first subnet</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">subnet1 = create_subnet('172.16.1.0/24', vpc_id, 'us-east-1a')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">ec2_subnet1 = subnet1['Subnet']['SubnetId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tag(subnet1,'drupal-sb1-us-east-1a')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">modify_subnet_attribute(ec2_subnet1)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Subnet 1 is Created with ID - ',ec2_subnet1)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Associating Route Table 1 to Subnet 1</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table1.associate_with_subnet(SubnetId=ec2_subnet1)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Route table 1 associated with Subnet 1 -',ec2_subnet1)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">routetable2_response = client.create_route_table(VpcId=vpc_id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tag_for_route_table('drupal-rt2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Route Table 2 Created - ',routetable2_response['RouteTable']['RouteTableId'])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table2 = ec2.RouteTable(routetable2_response['RouteTable']['RouteTableId'])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Creating second subnet</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">subnet2 = create_subnet('172.16.2.0/24', vpc_id, 'us-east-1a')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">ec2_subnet2 = subnet2['Subnet']['SubnetId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tag(subnet2,'drupal-sb2-us-east-1a')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Subnet 2 is Created with ID - ',ec2_subnet2)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Associating Route Table 2 to Subnet 2</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table2.associate_with_subnet(SubnetId=ec2_subnet2)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Route table 2 associated with Subnet 2 -',ec2_subnet2)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Creating third subnet</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">subnet3 = create_subnet('172.16.3.0/24', vpc_id, 'us-east-1b')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">ec2_subnet3 = subnet3['Subnet']['SubnetId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tag(subnet3,'drupal-sb3-us-east-1b')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">modify_subnet_attribute(ec2_subnet3)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Subnet 3 is Created with ID - ',ec2_subnet3)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Associating Route Table 1 to Subnet 3</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table1.associate_with_subnet(SubnetId=ec2_subnet3)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Route table 1 associated with Subnet 3 -',ec2_subnet3)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Creating fourth subnet</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">subnet4 = create_subnet('172.16.4.0/24', vpc_id, 'us-east-1b')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">ec2_subnet4 = subnet4['Subnet']['SubnetId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tag(subnet4,'drupal-sb4-us-east-1b')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Subnet 4 is Created with ID - ',ec2_subnet4)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Associating Route Table 2 to Subnet 4 </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">route_table2.associate_with_subnet(SubnetId=ec2_subnet4)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Route table 2 associated with Subnet 4 -',ec2_subnet4)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def create_security_group(descript, group_name):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> sg1_response = client.create_security_group(Description=descript,GroupName=group_name,VpcId=vpc_id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> return sg1_response</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def create_sg_tag(websg_or_elbsg,sg_group_name):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> sg_tag_response = client.create_tags(Resources=[websg_or_elbsg['GroupId']],Tags=[{'Key': 'Name','Value': sg_group_name}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> return sg_tag_response</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Create Security Group for Drupal instances which will accept traffic from ALB</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">web_sg1 = create_security_group('Accept traffic from ALB', 'drupal-web-sg')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">sgId = web_sg1['GroupId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_sg_tag(web_sg1,'drupal-web-sg')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Created Security Group for Web Instances -',sgId)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Create Security for ALB which will accept traffic from Internet</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">elb_sg1 = create_security_group('Accept traffic from Internet','drupal-elb-sg')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">elbsgId = elb_sg1['GroupId']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_sg_tag(elb_sg1,'drupal-elb-sg')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Created Security Group for ELB -',elbsgId)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">elb1 = ec2.SecurityGroup(elbsgId)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">elb1.authorize_ingress(GroupId=elbsgId,IpPermissions=[{'IpProtocol': 'tcp', 'FromPort': 80, 'ToPort': 80, 'IpRanges': [{'CidrIp': '0.0.0.0/0'}]}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">client.authorize_security_group_ingress(GroupId=sgId, IpPermissions=[{'IpProtocol': '-1','UserIdGroupPairs': [{'GroupId': elbsgId}]}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Creating SSH key file for drupal instances</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># create a file to store the key locally </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">outfile = open('drupal-ec2-keypair.pem','w') </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># call the boto ec2 function to create a key pair </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">key_pair = ec2.create_key_pair(KeyName='drupal-ec2-keypair') </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># capture the key and store it in a file </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">KeyPairOut = str(key_pair.key_material) </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">outfile.write(KeyPairOut) </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Creating instances for Drupal Infrastructure </span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">user_data_script = """#!/bin/bash</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">yum clean all</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">yum update -y</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">yum install httpd -y</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">echo "Hello this is drupal website" >> /var/www/html/index.html</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">systemctl start httpd</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">systemctl restart httpd</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">systemctl enable httpd"""</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">def create_instances(subnet_name, instance_name):</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> web_instance = ec2.create_instances(ImageId='ami-011b3ccf1bd6db744',InstanceType='t2.micro',MinCount=1,MaxCount=1,KeyName='drupal-ec2-keypair',SubnetId=subnet_name,UserData=user_data_script,SecurityGroupIds=[sgId],TagSpecifications=[{'ResourceType': 'instance','Tags': [{'Key': 'Name','Value': instance_name}]}])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> return web_instance</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">web1_instance = create_instances(ec2_subnet1, 'drupal-web1')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">time.sleep(60)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">response1 = client.describe_instances()</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">for reservation in response1["Reservations"]:</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> for instance in reservation["Instances"]:</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ec2 = boto3.resource('ec2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> web1 = ec2.Instance(instance["InstanceId"])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Launching web1 instance - ',web1.id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">web2_instance = create_instances(ec2_subnet3, 'drupal-web2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">time.sleep(60)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">response2 = client.describe_instances()</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">for reservation in response2["Reservations"]:</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> for instance in reservation["Instances"]:</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ec2 = boto3.resource('ec2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> web2 = ec2.Instance(instance["InstanceId"])</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Launching web2 instance - ',web2.id)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Application Load Balancer Code Starts here</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">lb = boto3.client('elbv2')</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_lb_response = lb.create_load_balancer(</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Name='drupal-web-elb',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Subnets=[</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ec2_subnet1, ec2_subnet3,</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ],</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> SecurityGroups=[</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> elbsgId,</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ],</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Scheme='internet-facing',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Tags=[</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> {</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> 'Key': 'Name',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> 'Value': 'drupal-web-elb'</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> },</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ],</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Type='application',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> IpAddressType='ipv4'</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">lbId = create_lb_response['LoadBalancers'][0]['LoadBalancerArn']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Successfully created load balancer - ',lbId)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">create_tg_response = lb.create_target_group(</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Name='drupal-web-tg',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Protocol='HTTP',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Port=80,</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> TargetType='instance',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> HealthCheckPath='/index.html',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> VpcId=vpc_id</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">tgId = create_tg_response['TargetGroups'][0]['TargetGroupArn']</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">print('Successfully created target group - ',tgId)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">#Create Listner for web elb</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">listnerId = lb.create_listener(</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> LoadBalancerArn=lbId,</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Protocol='HTTP',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> Port=80,</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> DefaultActions=[</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> {</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> 'Type': 'forward',</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> 'TargetGroupArn': tgId</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> },</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"> ]</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">)</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"><br /></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"># Register web instances with web-elb</span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;"></span></div>
<div style="background-color: white; box-sizing: border-box; margin-bottom: 16px;">
<span style="color: #24292e; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;">regis_targets = lb.register_targets(TargetGroupArn=tgId,Targets=[{'Id': web1.id,},{'Id': web2.id}])</span></div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-15010901439002439632019-04-04T17:21:00.000+05:302019-04-25T08:08:40.333+05:30Migrating on Premise VM to AWS Cloud<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="background: white; line-height: normal;">
</div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<br />
<div class="MsoListParagraphCxSpFirst" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
</div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<b style="mso-bidi-font-weight: normal;"><span style="background: white; color: black; font-family: "arial" , sans-serif;">Migrate on premise VM to
AWS - AWS VM Import / Export</span></b></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-list: Ignore;">1)<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">Export VM to .ovf or .vmdk
format. Ex. myvm.vmdk<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-list: Ignore;">2)<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">Upload “myvm.vmdk” to S3
bucket called “anupvmmigration”<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">3)<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">Go to IAM create role called
“vmimport” (role name should be <b style="mso-bidi-font-weight: normal;">vmimport</b>)<b style="mso-bidi-font-weight: normal;"> </b>– copy the role json format for AWS
docs links - </span><span class="MsoHyperlink"><a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html">https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html</a></span><o:p></o:p></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><o:p> </o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"> Click on IAM -> Click on Role -> Click on Create Role -> Click
on EC2 (</span><span style="background: #e6f3ff; color: #666666; font-family: "arial" , sans-serif; font-size: 10.5pt;">Allows EC2 instances to call AWS services on
your behalf.</span><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">) -> Click on Next -> Click on Next -> Give Tags & click on
Next -> Give Role Name – “vmimport” -> and finally click on Create Role<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>OR Command line to create role <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #444444; font-family: "arial" , sans-serif; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">-<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span style="background: white; color: #444444; font-family: "helvetica" , sans-serif;">Create
a file named </span><code><span style="background: white; color: #444444; font-family: "consolas"; font-size: 12.0pt;">trust-policy.json</span></code><span style="background: white; color: #444444; font-family: "helvetica" , sans-serif;"> with the following policy:</span><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Version"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"2012-10-17"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Statement"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Effect"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"Allow"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Principal"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: { </span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Service"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"vmie.amazonaws.com"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"> },<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Action"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"sts:AssumeRole"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Condition"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"StringEquals"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"sts:Externalid"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"vmimport"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">}<o:p></o:p></span></div>
<div style="background: white; border: solid #E1E1E8 1.0pt; margin-left: .25in; margin-right: 0in; mso-border-alt: solid #E1E1E8 .75pt; mso-element: para-border-div; padding: 0in 0in 0in 0in;">
<div class="MsoListParagraphCxSpLast" style="background: white; border: none; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-border-alt: solid #E1E1E8 .75pt; mso-list: l1 level1 lfo1; mso-padding-alt: 0in 0in 0in 0in; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #444444; font-family: "arial" , sans-serif; mso-bidi-font-size: 10.5pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">-<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><b><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.0pt;">aws iam create-role --role-name vmimport --assume-role-policy-document
"file://trust-policy.json"</span></b><span style="color: #444444; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
</div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-list: Ignore;">4)<span style="font: 7.0pt "Times New Roman";"> </span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">Click on Roles in IAM, click
on Role that you created i.e. “vmimport” -> Click on “Trust Relationship”
tab -> Click on Edit Trust Relationship button -> paste following policy
-> Finally click on Update Trust Policy<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>"Version":
"2012-10-17",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"Statement": [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"Effect": "Allow",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"Principal": {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"Service": "vmie.amazonaws.com"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>},<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"Action": "sts:AssumeRole",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"Condition": {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"StringEquals": {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;">
</span>"sts:Externalid": "vmimport"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto;">
<span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; mso-fareast-font-family: Arial; mso-themecolor: text1;"><span style="mso-list: Ignore;">5)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif;">Click on Policies in IAM
-> Click on Create policy -> Click on JSON tab -> paste the following
policy from AWS link - </span><span class="MsoHyperlink"><a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html">https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html</a></span>
-> Click on Review Policy button -> Give Policy name –“<b style="mso-bidi-font-weight: normal;">vmimportpolicy</b>” -> Finally create
policy button.<span style="background: white; color: black; font-family: "arial" , sans-serif;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Version"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"2012-10-17"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Statement"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:[<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Effect"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"Allow"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Action"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:[<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"s3:GetBucketLocation"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"s3:GetObject"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"s3:ListBucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"> <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>],<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Resource"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:[<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"arn:aws:s3:::</span><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"> </span><span style="background: white; color: red; font-family: "arial" , sans-serif; font-size: 12.0pt;">anupvmmigration</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<span style="mso-spacerun: yes;"> </span></span><span style="background: #fafafa; color: #383a42; font-family: "wingdings"; font-size: 10.5pt;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">ß</span></span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"> update your bucket name here<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"arn:aws:s3:::</span><span style="background: white; color: black; font-family: "arial" , sans-serif; font-size: 12.0pt;"> </span><span style="background: white; color: red; font-family: "arial" , sans-serif; font-size: 12.0pt;">anupvmmigration</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">/*"<span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "wingdings"; font-size: 10.5pt;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">ß</span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;"> Update your bucket name here</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>},<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Effect"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"Allow"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Action"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:[<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"ec2:ModifySnapshotAttribute"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"ec2:CopySnapshot"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"ec2:RegisterImage"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"ec2:Describe*"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>],<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Resource"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">:</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"*"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-tab-count: 1;"> </span>OR Command
line to create policy<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<span style="background: white; color: #444444; font-family: "helvetica" , sans-serif;"> Create
a file named </span><code><span style="background: white; color: #444444; font-family: "consolas"; font-size: 12.0pt;">role-policy.json</span></code><span style="background: white; color: #444444; font-family: "helvetica" , sans-serif;"> with the above policy, where </span><span style="background: white; color: red; font-family: "arial" , sans-serif; font-size: 12.0pt;">anupvmmigration</span><span style="background: white; color: #444444; font-family: "helvetica" , sans-serif;"> is the bucket where the
disk images are stored: <o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<code><b><span style="color: #383a42; font-family: "consolas"; font-size: 10.0pt;"> aws iam put-role-policy
--role-name vmimport --policy-name vmimport --policy-document
"file://role-policy.json"</span></b></code><span style="background: white; color: black; font-family: "arial" , sans-serif;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<code><b><span style="color: #383a42; font-family: "consolas"; font-size: 10.0pt;"><br /></span></b></code></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; mso-fareast-font-family: Arial; mso-themecolor: text1;"><span style="mso-list: Ignore;">6)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif;">Again, go to Roles in IAM
-> Click on role vmimport -> Under Permissions Policy click on Attach
Policy<span style="mso-spacerun: yes;"> </span>-> search policy “</span><b style="mso-bidi-font-weight: normal;">vmimportpolicy</b>” & select check box
-> Click on Attach policy button.<span style="background: white; color: black; font-family: "arial" , sans-serif;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; mso-fareast-font-family: Arial; mso-themecolor: text1;"><span style="mso-list: Ignore;">7)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif;">Go to Users in IAM ->
Click on Add User -> Give user name “<b style="mso-bidi-font-weight: normal;">anupvmuser</b>”
& Give him programmatic access -> Click on Next -> Click on “Attach
existing policies directly” -> Click on Create Policy & click on JSON
tab -> and paste following code from AWS doc link (update bucket as in red)
– <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span class="MsoHyperlink"> <a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmie_prereqs.html">https://docs.aws.amazon.com/vm-import/latest/userguide/vmie_prereqs.html</a></span><o:p></o:p></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;">{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>"Version":
"2012-10-17",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Statement": [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Effect": "Allow",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Action": [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:ListAllMyBuckets"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>],<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Resource": "*"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>},<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Effect": "Allow",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Action": [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:CreateBucket",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:DeleteBucket",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:DeleteObject",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:GetBucketLocation",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:GetObject",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:ListBucket",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"s3:PutObject"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>],<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Resource": ["arn:aws:s3:::</span><span style="background: white; color: red; font-family: "arial" , sans-serif; font-size: 12.0pt;"> anupvmmigration</span><span style="background: white; color: black; font-family: "arial" , sans-serif;">","arn:aws:s3:::</span><span style="background: white; color: red; font-family: "arial" , sans-serif; font-size: 12.0pt;"> anupvmmigration</span><span style="background: white; color: black; font-family: "arial" , sans-serif;">/*"]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>}, <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Effect": "Allow",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Action": [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"iam:CreateRole",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"iam:PutRolePolicy"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>],<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Resource": "*"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>},<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Effect": "Allow",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Action": [<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:CancelConversionTask",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:CancelExportTask",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:CreateImage",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:CreateInstanceExportTask",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:CreateTags",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DeleteTags",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeConversionTasks",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeExportTasks",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeInstanceAttribute",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeInstanceStatus",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>"ec2:DescribeInstances",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeTags",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:ImportInstance",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:ImportVolume",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:StartInstances",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:StopInstances",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:TerminateInstances",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:ImportImage",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:ImportSnapshot",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeImportImageTasks",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:DescribeImportSnapshotTasks",<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"ec2:CancelImportTask"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>],<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;">
</span>"Resource": "*"<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><span style="mso-spacerun: yes;"> </span>]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"> Click on Review Policy button -> Give Name to policy “<b style="mso-bidi-font-weight: normal;">anupcustompolicy</b>” -> Click on Create
policy -> Now attach two policy to user “anupvmuser” – “anupcustompolicy”
& “AdministratorAccess” </span><span style="background: white; color: black; font-family: "wingdings";"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">à</span></span><span style="background: white; color: black; font-family: "arial" , sans-serif;"> Click on Next -> On
review page click on Create user -> Finally downlod.csv file.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal;">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; mso-fareast-font-family: Arial; mso-themecolor: text1;"><span style="mso-list: Ignore;">8)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif;">Create /root/containers.json
file and copy following code from AWS doc link - </span><span class="MsoHyperlink"><a href="https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html">https://docs.aws.amazon.com/vm-import/latest/userguide/vmimport-image-import.html</a></span><span style="background: white; color: black; font-family: "arial" , sans-serif;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">[<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Description"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">Redhat Linux 64 bit</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Format"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"vmdk"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"UserBucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: {<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"S3Bucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: white; color: red; font-family: "arial" , sans-serif; font-size: 12.0pt;">anupvmmigration</span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<span style="mso-spacerun: yes;"> </span></span><span style="background: #fafafa; color: #383a42; font-family: "wingdings"; font-size: 10.5pt;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">ß</span></span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"> Give your bucket name here<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"S3Key"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">myvm.vmdk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"<span style="mso-spacerun: yes;"> </span></span><span style="color: #50a14f; font-family: "wingdings"; font-size: 10.5pt;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">ß</span></span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;"> Give your vmdk file name</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">}]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"> OR To import multiple vm’s use following
containers.json file format<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">[<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Description"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">First disk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Format"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">vmdk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"UserBucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"S3Bucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">my-import-bucket</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"S3Key"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">disksmy-windows-2008-vm-disk1.vmdk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>},<span style="mso-spacerun: yes;">
</span><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>{<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Description"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">Second disk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"Format"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">vmdk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"UserBucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: {<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"S3Bucket"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">my-import-bucket</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: #986801; font-family: "consolas"; font-size: 10.5pt;">"S3Key"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">: </span><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><i><span style="color: red; font-family: "consolas"; font-size: 10.0pt;">disks/my-windows-2008-vm-disk2.vmdk</span></i><span style="color: #50a14f; font-family: "consolas"; font-size: 10.5pt;">"</span><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal;">
<span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.5pt;">]<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: black; font-family: "arial" , sans-serif; mso-fareast-font-family: Arial; mso-themecolor: text1;"><span style="mso-list: Ignore;">9)<span style="font: 7.0pt "Times New Roman";">
</span></span></span><!--[endif]--><span style="background: white; color: black; font-family: "arial" , sans-serif;">Go to Linux or Windows
machine configure AWS CLI using Access key id & Secret access key of user “<b style="mso-bidi-font-weight: normal;">anupvmuser” </b><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal; mso-list: l0 level1 lfo2; text-indent: -.25in;">
<span style="background: white; color: black; font-family: "arial" , sans-serif;"><b style="mso-bidi-font-weight: normal;"> </b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="mso-bidi-font-weight: normal;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtVanIA28b3EKb-wW0wgvBpUjY-RP_S3WU6k3_gOtVh9plU9EtiO9-c8xUUqM5XbeaHVck7t8KCgSTAGnQYPtdC_Hot-ng61CnB7jDH9e7l2OeNXS8HYscSvdaeB9rOsFlZg6mYI-5VmCQ/s1600/blog1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="99" data-original-width="709" height="88" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtVanIA28b3EKb-wW0wgvBpUjY-RP_S3WU6k3_gOtVh9plU9EtiO9-c8xUUqM5XbeaHVck7t8KCgSTAGnQYPtdC_Hot-ng61CnB7jDH9e7l2OeNXS8HYscSvdaeB9rOsFlZg6mYI-5VmCQ/s640/blog1.png" width="640" /></a></b></div>
<div class="separator" style="clear: both; text-align: center;">
<b style="mso-bidi-font-weight: normal;"><br /></b></div>
<br />
<div class="MsoListParagraphCxSpFirst" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<span style="font-family: "arial" , sans-serif;">10)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;">
</span></span><!--[endif]--><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">Use following command to
start migration<o:p></o:p></span></div>
<br />
<div class="MsoListParagraphCxSpLast" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">
</span></div>
<div class="MsoListParagraphCxSpLast" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal;">
<b><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.0pt;">aws ec2 import-image --description
"Redhat Linux 64 bit" --disk-containers </span></b><span class="MsoHyperlink"><b><span style="background: #fafafa; font-family: "consolas"; font-size: 10.0pt;"><a href="file:///root/containers.json">file:///root/containers.json</a></span></b></span><b><span style="background: #fafafa; color: #383a42; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggX3ZrU6xtsUjg9LbOj6JeQnCuMBhgudXrxhBBHfecTrqjjftC0rCQIDqp9zTTshwXTVb8eiL-6nrldQ24dCZwpdH25mTV3FLSMVGArvHKr5j8sgJMOpMgD54r80DwaLY8-Va2Ek2bFpGl/s1600/blog2.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="228" data-original-width="773" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggX3ZrU6xtsUjg9LbOj6JeQnCuMBhgudXrxhBBHfecTrqjjftC0rCQIDqp9zTTshwXTVb8eiL-6nrldQ24dCZwpdH25mTV3FLSMVGArvHKr5j8sgJMOpMgD54r80DwaLY8-Va2Ek2bFpGl/s1600/blog2.JPG" /></a></div>
<div class="MsoListParagraphCxSpLast" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal;">
<span class="MsoHyperlink"></span></div>
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<br /></div>
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<span style="font-family: "arial" , sans-serif;">11)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;">
</span></span><!--[endif]--><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">To check the status of
import task use following command take the highlighted task id from previous
command<o:p></o:p></span></div>
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;"><br /></span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLT5bjMtoF9IHvkcSz3SghEJO3-BaTf9YWEI7H8tufIrlfoL9__sN7FJoCs8Pz2rRpHL8y-ZLUCGFSVwxaltI9vauzDEq3G3PqVBkOKjCUj_nnepC6F8sCwjX5sJ8vXBXy2x39yA_0jotH/s1600/anup3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="411" data-original-width="873" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLT5bjMtoF9IHvkcSz3SghEJO3-BaTf9YWEI7H8tufIrlfoL9__sN7FJoCs8Pz2rRpHL8y-ZLUCGFSVwxaltI9vauzDEq3G3PqVBkOKjCUj_nnepC6F8sCwjX5sJ8vXBXy2x39yA_0jotH/s640/anup3.jpg" width="640" /></a></div>
<div class="MsoListParagraphCxSpFirst" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<br /></div>
<div class="MsoListParagraphCxSpFirst" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">Troubleshooting</span></b></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">You might get following errors.<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">1) Error-<o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0IKzJOaUf55GRUysS62CY-F2swqoWWtCxFIWmDw7EOBZmrMXlFFy0PVsEeCjr8gNkoz5vgvodytWEB8MvbaJV-pw9MGix4UvHvahothwG7McSVCbjUkKr9FBi0mhq7YTphRgSO9sBLWCu/s1600/anup4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="68" data-original-width="1148" height="37" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0IKzJOaUf55GRUysS62CY-F2swqoWWtCxFIWmDw7EOBZmrMXlFFy0PVsEeCjr8gNkoz5vgvodytWEB8MvbaJV-pw9MGix4UvHvahothwG7McSVCbjUkKr9FBi0mhq7YTphRgSO9sBLWCu/s640/anup4.jpg" width="640" /></a></div>
<br />
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0.0001pt;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">For above error you should
go to roles click on role “vmimport” and check if you have attached policy to
it.<o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0.0001pt;">
<br /></div>
<br />
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0.0001pt; text-indent: -0.25in;">
<span style="font-family: "arial" , sans-serif;"> 2)<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;">
</span></span><!--[endif]--><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">Error- <o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkd1_KICEVfwXM2q9WQeBIprbb6aZldST07GTYJGm15A9q8dIZQa9HvhBqXezzw7C5eMz9nc0qQ-tSDpM8H9Ifj6M_EfKb2jKpHVESAyXPpal_XnU4At9rdeXFIo_oTaFysxNNJEGnchV1/s1600/anup5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="386" data-original-width="875" height="282" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkd1_KICEVfwXM2q9WQeBIprbb6aZldST07GTYJGm15A9q8dIZQa9HvhBqXezzw7C5eMz9nc0qQ-tSDpM8H9Ifj6M_EfKb2jKpHVESAyXPpal_XnU4At9rdeXFIo_oTaFysxNNJEGnchV1/s640/anup5.jpg" width="640" /></a></div>
<div class="MsoListParagraph" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0.0001pt; text-indent: -0.25in;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;"></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; margin-bottom: 0.0001pt;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;">For above error go to your
vm fstab file and check for any errors or wrong syntax and make correction, again
export vm from Vmware and upload again to S3 and start import <o:p></o:p></span></div>
<div class="MsoNormal" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal;">
<span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: "arial" , sans-serif;"><br /></span></div>
<div class="MsoListParagraphCxSpFirst" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; line-height: normal; text-indent: -0.25in;">
<br /></div>
</div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com2tag:blogger.com,1999:blog-2739902730161048005.post-82671672400551448002014-10-02T08:56:00.000+05:302014-10-02T08:56:04.498+05:30How to use yum command to download package without installing it?<div dir="ltr" style="text-align: left;" trbidi="on">
There are two ways to download a package without installing it.<br />
<br />
<b>First</b> - use "downloadonly" plugin of yum.<br />
<br />
1] Install the package including "downloadonly" plugin.<br />
<br />
RHEL-5<br />
<b>[root@server ~]# yum install yum-downloadonly</b><br />
<br />
RHEL-6<br />
<b>[root@server ~]# yum install yum-plugin-downloadonly</b><br />
<br />
2] Now use downloadonly plugin with following yum command.<br />
<br />
<b><b>[root@server ~]# </b>yum install --downloadonly --downloaddir=<directory-path> <package-name></b><br />
<br />
3] Confirm the downloaded package in specified download directory.<br />
<br />
<b>Note: </b><br />
<ul style="text-align: left;">
<li>This is only applicable to "yum install" and not for "yum groupinstall" .</li>
<li>If you specified only package name then latest package will be downloaded, to download</li>
<li>specific package type full package name and version.</li>
<li>If you do not use --downloaddir option files are saved by default in /var/cache/yum/.</li>
</ul>
<b>Second</b> - use "yumdownloader" utility to download package<br />
<br />
1] Install the yum-utils package which includes "yumdownloader" utility.<br />
<br />
<b>[root@server ~]# yum install yum-utils</b><br />
<br />
2] Now use the following command with desired package name.<br />
<br />
<b>[root@server ~]# yumdownloader <package-name></b> <br />
<br />
<strong>Note:</strong><br />
<ul>
<li>The package is saved in the current working directly by default; use the --destdir option to specify an alternate location.</li>
<li>Be sure to add --resolve if you need to download dependencies.</li>
</ul>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com1tag:blogger.com,1999:blog-2739902730161048005.post-53647282331559426522013-10-14T16:59:00.001+05:302013-10-14T16:59:21.437+05:3011 Tar Command Examples<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">P { margin-bottom: 0.21cm; }</style>
<br />
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>1. Create tar
Archive File
</b></span></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
Following command will create a
mytest.tar file for a directory "/home/anup/test".</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -cvf mytest.tar
/home/anup/test</b>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
Description of above options we have
used to create .tar file.
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
c – Creates a new .tar archive
file.
</div>
<div style="margin-bottom: 0cm;">
v – Verbosely show the .tar file
progress.
</div>
<div style="margin-bottom: 0cm;">
f – File name type of the archive
file. </div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>2. Create
tar.gz Archive File </b></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
To create tar.gz archive file we used
option z. [Note: .<b>tar.gz</b> and <b>.tgz</b> both are similar]. </div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -cvzf
mytest.tar.gz /home/anup/test
</b> OR
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -cvzf
mytest.tgz /home/anup/test
</b></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>3. Create
tar.bz2 Archive File</b></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
To create highly compressed tar file we
use option as j. [Note: <b>tar.bz2</b> and <b>tar.tbz</b> is similar
as <b>tb2</b>]</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -cvjf
mytest.tar.bz2 /home/anup/test
</b> OR</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -cvjf
mytest.tar.tbz /home/anup/test
</b> OR</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -cvjf
mytest.tar.tb2 /home/anup/test</b></div>
<div style="margin-bottom: 0cm;">
<b> </b>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>4. Untar tar
Archive File </b></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
Untar files in Current Directory. </div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf mytest.tar</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
Untar files in specified Directory
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf mytest.tar
-C /tmp/</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>5. Uncompress
tar.gz Archive File</b></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
Following command will untar .tar.gz
file at current location. If you want to untar in different directory
then use <b>-C</b> option as we used in above command.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf
mytest.tar.gz</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>6. Uncompress
tar.bz2 Archive File</b></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf
mytest.tar.bz2</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>7. List
Content of .tar / .tar.gz / .tar.bz2 Archive File</b></span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -tvf
mytest.tar</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -tvf
mytest.tar.gz</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -tvf
mytest.tar.bz2</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>8. Untar
Single file from .tar / .tar.gz / .tar.bz2 Archive File</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b> </b></span>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf mytest.tar
test/mytextfile</b> OR</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf --extract
--file=mytest.tar test/mytextfile</b></div>
<div style="margin-bottom: 0cm;">
<b> </b>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvzf
mytest.tar.gz test/mytextfile</b> OR</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvzf --extract
--file=mytest.tar.gz test/mytextfile</b></div>
<div style="margin-bottom: 0cm;">
<b> </b>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvjf
mytest.tar.bz2 test/mytextfile</b> OR</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvjf --extract
--file=mytest.tar.bz2 test/mytextfile</b></div>
<div style="margin-bottom: 0cm;">
<b> </b>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>9. Untar
Multiple files from .tar, .tar.gz and .tar.bz2 Archive File
</b></span></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf mytest.tar
"test/mytextfile1" "test/mytextfile2”</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvzf
mytest.tar.gz "test/mytextfile1" </b></div>
<div style="margin-bottom: 0cm;">
<b>"test/mytextfile2"</b></div>
<div style="margin-bottom: 0cm;">
<b> </b>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvjf
mytest.tar.bz2 "test/mytextfile1" "test/mytextfile2"
</b>
</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
<b><span style="color: red;">10.</span>
<span style="color: red;">Untar Single directory from .tar, .tar.gz and
.tar.bz2 Archive File</span></b></div>
<div style="margin-bottom: 0cm;">
<b><span style="color: red;"> </span>
</b></div>
<div style="margin-bottom: 0cm;">
<b>
</b></div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf mytest.tar
test/directoryname</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>
</b></div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf
mytest.tar.gz test/directoryname</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>
</b></div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf
mytest.tar.bz2 test/directoryname</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b>11. To see the
content of a particular file in .tar / .tar.gz / .tar.bz2 archive
without unzipping the contents</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="color: red;"><b> </b></span>
</div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf mytest.tar
--to-command=cat test/mytextfile</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
</div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf
mytest.tar.gz --to-command=cat test/mytextfile</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>
</b></div>
<div style="margin-bottom: 0cm;">
<b>[root@server ~]# tar -xvf
mytest.tar.bz2 --to-command=cat test/mytextfile</b>
</div>
<div style="margin-bottom: 0cm;">
</div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-6314076375657912552013-09-30T16:24:00.000+05:302013-09-30T16:24:40.143+05:30Install and configure AWStats on CentOS and RHEL System<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-size: small;">AWStats (Advanced Web Statistics) is a free powerful and featureful tool that generates advanced web (but also ftp or mail) server<br />statistics, graphically.<br /><br />Following are the steps to configure AWStats on CentOS and RHEL system.<br /><br /><b>1] Download the awstats</b><br /><br />[root@server ~]# wget http://sourceforge.net/projects/awstats/files/AWStats/7.0/awstats-7.0-1.noarch.rpm<br /><br /><b>2] Install awstats</b><br /><br />[root@server ~]# rpm -ivh awstats-7.2-1.noarch.rpm <br />error: Failed dependencies:<br /> perl(LWP::UserAgent) is needed by awstats-7.2-1.noarch<br /><br />If you receive above error then install below package :<br /><br />[root@server ~]# yum install perl-libwww-perl.noarch<br /><br />Now Again run the command :<br /><br />[root@server ~]# rpm -ivh awstats-7.2-1.noarch.rpm<br />Preparing... ############################## [100%]<br /> 1:awstats ############################## [100%]<br /><br />----- AWStats 7.2 - Laurent Destailleur -----<br />AWStats files have been installed in /usr/local/awstats<br /><br />If first install, follow instructions in documentation<br />(/usr/local/awstats/docs/index.html) to setup AWStats in 3 steps:<br />Step 1 : Install and Setup with awstats_configure.pl (or manually)<br />Step 2 : Build/Update Statistics with awstats.pl<br />Step 3 : Read Statistics<br /><br /><b>3] Now configure and setup AWstats with awstats_configure.pl</b><br /><br />[root@server ~]# cd /usr/local/awstats/tools<br /><br />[root@server tools]# perl awstats_configure.pl<br />----- AWStats awstats_configure 1.0 (build 1.9) (c) Laurent Destailleur -----<br />This tool will help you to configure AWStats to analyze statistics for<br />one web server. You can try to use it to let it do all that is possible<br />in AWStats setup, however following the step by step manual setup<br />documentation (docs/index.html) is often a better idea. Above all if:<br />- You are not an administrator user,<br />- You want to analyze downloaded log files without web server,<br />- You want to analyze mail or ftp log files instead of web log files,<br />- You need to analyze load balanced servers log files,<br />- You want to 'understand' all possible ways to use AWStats...<br />Read the AWStats documentation (docs/index.html).<br /><br />-----> Running OS detected: Linux, BSD or Unix<br /><br />-----> Check for web server install<br /><br />Enter full config file path of your Web server.<br />Example: /etc/httpd/httpd.conf<br />Example: /usr/local/apache2/conf/httpd.conf<br />Example: c:\Program files\apache group\apache\conf\httpd.conf<br />Config file path ('none' to skip web server setup):<br />> <b>/etc/httpd/conf/httpd.conf </b> --> Enter Apache configuration path<br /><br />-----> Check and complete web server config file '/etc/httpd/conf/httpd.conf'<br /> Add 'Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"'<br /> Add 'Alias /awstatscss "/usr/local/awstats/wwwroot/css/"'<br /> Add 'Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"'<br /> Add 'ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"'<br /> Add '<Directory>' directive<br /> AWStats directives added to Apache config file.<br /><br />-----> Update model config file '/etc/awstats/awstats.model.conf'<br /> File awstats.model.conf updated.<br /><br />-----> Need to create a new config file ?<br />Do you want me to build a new AWStats config/profile<br />file (required if first install) [y/N] ? <b>y</b><br /><br />-----> Define config file name to create<br />What is the name of your web site or profile analysis ?<br />Example: www.mysite.com<br />Example: demo<br />Your web site, virtual server or profile name:<br />> <b>www.anup.co.in</b> --> Enter your website name<br /><br />-----> Define config file path<br />In which directory do you plan to store your config file(s) ?<br />Default: /etc/awstats<br />Directory path to store config file(s) (Enter for default):<br />> --> <b>Press Enter</b><br /><br />-----> Create config file '/etc/awstats/awstats.www.anup.co.in.conf'<br /> Config file /etc/awstats/awstats.www.anup.co.in.conf created.<br /><br />-----> Restart Web server with '/sbin/service httpd restart'<br />Stopping httpd: [ OK ]<br />Starting httpd: [ OK ]<br /><br />-----> Add update process inside a scheduler<br />Sorry, configure.pl does not support automatic add to cron yet.<br />You can do it manually by adding the following command to your cron:<br />/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.anup.co.in<br />Or if you have several config files and prefer having only one command:<br />/usr/local/awstats/tools/awstats_updateall.pl now<br />Press ENTER to continue... <br /><br /><br />A SIMPLE config file has been created: /etc/awstats/awstats.www.anup.co.in.conf<br />You should have a look inside to check and change manually main parameters.<br />You can then manually update your statistics for 'www.anup.co.in' with command:<br />> perl awstats.pl -update -config=www.anup.co.in<br />You can also read your statistics for 'www.anup.co.in' with URL:<br />> http://localhost/awstats/awstats.pl?config=www.anup.co.in<br /><br />Press ENTER to finish...<br /><br /><b>4] Now update awstat</b><br /><br />[root@server ~]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update --config=www.anup.co.in<br />Error: AWStats database directory defined in config file by 'DirData' parameter (/var/lib/awstats) does not exist or is not writable.<br />Setup ('/etc/awstats/awstats.www.anup.co.in.conf' file, web server or permissions) may be wrong.<br />Check config file, permissions and AWStats documentation (in 'docs' directory).<br /><br />[root@server ~]# mkdir -p /var/lib/awstats<br /><br />Now configure your website config file:<br /><br />vi /etc/awstats/awstats.www.anup.co.in.conf<br /><br />LogFile="/var/log/httpd/access_log"<br /><br />and save the file.<br /><br />Now Again run the command :<br /><br />[root@server ~]# /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update --config=www.anup.co.in<br /><br /><b>5] Add crontab entry to update awstat for every 15 minute.</b><br /><br />[root@server ~]# crontab -e<br />15 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.www.anup.co.in<br /><br /><b>6] Now we configure apache file to enable http based authentication.</b><br /><br />Open the httpd.conf file and following lines at the end of file.<br /><br />[root@server ~]# vi /etc/httpd/conf/httpd.conf<br /><br /><Directory "/usr/local/awstats/cgi-bin"><br /> Order allow,deny<br /> Allow from all<br /></Directory><br /><br /># This is to force authentication when trying to access /awstats<br /><br /><Location /awstats><br />AuthType Basic<br />AuthName "AWStats Admin Access Required"<br />AuthUserFile /etc/httpd/conf.d/awstats.passwd<br />require valid-user<br /></Location><br /><br /><b>7] Set username and password for awstat link.</b><br /><br />[root@server ~]# htpasswd -c /etc/httpd/conf.d/awstats.passwd admin<br /><br /><b>8] Restart the httpd.</b><br /><br />[root@server ~]# service httpd restart<br /><br />That's it, access awstats url and check it.<br />http://localhost/awstats/awstats.pl?config=www.anup.co.in</span></div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-75493697598532712702013-07-17T21:56:00.001+05:302013-07-17T21:56:28.431+05:30How to configure Kickstart Server<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
<b>Install & Configure PXE Boot Server with Kickstart</b></div>
<br />
<b>1] Install syslinux & tftp-server</b><br />[root@server ~]# yum install tftp-server<br /><br /><b> 2] Enable syslinux at boot time</b><br />[root@server ~]# vim /etc/xinetd.d/tftp<br />edit the line no. 14<br />disable = no<br />:wq<br /><br /><b>3] Start service</b><br />[root@server ~]# service xinetd start<br />[root@server ~]# chkconfig xientd on<br />
<br /><b>4] Install FTP service</b><br />[root@server ~]# yum install vsftpd<br /><br /><b>5] Start vsftpd</b><br />[root@server ~]# service vsftpd start<br />[root@server ~]# chkconfig vsftpd on<br /><br /><b>6] Install syslinux, require boot loader</b><br />[root@server ~]# yum install syslinux<br /><br /><b>7] Copy the needed files from syslinux to the tftpboot directory</b><br />[root@server ~]# cp -rvp /usr/share/syslinux/{pxelinux.0,menu.c32,memdisk,mboot.c32,chain.c32} /var/lib/tftpboot/<br /><br /><b>8] Create the directory for your PXE menus</b><br />[root@server ~]# mkdir /var/lib/tftpboot/pxelinux.cfg<br /><br /><b>9] Create different directory for each PXE image</b><br />[root@server ~]# mkdir –p /var/lib/tftpboot/images/centos6<br /><br /><b>10] Mount CD/DVD and copy it to FTP public directory</b><br />[root@server ~]# mount /dev/cdrom /mnt<br />[root@server ~]# cp -rvp /mnt/* /var/ftp/pub/<br />[root@server ~]# umount /mnt<br /><br /><b>11] Copy vmlinuz and initrd.img from FTP public directory</b><br />[root@server ~]# cp -rvp /var/ftp/pub/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/images/centos6/<br /><br /><b>12] Instal DHCP server</b><br />[root@server ~]# yum install dhcp<br /><br /><b>13] Configure DHCP server. Add following lines to your /etc/dhcp/dhcpd.conf</b><br />[root@server ~]# vi /etc/dhcp/dhcpd.conf<br />option domain-name "anup.co.in";<br />option domain-name-servers 192.168.1.1;<br />default-lease-time 600;<br />max-lease-time 7200;<br /><br />allow booting;<br />allow bootp;<br />next-server 192.168.1.1;<br />filename “/pxelinux.0”;<br /><br />subnet 192.168.1.0 netmask 255.255.255.0 {<br /> range dynamic-bootp 192.168.1.100 192.168.1.200;<br /> option routers 192.168.1.1;<br />}<br /><br /><b>14] Start dhcp service</b><br />[root@server ~]# service dhcpd start<br />[root@server ~]# chkconfig dhcpd on<br /><br /><b>15] Create a menu for PXE server for os selection on PXE loading</b><br />[root@server ~]# vi /var/lib/tftpboot/pxelinux.cfg/default<br /><br />default menu.c32<br />prompt 0<br />timeout 50<br /><br />MENU TITLE ANUP PXE Menu<br /><br />LABEL CentOS 6.4 (Final)<br />MENU LABEL CentOS-6.4<br />KERNEL images/centos6/vmlinuz<br />append vga=normal initrd=images/centos6/initrd.img ramdisk_size=32768<br />ks=ftp://192.168.1.1/pub/ks.cfg<br /><br /><b>16] Now create KickStart file in FTP public directory</b><br />[root@server ~]# vi /var/ftp/pub/ks.cfg<br /><br />#It starts the installation process<br />Install<br />#configure a connection to a FTP server to locate installation files<br />url --url ftp://192.168.1.1/pub/<br />#setup language and keyboard<br />lang en_US.UTF-8<br />keyboard us<br />#Get network info from DHCP server<br />network --device eth0 bootproto dhcp<br />#setup encrypted root password, you can take out the encrypted password from /etc/shadow file<br />rootpw --iscrypted $6$NF6F/Yng442eA8oL$c/sHM<br />#setup firewall and open ssh port 22<br />firewall --service=ssh<br />#sets up the Shadow Password Suite<br />#(--enableshadow), the SHA 512 bit encryption algorithm for password encryption<br />#(--passalgo=sha512), and authentication with any existing fingerprint reader.<br />authconfig --enableshadow --passalgo=sha512 --enablefingerprint<br />#The selinux directive can be set to --enforcing, --permissive, or --disabled<br />selinux --enforcing<br />#setup timezone<br />timezone America/Toronto<br />#The default bootloader is GRUB. It should normally be installed on the Master<br />#Boot Record (MBR) of a hard drive. You can include a --driveorder switch to specify<br />#the drive with the bootloader and an --append switch to specify commands for<br />#the kernel.<br />bootloader --location=mbr --driveorder=sda --append=”crashkernel=auto rhgb quiet”<br />#Clear the Master Boot Record<br />zerombr yes<br />#This directive clears all volumes on the sda hard drive. If it hasn’t been used before,<br />#--initlabel initializes that drive.<br />clearpart --all --drives=sda --initlabel<br />#Changes are required in the partition (part) directives that follow.<br />part /boot --fstype=ext4 --size=500<br />part / --fstype=ext4 --size=27500<br />part swap --size=1000<br />part /home --fstype=ext4 --size=1000<br />#reboot machine<br />reboot<br />#skip answers to the First Boot process<br />firstboot --disable<br /><br /> Test the PXE server:<br />* Make changes in the BIOS settings and boot client machine from network. OR just press F12 to boot from network.<br /></div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com1tag:blogger.com,1999:blog-2739902730161048005.post-1994733114267417862013-07-13T17:53:00.000+05:302014-06-15T19:55:31.584+05:30Install and Configure NRPE in CentOS<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: center;">
Install NRPE on Linux</div>
<br />
<br />
NRPE is called as ‘Nagios Remote Plugin Executere’. NRPE allows nagios server<br />
to remotely execute nagios commands or plugins on other Linux/Unix machines. NRPE is also available windows servers. <br />
Following document shows you how to install NRPE, I am installing it on CentOS 6.4<br />
<br />
<b>1] Install NRPE required packages.</b><br />
<br />
[root@server ~]# yum install openssl-devel gcc xinetd make<br />
<br />
<b>2] NRPE runs under the user "nagios", so let's add that user.</b><br />
<br />
[root@server ~]# useradd nagios<br />
<br />
<b>3] Download and install Nagios-plugins.</b><br />
<br />
[root@server downloads]# wget https://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz<br />
<br />
[root@server downloads]# tar -xvzf nagios-plugins-2.0.tar.gz<br />
<br />
[root@server downloads]# cd nagios-plugins-2.0<br />
<br />
[root@server nagios-plugins-2.0]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios<br />
<br />
[root@server nagios-plugins-2.0]# make install<br />
<br />
<b>4] Assign nagios user ownership to nagios commands.</b><br />
<br />
[root@server nagios-plugins-2.0]# chown -R nagios:nagios /usr/local/nagios/libexec<br />
<br />
<br />
<b>5] Install and configure NRPE nagios client.</b><br />
<br />
[root@server downloads]# wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz?r=&ts=1363788540&use_mirror=hivelocity<br />
<br />
[root@server downloads]# tar -xvzf nrpe-2.15.tar.gz<br />
<br />
[root@server downloads]# cd nrpe-2.15.tar.gz<br />
<br />
[root@server downloads]# ./configure --enable-ssl <br />
<br />
[root@server nrpe-2.15]# make all<br />
<br />
[root@server nrpe-2.15]# make install-plugin<br />
<br />
[root@server nrpe-2.15]# make install-daemon<br />
<br />
[root@server nrpe-2.15]# make install-daemon-config<br />
<br />
[root@server nrpe-2.15]# make install-xinetd<br />
<br />
<b>6] Add following line at the end of file for NRPE in /etc/services</b><br />
<br />
[root@server ~]# vi /etc/services<br />
nrpe 5666/tcp # NRPE<br />
<br />
<b>7] NRPE will run under xinetd daemon. So update xinetd file.</b><br />
<br />
[root@server ~]# vi /etc/xinetd.d/nrpe<br />
<br />
# default: on<br />
# description: NRPE (Nagios Remote Plugin Executor)<br />
service nrpe<br />
{<br />
flags = REUSE<br />
socket_type = stream<br />
port = 5666<br />
wait = no<br />
user = nagios<br />
group = nagios<br />
server = /usr/local/nagios/bin/nrpe<br />
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd<br />
log_on_failure += USERID<br />
disable = no<br />
only_from = 127.0.0.1 192.168.1.1 --> [ Your Nagios Server IP ]<br />
}<br />
<br />
<b>8] Star/Restart xinetd service.</b><br />
<br />
[root@server ~]# service xinetd start<br />
<br />
[root@server ~]# chkconfig xinetd on</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com1tag:blogger.com,1999:blog-2739902730161048005.post-85205930503502476042013-04-19T16:57:00.003+05:302013-06-15T11:01:16.085+05:30Install RED5 server on Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">P { margin-bottom: 0.21cm; }</style>
<br />
<div style="margin-bottom: 0cm;">
<b>Install RED5 server on Linux</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Following blog post will describe how
to install RED5 server on Centos 5.7 (Final)
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>Red5 Working :</b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Red5 server converts the video file to
the flash file and we everyone knows that flash files play instantly
once someone accesses it. Here when we request or select a particular
video, the video script will send the video(stream the video) to red5
server. Red5 will convert the video file to flash and sends the
output to the video script to display on the browser. Lot of video
scripts are being used now a days like dolphin, videowhisper etc for
the site. You can configure the admin panel using the server's IP and
port details.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>Installation Steps: </b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>1. Download and Install Java: </b>
</div>
<div style="margin-bottom: 0cm;">
Red5 is a JAVA server. So install Java using yum.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# yum -y install
java-1.6.0-openjdk java-1.6.0-openjdk-devel
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>2. Install SVN: </b>
</div>
<div style="margin-bottom: 0cm;">
SVN will required to fetch latest release
of RED5 source from SVN repository at Google Code.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# yum install subversion
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>3. Download and Install Ant &
Ivy: </b>
</div>
<div style="margin-bottom: 0cm;">
Ant will need to compile RED5 server
code. Ant comes in binary form, so just download and install it in
/usr/local directory.
</div>
<div style="margin-bottom: 0cm;">
First off let’s change to another
directory.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# cd /usr/src
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# wget
http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.2-bin.tar.bz2
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# tar jxvf
apache-ant-1.8.2-bin.tar.bz2
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# mv apache-ant-1.8.2
/usr/local/ant
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server src]# svn co
https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# cd ivy
</div>
<div style="margin-bottom: 0cm;">
[root@server src]#
/usr/local/ant/bin/ant jar
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# cp
build/artifact/jars/ivy.jar /usr/local/ant/lib/
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>4. Export Variables for Ant and
Java: </b>
</div>
<div style="margin-bottom: 0cm;">
So now we have JAVA installed, and ANT
is in place. We need to make sure there are some environment
variables set. These are global variables with paths to different
binaries or applications. ANT and JAVA will need those.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server src]# export
ANT_HOME=/usr/local/ant
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# export
JAVA_HOME=/usr/lib/jvm/java
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# export
PATH=$PATH:/usr/local/ant/bin
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>5. Actually Installing the RED5
Server:</b>
</div>
<div style="margin-bottom: 0cm;">
Source:
</div>
<div style="margin-bottom: 0cm;">
Let’s get the RED5 source:
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server src]# svn co
http://red5.googlecode.com/svn/java/server/tags/1_0/ red5
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
This will fetch the complete Red5
source and save it in a new folder called, red5 (so in /usr/src/red5)
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Now that we have the source, let’s
move it to /usr/local/ using
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server src]# mv red5 /usr/local/
</div>
<div style="margin-bottom: 0cm;">
[root@server src]# cd /usr/local/red5
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
This is the folder where all the source
files reside. From here on, we prepare and build the red5 source.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server red5]#
/usr/local/ant/bin/ant prepare
</div>
<div style="margin-bottom: 0cm;">
[root@server red5]#
/usr/local/ant/bin/ant dist
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Wait for few minutes to .
After a few minutes you should end up with the last line in your
terminal window looking like this:
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
BUILD SUCCESSFUL
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
This means that you now have a working
RED5 build!
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Copy the conf directory from the dist
folder to the current directory and test the red5 installation.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server red5]# cp -r dist/conf .
</div>
<div style="margin-bottom: 0cm;">
[root@server red5]# ./red5.sh
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Make sure your server is actually
running, you should be able to see the webroot of Red5 when hitting
your server at port 5080 (http://yourserver.com:5080)
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Note : That the server is currently
only running as long as you keep that terminal window open. Once you
close it RED5 stops running. Let’s make sure RED5 can run on its
own from now on. Hit CTRL+C to stop the process.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>6. Init Script: </b>
</div>
<div style="margin-bottom: 0cm;">
Now we will create init script for red5
to start, stop and restart easily.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# vi /etc/init.d/red5
[Enter the following script into vi.]
</div>
<div style="margin-bottom: 0cm;">
#!/bin/sh
</div>
<div style="margin-bottom: 0cm;">
# For RedHat and cousins:
</div>
<div style="margin-bottom: 0cm;">
# chkconfig: 2345 85 85
</div>
<div style="margin-bottom: 0cm;">
# description: Red5 flash streaming
server
</div>
<div style="margin-bottom: 0cm;">
# processname: red5
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
PROG=red5
</div>
<div style="margin-bottom: 0cm;">
RED5_HOME=/usr/local/red5
</div>
<div style="margin-bottom: 0cm;">
DAEMON=$RED5_HOME/$PROG.sh
</div>
<div style="margin-bottom: 0cm;">
PIDFILE=/var/run/$PROG.pid
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
# Source function library
</div>
<div style="margin-bottom: 0cm;">
. /etc/rc.d/init.d/functions
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[ -r /etc/sysconfig/red5 ] && .
/etc/sysconfig/red5
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
RETVAL=0
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
case "$1" in
</div>
<div style="margin-bottom: 0cm;">
start)
</div>
<div style="margin-bottom: 0cm;">
echo -n $”Starting $PROG: ”
</div>
<div style="margin-bottom: 0cm;">
cd $RED5_HOME
</div>
<div style="margin-bottom: 0cm;">
$DAEMON >/dev/null 2>/dev/null &
</div>
<div style="margin-bottom: 0cm;">
RETVAL=$?
</div>
<div style="margin-bottom: 0cm;">
if [ $RETVAL -eq 0 ]; then
</div>
<div style="margin-bottom: 0cm;">
echo $! > $PIDFILE
</div>
<div style="margin-bottom: 0cm;">
touch /var/lock/subsys/$PROG
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
fi
</div>
<div style="margin-bottom: 0cm;">
[ $RETVAL -eq 0 ] && success
$”$PROG startup” || failure $”$PROG startup”
</div>
<div style="margin-bottom: 0cm;">
echo
</div>
<div style="margin-bottom: 0cm;">
;;
</div>
<div style="margin-bottom: 0cm;">
stop)
</div>
<div style="margin-bottom: 0cm;">
echo -n $”Shutting down $PROG: ”
</div>
<div style="margin-bottom: 0cm;">
killproc -p $PIDFILE
</div>
<div style="margin-bottom: 0cm;">
RETVAL=$?
</div>
<div style="margin-bottom: 0cm;">
echo
</div>
<div style="margin-bottom: 0cm;">
[ $RETVAL -eq 0 ] && rm -f
/var/lock/subsys/$PROG
</div>
<div style="margin-bottom: 0cm;">
;;
</div>
<div style="margin-bottom: 0cm;">
restart)
</div>
<div style="margin-bottom: 0cm;">
$0 stop
</div>
<div style="margin-bottom: 0cm;">
$0 start
</div>
<div style="margin-bottom: 0cm;">
;;
</div>
<div style="margin-bottom: 0cm;">
status)
</div>
<div style="margin-bottom: 0cm;">
status $PROG -p $PIDFILE
</div>
<div style="margin-bottom: 0cm;">
RETVAL=$?
</div>
<div style="margin-bottom: 0cm;">
;;
</div>
<div style="margin-bottom: 0cm;">
*)
</div>
<div style="margin-bottom: 0cm;">
echo $”Usage: $0
{start|stop|restart|status}”
</div>
<div style="margin-bottom: 0cm;">
RETVAL=1
</div>
<div style="margin-bottom: 0cm;">
esac
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
exit $RETVAL
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>7. Assign execute permission to red5 script.</b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# chmod +x
/etc/init.d/red5
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>8. Now start the service</b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# service red5 start OR
/etc/init.d/red5 start
</div>
<div style="margin-bottom: 0cm;">
<b>9. To start RED5 when the server
boots. </b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# chkconfig --add red5
</div>
<div style="margin-bottom: 0cm;">
[root@server ~]# chkconfig red5 on
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>10. To Install RED5 demos</b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
[root@server ~]# cd
/usr/local/red5/webapps/root
</div>
<div style="margin-bottom: 0cm;">
[root@server root]# svn checkout
http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos/
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>11. Test </b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Now test the RED5 installation by
opening following URL in browser.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
http://yourserverip:5080/</div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com13tag:blogger.com,1999:blog-2739902730161048005.post-481793114597555962013-03-29T19:16:00.001+05:302013-07-19T17:28:31.574+05:30Script to find out Linux Hardware Information<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">P { margin-bottom: 0.21cm; }</style>
<br />
<div align="CENTER" style="margin-bottom: 0cm;">
<span style="font-size: medium;"><b>How to get
Hardware Information on Linux</b></span></div>
<div align="CENTER" style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">Simple
script to find out Linux Hardware Information.</span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">exec
> /root/hard_info 2>&1
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">date
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Motherboard Model Number"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">dmidecode
-t baseboard | grep 'Product Name'
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo<span style="font-size: medium;"> </span>"<span style="font-size: medium;">=</span>==================================="
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Processor Information"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">dmidecode
-t processor | grep 'Socket Designation\|Version:'
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo "===================================="
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Memory Type & Size"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">dmidecode
-t memory | grep 'Type\|Size' | grep -v 'Type Detail\|Error
Correction Type'
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo</span><span style="font-size: medium;"> "===================================="
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Total Memory"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">free
-t -m
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo</span><span style="font-size: medium;"> "===================================="
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Hard Drive's of Machine"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">fdisk
-l | grep 'Disk /dev/s'
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo</span><span style="font-size: medium;"> "===================================="
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Serial Number of /dev/sda"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">hdparm
-I /dev/sda | grep 'Model Number:\|Serial Number'
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo</span><span style="font-size: medium;"> "===================================="
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo
"Serial Number of /dev/sdb"
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">hdparm
-I /dev/sdb | grep 'Model Number:\|Serial Number<span style="font-size: medium;">'</span>
</span></div>
<div align="LEFT" style="font-weight: normal; margin-bottom: 0cm;">
<span style="font-size: medium;">echo</span><span style="font-size: medium;"> "===================================="
</span></div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-72281819960800781782013-02-15T12:35:00.003+05:302017-02-20T09:38:02.382+05:30Install Nagios on Linux<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
</style>
<br />
<div align="CENTER" style="margin-bottom: 0cm;">
<span style="font-size: medium;"><b>Install
Nagios on Linux</b></span></div>
<div align="CENTER" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<span style="font-size: small;"><b>Introduction:-</b></span></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<span style="font-size: small;"><span style="font-weight: normal;"> </span></span><b><span style="font-weight: normal;">Nagios
is a powerful monitoring system that enables organizations to
identify and resolve IT infrastructure problems before they affect
critical business processes.</span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
Nagios is a popular open source computer system and network
monitoring software application. It watches hosts and services,
alerting users when things go wrong and again when they get better.</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;"> Nagios
was designed for use with the Linux operating system, but it will
also work under Unix and most Unix-based systems. </span></span></b>Nagios
runs periodic checks on user-specified resources and services.
Resources that can be monitored include memory</div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><u>Prerequisites</u></span></b><b><span style="font-size: small;"><span style="text-decoration: none;">:-</span></span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
<br /> Make sure you've </span></span></b><b><span style="font-size: small;"><span style="text-decoration: none;"><span style="font-weight: normal;">installed</span></span></span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
the following packages on your Linux installation before continuing. </span></span></b>
</div>
<ul>
<li><div style="margin-bottom: 0cm;">
Apache
</div>
</li>
<li><div style="margin-bottom: 0cm;">
PHP</div>
</li>
<li><div style="margin-bottom: 0cm;">
GCC compiler
</div>
</li>
<li>GD development libraries
<br />
</li>
</ul>
<ul>
<li><div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><b>IP</b></span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
= 192.168.1.1</span></span></b></div>
</li>
<li><div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><b>HOSTNAME</b></span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
= server.anup.co.in</span></span></b></div>
</li>
<li><div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">Firewall
and Selinux must be disabled.</span></span></b></div>
</li>
</ul>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">1]
Install gcc compiler, gd development libraries</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# yum install gd gd-devel gcc glibc glibc-common -y</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">2]
Install http package for nagios web-interface</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# yum install httpd php -y</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">3]
Create new user account and assign it password</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# useradd nagios</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# passwd nagios</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[
</span></span></b><b><span style="font-size: small;"><b>Note</b></span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
= apache user already created </span></span></b><b><span style="font-size: small;"><b>]</b></span></b><b><span style="font-size: small;"><span style="font-weight: normal;">
</span></span></b>
</div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">4] </span></span></b><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;"><span style="font-size: small;">Create</span></span></span></span><b><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;">
a new </span></span></span></b><i><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;">nagcmd
</span></span></span></i><b><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;">group
for allowing external commands to be submitted through the web
interface. Add both the nagios user and the apache user to the group.</span></span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# groupadd nagcmd</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# usermod -G nagcmd nagios</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# usermod -G nagcmd apache</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">5]
Download nagios and plugins from following links.</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY">
<b><span style="font-size: small;"><span style="font-weight: normal;">Create
a directory for storing the downloads.</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# mkdir /root/downloads</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# cd /root/downloads</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><b>Nagios
Download Link =</b></span></b></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@server">root@server</a>
downloads]# </span></span></b><b><span style="font-size: small;"><b>wget
http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz/download</b></span></b></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><b>Plugins
Download Link =</b></span></b></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@server">root@server</a>
downloads]# </span></span></b><b><span style="font-size: small;"><b>wget
http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download</b></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">6]
Now compile and install nagios </span></span></b>
</div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
downloads]# tar -xvzf nagios-3.3.1.tar.gz</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
downloads]# cd nagios</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# ./configure --with-command-group=nagcmd</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# make all</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">7]
Now install bineries, init script</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# make install</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# make install-init</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# make install-config</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# make install-commandmode</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">8]
Install web config file for nagios web-interface</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# make install-webconf</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios]# cd</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">9]
</span></span></b><b><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;">Create
a nagios</span></span></span></b><b><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><i><span style="font-weight: normal;">admin</span></i></span></span></b><b><span style="font-family: "liberation" serif , serif;"><span style="font-size: small;"><span style="font-weight: normal;">
account for logging into the Nagios web interface. Remember the
password you assign to this account – you’ll need it later.</span></span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users<span style="font-size: small;"><b> </b></span>nagios</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">10]
Now compile and install nagios plugins</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# cd /root/downloads</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
downloads]# tar -xvzf nagios-plugins-1.4.15.tar.gz</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
downloads]# cd nagios-plugins-1.4.15</span></span></b></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios <span style="font-size: small;"><b>--</b></span>with-nagios-group=nagios</span></span></b></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios-plugins-1.4.15]# make</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
nagios-plugins-1.4.15]# make install</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# cd</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">13]
Start nagios service ( Add Nagios to the list of system services and
have it automatically start when the system boots. )</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# chkconfig --add nagios</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# chkconfig nagios on</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">14]
Verify the sample nagios configuration file</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">15]
If there are no error start nagios and httpd (for nagios
web-interface)service</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# service nagios start</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b><span style="font-size: small;"><span style="font-weight: normal;">[<a href="mailto:root@rootuser">root@server</a>
~]# service httpd restart</span></span></b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
16] If you done this
successfully then login to Nagios Web-interface</div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b>[ Note =</b> You
should now be able to access the Nagios web interface at the URL
below. You'll be prompted for the username (<i>nagiosadmin</i>) and
password you specified earlier. <b>]</b></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b>URL is =
http://<</b><span style="font-weight: normal;">nagios server
ip/nagios</span></div>
<div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div align="JUSTIFY" style="margin-bottom: 0cm;">
<b>Example</b><span style="font-weight: normal;">
= http://192.168.1.1/nagios</span><br />
<br />
<span style="font-weight: normal;"><b>How to install Nagios Arana Theme ?</b><br /><br />1] Move old Nagios theme into new folder.<br /><br />[root@server ~]# mkdir /usr/local/nagios/share/old-theme<br />[root@server ~]# mv /usr/local/nagios/share/* old-theme<br /><br />2] Download Arana Theme.<br /><br />[root@server ~]# cd /usr/local/nagios/share<br />[root@server share]# wget http://kaz.dl.sourceforge.net/project/arana-nagios/arana_style-1.0for-Nagios3x-ENG.zip<br /><br />[root@server share]# unzip arana_style-1.0for-Nagios3x-ENG.zip<br />[root@server share]# cd<br /><br />3] Restart Nagios.<br /><br />[root@server ~]# service nagios reload </span></div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-86818407215883018272013-01-06T16:47:00.001+05:302013-01-06T16:51:00.015+05:30RkHunter Installtion<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
</style>
<br />
<br />
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>RKHunter
[Rootkit Hunter]
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>====================</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm; text-align: justify;">
<span style="font-family: Times New Roman, serif;">RootKit
is a feature rich scanning tool that scans for rootkits, backdoors,
and local exploits. It
scans hidden files, wrong permissions set on binaries, suspicious
strings in kernel etc.</span></div>
<div style="margin-bottom: 0cm; text-align: justify;">
<span style="font-family: Times New Roman, serif;">As
rootkits are installed into system files they cannot be removed
easily however, RKHunter will still
notify you of any rootkits that may exist in your system so that you
can take the necessary steps
to reload on server. </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">Rootkit
Hunter is not a reactive tool: it only enumerates encountered
threats.</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">It
is up to you to read the log file and investigate suspicious
activity.</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">To
know more about Rkhunter and its features visit
http://www.rootkit.nl/.</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">==================================
==============</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>Installing
Rkhunter (Rootkit Hunter) in RHEL, CentOS and Fedora
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">==================================
==============</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>Step
1: Downloading Rkhunter:
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# mkdir /download
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# cd /download
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
download]# wget
http://nchc.dl.sourceforge.net/project/rkhunter/rkhunter/1.4.0/rkhunter-1.4.0.tar.gz</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>Step
2: Installing Rkhunter:
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">Once
you have downloaded the latest version, run the following commands as
a root user to install it.
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
download]# tar -xvzf rkhunter-1.4.0.tar.gz
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
download]# cd rkhunter-1.4.0
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
rkhunter-1.4.0]# ./installer.sh --install
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
rkhunter-1.4.0]# cd </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>Step
3: Updating Rkhunter:
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">Run
the RKH updater to fill the database properties by running the
following command.
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# /usr/local/bin/rkhunter --update
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# /usr/local/bin/rkhunter --propupd </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>Step
4: Setting Cronjob and Email Alerts:
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">Create
one file "rkhunter.sh under /etc/cron.daily/, which then scans
your file system every day and sends email notifications to your
email id. </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# vi /etc/cron.daily/rkhunter.sh
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">#Add
the following lines of code to it and replace your “Server Name”
and your “Email Id“.
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">#!/bin/sh
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">(
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">/usr/local/bin/rkhunter
--versioncheck
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">/usr/local/bin/rkhunter
--update
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">/usr/local/bin/rkhunter
--cronjob --report-warnings-only
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">) |
/bin/mail -s 'rkhunter Daily Run (server.anup.co.in)'
mail@anup.co.in </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">Set
execute permission on the file.
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
[root@server
~]# chmod +x /etc/cron.daily/rkhunter.sh </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;"><b>Step
5: Manual Scan and Usage:
</b></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">To
scan the entire file system, run the Rkhunter as a root user.
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# rkhunter --check
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">The
above command generates log file under /var/log/rkhunter.log with the
checks results made by Rkhunter. </span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">For
more information and options please run the following command.
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Times New Roman, serif;">[root@server
~]# rkhunter --help</span></div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com1tag:blogger.com,1999:blog-2739902730161048005.post-23600354242213428012012-10-15T13:11:00.001+05:302012-10-15T13:11:42.991+05:30Serial key for VMware Workstation 9 <div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
</style>
<br />
<br />
<br />
<div style="margin-bottom: 0cm;">
<b>Serial key for VMware Workstation 9 </b>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
</style>
<br />
<div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm;">
VMWare
workstation is a free virtualization product that installs on any
existing server or powerful PC hardware and partitions a physical
computer or server into multiple virtual machines by abstracting
processor, memory, storage and networking resources, and thus able to
further fully utilize the hardware and have the flexibility to run
another same or operating system without the need of new computer.
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
To install VMWare
Workstation, users need to have serial number or product key. </div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
VMware Workstation
8 Serial Key: </div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
0A494-8U0EM-UZ2A9-0105M-A303M
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
MA406-25387-7ZNW8-F197P-1AL2D
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
4A4GP-6PLD0-QZTP9-WK0NK-C3UQD
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
4A2XP-D03DN-7Z6H9-Z2ANM-0C9PFD
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
0F0G8-FK29Q-AZ529-2J1NP-AC02F </div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
VMware Workstation
9 Serial Key: </div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
0F23V-4D38L-9ZQ38-2K37H-83C50
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
0F03K-80JEQ-8ZF89-8287H-A2R47
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
0A22R-400EM-EZ4W8-3K9NK-3AUPL
</div>
<div style="font-weight: normal; margin-bottom: 0cm;">
NA64Z-0V054-UZVC0-2L370-837K4 </div>
<div style="font-weight: normal; margin-bottom: 0cm;">
<br /></div>
<div style="font-weight: normal; margin-bottom: 0cm;">
Try above serial keys </div>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com36tag:blogger.com,1999:blog-2739902730161048005.post-64450848182926126652012-09-28T15:15:00.000+05:302012-09-28T15:15:59.308+05:30Configuring A High Availability Cluster (Heartbeat) On CentOS<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
PRE.cjk { font-family: "WenQuanYi Micro Hei", monospace }
PRE.ctl { font-family: "Lohit Hindi", monospace }
H3 { margin-bottom: 0.21cm }
H3.cjk { font-family: "WenQuanYi Micro Hei" }
H3.ctl { font-family: "Lohit Hindi" }
H2 { margin-bottom: 0.21cm }
H2.cjk { font-family: "WenQuanYi Micro Hei" }
H2.ctl { font-family: "Lohit Hindi" }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
</style>
<br />
In this example we will configure a
webserver using apache and we will cluster it. It can be implemented
on centos, fedora and other redhat flavors.
<h3 class="western">
<span style="font-size: small;">Pre-Configuration Requirements</span></h3>
<span style="font-size: small;">1] Following are the hostnames and ipv4 addresses
that will be used:</span><br />
<ul>
<li><div style="margin-bottom: 0cm;">
<span style="font-size: small;">Primary Node : IP -
192.168.1.1 Hostname - server1.linuxhome.in </span>
</div>
</li>
<li><div style="margin-bottom: 0cm;">
<span style="font-size: small;">Secondary Node : IP -
192.168.1.2 Hostname - server2.linuxhome.in </span>
</div>
</li>
<li><span style="font-size: small;">Virtual IP for Apache - 192.168.1.100</span><br />
</li>
</ul>
<div style="margin-bottom: 0cm;">
Assign virtual IP address using
following steps on both node :</div>
<div style="margin-bottom: 0cm;">
# <span style="font-size: small;">cp
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth0:0</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">
DEVICE=eth0
:0</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">BOOTPROTO=none
</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">BROADCAST=192.168.1.255
</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">HWADDR=00:15:17:a3:92:04
</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">IPADDR=192.168.1.100</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">NETMASK=255.255.255.0
</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">
ONBOOT=yes
</span></span></div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;">TYPE=Ethernet
</span></span></div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
2] Download and install the heartbeat
package. In our case we are using CentOS so we will install heartbeat
with yum:</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
[<a href="mailto:root@server1">root@server1</a>
~]# yum install heartbeat</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
or download below package</div>
<div style="margin-bottom: 0cm;">
heartbeat-2.08<br />heartbeat-pils-2.08<br />heartbeat-stonith-2.08</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
3] Now we have to configure heartbeat
on our two node cluster. We will deal with three files.
These are:
(authkeys, ha.cf, haresources)</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
[<a href="mailto:root@server1">root@server1</a>
~]# cp /usr/share/doc/heartbeat-2.1.2/{authkeys,ha.cf,haresources}
/etc/ha.d/</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
4] First we will deal with the authkeys
file, we will use authentication method 2 (sha1). For this we will
make changes in the authkeys file as below.</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
[<a href="mailto:root@server1">root@server1</a>
~]# vi /etc/ha.d/authkeys</div>
<div style="margin-bottom: 0cm;">
Add the following lines at the end of
file & save:</div>
<pre class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">auth 2</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">2 sha1 test-ha</span></span></pre>
<div style="margin-bottom: 0cm;">
5] Also the authkeys file must be read only root:</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
[<a href="mailto:root@server1">root@server1</a>
~]# chmod 600 /etc/ha.d/authkeys</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
6] Make changes in second file of
hearteat (haresources) :</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
[<a href="mailto:root@server1">root@server1</a>
~]# vi /etc/ha.d/ haresources</div>
<div style="margin-bottom: 0cm;">
#Add the following line at the end of
file & save:</div>
<div style="margin-bottom: 0cm;">
server1.linuxhome.in 192.168.1.100 httpd</div>
<pre class="western" style="margin-bottom: 0.5cm;"></pre>
<div style="margin-bottom: 0cm;">
7] The final piece of work in our configuration is to edit the ha.cf
file which is important :</div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
[<a href="mailto:root@server1">root@server1</a>
~]# vi /etc/ha.d/ha.cf</div>
<div style="margin-bottom: 0cm;">
#Add / Uncommnet below lines in ha.cf
file & save.</div>
<pre class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">logfile /var/log/ha-log</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">logfacility local0</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">keepalive 2</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">deadtime 30</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">initdead 120</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">bcast eth0</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">udpport 694</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">auto_failback on</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">node server1.linuxhome.in</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">node server2.linuxhome.in</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">8] As we want httpd highly enabled let's start configuring httpd:</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">[<a href="mailto:root@server1">root@server1</a> ~]# vi /etc/httpd/conf/httpd.conf</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">#Add following line:</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Listen 192.168.1.100:80</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">9] Copy the /etc/ha.d/ directory from server1 to server2:</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">[<a href="mailto:root@server1">root@server1</a> ~]# scp -rvp /etc/ha.d/ <a href="mailto:root@server2.linuxhome.in">root@server2.linuxhome.in</a>:/etc/</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">10] Copy httpd.conf file from server1 to server2:</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">[<a href="mailto:root@server1">root@server1</a> ~]# scp -rvp /etc/httpd/conf/httpd.conf <a href="mailto:root@server2.linuxhome.in">root@server2.linuxhome.in</a>:/etc/httpd/conf/</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">11] Create index.html file on both server under /var/www/html directory.</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">On server1.linuxhome.in</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">[<a href="mailto:root@server1">root@server1</a> ~]# echo "SERVER1 Apache test server" > /var/www/html/index.html</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">On server2.linuxhome.in</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">[<a href="mailto:root@server1">root@server2</a> ~]# echo "SERVER2 Apache test server" > /var/www/html/index.html</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language</style></span></span><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">12 ] Now start heartbeat on the primary server1 and slave server2:</span></span></pre>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">#
/etc/init.d/heartbeat start</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">13] Open
web-browser and type in the URL:</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">http://192.168.1.100</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">It will show
server1.linuxhome.in apache test server.</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">13. Now stop the
hearbeat daemon on server1.linuxhome.in:</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">#
/etc/init.d/heartbeat stop</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">In your browser
type in the URL http://192.168.1.100 and press enter.</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">It will show
server2.linuxhome.in apache test server.</span></span><br />
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com3tag:blogger.com,1999:blog-2739902730161048005.post-92220799221840011362012-09-25T15:35:00.000+05:302012-09-25T15:35:51.421+05:30Install and configure Apache with PHP on Windows machine<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
CODE.cjk { font-family: "WenQuanYi Micro Hei", monospace }
CODE.ctl { font-family: "Lohit Hindi", monospace }
A:link { so-language: zxx }
</style>
</div>
-->
<br />
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>Install and configure Apache with
PHP on Windows machine :</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b>Apache Installation :</b></div>
<div style="margin-bottom: 0cm;">
<span style="font-size: small;"><span style="font-weight: normal;">1]
</span></span>Download the latest apache at
<a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
2] Run the installer
<b>apache_2.2.9-win32-x86-no_ssl-r2.msi</b>.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
3] First screen is the <i>welcome
note</i>. Click <b>Next</b>.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
4] Second screen is the <i>licence
agreement</i>. Accept the terms in the license agreement, click
<b>Next</b>.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
5] Third screen, <i>brief desription
of the software</i>. <b>Next</b>.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
6] <i>Server Information Dialogue</i>
will ask you for the following values:</div>
<b>Network Domain</b> – name of your computer across a
network connection. To know the Full Computer Name, right-click My
Computer icon, choose Properties, click Computer Name Tab, and look
for Full computer name. Or you can simply type <b>localhost</b>
as its value.<br />
<b>Server Name</b> – the same value with the Network
Domain. Or <b>localhost</b>.<br />
<b>Admnistrator’s Email Address</b><br />
Choose the radio button <b>for All Users, on Port 80, as a
Service</b>. Click <b>Next</b>.<br />
<div style="margin-bottom: 0cm;">
7] Select <b>Typical</b> for
<i>Set up Type</i>. <b>Next</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">8]
Select </span></b><b>Typical</b><b><span style="font-weight: normal;">
for </span></b><i><span style="font-weight: normal;">Set up
Type</span></i><b><span style="font-weight: normal;">. </span></b><b>Next</b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">9]
</span></b><i><span style="font-weight: normal;">Destination
Folder</span></i><b><span style="font-weight: normal;">. Leave
the default value, click </span></b><b>Next</b><b><span style="font-weight: normal;">.</span></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">10]
Next screen is </span></b><i><span style="font-weight: normal;">Ready
to Install the Program</span></i><b><span style="font-weight: normal;">.
Click </span></b><b>Install</b><b><span style="font-weight: normal;">.</span></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">11]
</span></b><b>To Test Your Installation</b><b><span style="font-weight: normal;"><br />Open
a browser and point to </span></b><b>http://localhost</b><b><span style="font-weight: normal;">
or </span></b><b>http://127.0.0.1/</b><b><span style="font-weight: normal;">.
You should see the </span></b><b>Apache Installation</b><b><span style="font-weight: normal;">
page.</span></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><b>PHP Configuration :</b></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">1]
Download the latest php at <a href="http://www.php.net/downloads.php" target="_blank">http://www.php.net/downloads.php</a>
.</span></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">2]
Unzip the contents of php-5.2.6-Win32.zip package to C:\PHP folder.</span></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">3]
Find and rename the file php.ini-recommended to php.ini under PHP
folder.</span></b></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">4]
Open the file php.ini, look and uncomment the following directives
(Click Edit > Find or Ctrl F) and save file.</span></b></div>
<div style="margin-bottom: 0cm;">
<b><span style="font-weight: normal;">[
Uncomment – remove the ; before a directive to activate it. ]</span></b></div>
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
CODE.cjk { font-family: "WenQuanYi Micro Hei", monospace }
CODE.ctl { font-family: "Lohit Hindi", monospace }
A:link { so-language: zxx }
</style>
-->
<br />
<code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">display_errors
= on</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">register_globals
= off</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">magic_quotes_gpc
= on</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">extension_dir
= /PHP/ext</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">session.save_path
= /tmp Create a folder named TMP under the root directory (Drive
C:)</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">extension=php_mbstring.dll</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;"><br /></span></span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">extension=php_mysql.dll</span></span></span></code><br />
<code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;"><span style="font-weight: normal;"></span></span></span></code><br />
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
CODE.cjk { font-family: "WenQuanYi Micro Hei", monospace }
CODE.ctl { font-family: "Lohit Hindi", monospace }
A:link { so-language: zxx }
</style>
-->
<code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">5]</span></span></span></code><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: x-small;"><span style="font-weight: normal;">
</span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Attach
PHP to Apache as a module. Open the Apache configuration file</span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">
(C:\Program Files\Apache Software
Foundation\Apache2.2\Conf\httpd.conf).</span></span></span></code><br />
<b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Search
for</span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">
LoadModule. </span></span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Add
this at the end</span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">:<br />#LoadModule
vhost_alias_module modules/mod_vhost_alias.so<br />LoadModule
php5_module "c:/php/php5apache2_2.dll"<br />PHPIniDir
"C:/PHP"</span></span></span></code><br />
<b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Search
for </span></span></b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">DirectoryIndex
</span></span><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">and
add </span></span></b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">index.php.</span></span><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><IfModule
dir_module></span></span></code><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><br /></span></span><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">DirectoryIndex
</span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">index.php</span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">
index.html</span></span></code><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><br /></span></span><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"></IfModule></span></span></code><br />
<b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Add the
following under</span></span></b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">
<IfModule mime_module>:</span></span><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">AddType
application/x-httpd-php .php</span></span></code><br />
<br />
<code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">6]
</span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Copy</span></span></b><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">
libmysql.dll </span></span></code><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">file
from your C:\PHP folder to the C:\WINNT\system32 directory or
C:\Windows\System32 directory(Windows XP).</span></span></b><br />
<br />
<b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><span style="font-weight: normal;">7]
</span></span></span></b><b><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Restart
Apache.</span></span></b><br />
<b><span style="font-family: Liberation Serif, serif;">To Test PHP</span></b><br />
<span style="font-family: Liberation Serif, serif;">Create </span><i><span style="font-family: Liberation Serif, serif;">phpinfo.php</span></i><span style="font-family: Liberation Serif, serif;">,
type:</span><code class="western"><span style="font-family: Liberation Serif, serif;"><?php
echo phpinfo(); ?></span></code><br />
<span style="font-family: Liberation Serif, serif;">Save as </span><b><span style="font-family: Liberation Serif, serif;">phpinfo.php</span></b><span style="font-family: Liberation Serif, serif;">
in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\</span><br />
<span style="font-family: Liberation Serif, serif;">8] Open a browser and point
to http://localhost/phpinfo.php or http://127.0.0.1/phpinfo.php .</span></div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-88941835560734226112012-09-21T19:34:00.002+05:302012-09-21T19:34:44.102+05:30Find and Replace work in Multiple Files<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
PRE.cjk { font-family: "DejaVu Sans", monospace }
H1 { margin-bottom: 0.21cm }
H1.western { font-family: "Liberation Serif", serif }
H1.cjk { font-family: "DejaVu Sans" }
H1.ctl { font-family: "DejaVu Sans" }
P { margin-bottom: 0.21cm }
CODE.cjk { font-family: "DejaVu Sans", monospace }
A:link { so-language: zxx }
-->
</style>
<h1 class="western">
<span style="color: blue;"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Easy
Search and Replace word in Multiple Files on Linux Command Line</span></span></span></h1>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"> I
was trying to find a solution to do a find & replace word across
multiple files which was purely command line based. There are plenty
of scripts out there which will accomplish this but I needed a single
line command. After some google searches and some experimentation I
came up with this snippet.</span></span></div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Syntax
: [root@server ~]# grep -lr -e '<oldword>' * | xargs sed -i
's/<oldword>/<newword>/g'</span></span></div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Example
: [root@server ~]# grep -lr -e 'country' * | xargs sed -i
's/country/India/g'</span></span></div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">This command
broken down:</span></span><br />
<ul>
<li><div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">grep
for the word in a files, use recursion (to find files in sub
directories), and list only file matches </span></span>
</div>
</li>
<li><div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">xargs
passes the results from the grep command to sed </span></span>
</div>
</li>
<li><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">sed -i uses
a regular expression (regex) to evaluate the change: s (search) /
search word / target word / g (global replace) </span></span>
<br />
</li>
</ul>
<span style="color: blue;"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;"><u><b>Find
& Replace word of specific files:</b></u></span></span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">I want to
replace the word “country” with “India” from those files
which are having “.php” extension. To do so use the following
command :</span></span><br />
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Syntax :
[root@server ~]# find . -name “*.php” -print | xargs sed -i
's/old word/new word/g'</span></span><br />
<div style="margin-bottom: 0cm;">
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">Example
: [root@server ~]# </span></span><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">find
. -name “*.php” -print | xargs sed -i 's/country/India/g'</span></span></code></div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">It
looks bit complicated but quite simple. There are three components to
the command.</span></span></code><br />
<ol>
<li><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">find
. -name "*.php" -print</span></span></code><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">
– Find all files (recursively) which has “.php” in the file
and print them out. This will give you output like this: </span></span>
<br />
<pre class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">./file.php</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">./includes/test.php</span></span>
<span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">./classes/class.php</span></span></pre>
</li>
<li><div style="margin-bottom: 0cm;">
<code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">xargs</span></span></code><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">-
This command is used when you want to pass a lot of arguments to one
command. xargs will combine the single line output of find and run
commands with multiple<br />arguments, multiple times if necessary to
avoid the max chars per line limit. In this case we combine xargs
with sed </span></span>
</div>
</li>
<li><code class="western"><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">sed
-i 's/country/India/g'</span></span></code><span style="font-family: Liberation Serif, serif;"><span style="font-size: small;">
– Stream Editor is a tool which should be in every sys admin’s
toolkit. In this case every occurence of “country” is replaced
by “India” in all the files found using the “find” command.
Sed simply parses input and applies certain text transformations to
it.</span></span><br />
</li>
</ol>
</div>
Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-8567302763323599102012-05-19T11:54:00.001+05:302012-05-19T11:54:38.360+05:30How to Find and Check Number of Connections to a Server<div dir="ltr" style="text-align: left;" trbidi="on">
<style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
H1 { margin-bottom: 0.21cm }
H1.western { font-family: "Liberation Serif", serif }
H1.cjk { font-family: "DejaVu Sans" }
H1.ctl { font-family: "DejaVu Sans" }
A:link { so-language: zxx }
-->
</style><br />
<div align="LEFT" style="margin-bottom: 0cm;">
<br /> <span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"> Whenever
a client connects to a server via network, a connection is
established and opened on the system. On a busy high load server, the
number of connections connected to the server can be run into large
amount till hundreds if not thousands. Find out and get a list of
connections on the server by each node, client or IP address is
useful for system scaling planning, and in most cases, detect and
determine whether a web server is under DoS or DDoS attack
(Distributed Denial of Service), where an IP sends large amount of
connections to the server. To check connection numbers on the server,
administrators and webmasters can make use of netstat
command.<br /><br /> Below is some of the example a typically use command
syntax for ‘netstat’ to check and show the number of connections
a server has. Users can also use ‘man netstat’ command to get
detailed netstat help and manual where there are lots of configurable
options and flags to get meaningful lists and .<br /><br />1] Display
all active Internet connections to the servers and only established
connections are included.<br />[<a href="mailto:root@server">root@server</a>
~]# netstat -na</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"><br />2]
Show only active Internet connections to the server at port 80 and
sort the results. Useful in detecting single flood by allowing users
to recognize many connections coming from one IP.</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<br />
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -an | grep :80 | sort<br /><br />3] Let users know how many
active SYNC_REC are occurring and happening on the server. The number
should be pretty low, preferably less than 5. On DoS attack incident
or mail bombed, the number can jump to twins. However, the value
always depends on system, so a high value may be average in another
server.</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"><br />[<a href="mailto:root@server">root@server</a>
~]# netstat -n -p|grep SYN_REC | wc -l</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"><br />4]
List out the all IP addresses involved instead of just count.</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -n -p | grep SYN_REC | sort -u<br /><br />5] List all the
unique IP addresses of the node that are sending SYN_REC connection
status.</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -n -p | grep SYN_REC | awk '{print $5}' | awk -F: '{print
$1}'<br /><br />6] Use netstat command to calculate and count the number
of connections each IP address makes to the server.</span></span><br />
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c |
sort -n</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"><br />7]
List count of number of connections the IPs are connected to the
server using TCP or UDP protocol.</span></span><br />
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 |
sort | uniq -c | sort -n</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"><br />8]
Check on ESTABLISHED connections instead of all connections, and
displays the connections count for each IP.</span></span><br />
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -ntu | grep ESTAB | awk '{print $5}' | cut -d: -f1 | sort
| uniq -c | sort -nr</span></span></div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;"><br />9]
Show and list IP address and its connection count that connect to
port 80 on the server. Port 80 is used mainly by HTTP web page
request.</span></span></div>
<div style="margin-bottom: 0cm;">
<br />
</div>
<div align="LEFT" style="margin-bottom: 0cm;">
<span style="font-family: Liberation Sans,sans-serif;"><span style="font-size: small;">[<a href="mailto:root@server">root@server</a>
~]# netstat -plan|grep :80|awk {'print $5'}|cut -d: -f 1|sort|uniq
-c|sort -nk 1</span></span></div>
</div>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-10096403762204700202012-02-25T19:20:00.003+05:302012-02-25T19:20:52.421+05:30Basic OpenVz Commands<div dir="ltr" style="text-align: left;" trbidi="on"><style type="text/css">
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
</style> <br />
<div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">1] To Start the VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl start 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">2] To Stop the VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl stop 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">3] To stop the VPS quickly and forcefully.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl stop 101 –fast</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">4] To restart the VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl restart 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">5] To destroy VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl destroy 101</b> (good idea to stop it first)</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">6] To enter into VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl enter 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">7] To logout from VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@101">root@101</a> ~]# <b>exit</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">8] To display the list of active VPS's.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzlist</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">9] To display the list of all VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzlist -a</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">10] To check the status of a VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl status 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">11] To show resource usage on VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzcalc -v 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">12] Execute commands against the VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl exec 101 df -h</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">13] To set the Hostname of a VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --hostname server.linuxhome.in --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">14] To set new IP to the VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --ipadd 192.168.1.1 --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">15] To remove IP of VPS.</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --ipdel 192.168.1.1 --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">16] To set the nameserver for VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --nameserver 192.168.1.254 --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">17] To set root password of VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --userpasswd root:test</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm;"><span style="text-decoration: none;">18] </span>To set boot status.</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span><a href="mailto:root@server">root@server</a><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# </span></span><b>vzctl set 101 --onboot yes --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">19] To check CPU Power and Utilization. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzcpucheck -v</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">20] To set the number of CPUs available to a VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --cpus 2 --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">21] To set the minimum and maximum CPU limits. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --cpuunits 1500 --cpulimit 4 --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">22] To check Container's Resources Usage. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzcalc -v 101</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">23] To set quota & hardisk space. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --diskspace 10G:11G --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">24] To check the disk quota of a VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzquota stat 101 -t</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">25] To check memory consumption. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzmemcheck -v</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">26] To assign disk inodes. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzctl set 101 --diskinodes 90000:91000 --save</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">27] To run yum update on VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzyum 101 -y update</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">28] To install package using yum on VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzyum 101 -y install vsftpd*</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">29] To install package using rpm on VPS. </div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;">[<a href="mailto:root@server">root@server</a> ~]# <b>vzrpm 101 -Uvh vsftpd*</b></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm; text-decoration: none;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="text-decoration: none;"><span style="font-weight: normal;">30] T</span></span>o find out the templates installed on your system.</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span><a href="mailto:root@server">root@server</a><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# </span></span><b>vzpkgls</b></div></div>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0tag:blogger.com,1999:blog-2739902730161048005.post-65857187118503173792012-02-25T12:25:00.000+05:302012-02-25T12:25:03.862+05:30Install OpenVz on RedHat<div dir="ltr" style="text-align: left;" trbidi="on"> <style type="text/css">
<!--
@page { margin: 2cm }
PRE.cjk { font-family: "DejaVu Sans", monospace }
P { margin-bottom: 0.21cm }
A:link { so-language: zxx }
-->
</style> <br />
<div align="JUSTIFY" style="margin-bottom: 0cm;"><u><b>Introduction</b></u><span style="text-decoration: none;"><b>:-</b></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="text-decoration: none;"><b> </b></span><span style="text-decoration: none;"><span style="font-weight: normal;">OpenVZ is a complete server automation and virtualization software. OpenVZ creates multiple isolated Virtual Private Servers (VPSs) on a single physical server to share hardware and management effort with maximum efficiency. Each VPS performs and executes exactly like a stand-alone server for its users and applications as it can be rebooted independently and has its own root access, users, IP addresses, memory, processes, files, applications, system libraries, and configuration files.</span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="text-decoration: none;"><b>Note:- </b></span><span style="text-decoration: none;"><span style="font-weight: normal;">Following steps I have used to install OpenVz on Red Hat Enterprise Linux 5.4 [32 bit].</span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><u><b>Per quest</b></u><span style="text-decoration: none;"><b>:-</b></span></div><ul><li><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> Configure IP = 192.168.1.1 & Hostname = server.rootuser.in</div></li>
<li><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> Create separate partition for container's private directories i.e. /vz.</div></li>
<li><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> Firewall and Selinux should be off.</div></li>
<li><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">Download Kernel and OpenVz </span></span></span>Utilities<span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> from following link and save it on Desktop & also download precreate OS template.</span></span></span></div></li>
</ul><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> Kernel Download link = http://wiki.openvz.org/Download/kernel/rhel5/</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> vzctl utility = http://wiki.openvz.org/Download/vzctl</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> vzctl-lib=http://download.openvz.org/utils/vzctl/3.0.30.2/vzctl-lib-3.0.30.2-1.i386.rpm</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> vzquota utility = http://wiki.openvz.org/Download/vzquota</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> OS template = http://download.openvz.org/template/precreated/</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <br />
</div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <b>Install OpenVz on redhat:-</b></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> 1] Install kernel binary rpm.</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# cd Desktop</span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> Desktop]# rpm -i ovzkernel-2.6.18-274.12.1.el5.028stab096.1.i686</span></span></span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> 2] There are a number of kernel limits that should be set for OpenVZ to work correctly.</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">Edit and append </span></span></span><span style="font-style: normal;"><span style="text-decoration: none;"><b>sysctl.conf </b></span></span><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">file.</span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# vi /etc/sysctl.conf</span></span></span></div><pre class="western" style="text-align: justify;"><span style="font-family: Liberation Serif,Times New Roman,serif; font-size: small;"><span style="font-style: normal;"><span style="text-decoration: none;"><b>net.ipv4.</b></span></span></span><span style="color: black; font-size: small;"><span style="font-family: Liberation Serif,Times New Roman,serif;"><span style="font-style: normal;"><span style="text-decoration: none;"><b>ip_forward = 1</b></span></span></span></span></pre><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <b>net.ipv4.conf.default.proxy_arp = 0</b></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> # Enables source route verification</div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <b>net.ipv4.conf.all.rp_filter = 1</b></div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <b>kernel.sysrq = 1</b></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;"># we do not want all our interfaces to send redirects</span></div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;"><b>net.ipv4.conf.default.send_redirects = 1</b></span></div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;"><b>net.ipv4.conf.all.send_redirects = 0</b></span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">:wq</span></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">3] To apply changes use following command.</span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# sysctl -p </span></span></span></span> </div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">4] Make sure SELinux is disabled.</span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# vi /etc/sysconfig/selinux</span></span></span></span></div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;"><b>SELINUX = disabled</b></span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">:wq</span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">5] Now, you should reboot your computer and choose "OpenVZ" kernel from the boot loader menu.</span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# reboot</span></span></span></span></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">6] Install opevz utilities.</span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# cd Desktop</span></span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> Desktop]# rpm -ivh vzctl-lib-3.0.30.2-1.i386.rpm</span></span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> Desktop]# rpm -ivh vzctl-3.0.23-1.i386.rpm</span></span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> Desktop]# rpm -ivh vzquota-3.0.12-1.i386.rpm</span></span></span></span></div><div align="JUSTIFY" style="font-weight: normal; margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">7] Start vz service.</span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# service vz start</span></span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# chkconfig –level 235 vz on</span></span></span></span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><u><b>Creating New Virtual Private Server</b></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><b>:-</b></span></span></span></div><div align="JUSTIFY" style="font-style: normal; margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">1] Download the corresponding OS template and place it to the </span></span></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><b>/vz/template/cache</b></span></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> directory</span></span></span><span style="text-decoration: none;"><span style="font-style: normal;"><span style="font-weight: normal;"> of the physical machine.</span></span></span></span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm;"> <br />
</div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">2] Create new VPS by using following command.</span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">Syntax :- # vzctl create <Container ID> --ostemplate <templage name> --config basic</span></div><div align="JUSTIFY" style="font-style: normal; font-weight: normal; margin-bottom: 0cm; text-decoration: none;"> <span style="color: black;">Example :-</span></div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# vzctl create 101 --ostemplate </span></span></span></span>centos-5-x86 --config basic</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"> This will create a Virtual Private Server with ID 101, the private area based on</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;"> the centos-5-x86 OS template.</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><br />
</div><div align="JUSTIFY" style="margin-bottom: 0cm;">3] To check container is created or not.</div><div align="JUSTIFY" style="margin-bottom: 0cm;"><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;">[</span></span></span></span><span style="color: navy;"><span lang="zxx"><u><a href="mailto:root@server"><span style="font-style: normal;"><span style="font-weight: normal;">root@server</span></span></a></u></span></span><span style="color: black;"><span style="font-style: normal;"><span style="text-decoration: none;"><span style="font-weight: normal;"> ~]# vzlist -a</span></span></span></span></div></div>Anup Dubbewarhttp://www.blogger.com/profile/09516560973195559449noreply@blogger.com0