Chatur_India
Sunday, December 27, 2020
Monday, May 11, 2020
crontab
* * * * * /home/amitkumar/anisble/crontab.sh #every minute
* * * * * sleep 30; /home/amitkumar/anisble/crontab.sh #every 30 seconds
* * * * * sleep 00; timeout 15s /home/amitkumar/anisble/crontab.sh
* * * * * sleep 15; timeout 15s /home/amitkumar/anisble/crontab.sh #15seconds
* * * * * sleep 30; timeout 15s /home/amitkumar/anisble/crontab.sh
* * * * * sleep 45; timeout 15s /home/amitkumar/anisble/crontab.sh
This command allows cron to execute on first Saturday of every month.
0 2 * * sat [ $(date +%d) -le 06 ] && /script/script.sh
Saturday, May 9, 2020
nginx master configration
cd /etc/nginx/nginx.conf
cd /etc/nginx/config.d
cd /usr/share/nginx/html # default log file and defal nginx login file
cd /etc/nginx/nginx.conf.d
server {
listen 80;
server_name amit.com;
location / {
root /var/www/html;
index index.html index.htm;
access_log /var/www/html/access.log main;
error_log /var/www/html/error.log;
error_page 404 /404.html;
location = /40x.html {
root /var/www/html/india;
}
}
}
====================================================
dashboard.amit.com to Redirect project.mukesh.com
server {
# listen 80;
server_name dashboard.amit.com;
location / {
proxy_pass http://project.mukesh.com;
proxy_set_header Host $http_host;
}
}
+++++++++++++++++
## Generate ssl certifcate
openssl genrsa -des3 -out india.amit.com.key 1024 #Generate key
openssl req -new -key india.amit.com.key -out india.amit.com.csr #Generate csr
cp india.amit.com.org india.amit.com.key.org # unprotect key
openssl rsa -in india.amit.com.key.org -out india.amit.com.key # writing RSA key
openssl x509 -req -days 365 -in india.amit.com.csr -signkey india.amit.com.key -out india.amit.com.crt # Getting Private key
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /etc/nginx/conf.d/india.amit.com.crt ;
ssl_certificate_key /etc/nginx/conf.d/india.amit.com.key;
server_name amit.com;
location / {
root /var/www/html;
index index.html index.htm;
access_log /var/www/html/access.log main;
error_log /var/www/html/error.log;
error_page 404 /404.html;
location = /40x.html {
root /var/www/html/india;
}
}
}
==================================load Balancer=============
upstream prod_backend {
least_conn;
server 192.168.1.10 max_fails=3 fail_timeout=60s;
server 192.168.1.10 max_fails=3 fail_timeout=60s;
}
server {
listen 80;
location / {
proxy_set_header Host $host;
client_max_body_size 120m;
client_max_body_buffer_size 120k;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
proxy_pass http://prod_backend;
}
}
}
=======================revorce proxy================================
server {
listen 80;
server_name india.amit.com;
}
location/ {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Port $server_port;
}
###################### tomcat redirect to nginx===============
server {
server_name blog.amit.com;
rewrite ^/(.*)$/department2/$1; # for only redirect website
location /{
proxy_pass http://127.0.0.1:8282;
}
}
cd /etc/nginx/config.d
cd /usr/share/nginx/html # default log file and defal nginx login file
cd /etc/nginx/nginx.conf.d
server {
listen 80;
server_name amit.com;
location / {
root /var/www/html;
index index.html index.htm;
access_log /var/www/html/access.log main;
error_log /var/www/html/error.log;
error_page 404 /404.html;
location = /40x.html {
root /var/www/html/india;
}
}
}
====================================================
dashboard.amit.com to Redirect project.mukesh.com
server {
# listen 80;
server_name dashboard.amit.com;
location / {
proxy_pass http://project.mukesh.com;
proxy_set_header Host $http_host;
}
}
+++++++++++++++++
## Generate ssl certifcate
openssl genrsa -des3 -out india.amit.com.key 1024 #Generate key
openssl req -new -key india.amit.com.key -out india.amit.com.csr #Generate csr
cp india.amit.com.org india.amit.com.key.org # unprotect key
openssl rsa -in india.amit.com.key.org -out india.amit.com.key # writing RSA key
openssl x509 -req -days 365 -in india.amit.com.csr -signkey india.amit.com.key -out india.amit.com.crt # Getting Private key
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /etc/nginx/conf.d/india.amit.com.crt ;
ssl_certificate_key /etc/nginx/conf.d/india.amit.com.key;
server_name amit.com;
location / {
root /var/www/html;
index index.html index.htm;
access_log /var/www/html/access.log main;
error_log /var/www/html/error.log;
error_page 404 /404.html;
location = /40x.html {
root /var/www/html/india;
}
}
}
==================================load Balancer=============
upstream prod_backend {
least_conn;
server 192.168.1.10 max_fails=3 fail_timeout=60s;
server 192.168.1.10 max_fails=3 fail_timeout=60s;
}
server {
listen 80;
location / {
proxy_set_header Host $host;
client_max_body_size 120m;
client_max_body_buffer_size 120k;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
proxy_pass http://prod_backend;
}
}
}
=======================revorce proxy================================
server {
listen 80;
server_name india.amit.com;
}
location/ {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header X-Forwarded-Host $host;
# proxy_set_header X-Forwarded-Port $server_port;
}
###################### tomcat redirect to nginx===============
server {
server_name blog.amit.com;
rewrite ^/(.*)$/department2/$1; # for only redirect website
location /{
proxy_pass http://127.0.0.1:8282;
}
}
Friday, May 8, 2020
Install aws and Terraform and configration on CentOS 7
aws configure
Prerequisites:
You must ensure that you have at least Python 2 version 2.6.5+ or Python 3 version 3.3+ installed.
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
Once the package in unzipped, you can run the installation:
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Using the -b option allows all users to use the AWS CLI from any directory, meaning you will not need to specify the install directory in the user’s $PATH variable
The default output format specifies how the results are formatted. Values that can be used here include:
json
text
table
$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json
Multipal user
[default]
aws_access_key_id = AKIA5XDQIIYS6
aws_secret_access_key = eOHLpqPt0DQy5pIquRYyFq2+lk6VBNdoGC2f
[mukesh]
aws_access_key_id = AKIA5XDQIIYSZHQPZ
aws_secret_access_key = +x3yuhaARhYeSrgIkYtWwOtE862LfDBhozCv
How to Install Terraform on CentOS 7
To install Terraform on CentOS, start by updating the repository lists:
sudo yum update
You’ll need wget and unzip – if you don’t have them, install them by entering:
sudo yum install wget unzip
Download Terraform from the developer’s website:
sudo wget https://releases.hashicorp.com/terraform/0.12.2/terraform_0.12.2_linux_amd64.zip
Extract the downloaded file:
sudo unzip ./terraform_0.12.2_linux_amd64.zip -d /usr/local/bin
The output confirms that the files are now located in the /usr/local/bin directory.
output showing /usr/local/bin directory
Lastly, verify that Terraform accepts commands:
terraform –v
The system should display Terraform v.0.12.2.
Terraform version v.0.12.2. installed screen
Basic Terraform Usage Tutorial
Terraform is a tool used to manage datacenter infrastructure. That typically means providing access to cloud services like Azure, Amazon Web Services, and so forth. This tutorial will use AWS as an example.
Create a Directory and Configuration File
Enter the following:
mkdir sample
cd sample
Terraform uses a .tf configuration file. Create and edit one by entering:
sudo nano test.tf
Enter the following:
provider "aws" {
region = "us-west-2"
access_key = "access_key"
secret_key = "secret_key"
}
Replace access_key and secret_key with your own AWS keys.
How to Initialize Terraform
To initialize Terraform, enter the following:
terraform init
Thursday, October 31, 2019
Code testing type and used of tools
Code testing
type and use of tools
Stability
Testing is defined as the ability of the product to continue to function, over
time and over its full range of use, without failing or causing failure.
In Stability testing
under cover component
Transaction
Response Times
Hits per
Second
Throughput
Transaction
per second
CPU: CPU percentage utilization spent during a test.
Memory: Memory usage during a test.
Disk: utilization of disk spaces spent during a test.
Stability
Testing comes
under Performance Testing –a technique that is performed to check some of the
quality attributes of Software like stability, reliability, and availability.
Advantage of Stability Testing
- Provide confidence
in the stability of your system under test.
- Ensure
that your system can handle large programs.
- Monitor
the effectiveness of your system.
- Test
system stability under stress.
Tools used for stability testing
- Performance
Tester
- Testing
Anywhere
### https://codingsans.com/blog/code-quality#code_quality
Code quality
is a group of different attributes and requirements, determined and prioritized
by according to business.
Main
attributes of Code quality
Clarity
Maintainable
Documented
Refactored
Well-tested
Extendible
Efficiency
It is not
possible all quality in every product but we can identified according to
characteristics of project.
Tools use for code quality testing
Find Bugs
Checksystle
Sonar Qube
PMD
https://www.guru99.com/code-coverage.html
Code coverage is a
measurement of how many lines/blocks/arcs of your code are executed while the
automated tests are running. In code coverage
system gathers information about the running program
Why use Code Coverage?
- It helps
you to measure the efficiency of test implementation
- It offers
a quantitative measurement.
- It defines
the degree to which the source code has been tested.
Major code coverage methods
- Statement
Coverage
- Decision
Coverage
- Branch
Coverage
- Toggle
Coverage
- FSM
Coverage
Tools use for Code coverage
2.
Cobertura - an open source code coverage tool that
can easily be coupled with JUnit tests to generate reports.
3.
Emma - another - this one we've used for a slightly different
purpose than unit testing. It has been used to generate coverage reports when
the web application is accessed by end-users.
Maven
Few point about maven
Maven: Lifecycle vs. Phase vs. Plugin
vs. Goal
Life
cycle is a sequence of named phases.
Phases
executes sequentially. Executing a phase means executes all previous phases.
Plugin is a collection of goals also
called MOJO (Maven Old Java Object). Most of Maven's
functionality is in plugins. A plugin provides a set of goals that can be
executed using the following syntax:
mvn [plugin-name]:[goal-name]
Goal is the task (action) that is executed.
Maven is based around the central concept of a build lifecycle. There are three built-in build lifecycles: default, clean and site.
The default lifecycle handles your
project deployment
The clean lifecycle handles
project cleaning
The site lifecycle handles the
creation of your project's site documentation

Lifecycle default -> [validate, initialize,
generate-sources, process-sources, generate-resources, process-resources,
compile, process-classes, generate-test-sources, process-test-sources,
generate-test-resources, process-test-resources, test-compile,
process-test-classes, test, prepare-package, package, pre-integration-test,
integration-test, post-integration-test, verify, install, deploy]
Lifecycle clean -> [pre-clean, clean, post-clean]
Lifecycle site -> [pre-site, site, post-site,
site-deploy]


https://stackoverflow.com/questions/26607834/maven-lifecycle-vs-phase-vs-plugin-vs-goal
http://maven.apache.org/ref/3.6.2/maven-core/default-bindings.html
https://stackoverflow.com/questions/16205778/what-are-maven-goals-and-phases-and-what-is-their-difference
https://maven.apache.org/guides/introduction/introduction-to-profiles.html
https://www.baeldung.com/maven-goals-phases
Subscribe to:
Comments (Atom)
















