本文以K-Master服务器基础环境配置为例分别演示用户配置、sudo权限配置、网路配置、关闭防火墙、安装JDK工具等。用户需参照以下步骤完成KVMSlave1~KVMSlave3服务器的基础环境配置。
开发环境
硬件环境:CentOS 6.5 服务器4台(一台为Master节点,三台为Slave节点) 软件环境:Java 1.7.0_45、Hadoop-1.2.1
1、安装环境
硬件环境:CentOS 6.5 服务器4台(一台为Master节点,三台为Slave节点)
软件环境:Java 1.7.0_45、hadoop-1.2.1
2、 用户配置
1)添加一个用户
[[email protected] hadoop]$ adduser hadoop #新建hadoop用户
[[email protected] hadoop]$ passwd hadoop #hadoop用户设置密码
2)建工作组
[[email protected] hadoop]$ groupadd hadoop #新建hadoop工作组
3)给已有的用户增加工作组
[[email protected] hadoop]$ usermod -G hadoop hadoop
2、 sudo权限配置
1)新建个用户组admin
[[email protected] hadoop]# groupadd admin
2)将已有用户添加到admin用户组
[[email protected] hadoop]# usermod -G admin,hadoop hadoop
3)赋予修改/etc/sudoers文件写权限
[[email protected] hadoop]# chmod u+w /etc/sudoers
4)编辑/etc/sudoers文件
[[email protected] hadoop]# vi /etc/sudoers
缺省只有一条配置:
root ALL=(ALL) ALL
在下边再加一条配置:
%admin ALL=(ALL) ALL
这样admin用户组就拥有了sudo权限,属于admin用户组的hadoop用户同样拥有了sudo权限。
5)编辑完成后降低权限
[[email protected] hadoop]$ chmod u-w /etc/sudoers
3、 网络配置
1)配置IP地址
详细配置信息如下所示:
[[email protected] hadoop]$ su hadoop #切换为hadoop用户
[[email protected] hadoop]$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR=06:8D:30:00:00:27
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.100.147
PREFIX=24
GATEWAY=192.168.100.1
DNS1=192.168.100.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
UUID=660a57a1-5edf-4cdd-b456-e7e1059aef11
ONBOOT=yes
LAST_CONNECT=1411901185
2)重启网络服务使网络设置生效
[[email protected] hadoop]$ sudo service network restart
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1
[ OK ]
3)测试IP网络配置
通过ifconfig命令查看网络的ip地址,如下信息显示eth0无线网卡的IP地址为192.168.100.147,与上述我们配置的IP地址吻合,表明IP地址配置成功。
[[email protected] ~]$ ifconfig
eth0 Link encap:Ethernet HWaddr 06:8D:30:00:00:27
inet addr:192.168.100.147 Bcast:192.168.100.255 Mask:255.255.255.0
inet6 addr: fe80::48d:30ff:fe00:27/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:59099169 errors:0 dropped:0 overruns:0 frame:0
TX packets:30049168 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12477388443 (11.6 GiB) TX bytes:8811418526 (8.2 GiB)
loLink encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2266013 errors:0 dropped:0 overruns:0 frame:0
TX packets:2266013 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:666482169 (635.6 MiB) TX bytes:666482169 (635.6 MiB)
4)修改Host主机名
[[email protected] hadoop]$ sudo vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=Master
[[email protected] hadoop]$ sudo vi /etc/hosts
127.0.0.1 localhost.localdomain
::1 hdirect30 hdirect30
192.168.100.201 K-Master
5)重启主机使得主机名生效
[[email protected] hadoop]$ sudo reboot
4、 关闭防火墙
在启动前关闭集群中所有机器的防火墙,不然会出现datanode开后又自动关闭。
1)查看防火墙状态
[[email protected] ~]$ sudo service iptables status
iptables: Firewall is not running.
2)关闭防火墙
[[email protected] hadoop]$ sudo service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
3)永久关闭防火墙
[[email protected] hadoop]$ sudo chkconfig iptables off
4)关闭SELINUX
[[email protected] hadoop]$ sudo vi /etc/selinux/config
SELINUX=disabled
5、 安装JDK工具
1)解压
[[email protected] ~]$ scp [email protected]:/home/hadoop/jdk-7u65-linux-x64.rpm .
[[email protected] ~]$ sudo rpm -ivh jdk-7u65-linux-x64.rpm
2)编辑”/etc/profile”文件,在后面添加Java的”JAVA_HOME”、”CLASSPATH”以及”PATH”内容。
[[email protected] ~]$ sudo vim /etc/profile
#JAVA
export JAVA_HOME=/usr/java/jdk1.7.0_65
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
#HADOOP
export HADOOP_HOME=/usr/hadoop-1.2.1
export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_HOME_WARN_SUPPRESS=1
3)使配置文件生效
[[email protected] ~]$ source /etc/profile
更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2015-03/114669p2.htm
--------------------------------------分割线 --------------------------------------
Ubuntu14.04下Hadoop2.4.1单机/伪分布式安装配置教程 http://www.linuxidc.com/Linux/2015-02/113487.htm
CentOS安装和配置Hadoop2.2.0 http://www.linuxidc.com/Linux/2014-01/94685.htm
Ubuntu 13.04上搭建Hadoop环境 http://www.linuxidc.com/Linux/2013-06/86106.htm
Ubuntu 12.10 +Hadoop 1.2.1版本集群配置 http://www.linuxidc.com/Linux/2013-09/90600.htm
Ubuntu上搭建Hadoop环境(单机模式+伪分布模式) http://www.linuxidc.com/Linux/2013-01/77681.htm
Ubuntu下Hadoop环境的配置 http://www.linuxidc.com/Linux/2012-11/74539.htm
单机版搭建Hadoop环境图文教程详解 http://www.linuxidc.com/Linux/2012-02/53927.htm
搭建Hadoop环境(在Winodws环境下用虚拟机虚拟两个Ubuntu系统进行搭建) http://www.linuxidc.com/Linux/2011-12/48894.htm
原文链接:http://www.linuxidc.com/Linux/2015-03/114669.htm