-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhadoop.py
176 lines (131 loc) · 5.91 KB
/
hadoop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import os
os.system("tput setaf 3")
print("\t\t------->HADOOP CLUSTER<-------")
os.system("tput setaf 7")
print("\n")
def HadoopStart():
while(True):
print(
"""
\t\tPress 0: Exit
\t\tPress 1: Installing JAVA JDK
\t\tPress 2: Installing Hadoop Package
\t\tPress 3: Configure NameNode
\t\tPress 4: Configure DataNode
"""
)
choice = int(input("Enter The Choice :-> "))
if choice == 0:
break
if choice == 1:
loc = input("Enter Software location Incluting Package Name :-> ")
os.system("rpm -hiv {} ".format(loc))
if choice == 2:
loc = input("Enter Software location Including Package Name :-> ")
os.system("rpm -hiv {} --force".format(loc))
if choice == 3:
while True:
os.system("tput setaf 3")
print("\t\t --> NameNode <-- ")
os.system("tput setaf 7")
print(
"""
\t\tPress 0: EXIT
\t\tPress 1: Configure Hdfs file
\t\tPress 2: Configure Core file
\t\tPress 3: Format File System
\t\tPress 4: Start Service
\t\tPress 5: Check Service
"""
)
MNchoice = int(input("Enter Choice :-> "))
if MNchoice == 0:
break
if MNchoice == 1:
fs = open("/etc/hadoop/hdfs-site.xml",'w+')
print(fs.write(
"""
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.name.dir</name>
<value>{}</value>
</property>
</configuration>
""".format(input("Enter Folder Name With location "))))
if MNchoice == 2:
fs = open("/etc/hadoop/core-site.xml",'w+')
print(fs.write(
"""
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://0.0.0.0:{}</value>
</property>
</configuration>
""".format(input(" Enter the Port No :-> "))))
if MNchoice == 3:
os.system("hadoop namenode -format")
if MNchoice == 4:
os.system("hadoop-daemon.sh start namenode")
if MNchoice == 5:
os.system("jps")
if choice == 4:
while True:
os.system("tput setaf 3")
print("\t\t --> DataNode <-- ")
os.system("tput setaf 7")
print(
"""
\t\tPress 0: EXIT
\t\tPress 1: Configure Hdfs file
\t\tPress 2: Configure Core file
\t\tPress 3: Start Service
\t\tPress 4: Check Service
"""
)
dNchoice = int(input("Enter Choice :-> "))
if dNchoice == 0:
break
if dNchoice == 1:
x = input(" Enter Folder Name with location :-> ")
os.system("mkdir x")
fs = open("hdfs-site.xml",'w+')
print(fs.write(
"""
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.data.dir</name>
<value>{}</value>
</property>
</configuration>
""".format(x)))
if dNchoice == 2:
masterip = input("Enter NameNode IP :-> ")
masterport = input("Enter Hadoop Service Port NO :-> ")
fs = open("/etc/hadoop/core-site.xml",'w+')
print(fs.write(
"""
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://{}:{}</value>
</property>
</configuration>
""".format(masterip,masterport)))
if dNchoice ==3:
os.system("hadoop-daemon.sh start datanode")
if dNchoice == 4:
os.system("sleep 5")
os.system("jps")