Saturday, August 13, 2022

How to install Java on EC2



*****************************************
How to install Java on EC2
*****************************************





To be continued, In this post, we will see how to install java in EC2


Step 1: Check if java is already installed java version javac -version
Step 2: Update existing packages sudo yum update

Step 3: Make a new directory and switch to directory java
“mkdir java”
“cd java”

Step 3. Now install java on the EC2 server

1. Go to Root Directory
“sudo su”

2. Check if java exist
“java -version”

3. Install java
“yum install java-1.8.0”
It will start installing  java of version 1.8, you can also use the latest tag to install the latest version of java
“yum install java-latest”

4. Check java, if java is installed successfully
“java -version”
You should be able to get the java version successfully.





 

 

 

 

 



How to install docker compose on EC2



******************************************
How to Install docker compose on EC2
******************************************



Here, we will see how to install the docker compose. 

1. Copy the appropriate docker-compose binary from GitHub:
sudo curl -L “https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose”

2.To get the latest version 
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose


3. Fix permissions after download:
“sudo chmod +x /usr/local/bin/docker-compose”

4. Verify if the docker compose successfully installed
“docker-compose version”




















To go to previous post, click on below link

How to install docker on EC2 instance



**************************************
How to install docker on EC2 instance
***************************************



To be continued,
This post will show how to install docker in the Ec2 server.

I have explained two ways here.

1. Install docker on EC2

8. Now let’s see how to install docker on an EC2 instance
    
1. Update the installed packages and package cache on your instance.
“sudo yum update -y”
    - Is this ok (y/d/N) : type ‘Y’ and enter

2. Install the most recent Docker.
“sudo yum install docker -y”

3. Check the docker status if the docker is active or inactive state
“sudo service docker status”

It shows the status as “Inactive(dead)”, That means docker service is not started yet.

4. To start the Docker service, run below command and check status again.
“sudo service docker start”
“sudo service docker status”

After running the above two commands docker service should start and in Active state(running state). To confirm check the below step

5. Let’s check the docker version and available images
“docker --version”


  To check the docker images, run below command.
  “sudo docker images”
  Obviously , there will not be any images running.

6. Add the ec2-user to the docker group so you can execute Docker commands without using sudo as prefix to any command.
“sudo usermod -a -G docker ec2-user”

Now let’s check docker images without using sudo command
“docker images”

Note - In case if you get ‘permission denied’ message because we need to restart ec2 instance so that the changes will of adding ec2-user to docker group changes will be reflected.

8. Restart EC2 instance
“sudo reboot”

9.Now login to ec2 instance again.
“ssh -i DockerisedSeleniumGrid.pem ec2-user@ec2_public_ip_address”

Now check docker images command without using sudo
“docker images”
Because docker service is not started yet, let’s start docker using below command
“sudo service docker start” and the check docke image "docker images". It should work.

10. Check any running container available
“docker ps -a”


Up till here, we have seen how to install docker on EC2. Now we need to install docker compose on EC2
Click on below to check how to do that.

After installing docker compose, We need to install the Java on EC2 in order to run the docker.
To check, click on below link


So far, We have EC2 instance ready and Docker and Java installed in it, Now we will configure selenium Hub and Node using docker-compose file
- This time we will launch EC2 using WinSCP, Download WinSCP
- Launch WinSCP
-Host name "Public ipv4 ip address" of Ec2
-User name as "ec2-user"
-Click on Advance
-
-Click on "OK" ->  Click on Login
-After completing the process user will be able to login to EC2 and see the below screen

- Create a file as I have created,
-Right click -> File -> name the file as docker-compose
-Double click on the file and paste the below content
- Login to Ec2 using command prompt as we did previously.-Envoke the docker-compose file using "docker-compose up"-You can access hu using "EC2 IP address:4445(Port)"
-And you can use the same URL in selenium RemoteDriver
-Selenium Hub will be triggered and Hub will delegate tests to respective node


2. Install docker on EC2

1) Create a AWS ec2 server 
2) $ sudo 
3) # apt-get update 
4) # curl -fsSL https:i!get.docker.com -o get-docker.sh 
5) # sh get-docker.sh 
6) # docker --version 
7) # docker run --name myc1 -d -p 8081:8080 <image name> 

To login to Ec2:

1) Go to the location where the pem file is downloaded
2) Right-click "git bash" (Git bash must be downloaded in the system)
3) You will be inside the Ec2 instance.





To go to previous post, Click here

 

Run Selenium tests on Dockerized Grid on EC2 step by step guide - Part 2

 

*******************************************
Run selenium test on Docker grid on EC2 server
*******************************************




To be continue,



- Select ‘Create new Key pair
- Type Key pair name ‘DockerisedASeleniumGrid
- Click on launch instance
- DockerisedASeleniumGrid.pem will be downloaded automatically to login to EC2 instance using SSH


- Success message
- That means EC2 instance successfully created


6. On EC2 dashboard you can see EC2 instance ID. I have provided name it as ‘Ec2_docker’



7. Now let’s login to EC2 instance using SSH
- Open command prompt
- Go to the location(download) where DockerisedSeleniumGrid.pem file is downloaded.
- Use below command
“ssh -i DockerisedSeleniumGrid.pem ec2-user@ec2_public_ip_address”

If you are able to see Amazon Linux 2 AMI, means you are successfully logged in to your server. - shown below


- Update packages using the command “sudo yum update”


We have successfully created and launch the EC2 successfully, Now our next job is to install docker on EC2. 
Check the below link



To go to previous post, click on below link
























Monday, August 1, 2022

Run Selenium tests on Dockerized Grid on EC2 step by step guide - Part 1




*******************************************
Run selenium test on Docker grid on EC2 server
*******************************************

It’s always being a challenging task to run parallel tests in selenium. To setup parallel run on a single machine we need to set up multiple VM’s which consumes so much memory and leads to problems like given below.
  • Makes test slow.
  • Leads to hanging browser sessions.
  • Sometimes browser crash.
To overcome this issue docker came into picture. Which is super easy solution of running selenium tests on a single machine using Docker.


Here Selenium Hub will be running(in docker) on our system and it will delegate tests to respective nodes. But why to maintain the selenium hub on local machine when we have AWS. So to make it more simpler. We are setting everything up on EC2 server itself. lets EC2 manage everything.

Follow the below steps:

1. Login to Amazon console using IAM user credentials

2. Type EC2 in search bar and Select EC2 option.



3. Select Instances option to check if there is any EC2 instance already running.
As you can see below, there is no instance is running.




4. So, let’s create a new EC2 instance. Click on ‘Launch instances




5. Now select Amazon Linux

- Under that Select "Amazon Linux AMI (HVM) of 64 Arch Server" which is marked as Free tier eligible.

Here, An Amazon Machine Image (AMI) is a master image for the creation of virtual servers -- known as EC2 instances -- in the Amazon Web Services (AWS) environment.


- Select Instance Type as T2.micro – free tier eligible
- Click on Launch Instance (Shown below)

Note – Select only free tier eligible otherwise other AMI type is paid which may cost you if you select other than Free tier eligible AMI.




To continue to next post, click on below link
 

How to install Java on EC2

***************************************** How to install Java on EC2 ***************************************** To be continued, In this post...

All Time Popular Post