Create a Hadoop Cluster Using Ansible

Cluster Using Name Node-
- hosts: 192.168.0.187
tasks:
- name:
copy:
src: hadoop-1.2.1-1.x86_64.rpm
dest: /root/hadoop-1.2.1-1.x86_64.rpm

- name:
copy:
src: jdk-8u171-linux-x64.rpm
dest: /root/jdk-8u171-linux-x64.rpm

- name: Install package
command: rpm -i hadoop-1.2.1-1.x86_64.rpm --force
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0

- name: install package
command: rpm -i jdk-8u171-linux-x64.rpm
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0

- copy:
dest: "/etc/hadoop/hdfs-site.xml"
src: "hdfs-site.xml"

- copy:
dest: "/etc/hadoop/core-site.xml"
src: "core-site.xml"

- file:
state: directory
path: "/nn"

- name: Formating namenode dir
command: echo Y | hadoop namenode -format

- name: starting services
command: hadoop-daemon.sh start namenode

Data Node Cluster-
- hosts: 192.168.0.187
tasks:
- name:
copy:
src: hadoop-1.2.1-1.x86_64.rpm
dest: /root/hadoop-1.2.1-1.x86_64.rpm

- name:
copy:
src: jdk-8u171-linux-x64.rpm
dest: /root/jdk-8u171-linux-x64.rpm

- name: Install package
command: rpm -i hadoop-1.2.1-1.x86_64.rpm --force
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0

- name: install package
command: rpm -i jdk-8u171-linux-x64.rpm
args:
warn: false
register: package_installed
failed_when: false
changed_when: package_installed.rc != 0

- copy:
dest: "/etc/hadoop/hdfs-site.xml"
src: "hdfs-site.xml"

- copy:
dest: "/etc/hadoop/core-site.xml"
src: "core-site.xml"

- file:
state: directory
path: "/dn"

- name: starting services
command: hadoop-daemon.sh start datanode

This commands will help to configure Hadoop and start cluster services using ansible playbook .

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store