CentOS7下安装hadoop
固定IP
修改文件 /etc/sysconfig/network-scripts/ifcfg-ens33
下面内容为参考
TYPE=Ethernet
BOOTPROTO=static
NM_CONTROLLED=yes
#--------------下面内容根据vmware配置相应变更
IPADDR=192.168.41.199
NETMASK=255.255.255.0
GATEWAY=192.168.41.2
#--------------
DNS1=8.8.8.8
DNS2=114.114.114.114
NAME=ens33
DEVICE=ens33
ONBOOT=yes
重启网络服务 systemctl start network 或 service network restart
查看IP地址 ip addr
4. 设置IP地址映射
vi /etc/hosts
添加Hadoop节点的映射信息
192.168.41.151 master
192.168.41.152 slave1
192.168.41.153 slave2
5. 选择性安装 yum -y install vim ntp
6. 关闭防火墙
#service iptables stop & chkconfig iptables off
systemctl stop firewalld systemctl disable firewalld
禁用SELinux vi /etc/selinux/config 将SELINUX设置为disabled,重启系统后生效
7. 修改hostname
vi /etc/hostname
或者 hostnamectl set-hostname master(主机名称)
8. 安装java1.8版本
tar -zxvf /opt/jdk-8u162-linux-x64.tar.gz -C ./
在 /etc/profile中添加
export JAVA_HOME=/usr/java/jdk1.8.0_162
export PATH=$PATH:$JAVA_HOME/bin:.
执行 source /etc/profile 让配置生效
执行 java -version验证java安装正确
9. poweroff停止虚拟机
然后克隆出slave1和slave2
10. 设置slave1和slave2的IP地址
vi /etc/sysconfig/network-scripts/ifcfg-ens33
11. 设置slave1和slave2的hostname
hostnamectl set-hostname xxxx
12. 设置master机器的ntp配置(可选)
13. 设置slave1和slave2的ntp配置(可选)
14. 在master上配置SSH无密码登录
(1)使用ssh-keygen产生公钥与私钥对。
输入命令“ssh-keygen -t rsa”,接着按三次Enter键
(2)用ssh-copy-id将公钥复制到远程机器中
ssh-copy-id -i /root/.ssh/id_rsa.pub master//依次输入yes,123456(root用户的密码)
ssh-copy-id -i /root/.ssh/id_rsa.pub slave1
ssh-copy-id -i /root/.ssh/id_rsa.pub slave2
(3)验证是否设置无密码登录
依次输入
ssh slave1
ssh slave2
15. 安装hadoop
上传 安装包 后解压 tar -zxvf /opt/hadoop-2.7.1.tar.gz -C /usr/local
15.3. 配置Hadoop
进入目录:
cd /usr/local/hadoop-2.7.1/etc/hadoop/
依次修改下面的文件:
15.4.1 core-site.xml
fs.defaultFS
hdfs://master:8020
hadoop.tmp.dir
/var/log/hadoop/tmp //生成日志目录
15.4.2 hadoop-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_151
电脑中自己的路径:export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_162
15.4.3 hdfs-site.xml
dfs.namenode.name.dir
file:///data/hadoop/hdfs/name
dfs.datanode.data.dir
file:///data/hadoop/hdfs/data
dfs.namenode.secondary.http-address
master:50090
//备份数,缺省为3份
dfs.replication
3
15.4.4 mapred-site.xml
复制cp mapred-site.xml.template mapred-site.xml
mapreduce.framework.name
yarn //配置yarn框架
mapreduce.jobhistory.address
master:10020
mapreduce.jobhistory.webapp.address
master:19888
15.4.5 yarn-site.xml //yarn框架
yarn.resourcemanager.hostname
master
yarn.resourcemanager.address
${yarn.resourcemanager.hostname}:8032
yarn.resourcemanager.scheduler.address
${yarn.resourcemanager.hostname}:8030
yarn.resourcemanager.webapp.address
${yarn.resourcemanager.hostname}:8088
yarn.resourcemanager.webapp.https.address
${yarn.resourcemanager.hostname}:8090
yarn.resourcemanager.resource-tracker.address
${yarn.resourcemanager.hostname}:8031
yarn.resourcemanager.admin.address
${yarn.resourcemanager.hostname}:8033
yarn.nodemanager.local-dirs
/data/hadoop/yarn/local
yarn.log-aggregation-enable
true
yarn.nodemanager.remote-app-log-dir
/data/tmp/logs
yarn.log.server.url http://master:19888/jobhistory/logs/
URL for job history server
yarn.nodemanager.vmem-check-enabled
false
yarn.nodemanager.aux-services
mapreduce_shuffle
yarn.nodemanager.aux-services.mapreduce.shuffle.class
org.apache.hadoop.mapred.ShuffleHandler
yarn.nodemanager.resource.memory-mb
2048
yarn.scheduler.minimum-allocation-mb
512
yarn.scheduler.maximum-allocation-mb
4096
mapreduce.map.memory.mb 2048 mapreduce.reduce.memory.mb 2048 yarn.nodemanager.resource.cpu-vcores 1
15.4.6 yarn-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_151
15.4.7 slaves
删除localhost,添加:
slave1
slave2
拷贝hadoop安装文件到集群slave节点
scp -r /usr/local/hadoop-2.7.1 slave1:/usr/local/
scp -r /usr/local/hadoop-2.7.1 slave2:/usr/local/
15.5.在/etc/profile添加Hadoop路径
export HADOOP_HOME=/usr/local/hadoop-2.7.1
export PATH=$HADOOP_HOME/bin:$PATH
source /etc/profile使修改生效
15.6. 格式化NameNode
进入目录
cd /usr/local/hadoop-2.7.1/bin
执行格式化
./hdfs namenode -format
15.7.启动集群
进入目录
cd /usr/local/hadoop-2.7.1/sbin
执行启动:
./start-dfs.sh
./start-yarn.sh
./mr-jobhistory-daemon.sh start historyserver
使用jps,查看进程
[root@master sbin]# jps
1765 NameNode
1929 SecondaryNameNode
2378 JobHistoryServer
2412 Jps
2077 ResourceManager
[root@slave1 ~]# jps
1844 Jps
1612 DataNode
1711 NodeManager
在Windows下C:\Windows\System32\drivers\etc\hosts添加IP映射
192.168.41.151 master
15.8. 浏览器查看:
http://master:50070
http://master:8088
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~