Hadoop1.x分布式安装与配置
(1)虚拟机环境准备
192.168.184.130 hadoopmaster1
192.168.184.131 hadoopslave1
192.168.184.132 hadoopslave2
192.168.184.133 hadoopslave3
(2)配置虚拟机,机器名,host,固定ip,安装java环境
#vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=hadoopmaster1
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NETMASK=255.255.255.0
IPADDR=192.168.184.128
BOOTPROTO=static
ONBOOT=yes
GATEWAY=192.168.1184.2
DNS1=192.168.184.2
PEERDNS=yes
#vi /etc/resolv.conf
nameserver 8.8.8.8
#重启网络服务
# /etc/init.d/network restart
#vi /etc/hosts
192.168.184.130 hadoopmaster1
192.168.184.131 hadoopslave1
192.168.184.132 hadoopslave2
192.168.184.133 hadoopslave3
# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/lib:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin:$PATH
export JAVA_TOOLS=$JAVA_HOME/lib/tools.jar
(3)创建hadoop用户,并配置SSH免密码登录
在每一台机器上执行
#su hadoop
#cd ~
#ssh-keygen -t rsa -P ''
在每一台机器上把以下文件的内容copy到hadoopmaster1机器上
#cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
#chmod 600 ~/.ssh/authorized_keys
#su --切换到root用户
#vi /etc/ssh/sshd_config
RSAAuthentication yes #启用RSA认证
PubkeyAuthentication yes #启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys #公钥文件路径
#su hadoop --切换到hadoop用户
然后把hadoopmaster1的authorized_keys文件copy到hadoopsalve1,hadoopsalve2,hadoopslave3机器上。
#ssh hadoopslave1
如果不需要密码,则表示成功。
(4)配置hadoop
将hadoop-1.0.1.tar.gz放到hadoopmaster1机器上,并解压
/home/hadoop/hadoop-1.0.1
修改配置文件
#vi conf/core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://hadoopmaster1:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/tmp</value>
</property>
</configuration>
修改Hadoop中HDFS的配置,配置的备份方式默认为3。
(备注:replication 是数据副本数量,默认为3,salve少于3台就会报错)
#vi conf/hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<configuration>
修改Hadoop中MapReduce的配置文件,配置的是JobTracker的地址和端口。
#vi conf/mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>http://hadoopmaster1:9001</value>
</property>
</configuration>
配置masters文件
# vi masters
hadoopmaster1
slaves文件(Master主机特有)
# vi slaves
hadoopslave1
hadoopslave2
hadoopslave3
启动hadoop
/home/hadoop/hadoop-1.0.1/bin/hadoop namenode -format
/home/hadoop/hadoop-1.0.1/bin/start-all.sh
/home/hadoop/hadoop-1.0.1/bin/stop-all.sh
/home/hadoop/hadoop-1.0.1/bin/hadoop dfsadmin -report
http://hadoopmaster1:50070/dfshealth.jsp
http://hadoopmaster1:50030/jobtracker.jsp
192.168.184.130 hadoopmaster1
192.168.184.131 hadoopslave1
192.168.184.132 hadoopslave2
192.168.184.133 hadoopslave3
(2)配置虚拟机,机器名,host,固定ip,安装java环境
#vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=hadoopmaster1
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NETMASK=255.255.255.0
IPADDR=192.168.184.128
BOOTPROTO=static
ONBOOT=yes
GATEWAY=192.168.1184.2
DNS1=192.168.184.2
PEERDNS=yes
#vi /etc/resolv.conf
nameserver 8.8.8.8
#重启网络服务
# /etc/init.d/network restart
#vi /etc/hosts
192.168.184.130 hadoopmaster1
192.168.184.131 hadoopslave1
192.168.184.132 hadoopslave2
192.168.184.133 hadoopslave3
# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/lib:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin:$PATH
export JAVA_TOOLS=$JAVA_HOME/lib/tools.jar
(3)创建hadoop用户,并配置SSH免密码登录
在每一台机器上执行
#su hadoop
#cd ~
#ssh-keygen -t rsa -P ''
在每一台机器上把以下文件的内容copy到hadoopmaster1机器上
#cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
#chmod 600 ~/.ssh/authorized_keys
#su --切换到root用户
#vi /etc/ssh/sshd_config
RSAAuthentication yes #启用RSA认证
PubkeyAuthentication yes #启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys #公钥文件路径
#su hadoop --切换到hadoop用户
然后把hadoopmaster1的authorized_keys文件copy到hadoopsalve1,hadoopsalve2,hadoopslave3机器上。
#ssh hadoopslave1
如果不需要密码,则表示成功。
(4)配置hadoop
将hadoop-1.0.1.tar.gz放到hadoopmaster1机器上,并解压
/home/hadoop/hadoop-1.0.1
修改配置文件
#vi conf/core-site.xml
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://hadoopmaster1:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/tmp</value>
</property>
</configuration>
修改Hadoop中HDFS的配置,配置的备份方式默认为3。
(备注:replication 是数据副本数量,默认为3,salve少于3台就会报错)
#vi conf/hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<configuration>
修改Hadoop中MapReduce的配置文件,配置的是JobTracker的地址和端口。
#vi conf/mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>http://hadoopmaster1:9001</value>
</property>
</configuration>
配置masters文件
# vi masters
hadoopmaster1
slaves文件(Master主机特有)
# vi slaves
hadoopslave1
hadoopslave2
hadoopslave3
启动hadoop
/home/hadoop/hadoop-1.0.1/bin/hadoop namenode -format
/home/hadoop/hadoop-1.0.1/bin/start-all.sh
/home/hadoop/hadoop-1.0.1/bin/stop-all.sh
/home/hadoop/hadoop-1.0.1/bin/hadoop dfsadmin -report
http://hadoopmaster1:50070/dfshealth.jsp
http://hadoopmaster1:50030/jobtracker.jsp