Master Slave Configuration in Jenkins

Share via:

Dear Readers,

In this article, we will see the following Master Slave Configuration in Jenkins.

Steps to Follow :

Master Server:
👉Launch Master Server
👉Install Jenkins

Slave Server:
👉Launch Slave Server
👉Create SSH Password Authentication 
👉Install java
👉Generate SSH Key
👉Move the Public SSH Key to Authorized keys
👉Give Permission to the Authorized keys

Master Server:
👉Scan the SSH Key from Slave server and copy to this directory “/var/lib/jenkins/.ssh/”
👉Give permission to file “known_hosts”
👉Logging to Jenkins and Create a Node
👉Create Job and Build Job
👉Verify Console Output

Master Server:

1. Launch Master Server

we need to open SSH,HTTP and 8080 ports.

Please check below link to Launch Linux EC2 Instance.

Launch Master Server

We can see “master” which was created earlier.

2. Install Jenkins 

We can install Jenkins by using below link.

Install Jenkins on AWS EC2  

Slave Server:

1. Launch Slave Server

we need to open SSH,HTTP and 8080 ports.

Please check below link to Launch Linux EC2 Instance.

Launch Slave Server

We can see “Slave” which was created earlier.

.

Connect to slave server through putty 
Update available packages

If you mention -y it will do all the updates automatically otherwise it will wait until hit enter y(yes)

2. Create SSH Password Authentication for Slave Server

Please check below link to create SSH Password Authentication for Slave Server.
SSH Password Authentication for Slave Server

3. Install the Java Package

Verify Version of Java

4. Generate SSH Key

Verify SSH Key

6. Move the Public SSH Key to Authorized keys

Give Permission to the Authorized keys

Master Server:

Go inside the master server

Create a directory /var/lib/jenkins/.ssh  for storing the key

1. Scan the SSH Key from Slave server and copy to this directory “/var/lib/jenkins/.ssh/”

2. Give permission to file “known_hosts”

Make Directory in slave server

3. Logging to Jenkins

Specify username and password for logging to Jenkins.

Click on Manage Jenkins.

Click on Manage Nodes and Clouds.

4. Create New Node

Click on Create a New Node.

Specify Node Name “Slave” and select Permanent Agent and click on ok.

Specify Remote root directory “/home/ec2-user/slave” ,Usage “Use this node as much as possible”,Launch method “Lanch agents via SSH”.

We need to provide slave server public IP in the Host and provide credentials of slave server by clicking add.

Specify slave server username and password and click on Add.

Select root in the credentials and click on Save.

we can see the slave node has created successfully.

5. Create a Job

Go to Jenkins dashboard ,click on New item.

Specify item name “Slave-Test” and select Free style project and click Ok.

Go to Build and mention Linux command in the Execute shell and click on Save.

6. Build the job 

Click on Build Now.

we can see the blue ball means the build has done succussfully.

 

 

Verify Console Output

Go to build ball and click on that to see the console output.

We can see the console output.

Here we can see the build has done in the slave server and workspace has created with jobname ” /home/ec2-user/slave/workspace/Slave-Test”

 

 

Thank you for giving your valuable time to read the above information.
Follow us on 
Website  www.ktexperts.com
Facebook Page KTexperts
Linkedin Page : KT EXPERTS

Follow Me
Ramesh’s Linkedin : Ramesh Atchala

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment