一聚教程网:一个值得你收藏的教程网站

热门教程

CentOS 6.6 安装 Hadoop 集群记录(准备阶段)

时间:2022-06-30 21:07:10 编辑:袖梨 来源:一聚教程网


本次安装选用的是Cloudera Hadoop CDH 5.2.3版本,Cent OS 6.6 的系统,安装流程为非常的不专业。仅供记录,勿参考。

一、安装前准备

1、更新系统

yum update

2、安装JDK

A、下载并安装RPM包

cd /usr/local/src
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm"
rpm -ivh jdk-7u75-linux-x64.rpm

注意事项,由于Oracle有Cookie验证,所以不能直接使用 wget http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.rpm 直接下载,需要采用上述模拟Cookie的方式。

注意:不要使用JDK 1.8 会存在兼容性问题

B、配置环境变量

创建软链接(便于后期升级SDK)


ln -s /usr/java/jdk1.7.0_75 /usr/java/latest

添加环境变量


vim /etc/profile

在profile文件下面追加写入下面信息:


export JAVA_HOME=/usr/java/latest
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
保存退出,执行:


source /etc/profile

3、 梳理安装内容

准备好了三台虚拟机,IP地址分别为:

192.168.150.136
192.168.150.137
192.168.150.138

4、系统配置

A、关闭IPV6


vim /etc/sysctl.conf
在文件中追加如下内容:


#disable ipv6
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

刷新配置文件,使其生效

sysctl -p

确认ipv6是否已经禁用

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

B、关闭防火墙

setenforce 0 #临时禁用,不需要重启
iptables -F #清空iptables
vim /etc/sysconfig/selinux #修改SELINUX=disabled
chkconfig iptables off #重启后永久失效

查看防火墙是否有关闭:


/etc/init.d/iptables status
chkconfig --list

可以看到ip6tables还有开着,执行:


chkconfig ip6tables off

C、hostname的设置


vim /etc/sysconfig/network

将文件中的HOSTNAME=localhost.localdomain,修改为HOSTNAME=h1.hadoop,依次类推。使用命令hostname检查设置使用已经更新,返回的结果还是localhost.localdomain


[root@localhost qw]# hostname
localhost.localdomain

解决方案是使用hostname命令再重新设置一遍:


hostname h1.hadoop

D、hosts的修改


vim /etc/hosts

192.168.150.136 h1.hadoop
192.168.150.137 h2.hadoop
192.168.150.138 h3.hadoop

E、时钟同步

这里选择 h1.hadoop 节点为时钟同步服务器,其他节点为客户端同步时间到该节点。在设置时钟同步前,需要先设置好时区。先看一下机器的时区是否是对的:
date -R

如果不是”+8000”,则要修改时区,

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

安装ntp:

yum install ntp

修改 h1.hadoop 上的配置文件 /etc/ntp.conf

vim /etc/ntp.conf

修改内容为:

# restrict default kod nomodify notrap nopeer noquery
# restrict -6 default kod nomodify notrap nopeer noquery
restrict default nomodify
 
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.150.0 mask 255.255.255.0 nomodify notrap
 
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 127.127.1.0
fudge  127.127.1.0 stratum 10

启动 ntp:

service ntpd start

设置开机启动:

chkconfig ntpd on

客户端设置(设置每小时同步一次时间)

vim /etc/crontab

新增如下内容:


# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
  1  *  *  *  * root ntpdate h1.hadoop && hwclock -w

F、SSH无密码验证配置

创建hadoop用户以便使用专有用户执行相关操作

groupadd hadoop
useradd -g hadoop hadoop
passwd hadoop

因为Hadoop运行过程需要远程管理Hadoop的守护进程,NameNode节点需要通过SSH(Secure Shell)连接各个DataNode节点,停止或启动他们的进程,所以SSH必须是没有密码的,所以我们要把NameNode节点和DataNode节点配制成无密码通信,同理DataNode也需要配置无密码链接NameNode节点。在每一台机器上配置:

在每一台机器上配置:


vim /etc/ssh/sshd_config

修改如下内容:


RSAAuthentication yes # 启用 RSA 认证,
PubkeyAuthentication yes # 启用公钥私钥配对认证方式

给每天机器添加RSA认证:


su hadoop
ssh-keygen -t rsa -P ''

h1.hadoop上操作

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h2.hadoop:/home/hadoop/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h3.hadoop:/home/hadoop/.ssh/authorized_keys

h2.hadoop上操作


cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h1.hadoop:/home/hadoop/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h3.hadoop:/home/hadoop/.ssh/authorized_keys

h3.hadoop上操作


cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h1.hadoop:/home/hadoop/.ssh/authorized_keys
scp /home/hadoop/.ssh/authorized_keys h2.hadoop:/home/hadoop/.ssh/authorized_keys

每台服务器执行:

chmod 400 ~/.ssh/authorized_keys

进行测试


ssh h2.hadoop

G、搭建本地Yum源

新开一台机器,搭建Tegine环境,进行如下设置:


vim /usr/local/nginx/conf/nginx.conf

location / {
root /usr/local/nginx/html; //指定实际目录绝对路径;
autoindex on; //通过设置开启tengine的目录浏览功能
autoindex_exact_size off;
autoindex_localtime on;
}

重启服务


service nginx restart

下载相应的源:

cd /usr/local/nginx/html
wget http://archive.cloudera.com/cdh5/repo-as-tarball/5.3.2/cdh5.3.2-centos6.tar.gz
wget http://archive-primary.cloudera.com/cm5/repo-as-tarball/5.3.2/cm5.3.2-centos6.tar.gz
tar zxvf cdh5.3.2-centos6.tar.gz
打开http://192.168.150.128/cdh/ 就可以看到解压的内容。

使用本地源的方法非常的简单:


vim /etc/yum.repos.d/cloudera-cdh5.repo

添加如下内容:


[cloudera-cdh5]
# Packages for Cloudera's Distribution for Hadoop, Version 5, on RedHat or CentOS 6 x86_64
name=Cloudera's Distribution for Hadoop, Version 5
baseurl=http://192.168.150.128/cdh/5.3.2/
enabled=1
gpgcheck = 0
添加完毕后就可以使用 yum install xxx 进行安装了~

热门栏目