victorzhzh 2019-12-02
首先保证Zookeeper集群的正常部署,并启动之:
/opt/module/zookeeper-3.4.5/bin/zkServer.sh start
Hadoop集群的正常部署并启动:
/opt/module/hadoop-2.8.4/sbin/start-dfs.sh
/opt/module/hadoop-2.8.4/sbin/start-yarn.sh
解压HBase到指定目录:
tar -zxf /opt/software/hbase-1.3.1-bin.tar.gz -C /opt/module/
需要修改HBase对应的配置文件。
hbase-env.sh修改内容:
export JAVA_HOME=/opt/module/jdk1.8.0_121
export HBASE_MANAGES_ZK=false
提示:如果使用的是JDK8以上版本,注释掉hbase-env.sh的45-47行,不然会报警告
hbase-site.xml修改内容:
<property>
<name>hbase.rootdir</name>
<value>hdfs://master:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.master.port</name>
<value>16000</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>master:2181,slave1:2181,slave2:2181</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/module/zookeeper-3.4.10/zkData</value>
</property>
<property>
<name>hbase.master.maxclockskew</name>
<value>180000</value>
</property>
regionservers:
master
slave1
slave2
由于HBase需要依赖Hadoop,所以替换HBase的lib目录下的jar包,以解决兼容问题:
1) 删除原有的jar:
rm -rf /opt/module/hbase-1.3.1/lib/hadoop-*
rm -rf /opt/module/hbase-1.3.1/lib/zookeeper-3.4.10.jar
2) 拷贝新jar,涉及的jar有:
hadoop-annotations-2.8.4.jar
hadoop-auth-2.8.4.jar
hadoop-client-2.8.4.jar
hadoop-common-2.8.4.jar
hadoop-hdfs-2.8.4.jar
hadoop-mapreduce-client-app-2.8.4.jar
hadoop-mapreduce-client-common-2.8.4.jar
hadoop-mapreduce-client-core-2.8.4.jar
hadoop-mapreduce-client-hs-2.8.4.jar
hadoop-mapreduce-client-hs-plugins-2.8.4.jar
hadoop-mapreduce-client-jobclient-2.8.4.jar
hadoop-mapreduce-client-jobclient-2.8.4-tests.jar
hadoop-mapreduce-client-shuffle-2.8.4.jar
hadoop-yarn-api-2.8.4.jar
hadoop-yarn-applications-distributedshell-2.8.4.jar
hadoop-yarn-applications-unmanaged-am-launcher-2.8.4.jar
hadoop-yarn-client-2.8.4.jar
hadoop-yarn-common-2.8.4.jar
hadoop-yarn-server-applicationhistoryservice-2.8.4.jar
hadoop-yarn-server-common-2.8.4.jar
hadoop-yarn-server-nodemanager-2.8.4.jar
hadoop-yarn-server-resourcemanager-2.8.4.jar
hadoop-yarn-server-tests-2.8.4.jar
hadoop-yarn-server-web-proxy-2.8.4.jar
zookeeper-3.4.10.jar
尖叫提示:这些jar包的对应版本应替换成你目前使用的hadoop版本,具体情况具体分析。
查找jar包举例:
find /opt/module/hadoop-2.8.4/ -name hadoop-annotations*
然后将找到的jar包复制到HBase的lib目录下即可。
ln -s /opt/module/hadoop-2.8.4/etc/hadoop/core-site.xml /opt/module/hbase-1.3.1/conf/core-site.xml
ln -s /opt/module/hadoop-2.8.4/etc/hadoop/hdfs-site.xml /opt/module/hbase-1.3.1/conf/hdfs-site.xml
vi /etc/profile
export HBASE_HOME=/opt/module/hbase-1.3.1
export PATH=$HBASE_HOME/bin:$PATH
source /etc/profile
scp -r /opt/module/hbase-1.3.1/ slave1:/opt/module/
scp -r /opt/module/hbase-1.3.1/slave2:/opt/module/
启动方式1:
bin/hbase-daemon.sh start master
bin/hbase-daemon.sh start regionserver
尖叫提示:如果集群之间的节点时间不同步,会导致regionserver无法启动,抛出ClockOutOfSyncException异常。
启动方式2:
bin/start-hbase.sh
对应的停止服务:
bin/stop-hbase.sh
启动成功后,可以通过“host:port”的方式来访问HBase管理页面,例如:
http://master:16010
环境准备
因为我们后续可能会在操作Hive的同时对HBase也会产生影响,所以Hive需要持有操作HBase的Jar,那么接下来拷贝Hive所依赖的Jar包(或者使用软连接的形式)。记得还有把zookeeper的jar包考入到hive的lib目录下。
#环境变量/etc/profile
$ export HBASE_HOME=/opt/module/hbase-1.3.1
$ export HIVE_HOME=/opt/module/apache-hive-1.2.2-bin
#Shell执行
$ ln -s $HBASE_HOME/lib/hbase-common-1.3.1.jar $HIVE_HOME/lib/hbase-common-1.3.1.jar
$ ln -s $HBASE_HOME/lib/hbase-server-1.3.1.jar $HIVE_HOME/lib/hbase-server-1.3.1.jar
$ ln -s $HBASE_HOME/lib/hbase-client-1.3.1.jar $HIVE_HOME/lib/hbase-client-1.3.1.jar
$ ln -s $HBASE_HOME/lib/hbase-protocol-1.3.1.jar $HIVE_HOME/lib/hbase-protocol-1.3.1.jar
$ ln -s $HBASE_HOME/lib/hbase-it-1.3.1.jar $HIVE_HOME/lib/hbase-it-1.3.1.jar
$ ln -s $HBASE_HOME/lib/htrace-core-3.1.0-incubating.jar $HIVE_HOME/lib/htrace-core-3.1.0-incubating.jar
$ ln -s $HBASE_HOME/lib/hbase-hadoop2-compat-1.3.1.jar $HIVE_HOME/lib/hbase-hadoop2-compat-1.3.1.jar
$ ln -s $HBASE_HOME/lib/hbase-hadoop-compat-1.3.1.jar $HIVE_HOME/lib/hbase-hadoop-compat-1.3.1.jar
同时在hive-site.xml中修改zookeeper的属性,如下:
<property>
<name>hive.zookeeper.quorum</name>
<value>bigdata11,bigdata12,bigdata13</value>
<description>The list of ZooKeeper servers to talk to. This is only needed for read/write locks.</description>
</property>
<property>
<name>hive.zookeeper.client.port</name>
<value>2181</value>
<description>The port of ZooKeeper servers to talk to. This is only needed for read/write locks.</description>
</property>
注意:需要更换hive的lib目录下的
1.phoenix安装包解压缩更换目录
tar -zxvf apache-phoenix-4.14.1-HBase-1.2-bin.tar.gz -C /opt/module
mv apache-phoenix-4.14.1-HBase-1.2-bin phoenix-4.14.1
环境变量vi /etc/profile
#在最后两行加上如下phoenix配置
export PHOENIX_HOME=/opt/module/phoenix-4.14.1
export PATH=$PATH:$PHOENIX_HOME/bin
#使环境变量配置生效
source /etc/profile
将主节点的phoenix包传到从节点
$ scp -r phoenix-4.14.1 :/opt/module
$ scp -r phoenix-4.14.1 :/opt/module
拷贝hbase-site.xml(注)三台都要
cp hbase-site.xml /opt/module/phoenix-4.14.1/bin/
将如下两个jar包,目录在/opt/module/phoenix-4.14.1下,拷贝到hbase的lib目录,目录在/opt/module/hbase-1.3.1/lib/
(注)三台都要
phoenix-4.14.1-HBase-1.3-server.jar
phoenix-core-4.14.1-HBase-1.3.jar
配置好之后重启下hbase。
sqlline.py master:2181