Devops

Docker

Technical questions: https://kodekloud.com/community/c/docker-for-beginners/5

hub.docker.com – find applications here

Install docker in ubuntu: https://docs.docker.com/engine/install/ubuntu/

https://docs.docker.com/compose/

https://docs.docker.com/engine/reference/commandline/compose/

https://github.com/dockersamples/example-voting-app

github.com/dockersamples – images files

https://github.com/dockersamples/example-voting-app/tree/main

Docker Engine – what actually happens in back end:
When docker is installed, these 3 are installed actually:
docker cli
rest api
docker demon

namespace – container thinks pid is 1, but system will take the next available pid number.

Docker stores all data by default: /var/lib/docker
=========================
network:
docker network create \
–driver bridge \
–subnet 182.18./16
custom-isolated-network

docker network ls

docker inspect cname – find network details here.

docker run –name=alpine-2 –network=none alpine – Run a container named alpine-2 using the alpine image and attach it to the none network.

===============================
docker run –network=wp-mysql-network -e DB_Host=mysql-db -e DB_Password=******* -p 38080:8080 –name webapp –link mysql-db:mysql-db -d kodekloud/simple-webapp-mysql –
Deploy a web application named webapp using the kodekloud/simple-webapp-mysql image. Expose the port to 38080 on the host.

The application makes use of two environment variable:
1: DB_Host with the value mysql-db.
2: DB_Password with the value ********.
Make sure to attach it to the newly created network called wp-mysql-network.

Also make sure to link the MySQL and the webapp container.
===============================
docker registry:

central repo for all images stored in cloud.

docker login server_name – command is used for Login to a self-hosted registry
============
docker run -d -p 5000:5000 –restart=always –name my-registry registry:2 –

deploying a registry server on our own.
Run a registry server with name equals to my-registry using registry:2 image with host port set to 5000, and restart policy set to always.
Registry server is exposed on port 5000 in the image.
============
docker pull nginx:latest
docker image tag nginx:latest localhost:5000/nginx:latest
docker push localhost:5000/nginx:latest

push image.i.e. nginx:latest to our registry server

To check the list of images pushed , use curl -X GET localhost:5000/v2/_catalog
==========
pull image from our registry – docker pull localhost:5000/nginx

Remove our registry:
docker stop my-registry
docker rm my-registry

===========
move container from virtualbox-to-hyper-v – https://kags.me.ke/post/virtualbox-to-hyper-v/
===========

Container orchestration:
if one fails,

docker service create –replication=100 nodejs

===========
docker swarm: cluster
set up – multiple hosts with docker installed.

1 swarm manager and others are workers

docker swarm init – run this fro swarm manager.
docker swarm join –token <token> – run this from the worker nodes.

create a Docker service with three replicas running a Node.js application:
run this in manager node to : docker service create –replicas=3 nodejs

we can add –network network_name, -p 8080:80 etc in the above command.
===========
Kubernetes:

kubectl run –replicas=100 my-server

node – server/host physical/virtual worker machine
cluster – set of nodes
master node – manage the cluster. info of nodes stored, control pain control installed here.

kubelet – agent makes sure containers in node is running.

kubectl – cli to deploy and manage cluster
kubectl run app_name – deploy app in cluster
kubectl cluster-info – details about cluster
kubectl get nodes – list all nodes part of the cluster.

============================================
YAML:
used to represent data. spacing is very important

Example:
#COMMENT
Servers:
– name: server_name
owner: John
created: 02231993
============================================
Docker compose:
cli tool issue multiple commands easily insead of docker cli
automate commands
easily start up multiple containers simultaniously
connect multiple containers using network

using: docker-compose.yml

Example: What we need:
redis-server – make it using redis image
node-app – make it using Dockerfile in curren directory
map port 8081 to 8081

docker-compose.yml will look like this:
version: ‘3’
services:
redis-server:
image: ‘redis’

node-app:
build: .
ports:
– “4001:8081”
“““““`
“8081:8081” – this is to map port 4001 in local machine to 8081 inside container (for networking)

docker compose will automatically create these 2 containers in same network.
===========
Dockerfile: This file contains instructions for building a Docker image. It defines how your application should be packaged into a Docker container. You can use the docker build command to build an image based on this file.

docker-compose.yml: This file is used for defining and running multi-container Docker applications. It allows you to specify the services, networks, and volumes for your application, making it easier to manage complex setups.

index.js: This is the main JavaScript file for your Node.js application.
It contains the code that will be executed when you run your application.

package.json: This file contains metadata about your Node.js application, including its dependencies and scripts. It’s used by npm (Node Package Manager) to manage and install the required packages and to execute various scripts.
===========
alternative for docker commands in docker compose:
docker run myimage – docker-compose up

docker build .
docker run myimage – docker-compose up –build – for 2 commands in docker cli, this single command is enough. same under docker-compose
================================

docker version

docker run container_name – run a container from an image

docker ps – list running containers

docker ps -a – list all containers including stopped ones.

docker stop container_name- stop a container

docker rm container_name – delete container
===========
docker images – list all available images

docker run -p 8282:8080 webapp-color – Run an instance of the image webapp-color and publish port 8080 on the container to 8282 on the host.

docker run python:3.6 cat /etc/*release* – find base os of image names python from docker images list.

==================
Docker file:

FROM image_name
RUN apk add –update redis
CMD [“redis-server”]

docker build .

docker build -t docker_ID/project_name:version . – Build an image from a Dockerfile and give a image_name
Example: docker build stephengrider/redis:latest .

docker run docker_ID/project_name – run the image you just created

Modify docker file and update “FROM” to change image.
To run the container in the background, add the -d flag.

docker commit -c ‘CMD[“redis-server”]’ cid – Take a snapshot of running container and assign a default command and generate an image.

Dockerfile Commands:
ADD
CMD
ENTRYPOINT
ENV
EXPOSE
FROM
MAINTAINER
RUN
USER
VOLUME
WORKDIR
============

docker rmi image_name – delete an image available.

docker pull image_name – only download, no install

To tag or add a name for a container, use -t

docker run -it centos bash – login to centos container

-v – add volume

docker inspect cname – details about container in json format

docker logs cid – Log of container run

docker run ubuntu cat /etc/*release*

docker run ubuntu:17.10 – Add tag (version of ubuntu)

docker run -d –name webapp image_name – run with container name webapp
““““““““““““““““““““`
docker run:

-i – interactive mode

-d – run in detached mode
docker attach cid – re-attach the container.

-p – port mapping

-t – all text you are entering shows up nicely formatted matter.

–links – command line option to link 2 containers together.

docker run -V my_folder folder_in_docker_container – mount the external directory to a folder inside container. Data stored in my_folder

Env variables:
docker run -e APP_COLOR=blue cname

docker iinspect cname – find env variables set on container already running.

docker run -p 38282:8080 -e APP_COLOR=blue -name blue-app kodekloud/simple-webapp – docker run -p 38282:8080 -e APP_COLOR=blue –name blue-app kodekloud/simple-webapp

Comands and entry points:

Docker run:
docker run image_name

execute additional command in container:
docker exec -it cid command

docker exec -it 8e876e4f9c85 redis-cli
the redis cli opens up.
““““““““““`
Open terminal in container:
docker exec -it 8e876e4f9c85 bash

Other options: bash, sh, zsh, powershell
““““““““““`

======================
docker compose

docker compose – create config file in yaml format caled docker-conpose,yaml
docker compose up – run the docker-compose.yaml file.

–links – command line option to link 2 containers together. uses /etc/hosts to set ip to the applocation.

Docker containers linked with each other example:
docker run -d –name=redis redis
docker run -d –name=db postgres:9.4
docker run -d –name=vote -p 5000:80 –link redis:redis voting-app
docker run -d –name=result -p 5000:80 –link db:db result-app
docker run -d –name=worker –link db:db –link redis:redis worker

docker-conpose.yaml file:
redis:
image: redis

db:
image: postgres:9.4

vote:
image:voting-app
ports:
– 5000:80

result:
image: result-app
ports:
– 5001:80

worker:
image: worker
links:
-redis
– db

▪ docker-compose up – bring up the above entire application stack

-build — if the image is not in docker hub, use this

vote:
build: ./vote
ports:
– 5000:80
depends on:
– redis
all app code are in this folder: vote

docker compose version 2 docker-compose.yml file will be like this-

version:2
services:
redis:
image: redis

db:
image: postgres:9.4

links are no longer needed as a network is setup for the entire app stack

Networks:

redis:
image: redis
networks:
– back-end
db:
image: postgres:9.4
networks:
– back-end
vote:
image:voting-app
networks:
– front-end
result:
image: result-app
networks:
– front-end
worker:
image: worker
networks:
– front-end
– back-end

version 3:
Network is automatically created by docker when the app stack is run using “docker-compose run” command. So, we no longer need links section

docker-conpose.yaml file:

version: “3”
services:

redis:
image: redis

db:
image: postgres:9.4
environment:
POSTGRES_USER: username
POSTGRES_PASSWORD: new_password

vote:
image:voting-app
ports:
– 5000:80

result:
image: result-app
ports:
– 5001:80

worker:
image: worker

result:
image: result-app
ports:
– 5001:80
================================
Volume:

-v $(pwd):/app – this is for volume. map current directory to /app in container.
-v /app/node_modules – bookmark the mode_modules folder
example: docker run -p 3000:3000 -v $(pwd):/app image_id

Kubernetes:

https://kodekloud.com/wp-content/uploads/2021/10/KubernetesForBeginners-MumshadMannambeth-2.pdf

kubectl get pods – list pods

kubectl run nginx –image=nginx – create a new pod with the nginx image

kubectl describe pod pod_name – replace pod_name, used to check the details of the pods.

kubectl delete pod webapp – delete a pod

controller – brain behind kubernetes

Replication controller – helps to run multiple instances of single pod. load balancing. spans across multiple nodes.

replica set – newer technology.
=======================================
rc-definition.yml:

apiVersion: v1
kind: Replicationcontroller
metadata:
name: my-app
labels:
app: myapp
type: frent-end
spec:
tempate:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
– name: nginx-container
image: nginx

replicas: 3


pod-definition.yml:

apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
– name: nginx-container
image: nginx

kubectl create -f rc-definition.yml – create the replication controller
kubectl get replicationcontroller – list of replication controllers.
===========
Replicaset-definition.yml:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-app-replicaset
labels:
app: myapp
type: frent-end
spec:
tempate:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
– name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end

Replicaset-definition.yml:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: my-app-replicaset
labels:
app: myapp
type: frent-end
spec:
tempate:
metadata:
name: myapp-pod
labels:
app: myapp
type: front-end
spec:
containers:
– name: nginx-container
image: nginx
replicas: 3
selector:
matchLabels:
type: front-end

pod-definition.yml:

apiVersion: v1
kind: Pod

kubectl create -f replicaset-definition.yml – create the replication controller
kubectl get replicaset – list of replication controllers.
=====================
kubectl delete replicaset replicaset_name – delete replicaset and underlying PODs.

kubectl replace -f replicaset-definition.yml – replace or change replicaset

kubectl describe replicaset replicaset_name – details of replicaset.

kubectl scale replicaset new-replica-set –replicas=2 – change number of replicaes to 2

kubectl edit replicaset – edit the settings of the replicaset

kubectl create deployment –help – gets options to use under this command.

kubectl create deployment http-frontend –image=httpd:2.4-alpine –replicaes=3 – this creates new deployment with name httpd-frontend, replies 3 , image – httpd:2.4-alpine

kubectl rollout status deployment_name – check status of a deployment after the deployment is run.

kubectl create -f deployment_name –record – instructs kubernetes to record cause of change.
kubectl rollout history deplyment_name – this shows the history of the revisions after the –record command is run.

kubectl edit deployment reployment_name –record – make changes to the code/deployment and record the changes.

kubectl set image deployment deployment_name nginx=nginx:1.18-perl –record – chage nginx image version and record the change.
==========================
Networking:

internal IP address is assigned to a pod
===========================
Services:
kubectl get svc – list all services running.
kubectl describe service service_name – details of a service

To get browser URL: minicube service myapp-service –url

service-definition.yml:

apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
type: NodePort
ports:
– port: 80
targetPort: 80
nodeport: 3004
selector:app: myapp

===========================
AWS EKShttps://docs.aws.amazon.com/eks/latest/userguide/getting-started-console.html

AWS Travis

Creating above application and running using aws beanstalk, travis CI, docker:

AWS Configuration Cheat Sheet

This lecture note is not intended to be a replacement for the videos, but to serve as a cheat sheet for students who want to quickly run thru the AWS configuration steps or easily see if they missed a step. It will also help navigate through the changes to the AWS UI since the course was recorded.

Docker Compose config Update

Make sure to follow the steps in the earlier lecture note to rename your development docker compose file and create a new production compose file:

https://www.udemy.com/course/docker-and-kubernetes-the-complete-guide/learn/lecture/27975358

Create EC2 IAM Instance Profile

1. Go to AWS Management Console

2. Search for IAM and click the IAM Service.

3. Click Roles under Access Management in the left sidebar.

4. Click the Create role button.

5. Select AWS Service under Trusted entity type. Then select EC2 under common use cases.

6. Search for AWSElasticBeanstalk and select the AWSElasticBeanstalkWebTier, AWSElasticBeanstalkWorkerTier and AWSElasticBeanstalkMulticontainerDocker policies. Click the Next button.

7. Give the role the name of aws-elasticbeanstalk-ec2-role

8. Click the Create role button.

Create Elastic Beanstalk Environment

1. Go to AWS Management Console

2. Search for Elastic Beanstalk and click the Elastic Beanstalk service.

3. If you’ve never used Elastic Beanstalk before you will see a splash page. Click the Create Application button. If you have created Elastic Beanstalk environments and applications before, you will be taken directly to the Elastic Beanstalk dashboard. In this case, click the Create environment button. There is now a flow of 6 steps that you will be taken through.

5. You will need to provide an Application name, which will auto-populate an Environment Name.

6. Scroll down to find the Platform section. You will need to select the Platform of Docker. You then must manually change from Docker running on 64bit Amazon Linux 2023 to Docker running on 64bit Amazon Linux 2.

7. Scroll down to the Presets section and make sure that free tier eligible has been selected:

8. Click the Next button to move to Step #2.

9. You will be taken to a Service Access configuration form.

Select Create and use new service role and name it aws-elasticbeanstalk-service-role. You will then need to set the EC2 instance profile to the aws-elasticbeanstalk-ec2-role created earlier (this will likely be auto-populated for you).

10. Click the Skip to Review button as Steps 3-6 are not applicable.

11. Click the Submit button and wait for your new Elastic Beanstalk application and environment to be created and launch.

12. Click the link below the checkmark under Domain. This should open the application in your browser and display a Congratulations message.

Update Object Ownership of S3 Bucket

1. Go to AWS Management Console

2. Search for S3 and click the S3 service.

3. Find and click the elasticbeanstalk bucket that was automatically created with your environment.

4. Click Permissions menu tab

5. Find Object Ownership and click Edit

6. Change from ACLs disabled to ACLs enabled. Change Bucket owner Preferred to Object Writer. Check the box acknowledging the warning.

7. Click Save changes.

Add AWS configuration details to .travis.yml file’s deploy script

1. Set the region. The region code can be found by clicking the region in the toolbar next to your username.

eg: ‘us-east-1’

2. app should be set to the Application Name (Step #4 in the Initial Setup above)

eg: ‘docker’

3. env should be set to the lower case of your Beanstalk Environment name.

eg: ‘docker-env’

4. Set the bucket_name. This can be found by searching for the S3 Storage service. Click the link for the elasticbeanstalk bucket that matches your region code and copy the name.

eg: ‘elasticbeanstalk-us-east-1-923445599289’

5. Set the bucket_path to ‘docker’

6. Set access_key_id to $AWS_ACCESS_KEY

7. Set secret_access_key to $AWS_SECRET_KEY

Create an IAM User

1. Search for the “IAM Security, Identity & Compliance Service”

2. Click “Create Individual IAM Users” and click “Manage Users”

3. Click “Add User”

4. Enter any name you’d like in the “User Name” field.

eg: docker-react-travis-ci

5. Click “Next”

6. Click “Attach Policies Directly”

7. Search for “beanstalk”

8. Tick the box next to “AdministratorAccess-AWSElasticBeanstalk”

9. Click “Next”

10. Click “Create user”

11. Select the IAM user that was just created from the list of users

12. Click “Security Credentials”

13. Scroll down to find “Access Keys”

14. Click “Create access key”

15. Select “Command Line Interface (CLI)”

16. Scroll down and tick the “I understand…” check box and click “Next”

Copy and/or download the Access Key ID and Secret Access Key to use in the Travis Variable Setup.

Travis Variable Setup

1. Go to your Travis Dashboard and find the project repository for the application we are working on.

2. On the repository page, click “More Options” and then “Settings”

3. Create an AWS_ACCESS_KEY variable and paste your IAM access key from step #13 above.

4. Create an AWS_SECRET_KEY variable and paste your IAM secret key from step #13 above.

Deploying App

1. Make a small change to your src/App.js file in the greeting text.

2. In the project root, in your terminal run:

git add.
git commit -m “testing deployment”
git push origin main

3. Go to your Travis Dashboard and check the status of your build.

4. The status should eventually return with a green checkmark and show “build passing”

5. Go to your AWS Elastic Beanstalk application

6. It should say “Elastic Beanstalk is updating your environment”

7. It should eventually show a green checkmark under “Health”. You will now be able to access your application at the external URL provided under the environment name.

GIT

Configure git in local device:
Local device:
ssh-keygen -t rsa -b 4096 -C “host1946@gmail.com”
Add the contents of file git_justin.pub to Github -> Settings -> SSH and GPG keys -> New SSH key or Add SSH key.

eval “$(ssh-agent -s)” ssh-add git_justin
ssh -T git@github.com > test connection.

git init
git config –global user.email “host1946@gmail.com”
git config –global user.name ” Justin Mathew”
git config –global credential.helper store
git config –global credential.https://github.com.username justin23293
git config –global credential.https://github.com.token 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
git commit -m “note”

git remote add origin git@github.com:justin23293/justinmathew.in.git
git remote set-url origin git@github.com:justin23293/justinmathew.in.git
git remote -v >> verify the repo
git add . >> from the folder with contents – add files to staging area
git commit -m >> Commit the changes
git push -u origin master > push changes to remote repo.

========================================
GIT:

git init
git remote add origin https://justinmathew23293@bitbucket.org/bone_digital/restrict-content-pro-campaign-monitor-addon.git
git remote add origin https://justinmathew23293@bitbucket.org/bone_digital/gravity-forms-campaign-monitor-addon.git
git remote remove origin
git remote add origin git@bitbucket.org:bone_digital/restrict-content-pro-campaign-monitor-addon.git
git remote -v

git add .
git commit -m “[chore] Initial Commit”
git push origin master

git config –list
git config –global http.proxy http://justin.m:5sOSW..q89v8M@proxy.inhouse.net:3333/
git config –global http.proxyAuthMethod ‘basic’
git config –global user.email “devops@bone.digital”
git config –global user.name “Justin Mathew”
git config –global http.sslVerify false

environment variable:
eval `ssh-agent`
ssh-add ~/.ssh/
Show environment variable: ssh-add -l
Remove environment valriable: ssh-add -D

force push: git push -f origin master

{
“name”: “restrict-content-pro/restrict-content-pro-campaign-monitor-addon”,
“type”: “wordpress-plugin”
}

Load testing

ulimit -n
ulimit -n 655360
ps aux | grep siege
kill -9 247049
sar -q
sudo ufw disable

Apache jmeter:
apt install default-jdk
java -version
wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.zip
./jmeter -n -t TestPlan.jmx -l results.jtl -e

Siege:
apt install siege
vi /etc/siege/siegerc
cat /root/.siege/siege.conf
siege -c 23000 -t 1M -i -f loadtest.txt
siege -c 23000 -t 1M -i -d 0.5 -r 200 –reps=200 –no-follow

Apache benchmark:
apt install apache2-utils
ab -n 23000 -c 5000 https://www.melbournefoodandwine.com.au/
=============================================================
Siege:

-c [num]: Set the number of concurrent users. Most web servers have less than a couple hundred users trying to access their website at the same time, so setting this to more than a few hundred is often not needed.

-t [num]: Set a time limit for which Siege runs. Siege can run with the modifiers s for seconds, m for minutes, or h for hours. There should be no space between the number and the modifier (-t10s not -t10 s).

-d [num]: Set the delay for each Siege user. Each user is then delayed for a random amount of seconds in between 1 and the set number. The default value is 3.

-i: Used in conjunction with a URLs file, this causes each user to randomly hit one of the URLs, with no predetermined pattern. Similar to real life (the ‘i’ stands for “internet”), where you will not know where site visitors go, not all pages may be hit.

-v: Verbose output. This outputs the results Siege gets in real time before printing the final results.

-f [file]: Run Siege with a file containing a list of URLs that is not the default urls.txt file.

-g [url]: Pull down the HTTP headers.

-l: Generates a log file.

-m “[message]”: Include a message in the log file.

-C: Outputs Siege’s current configuration profile.

-V: Outputs Siege’s version information.

-h: Outputs help information.

root@ip-172-31-22-128:/etc/siege# siege -c 250 -t 1M

{ “transactions”: 5548,
“availability”: 100.00,
“elapsed_time”: 59.26,
“data_transferred”: 93.71,
“response_time”: 1.06,
“transaction_rate”: 93.62,
“throughput”: 1.58,
“concurrency”: 99.59,
“successful_transactions”: 5548,
“failed_transactions”: 0,
“longest_transaction”: 56.82,
“shortest_transaction”: 0.00
}
LOG FILE: /home/ubuntu/loadtest/siege.log
You can disable this log file notification by editing
/root/.siege/siege.conf and changing ‘show-logfile’ to false.
root@ip-172-31-22-128:/etc/siege# cat /home/ubuntu/loadtest/siege.log
2024-01-10 02:12:44, 0, 2.05, 0, -nan, 0.00, 0.00, 0.00, 0, 327
2024-01-10 02:24:18, 0, 2.05, 0, -nan, 0.00, 0.00, 0.00, 0, 245
2024-01-10 02:27:05, 5548, 59.26, 93, 1.06, 93.62, 1.57, 99.59, 5548, 0
root@ip-172-31-22-128:/etc/siege# cat /etc/siege/urls.txt
# URLS file for siege
# —
# Format the url entries in any of the following formats:
# http://www.whoohoo.com/index.html
# http://www/index.html
# www/index.html
# http://www.whoohoo.com/cgi-bin/howto/display.cgi?1013
# Use the POST directive for pages that require it:
# http://www.whoohoo.com/cgi-bin/haha.cgi POST ha=1&ho=2
# or POST content from a file:
# http://www.whoohoo.com/melvin.jsp POST </home/jeff/haha
# http://www.whoohoo.com/melvin.jsp POST <./haha
# You may also set and reference variables inside this file,
# for more information, man urls_txt
# ——————————————————-

“““““““““““““““““““““““““““““““““““““““““““““““““““““
Jmeter: TestPlan.jmx

<?xml version=”1.0″ encoding=”UTF-8″?>
<jmeterTestPlan version=”1.2″ properties=”5.0″ jmeter=”5.4.1 r1853635″>
<hashTree>
<TestPlan guiclass=”TestPlanGui” testclass=”TestPlan” testname=”Test Plan” enabled=”true”>
<stringProp name=”TestPlan.comments”></stringProp>
<boolProp name=”TestPlan.functional_mode”>false</boolProp>
<boolProp name=”TestPlan.tearDown_on_shutdown”>true</boolProp>
<boolProp name=”TestPlan.serialize_threadgroups”>false</boolProp>
<elementProp name=”TestPlan.user_define_classpath” elementType=”Arguments” guiclass=”ArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”TestPlan.user_define_classpath”></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass=”ThreadGroupGui” testclass=”ThreadGroup” testname=”Thread Group” enabled=”true”>
<stringProp name=”ThreadGroup.on_sample_error”>continue</stringProp>
<elementProp name=”ThreadGroup.main_controller” elementType=”LoopController” guiclass=”LoopControlPanel” testclass=”LoopController” testname=”Loop Controller” enabled=”true”>
<boolProp name=”LoopController.continue_forever”>false</boolProp>
<intProp name=”LoopController.loops”>1</intProp>
</elementProp>
<stringProp name=”ThreadGroup.num_threads”>23000</stringProp>
<stringProp name=”ThreadGroup.ramp_time”>3600</stringProp>
<boolProp name=”ThreadGroup.scheduler”>true</boolProp>
<stringProp name=”ThreadGroup.duration”>60</stringProp>
<stringProp name=”ThreadGroup.delay”></stringProp>
</ThreadGroup>
<hashTree>
<ConfigTestElement guiclass=”HttpDefaultsGui” testclass=”ConfigTestElement” testname=”HTTP Request Defaults” enabled=”true”>
<elementProp name=”HTTPsampler.Arguments” elementType=”Arguments” guiclass=”HTTPArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”HTTPSampler.domain”></stringProp>
<stringProp name=”HTTPSampler.port”></stringProp>
<stringProp name=”HTTPSampler.protocol”></stringProp>
<stringProp name=”HTTPSampler.contentEncoding”></stringProp>
<stringProp name=”HTTPSampler.path”></stringProp>
<stringProp name=”HTTPSampler.concurrentPool”>6</stringProp>
<stringProp name=”HTTPSampler.connect_timeout”></stringProp>
<stringProp name=”HTTPSampler.response_timeout”></stringProp>
<stringProp name=”HTTPSampler.follow_redirects”>true</stringProp>
<stringProp name=”HTTPSampler.auto_redirects”>false</stringProp>
<stringProp name=”HTTPSampler.use_keepalive”>true</stringProp>
<stringProp name=”HTTPSampler.DO_MULTIPART_POST”>false</stringProp>
<stringProp name=”HTTPSampler.embedded_url_re”></stringProp>
<stringProp name=”HTTPSampler.connect_timeouts”></stringProp>
<stringProp name=”HTTPSampler.response_timeouts”></stringProp>
<stringProp name=”HTTPSampler.use_multipart_for_http_post”>false</stringProp>
<stringProp name=”HTTPSampler.http_request”>GET</stringProp>
</ConfigTestElement>
<hashTree>
<!– Add HTTP Request Samplers for each URL –>
<HTTPSamplerProxy guiclass=”HttpTestSampleGui” testclass=”HTTPSamplerProxy” testname=”https://mfw.bonestaging.com.au/” enabled=”true”>
<elementProp name=”HTTPsampler.Arguments” elementType=”Arguments” guiclass=”HTTPArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”HTTPSampler.domain”>mfw.bonestaging.com.au</stringProp>
<stringProp name=”HTTPSampler.port”></stringProp>
<stringProp name=”HTTPSampler.protocol”>https</stringProp>
<stringProp name=”HTTPSampler.contentEncoding”></stringProp>
<stringProp name=”HTTPSampler.path”></stringProp>
<stringProp name=”HTTPSampler.method”>GET</stringProp>
</HTTPSamplerProxy>
<hashTree/>

<!– Repeat the above block for each URL –>

</hashTree>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>

““““““““““““““““““““““““““““““““““““““““““““““““““““““““““““““““““““““
Another option:

<?xml version=”1.0″ encoding=”UTF-8″?>
<jmeterTestPlan version=”1.2″ properties=”5.0″ jmeter=”5.4.1″>
<hashTree>
<TestPlan guiclass=”TestPlanGui” testclass=”TestPlan” testname=”Test Plan” enabled=”true”>
<stringProp name=”TestPlan.comments”></stringProp>
<boolProp name=”TestPlan.functional_mode”>false</boolProp>
<boolProp name=”TestPlan.tearDown_on_shutdown”>true</boolProp>
<boolProp name=”TestPlan.serialize_threadgroups”>false</boolProp>
<elementProp name=”TestPlan.user_defined_variables” elementType=”Arguments” guiclass=”ArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”TestPlan.user_define_classpath”></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass=”ThreadGroupGui” testclass=”ThreadGroup” testname=”Thread Group” enabled=”true”>
<stringProp name=”ThreadGroup.on_sample_error”>continue</stringProp>
<elementProp name=”ThreadGroup.main_controller” elementType=”LoopController” guiclass=”LoopControllerGui” testclass=”LoopController” testname=”Loop Controller” enabled=”true”>
<boolProp name=”LoopController.continue_forever”>false</boolProp>
<intProp name=”LoopController.loops”>1</intProp>
</elementProp>
<stringProp name=”ThreadGroup.num_threads”>23000</stringProp>
<stringProp name=”ThreadGroup.ramp_time”>60</stringProp>
<boolProp name=”ThreadGroup.scheduler”>false</boolProp>
<stringProp name=”ThreadGroup.duration”>60</stringProp>
<stringProp name=”ThreadGroup.delay”></stringProp>
</ThreadGroup>
<hashTree>
<ConfigTestElement guiclass=”HttpDefaultsGui” testclass=”ConfigTestElement” testname=”HTTP Request Defaults” enabled=”true”>
<elementProp name=”HTTPsampler.Arguments” elementType=”Arguments” guiclass=”HTTPArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”HTTPSampler.domain”>mfw.bonestaging.com.au</stringProp>
<stringProp name=”HTTPSampler.port”></stringProp>
<stringProp name=”HTTPSampler.protocol”>https</stringProp>
<stringProp name=”HTTPSampler.contentEncoding”></stringProp>
<stringProp name=”HTTPSampler.path”></stringProp>
<stringProp name=”HTTPSampler.concurrentPool”>4</stringProp>
<stringProp name=”HTTPSampler.connect_timeout”></stringProp>
<stringProp name=”HTTPSampler.response_timeout”></stringProp>
</ConfigTestElement>
<hashTree/>
<HTTPSamplerProxy guiclass=”HttpTestSampleGui” testclass=”HTTPSamplerProxy” testname=”Open Home Page” enabled=”true”>
<elementProp name=”HTTPsampler.Arguments” elementType=”Arguments” guiclass=”HTTPArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”HTTPSampler.domain”></stringProp>
<stringProp name=”HTTPSampler.port”></stringProp>
<stringProp name=”HTTPSampler.protocol”></stringProp>
<stringProp name=”HTTPSampler.contentEncoding”></stringProp>
<stringProp name=”HTTPSampler.path”>/</stringProp>
<stringProp name=”HTTPSampler.method”>GET</stringProp>
<boolProp name=”HTTPSampler.follow_redirects”>true</boolProp>
<boolProp name=”HTTPSampler.auto_redirects”>false</boolProp>
<boolProp name=”HTTPSampler.use_keepalive”>true</boolProp>
<boolProp name=”HTTPSampler.DO_MULTIPART_POST”>false</boolProp>
<boolProp name=”HTTPSampler.monitor”>false</boolProp>
<stringProp name=”HTTPSampler.embedded_url_re”></stringProp>
<stringProp name=”HTTPSampler.connect_timeout”></stringProp>
<stringProp name=”HTTPSampler.response_timeout”></stringProp>
</HTTPSamplerProxy>
<hashTree/>
<!– Add more HTTPSamplerProxy elements for each URL you want to test –>
</hashTree>
</hashTree>
<WorkBench guiclass=”WorkBenchGui” testclass=”WorkBench” testname=”WorkBench” enabled=”true”>
<elementProp name=”TestPlan.user_defined_variables” elementType=”Arguments” guiclass=”ArgumentsPanel” testclass=”Arguments” testname=”User Defined Variables” enabled=”true”>
<collectionProp name=”Arguments.arguments”/>
</elementProp>
<stringProp name=”TestPlan.user_define_classpath”></stringProp>
</WorkBench>
<hashTree/>
</hashTree>
</jmeterTestPlan>

Install Apache JMeter:

1. Download JMeter:
• Visit the Apache JMeter download page and download the latest version.

Extract the Archive:
◇ Extract the downloaded archive to a location on your server.

bash

tar -xvf apache-jmeter-<version>.tgz

Navigate to JMeter Bin Directory:
◇ Go to the bin directory within the extracted JMeter directory.

bash

1. cd apache-jmeter-<version>/bin

Run a Basic Test:

1. Start JMeter:
◇ Run the JMeter script.

bash

1. ./jmeter

2. Create a Test Plan:
◇ In JMeter, create a new test plan (File > New Test Plan).

Add a Thread Group:
◇ Right-click on the test plan and add a “Thread Group” (Add > Threads (Users) > Thread Group).

Add Sampler (HTTP Request):
◇ Add an HTTP request sampler (Add > Sampler > HTTP Request) and provide the target URL.

Configure Test Duration and Threads:
◇ In the Thread Group, set the number of threads (concurrent users) and the duration of the test.

Run the Test:
◇ Click the “Run” button to start the test.

Additional Resources:

◇ JMeter Getting Started
◇ JMeter Documentation

JMeter is widely used, well-documented, and has a large user community. It can handle a variety of protocols, making it suitable for testing web applications, APIs, databases, and more.

Yes, Apache JMeter can be used to perform load testing on a server set up with Ubuntu, Nginx, and AWS EC2, regardless of whether it’s managed by SpinupWP. Here’s a general guide on how you can use Apache JMeter to perform load testing:

1. Install Java:

Ensure that Java is installed on your Ubuntu server, as JMeter requires Java to run.
bash

sudo apt update
sudo apt install default-jre

2. Download and Install JMeter:

Follow the steps mentioned earlier to download and install Apache JMeter on your server.

3. Create a Simple Test Plan:

1. Open JMeter by navigating to the bin directory and running ./jmeter.

2. Create a new test plan (File > New Test Plan).

3. Add a Thread Group (Add > Threads (Users) > Thread Group).

4. Add an HTTP Request Sampler (Add > Sampler > HTTP Request) and configure it with the target URL.

5. Configure the Thread Group with the desired number of threads and test duration.

4. Run the Test:

1. Save your test plan (File > Save Test Plan).

2. Click the “Run” button to start the test.

Tips:

• JMeter can generate various types of reports. You can explore the “View Results Tree” or use the “Summary Report” listener to view test results.

• Adjust the test plan based on your specific load testing requirements, such as adding additional samplers, modifying thread group settings, etc.

• Ensure that your server can handle the expected load and that the necessary security measures are in place to prevent unintended consequences.

This general guide should work for servers set up with Ubuntu, Nginx, and AWS EC2. However, it’s important to consider the specifics of your application and test plan when performing load testing. Always be cautious not to overload your server, especially in a production environment.

If you install the default JDK using apt install default-jdk, you can remove it safely when it’s no longer needed. To uninstall the default JDK, you can use the apt remove command. Here’s the process:
1. Remove the JDK:
bash

2. sudo apt remove default-jdk

3. Remove Configuration Files (Optional):
bash

4. sudo apt purge default-jdk

The purge command removes the package along with its configuration files. If you want to completely remove all traces of the package, including configuration files, use the purge option.

5. Autoremove Unused Dependencies:
bash

6. sudo apt autoremove

This command removes any automatically installed but no longer required dependencies.

7. Clean Up:
bash

1. sudo apt clean
sudo apt autoclean

The clean command removes downloaded packages, and autoclean removes outdated .deb files.

By following these steps, you should safely remove the default JDK from your system. Keep in mind that if you have installed other JDK versions or packages, you might need to remove them separately using the apt remove or apt purge commands.

what are the requirements ?
To run Apache JMeter for load testing on your server, you’ll need to ensure that your environment meets certain requirements. Here are the key requirements:
1. Java Runtime Environment (JRE):
◇ JMeter is a Java-based application, so you need to have Java installed on your server.
◇ You can install the default JRE using a package manager like apt on Ubuntu.

bash

sudo apt update
sudo apt install default-jre

Server Access:
◇ You should have SSH access to your server to install and run JMeter.

Network Access:
◇ Ensure that your server has internet access to download JMeter and any necessary plugins or dependencies.

Server Resources:
◇ Depending on the scale of your load test, make sure your server has sufficient resources (CPU, RAM) to handle the load.

Security Considerations:
◇ If you’re conducting load testing on a production server, be aware of the potential impact on the server’s performance and the security implications.

JMeter Installation:
◇ Download and install Apache JMeter on your server. You can download the latest version from the official Apache JMeter website.

bash

1. # Example commands to download and extract JMeter
wget https://downloads.apache.org/jmeter/binaries/apache-jmeter-5.4.1.tgz
tar -xzf apache-jmeter-5.4.1.tgz

2. Test Plan:
◇ Create a test plan using the JMeter GUI or by editing a JMX file directly. The test plan defines the structure of your load test, including threads, samplers, and listeners.

Server Configuration:
◇ Understand the configuration of your server, including the web server (e.g., Nginx), and make any necessary adjustments to handle the expected load.

Remember to adjust the number of threads, test duration, and other settings in your JMeter test plan based on your specific load testing goals and the capacity of your server.
Always perform load testing carefully, especially on production servers, to avoid potential negative impacts on your application and infrastructure.

×