Hadoop zookeeper HA高可靠集群部署搭建,及错误诊断
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hadoop zookeeper HA高可靠集群部署搭建,及错误诊断相关的知识,希望对你有一定的参考价值。
http://archive-primary.cloudera.com/cdh5/cdh/5/
一.准备工作
1.修改Linux主机名,每台都得配置
[[email protected] ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=h201
2.修改IP /etc/sysconfig/network-scripts/ifcfg-eth0
3.修改主机名和IP的映射关系(h24,h25为主,h21,h22,h23为从)
[[email protected] ~]# vim /etc/hosts
192.168.1.21 h21
192.168.1.22 h22
192.168.1.23 h23
192.168.1.24 h24
192.168.1.25 h25
######注意######如果你们公司是租用的服务器或是使用的云主机(如华为用主机、阿里云主机等)
/etc/hosts里面要配置的是内网IP地址和主机名的映射关系
4.关闭防火墙
#查看防火墙状态
[[email protected] ~]# service iptables status
#关闭防火墙
[[email protected] ~]# service iptables stop
#查看防火墙开机启动状态
[[email protected] ~]# chkconfig iptables --list
#关闭防火墙开机启动
[[email protected] ~]# chkconfig iptables off
5台机器 创建hadoop 用户
[[email protected] ~]# useradd hadoop
[[email protected] ~]# passwd hadoop
hadoop 密码:123456
前4步用root用户操作,操作完后重启机器
5.ssh免登陆hadoop用户操作
[[email protected] ~]# su - hadoop
#生成ssh免登陆密钥
#进入到我的home目录
cd ~/.ssh
ssh-keygen -t rsa (四个回车)
执行完这个命令后,会生成两个文件id_rsa(私钥)、id_rsa.pub(公钥)
将公钥拷贝到要免密登陆的目标机器上
[[email protected] ~]$ ssh-keygen -t rsa
[[email protected] ~]$ ssh-keygen -t rsa
[[email protected] ~]$ ssh-keygen -t rsa
[[email protected] ~]$ ssh-keygen -t rsa
[[email protected] ~]$ ssh-keygen -t rsa
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h21
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h22
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h23
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h24
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h25
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h21
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h22
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h23
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h24
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h25
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h21
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h22
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h23
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h24
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h25
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h21
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h22
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h23
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h24
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h25
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h21
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h22
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h23
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h24
[[email protected] ~]$ ssh-copy-id -i /home/hadoop/.ssh/id_rsa.pub h25
6.安装JDK,配置环境变量等root用户操作( //根据自己的路金配置)
卸载系统之前jdk版本(便于已安装的jdk生效)
[[email protected] ~]$rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
[[email protected] tmp]# tar -zxvf jdk-7u25-linux-i586.tar.gz -C /usr/local
[[email protected] ~]# vim /etc/profile 或者在用户下 vim .bash_profile
export JAVA_HOME=/usr/local/jdk1.7.0_25
export HADOOP_HOME=/usr/local/hadoop-2.6.0
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
source /etc/profile 或者 source .bash_profile
查看java版本
[[email protected] ~]# java -version
————————————————————————————————
(/etc/bashrc
export JAVA_HOME=/usr/jdk1.7.0_25
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$PATH)
————————————————————————————————
二.集群规划:
主机名 IP 安装软件 运行进程
h24 192.168.1.24:jdk、hadoop
namenode resourcemanage
DFSZKFailoverController(zkfc)
h25 192.168.1.25:jdk、hadoop
namenode resourcemanage
DFSZKFailoverController(zkfc)
h21 192.168.1.21:jdk、hadoop、zookeeper
datanode nodemanage
journalnode QuorumPeerMain
h22 192.168.1.22:jdk、hadoop、zookeeper
datanode nodemanage
journalnode QuorumPeerMain
h23 192.168.1.23:jdk、hadoop、zookeeper
datanode nodemanage
journalnode QuorumPeerMain
三.安装步骤:
1.安装配置zooekeeper集群(在hadoop-server3上)
1.1解压
[[email protected] tmp]# tar zxvf zookeeper-3.4.5-cdh5.5.2.tar.gz -C /usr/local/
1.2修改配置
[[email protected] tmp]# cd /usr/localzookeeper-3.4.5/conf/
[[email protected] conf]# cp zoo_sample.cfg zoo.cfg
[[email protected] conf]# vim zoo.cfg
修改添加:
dataDir=/usr/local/zookeeper-3.4.5-cdh5.5.2/data
dataLogDir=/usr/local/zookeeper-3.4.5-cdh5.5.2/log
在最后添加:
server.1=192.168.1.23:2888:3888
server.2=192.168.1.24:2888:3888
server.3=192.168.1.25:2888:3888
保存退出
然后创建一个data文件夹
[[email protected] ~]# cd /usr/local/zookeeper-3.4.5-cdh5.5.2/
[[email protected] zookeeper-3.4.5-cdh5.5.2]# mkdir -pv data log
再创建一个空文件
touch /usr/localzookeeper-3.4.5/data/myid
最后向该文件写入ID
echo 1 > /usr/localzookeeper-3.4.5/data/myid
1.3将配置好的zookeeper拷贝到其他节点
[[email protected] ~]# scp -r /usr/localzookeeper-3.4.5/ h22:/usr/local
[[email protected] ~]# scp -r /usr/localzookeeper-3.4.5/ h23:/usr/local
注意:修改hadoop-server4、hadoop-server5对应/usr/localzookeeper-3.4.5/data/myid内容
hadoop-server4:
echo 2 > /usr/localzookeeper-3.4.5/data/myid
hadoop-server5:
echo 3 > /usr/localzookeeper-3.4.5/data/myid
2.安装配置hadoop集群(在hadoop-server1上操作)
2.1解压
[[email protected] tmp]# tar -zxvf hadoop-2.6.0-cdh5.5.2.tar.gz -C /usr/local/
mv hadoop-2.6.0-cdh5.5.2 hadoop-2.6.0
2.2配置HDFS(hadoop2.0所有的配置文件都在$HADOOP_HOME/etc/hadoop目录下)
#将hadoop添加到环境变量中
vim /etc/profile或者在用户下 vim .bash_profile
export JAVA_HOME=/usr/local/jdk1.7.0_25
export HADOOP_HOME=/usr/local/hadoop-2.6.0
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin
#hadoop2.0的配置文件全部在$HADOOP_HOME/etc/hadoop下
[[email protected] local]# cd /usr/local/hadoop-2.6.0/etc/hadoop
2.2.1修改vim hadoop-env.sh
export JAVA_HOME=/usr/local/jdk1.7.0_25
2.2.2修改vim core-site.xml
<configuration>
以上是关于Hadoop zookeeper HA高可靠集群部署搭建,及错误诊断的主要内容,如果未能解决你的问题,请参考以下文章
七Hadoop3.3.1 HA 高可用集群QJM (基于Zookeeper,NameNode高可用+Yarn高可用)
最新Hadoop-2.7.2+hbase-1.2.0+zookeeper-3.4.8 HA高可用集群配置安装