centos6+jdk1.8.0_141+hadoop2.7.4

一、配置静态网络

vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT="yes"			//修改或插入
BOOTPROTO="static"
IPADDR=192.168.43.101
NETMASK=255.255.255.0
GATEWAY=192.168.43.2

二、ip映射

vi /etc/hosts
192.168.43.101 server1
192.168.43.102 server2
192.168.43.103 server3

三、添加DNS

vi /etc/resolv.cong
nameserver 192.168.43.2	
nameserver 8.8.8.8

四、修改主机名

vi /etc/sysconfig/network
//修改
HOSTNAME=新主机名

重启使主机名生效

五、关闭防火墙

service iptables stop
service iptables status
chkconfig iptables off
chkconfig iptables --list

六、安装ssh

yum install -y openssh-clients

七、创建普通用户hadoop

adduser hadoop
passwd hadoop
su -l hadoop
mkdir software

八、拍摄快照克隆虚拟机并配置网络

虚拟机的复制、快照和克隆

1.拍摄快照

打开VMware,在菜单项选择自己需要复制的虚拟机,不要开机,右键点击或者在菜单栏点击虚拟机选择快照,再点击拍摄快照

centos7上安装Hadoop centos6安装hadoop_大数据


编辑快照名称并保存,这就是一个快照文件了。快照还需要用克隆来组建一个完整的虚拟机,虚拟机的克隆可以看接下来的操作。

centos7上安装Hadoop centos6安装hadoop_大数据_02

  • 虚拟机的克隆:使用快照制作一台虚拟机,有两种选择:一种是依赖于拍摄快照的源虚拟机;一种是完全独立的“副本”

2.克隆虚拟机

步骤如下图:

centos7上安装Hadoop centos6安装hadoop_centos7上安装Hadoop_03


centos7上安装Hadoop centos6安装hadoop_java_04


点击完成后就有一个系的虚拟机的,按照分类来开启虚拟机

同一个虚拟机不能有一样的IP地址,所以需要更改虚拟机配置

3.修改虚拟配置

查看MAC地址
cat /etc/udev/rules.d/70-persistent-net.rules

最后一条为最新的MAC地址,并记住ATTR和NAME的值

centos7上安装Hadoop centos6安装hadoop_hadoop_05

修改MAC地址和IP地址

需要到profile文件中修改最新的MAC地址和网络名称

vi /etc/sysconfig/network-scripts/ifcfg-eth0		//未修改前的“eth0”未更改

centos7上安装Hadoop centos6安装hadoop_大数据_06

修改主机名
vi /etc/sysconfig/network
//改写:
HOSTNAME=新主机名
//重启使修改生效
reboot
验证修改成功

使用ifconfig命令

centos7上安装Hadoop centos6安装hadoop_大数据_07


修改成功

九、设置免密

1.生成公匙

ssh-keygen -t rsa

一直按回车就好

ssh-copy-id server1
ssh-copy-id server2
ssh-copy-id server3

2.检验

ssh server1
exit
ssh server2
exit
ssh server3
exit

十、安装jdk

1.上传jdk安装包

2.解压

tar zxvf jdk包

3.查路径

cd jdk1.8.0_141
pwd

记住路径接下来配置环境需要用到

vi /etc/profile
export JAVA_HOME=/home/hadoop/software/jdk1.8.0_141
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile

4.检验

java -version

十一、安装hadoop-2.7.4

hadoop保存路径:/home/hadoop/software/hadoop-2.7.4

cd software/
tar -zxvf hadoop(按Tab键补全)
cd hadoop-2.7.4/etc/hadoop

修改hadoop-env.sh

vi hadoop-env.sh
//修改
export JAVA_HOME=/home/hadoop/software/jdk1.8.0_141

修改core-site.xml

vi core-site.xml
//插入
<configuration>
        <property>
                <name>fs.defaultFS</name>
        		<value>hdfs://192.168.43.101:9000</value> 
        </property>
        <property>
                <name>hadoop.tmp.dir</name>
                <value>/home/hadoop/software/hadoop-2.7.4/tmp</value>
        </property>
</configuration>

修改hdfs-site.xml

vi hdfs-site.xml
<configuration>
        <property>
             <name>dfs.replication</name>
             <value>2</value>
        </property>
        <property>
             <name>dfs.namenode.name.dir</name>
             <value>/home/hadoop/software/hadoop-2.7.4/tmp/dfs/name</value>
        </property>
        <property>
             <name>dfs.datanode.data.dir</name>
             <value>/home/hadoop/software/hadoop-2.7.4/tmp/dfs/data</value>
        </property>
        <property>
             <name>dfs.namenode.rpc-address</name>
             <value>192.168.43.101:9000</value>
        </property>
        <property>
             <name>dfs.namenode.http-address</name>
             <value>192.168.43.101:50070</value>
        </property>
        <property>
             <name>dfs.namenode.secondary.http-address</name>
             <value>192.168.43.102:50090</value>
        </property>
        <property> 
             <name>dfs.permissions</name> 
             <value>false</value> 
        </property>
</configuration>

修改mapred-site.xml

cp mapred-site.xml.template mapred-site.xml
vi mapred-site.xml
<configuration>
    <!-- 指定mr运行在yarn上 -->
    <property>
       <name>mapreduce.framework.name</name>
       <value>yarn</value>
    </property>
</configuration>

修改yarn-site.xml

vi yarn-site.xml
<configuration>
     <!-- Site specific YARN configuration properties -->
     <property>
           <name>yarn.nodemanager.aux-services</name>
           <value>mapreduce_shuffle</value>
     </property>
     <property>
           <name>yarn.resourcemanager.hostname</name>
           <value>server1</value>
    </property>
    <property>
           <name>yarn.nodemanager.resource.memory-mb</name>
           <value>20480</value>
    </property>
    <property>
	       <name>yarn.nodemanager.resource.cpu-vcores</name>
	       <value>1</value>
    </property>
</configuration>

配置slaves

vi **slaves**
//删除
localhost
//插入
server1
server2
server3

配置环境变量vi /etc/profile

# hadoop
export HADOOP_HOME=/home/hadoop/software/hadoop-2.7.4
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
source /etc/profile

初始化namenode

hdfs namenode -format

启动hadoop集群

方法一:

start-all.sh

方法二:

start-dfs.sh
start-yarn.sh

hdfs在各台机器启动的节点

server1

server2

server3

NameNode

DataNode

DataNode

DataNode

NodeManager

NodeManager

ResourceManager

SecondaryNameNode

NodeManager

Hadoop启动成功后,可以在浏览器中查看相关资源情况:http://192.168.43.101:50070,192.168.43.101是NameNode节点的IP