版本:
JAVA8
hadoop-3.1.1
hbase-2.0.2
zookeeper-3.4.10
集群配置:hadoop master 主备切换
hbase master 主备切换
zookeeper 三台
hadoop |
SZC-L0136287 |
30.18.176.81 |
hadoop-master1 hbase-master | |||
hadoop |
SZC-L0136288 |
30.18.176.82 |
hadoop-master2 hbase | |||
hadoop |
SZC-L0136289 |
30.18.176.83 |
hadoop hbase ZK (Backup hbase-master) | |||
hadoop |
SZC-L0136321 |
30.18.176.84 |
hadoop hbase ZK | |||
hadoop |
SZC-L0136342 |
30.18.176.86 |
hadoop hbase ZK |
添加 /etc/hosts
30.18.176.81 SZC-L0136287
30.18.176.82 SZC-L0136288
30.18.176.83 SZC-L0136289
30.18.176.84 SZC-L0136321
30.18.176.86 SZC-L0136342
PS:Profile
/etc/profile
需要添加
export JAVA_HOME=/var/hadoop/java
export HADOOP_HOME=/var/hadoop/hadoop
export ZK_HOME=/var/hadoop/zookeeper/
export HBASE_HOME=/var/hadoop/hbase
export PATH=$HBASE_HOME/bin:$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
前期工作:
useradd hadoop //添加hadoop用户
passwd hadoop //设置密码
usermod -a -G hadoop hadoop //添加hadoop用户到hadoop用户组
cat /etc/group |grep hadoop //检查是否添加用户组成功
ps: chown -R hadoop:hadoop ./ //赋予用户组用户某个文件/文件夹的权限
正式步骤:
先在以下机器安装,在通过scp 传输文件程序
hadoop |
SZC-L0136289 |
30.18.176.83 |
hadoop hbase ZK (Backup hbase-master) |
【1】安装java环境
vi /etc/profile
JAVA_HOME=/var/hadoop/jdk1.8.0_11/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
【2】安装zookeeper
1.vi /etc/profile
export ZK_HOME=/var/hadoop/zookeeper/
export PATH=$HBASE_HOME/bin:$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH
2. vi $ZK_HOME/conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/wls/zkdata
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=30.18.176.83:2888:3888
server.2=30.18.176.84:2888:3888
server.3=30.18.176.86:2888:3888
3.更改日志目录
if [ "x${ZOO_LOG_DIR}" = "x" ]
then
ZOO_LOG_DIR="/var/hadoop/zookeeper/logs" //这是日志目录,可以更改
fi
if [ "x${ZOO_LOG4J_PROP}" = "x" ]
then
ZOO_LOG4J_PROP="INFO,CONSOLE"
fi
【3】安装hadoop
vi /etc/profile
export HADOOP_HOME=/var/hadoop/hadoop
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile
需要更改的文件有:mapred-site.xml, workers , core-site.xml, hadoop-env.sh, yarn-env.sh, hdfs-site.xml, yarn-site.xml
mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapreduce.jobhistory.address</name>
<value>30.18.176.81:10020</value> ----------Hadoop master hosts
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>30.18.176.81:19888</value> ----------Hadoop master hosts
</property>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
workers
----五台主机host name
SZC-L0136287
SZC-L0136288
SZC-L0136289
SZC-L0136321
SZC-L0136342
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://anomalycluster</value> ----clusterName
</property>:
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/wls/hadoopdata/tmp</value> ---需要更改
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>30.18.176.83:2181,30.18.176.84:2181,30.18.176.86:2181</value> ---zk Server
</property>
<property>
<name>ha.zookeeper.session-timeout.ms</name>
<value>300000</value>
</property>
<property>
<name>hadoop.http.staticuser.user</name>
<value>hadoop</value>
<description>user</description>
</property>
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>hadoop</value>
<description>Allow the superuser oozie to impersonate any members of the group group1 and group2</description>
</property>
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>*</value>
<description>The superuser can connect only from host1 and host2 to impersonate a user</description>
</property>
<property>
<name>fs.trash.interval</name>
<value>1440</value>
</property>
</configuration>
在hadoop-env.sh , yarn-env.sh 最后一行添加 JAVA 的位置
export JAVA_HOME=/var/hadoop/java
hdfs-site.xml
<configuration>
<property>
<name>dfs.nameservices</name>
<value>anomalycluster</value> ------修改cluster Name
</property>
<property>
<name>dfs.ha.namenodes.anomalycluster</name> ------修改cluster Name
<value>namenode1,namenode2</value> -----主备Master
</property>
<property>
<name>dfs.namenode.rpc-address.anomalycluster.namenode1</name>
<value>SZC-L0136287:9000</value> -------主Master
</property>
<property>
<name>dfs.namenode.http-address.anomalycluster.namenode1</name>
<value>SZC-L0136287:50070</value> -------主Master
</property>
<property>
<name>dfs.namenode.rpc-address.anomalycluster.namenode2</name>
<value>SZC-L0136288:9000</value> -------备Master
</property>
<property>
<name>dfs.namenode.http-address.anomalycluster.namenode2</name>
<value>SZC-L0136288:50070</value> -------备Master
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>
qjournal://SZC-L0136287:8485;SZC-L0136288:8485;SZC-L0136289:8485;SZC-L0136321:8485;SZC-L0136342:8485/anomalycluster -------修改
</value>
</property>
<property>
<name>dfs.client.failover.proxy.provider.anomalycluster</name>
<value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
</property>
<property>
<name>dfs.ha.fencing.methods</name>
<value>sshfence</value>
</property>
<property>
<name>dfs.ha.fencing.ssh.private-key-files</name>
<value>/home/hadoop/.ssh/id_rsa</value>
</property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/wls/hadoopdata/journal</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
<property>
<name>dfs.datanode.max.xcievers</name>
<value>81920</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>30.18.176.83:2181,30.18.176.84:2181,30.18.176.86:2181</value>-----------------
</property>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>/wls/hadoopdata/name</value> ------------
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/wls/hadoopdata/data</value>--------------------
</property>
<property>
<name>dfs.blocksize</name>
<value>268435456</value>
</property>
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
</configuration>
yarn-site.xml
<?xml version="1.0"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
</property>
<property>
<name>yarn.log-aggregation.retain-seconds</name>
<value>259200</value>
</property>
<property>
<name>yarn.resourcemanager.connect.retry-interval.ms</name>
<value>2000</value>
</property>
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>30.18.176.83:2181,30.18.176.84:2181,30.18.176.86:2181</value> ------------
</property>
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>besttonecluster-yarn</value>
</property>
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value> -----------------------
</property>
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>30.18.176.81</value> ---------------------
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>30.18.176.82</value> -------------------------
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>30.18.176.81:8188</value> ---------------------
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>30.18.176.82:8188</value> -----------------------
</property>
<property>
<name>yarn.resourcemanager.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.ha.automatic-failover.embedded</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.ha.automatic-failover.zk-base-path</name>
<value>/yarn-leader-election</value>
</property>
<property>
<name>yarn.resourcemanager.recovery.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.store.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
</property>
<property>
<name>yarn.resourcemanager.zk-state-store.parent-path</name>
<value>/rmstore</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
<property>
<name>yarn.application.classpath</name>
<value>
/var/hadoop/hadoop/etc/hadoop:/var/hadoop/hadoop/share/hadoop/common/lib/*:/var/hadoop/hadoop/share/hadoop/common/*:/var/hadoop/hadoop/share/hadoop/hdfs:/var/hadoop/hadoop/share/hadoop/hdfs/lib/*:/var/hadoop/hadoop/share/hadoop/hdfs/*:/var/hadoop/hadoop/share/hadoop/mapreduce/lib/*:/var/hadoop/hadoop/share/hadoop/mapreduce/*:/var/hadoop/hadoop/share/hadoop/yarn:/var/hadoop/hadoop/share/hadoop/yarn/lib/*:/var/hadoop/hadoop/share/hadoop/yarn/*
</value>
</property>
</configuration>
【4】安装Hbase
vi /etc/profile
export HBASE_HOME=/var/hadoop/hbase
export PATH=$HBASE_HOME/bin:$HADOOP_HOME/bin:$JAVA_HOME/bin:$PATH
source /etc/profile
需要修改的文件有regionservers, hbase-env.sh , hbase-site.xml
当然请把hadoop的core-site.xml , hdfs-site.xml 都到conf 文件夹中
regionservers
SZC-L0136287
SZC-L0136288
SZC-L0136289
SZC-L0136321
SZC-L0136342
hbase-env.sh
#!/usr/bin/env bash
#
#/**
# * Licensed to the Apache Software Foundation (ASF) under one
# * or more contributor license agreements. See the NOTICE file
# * distributed with this work for additional information
# * regarding copyright ownership. The ASF licenses this file
# * to you under the Apache License, Version 2.0 (the
# * "License"); you may not use this file except in compliance
# * with the License. You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LICENSE-2.0
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
# Set environment variables here.
# This script sets variables multiple times over the course of starting an hbase process,
# so try to keep things idempotent unless you want to take an even deeper look
# into the startup scripts (bin/hbase, etc.)
# The java implementation to use. Java 1.8+ required.
# export JAVA_HOME=/usr/java/jdk1.8.0/
export HBASE_HOME=/var/hadoop/hbase -------------------------
# Extra Java CLASSPATH elements. Optional.
export HBASE_CLASSPATH=${HBASE_HOME}/conf ----------------------------------
# The maximum amount of heap to use. Default is left to JVM default.
export HBASE_HEAPSIZE=8G --------------------------------------
# Uncomment below if you intend to use off heap cache. For example, to allocate 8G of
# offheap, set the value to "8G".
# export HBASE_OFFHEAPSIZE=1G
# Extra Java runtime options.
# Below are what we set by default. May only work with SUN JVM.
# For more on why as well as other possible settings,
# see http://hbase.apache.org/book.html#performance
export HBASE_OPTS="$HBASE_OPTS -XX:+UseConcMarkSweepGC"
# Uncomment one of the below three options to enable java garbage collection logging for the server-side processes.
# This enables basic gc logging to the .out file.
# export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
# This enables basic gc logging to its own file.
# If FILE-PATH is not replaced, the log file(.gc) would still be generated in the HBASE_LOG_DIR .
# export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<FILE-PATH>"
# This enables basic GC logging to its own file with automatic log rolling. Only applies to jdk 1.6.0_34+ and 1.7.0_2+.
# If FILE-PATH is not replaced, the log file(.gc) would still be generated in the HBASE_LOG_DIR .
# export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<FILE-PATH> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=512M"
# Uncomment one of the below three options to enable java garbage collection logging for the client processes.
# This enables basic gc logging to the .out file.
# export CLIENT_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
# This enables basic gc logging to its own file.
# If FILE-PATH is not replaced, the log file(.gc) would still be generated in the HBASE_LOG_DIR .
# export CLIENT_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<FILE-PATH>"
...skipping...
# If FILE-PATH is not replaced, the log file(.gc) would still be generated in the HBASE_LOG_DIR .
# export CLIENT_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:<FILE-PATH> -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=512M"
# See the package documentation for org.apache.hadoop.hbase.io.hfile for other configurations
# needed setting up off-heap block caching.
# Uncomment and adjust to enable JMX exporting
# See jmxremote.password and jmxremote.access in $JRE_HOME/lib/management to configure remote password access.
# More details at: http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
# NOTE: HBase provides an alternative JMX implementation to fix the random ports issue, please see JMX
# section in HBase Reference Guide for instructions.
# export HBASE_JMX_BASE="-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
# export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10101"
# export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10102"
# export HBASE_THRIFT_OPTS="$HBASE_THRIFT_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10103"
# export HBASE_ZOOKEEPER_OPTS="$HBASE_ZOOKEEPER_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10104"
# export HBASE_REST_OPTS="$HBASE_REST_OPTS $HBASE_JMX_BASE -Dcom.sun.management.jmxremote.port=10105"
# File naming hosts on which HRegionServers will run. $HBASE_HOME/conf/regionservers by default.
# export HBASE_REGIONSERVERS=${HBASE_HOME}/conf/regionservers
# Uncomment and adjust to keep all the Region Server pages mapped to be memory resident
#HBASE_REGIONSERVER_MLOCK=true
#HBASE_REGIONSERVER_UID="hbase"
# File naming hosts on which backup HMaster will run. $HBASE_HOME/conf/backup-masters by default.
# export HBASE_BACKUP_MASTERS=${HBASE_HOME}/conf/backup-masters
# Extra ssh options. Empty by default.
# export HBASE_SSH_OPTS="-o ConnectTimeout=1 -o SendEnv=HBASE_CONF_DIR"
# Where log files are stored. $HBASE_HOME/logs by default.
# export HBASE_LOG_DIR=${HBASE_HOME}/logs
# Enable remote JDWP debugging of major HBase processes. Meant for Core Developers
# export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8070"
# export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8071"
# export HBASE_THRIFT_OPTS="$HBASE_THRIFT_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8072"
# export HBASE_ZOOKEEPER_OPTS="$HBASE_ZOOKEEPER_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8073"
# A string representing this instance of hbase. $USER by default.
# export HBASE_IDENT_STRING=$USER
# The scheduling priority for daemon processes. See 'man nice'.
# export HBASE_NICENESS=10
# The directory where pid files are stored. /tmp by default.
# export HBASE_PID_DIR=/var/hadoop/pids
# Seconds to sleep between slave commands. Unset by default. This
# can be useful in large clusters, where, e.g., slave rsyncs can
# otherwise arrive faster than the master can service them.
# export HBASE_SLAVE_SLEEP=0.1
# Tell HBase whether it should manage it's own instance of ZooKeeper or not.
export HBASE_MANAGES_ZK=false
# The default log rolling policy is RFA, where the log file is rolled as per the size defined for the
# RFA appender. Please refer to the log4j.properties file to see more details on this appender.
# In case one needs to do log rolling on a date change, one should set the environment property
# HBASE_ROOT_LOGGER to "<DESIRED_LOG LEVEL>,DRFA".
# For example:
# HBASE_ROOT_LOGGER=INFO,DRFA
# The reason for changing default to RFA is to avoid the boundary case of filling out disk space as
# DRFA doesn't put any cap on the log size. Please refer to HBase-5655 for more context.
export JAVA_HOME=/var/hadoop/java -------------------
export HBASE_LOG_DIR=${HBASE_HOME}/logs ----------------------
export HADOOP_HOME=/var/hadoop/hadoop ----------------------
hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://anomalycluster/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/wls/hadoopdata/hbase_tmp</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>SZC-L0136289,SZC-L0136321,SZC-L0136342</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
</configuration>
【5】传送文件夹
1. 传到各台机器的文件夹/文件有
/etc/profile , /ect/hosts , hadoop , hbase , java
2. 传到zookeeper的三台机器: zookeeper
【6】启动程序 zookeeper----hadoop-----hbase
1. zk:
三台机器跑
bin/zkServer.sh start
2.hadoop
只需要在master上跑
sbin/start-dfs.sh
sbin/start-yarn.sh
3. hbase
只需要在master上跑
bin/start-hbase.sh
backup HMaster =====在其他一台机器跑
bin/local-master-backup.sh start 1
最后JPS有
Master: 主备
99072 ResourceManager
96437 JournalNode
98917 DFSZKFailoverController
99684 HRegionServer
98615 NameNode
105798 Jps
98731 DataNode
99183 NodeManager
其他机器:
65793 HRegionServer
67379 HMaster
87682 QuorumPeerMain
93314 JournalNode
65483 NodeManager
71900 Jps
65326 DataNode
Done