Hbase集群部署
Hbase集群部署
机器 | 角色 | hbase进程 | 备注 |
---|---|---|---|
192.168.101.65 | datanode1,namenode,secondaryNameNode | Hmaster | |
192.168.101.66 | datanode2 | HRegionServer | |
192.168.101.67 | datanode3 | HRegionServer |
目录
mkdir /data/application/{app,data,logs,backup,tmp,tools,prometheus} -p
解析
vim /etc/hosts
192.168.101.65 datanode1 namenode secondarynamenode
192.168.101.66 datanode2
192.168.101.67 datanode3
配置免密
ssh-keygen
ssh-copy-id root@IP
安装JDK
tar xvf jdk-8u121-linux-x64.tar.gz -C /data/application/app/
vim /etc/profile
export JAVA_HOME=/data/application/app/jdk1.8.0_121/
export JRE_HOME=/data/application/app/jdk1.8.0_121/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
zookeeper 部署
tar xvf apache-zookeeper-3.8.0-bin.tar.gz -C /data/application/app/
mkdir /data/application/data/zookeeper
配置文件zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/application/data/zookeeper
dataLogDir=/data/application/logs/zookeeper/log
clientPort=2181
server.1=192.168.101.65:2887:3887
server.2=192.168.101.66:2887:3887
server.3=192.168.101.67:2887:3887
autopurge.purgeInterval=1
autopurge.snapRetainCount=5
#192.168.101.65
echo "1" > /data/application/data/zookeeper/myid
#192.168.101.66
echo "2" > /data/application/data/zookeeper/myid
#192.168.101.67
echo "3" > /data/application/data/zookeeper/myid
配置启动文件
vim /usr/lib/systemd/system/zookeeper.service
[Unit]
Description=Zookeeper Server Service
After=network.target
[Service]
Type=forking
UMask=0027
User=root
Group=root
ExecStart=/data/application/app/apache-zookeeper-3.8.0-bin/bin/zkServer.sh start
ExecStop=/data/application/app/apache-zookeeper-3.8.0-bin/bin/zkServer.sh stop
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
vim /data/application/app/apache-zookeeper-3.8.0-bin/bin/zkEnv.sh
JAVA_HOME="/data/application/app/jdk1.8.0_121/"
启动
systemctl start zookeeper
systemctl enable zookeeper
hbase 部署
hadoop 部署
cd /data/application/tools/
tar xvf hadoop-3.2.2.tar.gz -C /data/application/app/
mkdir -p /data/application/app/hadoop-3.2.2/conf/
touch /data/application/app/hadoop-3.2.2/conf/excludes
mkdir -p /data/application/app/hadoop-3.2.2/log/
mkdir -p /data/application/app/hadoop-3.2.2/mapred/log/
mkdir -p /data/application/app/hadoop-3.2.2/pids/
mkdir -p /data/application/data/hadoop/tmp/
mkdir -p /data/application/data/hadoop/hdfs/name/coredata/
mkdir -p /data/application/data/hadoop/hdfs/data-1/coredata/
mkdir -p /data/application/data/hadoop/hdfs/journal/
mkdir -p /data/application/data/hadoop/yarn/local-1/coredata/
mkdir -p /data/application/data/hadoop/namesecondary/coredata
hadoop 添加环境变量
cat << EOF >> /etc/profile
#HADOOP_HOME
export HADOOP_HOME=/data/application/app/hadoop-3.2.2/
export PATH=\$PATH:\$HADOOP_HOME/bin:\$HADOOP_HOME/sbin
export HADOOP_CONF_DIR=/data/application/app/hadoop-3.2.2/conf
EOF
cp -rp /data/application/app/hadoop-3.2.2/etc/hadoop/* /data/application/app/hadoop-3.2.2/conf/
cat << EOF >> /data/application/app/hadoop-3.2.2/conf/hadoop-env.sh
export JAVA_HOME=/data/application/app/jdk1.8.0_121/
export HADOOP_LOG_DIR=/data/application/app/hadoop-3.2.2/log
export HADOOP_PID_DIR=/data/application/app/hadoop-3.2.2/pids
export HADOOP_HEAPSIZE=4096
export HADOOP_OPTS="-Djava.net.preferIPv4Stack=true -XX:+UseCompressedOops -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:+DisableExplicitGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=75 -XX:SoftRefLRUPolicyMSPerMB=0"
EOF
hadoop 配置文件
core-site.xml
cat << EOF > /data/application/app/hadoop-3.2.2/conf/core-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://192.168.101.65</value>
</property>
<property>
<name>ha.zookeeper.quorum</name>
<value>192.168.101.65:2181,192.168.101.66:2181,192.168.101.67:2181</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>file:/data/application/data/hadoop/tmp/</value>
</property>
<property>
<name>hadoop.logfile.size</name>
<value>10000000</value>
</property>
<property>
<name>hadoop.logfile.count</name>
<value>10</value>
</property>
</configuration>
EOF
hdfs-site.xml
cat << EOF > /data/application/app/hadoop-3.2.2/conf/hdfs-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/data/application/data/hadoop/hdfs/name/coredata/</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/data/application/data/hadoop/hdfs/data-1/coredata/</value>
</property>
<property>
<name>dfs.namenode.checkpoint.dir</name>
<value>file:/data/application/data/hadoop/namesecondary/coredata</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.http-address</name>
<value>namenode:50070</value>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>secondarynamenode:50090</value>
</property>
<property>
<name>dfs.hosts.exclude</name>
<value>/data/application/app/hadoop-3.2.2/conf/excludes</value>
</property>
<property>
<name>dfs.namenode.fs-limits.max-directory-items</name>
<value>6400000</value>
</property>
</configuration>
EOF
mapred-site.xml
cat << EOF > /data/application/app/hadoop-3.2.2/conf/mapred-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.jobhistory.address</name>
<value>namenode:10020</value>
</property>
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>namenode:19888</value>
</property>
<property>
<name>mapred.hosts.exclude</name>
<value>/data/application/app/hadoop-3.2.2/conf/excludes</value>
</property>
<!-- Windows commit MapReduce job -->
<property>
<name>mapreduce.app-submission.cross-platform</name>
<value>true</value>
</property>
<!-- 开启任务调度,不同集群拷贝镜像时双方都需加以下参数 -->
<!--
<property>
<name>yarn.app.mapreduce.am.env</name>
<value>HADOOP_MAPRED_HOME=/data/application/app/hadoop-3.2.2</value>
</property>
<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=/data/application/app/hadoop-3.2.2</value>
</property>
<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=/data/application/app/hadoop-3.2.2</value>
</property>
-->
<property>
<name>mapred.child.java.opts</name>
<value>-Xmx4096m</value>
</property>
</configuration>
EOF
yarn-site.xml
cat << EOF > /data/application/app/hadoop-3.2.2/conf/yarn-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>namenode</value>
</property>
<property>
<name>yarn.resourcemanager.address</name>
<value>namenode:8032</value>
</property>
<!-- comma-separated directory for round-robin -->
<property>
<name>yarn.nodemanager.local-dirs</name>
<value>file:/data/application/data/hadoop/yarn/local-1/coredata/</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>8192</value>
</property>
<property>
<name>yarn.nodemanager.vmem-pmem-ratio</name>
<value>2.1</value>
</property>
<property>
<name>yarn.nodemanager.resource.cpu-vcores</name>
<value>8</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>namenode:8088</value>
</property>
<property>
<name>yarn.resourcemanager.nodes.exclude-path</name>
<value>/data/application/app/hadoop-3.2.2/conf/excludes</value>
</property>
</configuration>
EOF
配置slaves
vim /data/application/app/hadoop-3.2.2/conf/workers
datanode1
datanode2
datanode3
hbase 部署
解压
cd /data/application/tools
tar xvf hbase-2.3.5-bin.tar.gz -C /data/application/app/
环境变量
cat << EOF >> /etc/profile
#HBASE_HOME
export HBASE_HOME=/data/application/app/hbase-2.3.5
export PATH=\$PATH:\$HBASE_HOME/bin
export HBASE_CONF_DIR=/data/application/app/hbase-2.3.5/conf
EOF
cat << EOF >> /data/application/app/hadoop-3.2.2/conf/hadoop-env.sh
export HBASE_HOME=/data/application/app/hbase-2.3.5
for f in \$HBASE_HOME/lib/*.jar; do
HADOOP_CLASSPATH=\${HADOOP_CLASSPATH}:\$f
done
EOF
cat << EOF >> /data/application/app/hbase-2.3.5/conf/hbase-env.sh
export JAVA_HOME=/data/application/app/jdk1.8.0_121/
export HBASE_LOG_DIR=/data/application/app/hbase-2.3.5/logs
export HBASE_PID_DIR=/data/application/app/hbase-2.3.5/pids
export HBASE_HEAPSIZE=2G
export HBASE_MANAGES_ZK=false
export HBASE_OPTS="-XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:GCPauseIntervalMillis=100"
export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=50M"
EOF
cp -rp /data/application/app/hbase-2.3.5/conf/ /data/application/app/hbase-2.3.5/conf-bak
配置文件hbase-site.xml
cat << EOF > /data/application/app/hbase-2.3.5/conf/hbase-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://192.168.101.65/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.unsafe.stream.capability.enforce</name>
<value>false</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>192.168.101.65:2181,192.168.101.66:2181,192.168.101.67:2181</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>300000</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
<property>
<name>hbase.regionserver.info.port</name>
<value>60030</value>
</property>
<property>
<name>hbase.regionserver.region.split.policy</name>
<value>org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy</value>
</property>
<property>
<name>hbase.hregion.max.filesize</name>
<value>10737418240</value>
</property>
<property>
<name>hbase.regionserver.handler.count</name>
<value>200</value>
</property>
<property>
<name>zookeeper.znode.parent</name>
<value>/hbase</value>
</property>
<property>
<name>hbase.table.sanity.checks</name>
<value>false</value>
</property>
<property>
<name>hbase.regionserver.wal.codec</name>
<value>org.apache.hadoop.hbase.regionserver.wal.IndexedWALEditCodec</value>
</property>
<property>
<name>phoenix.schema.isNamespaceMappingEnabled</name>
<value>true</value>
</property>
<property>
<name>phoenix.schema.mapSystemTablesToNamespace</name>
<value>true</value>
</property>
</configuration>
EOF
日志参数调整
sed -i 's/hbase.log.maxfilesize=256MB/hbase.log.maxfilesize=16MB/g' /data/application/app/hbase-2.3.5/conf/log4j.properties
sed -i 's/hbase.security.log.maxfilesize=256MB/hbase.security.log.maxfilesize=16MB/g' /data/application/app/hbase-2.3.5/conf/log4j.properties
phoenix
cd /data/application/tools
tar xvf phoenix-hbase-2.3-5.1.2-bin.tar.gz -C /data/application/app/
# 软连接
ln -s /data/application/app/phoenix-hbase-2.3-5.1.2-bin /usr/local/phoenix
#拷贝jar 包
cd /data/application/app/phoenix-hbase-2.3-5.1.2-bin/
cp phoenix-server-hbase-2.3-5.1.2.jar /data/application/app/hbase-2.3.5/lib/
cat << EOF >> /etc/profile
#添加环境变量
export PHOENIX_HOME=/data/application/app/phoenix-hbase-2.3-5.1.2-bin
export PATH=\$PHOENIX_HOME/bin:\$PATH
EOF
指定用户启动
cat << EOF >> /etc/profile
#指定hbase安装用户
export HDFS_NAMENODE_USER=root
export HDFS_DATANODE_USER=root
export HDFS_JOURNALNODE_USER=root
export HDFS_SECONDARYNAMENODE_USER=root
export YARN_RESOURCEMANAGER_USER=root
export YARN_NODEMANAGER_USER=root
export HDFS_ZKFC_USER=root
EOF
启动服务
HDFS 格式化
# 在namenode上格式化
#master 上
hdfs namenode -format
启动hadoop 服务
#master节点
hdfs --daemon start namenode
#core节点
hdfs --daemon start datanode
# master节点
hdfs --daemon start secondarynamenode
# 启动yarn
# master节点
yarn --daemon start resourcemanager
# core节点
yarn --daemon start nodemanager
# master节点
mapred --daemon start historyserver
启动hbase
# master节点
hbase-daemon.sh --config /data/application/app/hbase-2.3.5/conf start master
# core节点
hbase-daemon.sh --config /data/application/app/hbase-2.3.5/conf start regionserver
设置压缩
#所有节点
yum install https://zgxt-uat-4-0-1258776458.cos.ap-beijing.myqcloud.com/package/HBASE-2.3.5/libzstd-1.5.5-1.el7.x86_64.rpm
#查看是否支持压缩 zstd
hadoop checknative
hadoop checknative -a
故障处理
openssl: false Cannot load libcrypto.so
#故障处理
yum -y install openssl-devel
#查看是否支持压缩
hadoop checknative -a