1.关闭防火墙
1.1 查看防火墙状态
service iptables status
1.2 关闭防火墙
service iptables off
1.3 关闭防火墙开机启动
chkconfig iptables off
2.关闭selinux
vi /etc/selinux/config
将 SELINUX=enforcing 改为 SELINUX=disabled
3.ssh免密登陆
ssh-keygen -t rsa
ssh-copy-id hostname
4.解压安装hadoop jdk zookeeper hive
tar -zxvf hadoop-2.7.2.tar.gz -C /opt/soft
tar -zxvf jdk-8u171-linux-x64.tar.gz -C /opt/soft
tar -zxvf zookeeper-3.4.5.tar.gz -C /opt/soft
tar -zxvf apache-hive-3.1.1-bin.tar.gz -C /opt/soft
5.配置hadoop jdk zookeeper hive 环境变量
5.1 打开添加
vi /etc/profile
5.2 添加
# Java Env
export JAVA_HOME=/opt/soft/jdk1.8.0_171
export JRE_HOME=/opt/soft/jdk1.8.0_171/jre
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
# Hadoop Env
export HADOOP_HOME=/opt/soft/hadoop-2.7.2
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
# Zookeeper Env
export ZOOKEEPER_HOME=/opt/soft/zookeeper-3.4.5
export PATH=$PATH:$ZOOKEEPER_HOME/bin
# Hive Env
export HIVE_HOME=/opt/soft/apache-hive-3.1.1-bin
export PATH=$PATH:$HIVE_HOME/bin
5.3 使改动生效
source /etc/profile
6、配置zookeeper
6.1 创建zookeeper的数据及日志存放文件夹
mkdir /opt/soft/zookeeper-3.4.5/zkData
mkdir /opt/soft/zookeeper-3.4.5/logs
6.2 配置zoo.cfg
cd /opt/soft/zookeeper-3.4.5/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
#发送心跳的间隔时间,单位:毫秒
tickTime=2000
#zookeeper保存数据的目录
dataDir=/opt/soft/zookeeper-3.4.5/zkData
#日志目录
dataLogDir=/opt/soft/zookeeper-3.4.5/logs
#端口
clientPort=2181
#leader和follower初始化连接时最长能忍受多少个心跳时间的间隔数
initLimit=5
#leader和follower之间发送消息,响应最长不能超过多少个tickTime的时间长度
syncLimit=2
#zookeeper机器列表
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888
6.3 创建myid文件并写入数据
cd /opt/soft/zookeeper-3.4.5/zkData/
touch myid
echo 1 > myid
7、配置hadoop
7.1 修改core-site.xml
vim core-site.xml
7.2 修改hdfs-site.xml
vim hdfs-site.xml
7.3 修改mapred-site.xml
vim mapred-site.xml
7.4 修改yarn-site.xml
vim yarn-site.xml
7.5 修改slaves文件
vim slaves
8、初始化HA集群
8.1 每台机器启动zookeeper
zkServer.sh start
8.2 在任意一主节点上格式化zookeeper集群
hdfs zkfc -formatZK
8.3 每台机器上启动 journalnode
hadoop-daemon.sh start journalnode
8.4 在主节点格式化HDFS
hadoop namenode -format
8.5 在主节点启动HDFS和YARN
start-dfs.sh
start-yarn.sh
8.6 备用NN同步主NN的元数据信息(master2上执行)
hdfs namenode -bootstrapStandby
8.7 启动备用NN(master2上执行)
hadoop-daemon.sh start namenode
9、日常启动关闭HA集群
9.1 每台机器启动zookeeper
zkServer.sh start
9.2 在主节点启动HDFS和YARN
start-dfs.sh
start-yarn.sh
9.3 关闭HDFS和YARN
stop-all.sh
原文地址:https://www.cnblogs.com/sunburstcc/p/10105177.html