华为MRS部署开源Phoenix
【摘要】 华为公有云大数据平台MRS默认不支持Phoenix,此文档介绍如何将开源Phoenix集成到MRS中,以便在HBase中使用SQL。
1.下载安装包
MRS 2.0 对应的Phoenix版本 5.0.0-HBase-2.0
https://phoenix.apache.org/download.html
wget https://mirror.bit.edu.cn/apache/phoenix/apache-phoenix-5.0.0-HBase-2.0/bin/apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz
2.上传到master节点
登陆任一master节点
上传到/opt目录
# 进入opt目录 cd /opt # 解压 tar zxvf apache-phoenix-5.0.0-HBase-2.0-bin.tar.gz # 授权 chown -R omm:wheel apache-phoenix-5.0.0-HBase-2.0-bin
3.安装phoenix
# 切换omm用户 su - omm cd /opt/apache-phoenix-5.0.0-HBase-2.0-bin touch installPhoenixJar.sh chmod 755 installPhoenixJar.sh # installPhoenixJar.sh的内容 # ============================ #!/bin/bash PHOENIX_HBASE_VERSION=$1 shift MRS_VERSION=$1 shift IPs=$1 shift check_cmd_result() { echo "executing command: $*" str="$@" if [ ${#str} -eq 7 ]; then echo "please check input args, such as, sh installPhoenixJar.sh 5.0.0-HBase-2.0 2.0.1 xx.xx.xx.xx,xx.xx.xx.xx,xx.xx.xx.xx" exit 1 fi if ! eval $* then echo "Failed to execute: $*" exit 1 fi } check_cmd_result [ -n "$PHOENIX_HBASE_VERSION" ] check_cmd_result [ -n "$MRS_VERSION" ] check_cmd_result [ -n "$IPs" ] if [ ${MRS_VERSION}X = "1.8.5"X ]; then MRS_VERSION="1.8.3" fi if [[ ${MRS_VERSION} =~ "1.6" ]]; then WORKDIR="FusionInsight" elif [[ ${MRS_VERSION} =~ "1.7" ]]; then WORKDIR="MRS" else WORKDIR="MRS_${MRS_VERSION}/install" fi check_cmd_result HBASE_LIBDIR=$(ls -d /opt/Bigdata/${WORKDIR}/FusionInsight-HBase-*/hbase/lib) # copy jars to local node. check_cmd_result cp phoenix-${PHOENIX_HBASE_VERSION}-server.jar ${HBASE_LIBDIR} check_cmd_result cp phoenix-core-${PHOENIX_HBASE_VERSION}.jar ${HBASE_LIBDIR} check_cmd_result chmod 700 ${HBASE_LIBDIR}/phoenix-${PHOENIX_HBASE_VERSION}-server.jar check_cmd_result chmod 700 ${HBASE_LIBDIR}/phoenix-core-${PHOENIX_HBASE_VERSION}.jar check_cmd_result chown omm:wheel ${HBASE_LIBDIR}/phoenix-${PHOENIX_HBASE_VERSION}-server.jar check_cmd_result chown omm:wheel ${HBASE_LIBDIR}/phoenix-core-${PHOENIX_HBASE_VERSION}.jar if [[ "$MRS_VERSION" =~ "2." ]]; then check_cmd_result rm -rf ${HBASE_LIBDIR}/htrace-core-3.1.0-incubating.jar check_cmd_result rm -rf /opt/client/HBase/hbase/lib/joda-time-2.1.jar check_cmd_result ln -s /opt/share/htrace-core-3.1.0-incubating/htrace-core-3.1.0-incubating.jar \ ${HBASE_LIBDIR}/htrace-core-3.1.0-incubating.jar check_cmd_result ln -s /opt/share/joda-time-2.1/joda-time-2.1.jar /opt/client/HBase/hbase/lib/joda-time-2.1.jar fi # copy jars to other nodes. localIp=$(hostname -i) ipArr=($(echo "$IPs" | sed "s|\,|\ |g")) for ip in ${ipArr[@]} do if [ "$ip"X = "$localIp"X ]; then echo "skip copying jar to local node." continue fi check_cmd_result scp ${HBASE_LIBDIR}/phoenix-${PHOENIX_HBASE_VERSION}-server.jar ${ip}:${HBASE_LIBDIR} check_cmd_result scp ${HBASE_LIBDIR}/phoenix-core-${PHOENIX_HBASE_VERSION}.jar ${ip}:${HBASE_LIBDIR} 2>./install.log if [[ "$MRS_VERSION" =~ "2." ]]; then check_cmd_result ssh $ip "rm -rf ${HBASE_LIBDIR}/htrace-core-3.1.0-incubating.jar" 2>./install.log check_cmd_result ssh $ip "rm -rf /opt/client/HBase/hbase/lib/joda-time-2.1.jar" 2>./install.log check_cmd_result ssh $ip "ln -s /opt/share/htrace-core-3.1.0-incubating/htrace-core-3.1.0-incubating.jar \ ${HBASE_LIBDIR}/htrace-core-3.1.0-incubating.jar" 2>./install.log check_cmd_result ssh $ip "ln -s /opt/share/joda-time-2.1/joda-time-2.1.jar /opt/client/HBase/hbase/lib/joda-time-2.1.jar" 2>./install.log fi done echo "installing phoenix jars to hbase successfully..." # ============================ # 执行安装 # sh installPhoenixJar.sh <PHOENIX_HBASE_VERSION> <MRS_VERSION> <IPs> # MRS_VERSION,查看命令:cat /opt/VERSION # IP为HBase安装节点的IP,即所有Master和Core节点的IP,并以当前集群实际IP为准,见下图 sh installPhoenixJar.sh 5.0.0-HBase-2.0 2.1.0 192.168.0.8,192.168.0.225,192.168.0.30,192.168.0.139 #Huawei@123
查看节点的IP
安装成功提示
4.重启MRS的hbase服务
登陆mrs
https://121.36.107.***:9022/mrsmanager/index.jsp
找到hbase服务
点击“重启服务”
再次输入密码
勾选“重启所有上层服务”
服务重启中
服务重启完成
5.安装MRS客户端
登陆mrs
https://121.36.107.***:9022/mrsmanager/index.jsp
下载客户端
点击确定 下载
下载后在服务器公网IP就是managerIP:121.36.107.***
如果需要安装在其他服务器,请确保服务器的CPU类型要和集群的CPU类型保持一致,否则会安装不成功。
查看CPU类型
uname -a
x86服务器:
arm服务器:
以本机安装为例,安装客户端:
cd /tmp/MRS-client tar xf MRS_Services_Client.tar tar xf MRS_Services_ClientConfig.tar # 进入安装目录 cd MRS_Services_ClientConfig # 执行安装,后面的参数必须是不存在的目录,或者是为空的目录 sh install.sh /opt/mrs_client
安装完成提示:
6.配置phoenix客户端(开启Kerberos认证集群需要配置)
前置条件:安装MRS客户端
修改两处:
1、配置文件 hbase-site.xml
2、启动程序 sqlline.py
# 从客户端中找 hbase-site.xml find /opt/mrs_client -name "hbase-site.xml" -exec ls -ltr {} \; # 获取对应的参数值 [root@node-master1BEIl ~]# grep "kerberos.principal" /opt/mrs_client/HBase/hbase/conf/hbase-site.xml -A1 <name>hbase.regionserver.kerberos.principal</name> <value>hbase/hadoop.5c565581_5f7d_4659_8bef_34597a016ec1.com@5C565581_5F7D_4659_8BEF_34597A016EC1.COM</value> -- <name>hbase.master.kerberos.principal</name> <value>hbase/hadoop.5c565581_5f7d_4659_8bef_34597a016ec1.com@5C565581_5F7D_4659_8BEF_34597A016EC1.COM</value> -- <name>hbase.thrift.kerberos.principal</name> <value>thrift/hadoop.5c565581_5f7d_4659_8bef_34597a016ec1.com</value> # 键 hbase.regionserver.kerberos.principal 和 hbase.master.kerberos.principal #对应的值都是:hbase/hadoop.5c565581_5f7d_4659_8bef_34597a016ec1.com@5C565581_5F7D_4659_8BEF_34597A016EC1.COM # 进入phoenix目录 cd /opt/apache-phoenix-5.0.0-HBase-2.0-bin/bin # 修改配置文件:hbase-site.xml vi hbase-site.xml # 添加如下内容
<property> <name>hbase.regionserver.kerberos.principal</name> <value>hbase/hadoop.5c565581_5f7d_4659_8bef_34597a016ec1.com@5C565581_5F7D_4659_8BEF_34597A016EC1.COM</value> </property> <property> <name>hbase.master.kerberos.principal</name> <value>hbase/hadoop.5c565581_5f7d_4659_8bef_34597a016ec1.com@5C565581_5F7D_4659_8BEF_34597A016EC1.COM</value> </property> <property> <name>hbase.security.authentication</name> <value>kerberos</value> </property>
从客户端中找 hbase-site.xml
修改后的配置文件
# 进入phoenix目录 cd /opt/apache-phoenix-5.0.0-HBase-2.0-bin/bin #修改sqlline.py,添加hbase的依赖 vi sqlline.py # 在108行 添加:$HBASE_OPTS 和$HBASE_HOME/lib/*: java_cmd = java + ' $PHOENIX_OPTS $HBASE_OPTS' + \ ' -cp "$HBASE_HOME/lib/*:' + hbase_config_path + os.pathsep + phoenix_utils.hbase_conf_dir + os.pathsep + pho enix_utils.phoenix_client_jar + \ os.pathsep + phoenix_utils.hadoop_common_jar + os.pathsep + phoenix_utils.hadoop_hdfs_jar + \ os.pathsep + phoenix_utils.hadoop_conf + os.pathsep + phoenix_utils.hadoop_classpath + '" -Dlog4j.configurati on=file:' + \ os.path.join(phoenix_utils.current_dir, "log4j.properties") + \ " sqlline.SqlLine -d org.apache.phoenix.jdbc.PhoenixDriver" + \ " -u jdbc:phoenix:" + phoenix_utils.shell_quote([zookeeper]) + \ " -n none -p none --color=" + colorSetting + " --fastConnect=" + args.fastconnect + \ " --verbose=" + args.verbose + " --incremental=false --isolation=TRANSACTION_READ_COMMITTED " + sqlfile print("java_cmd:"+java_cmd) # 创建软连接 ln -s /opt/apache-phoenix-5.0.0-HBase-2.0-bin/bin/sqlline.py /opt/mrs_client/HBase/hbase/bin/sqlline.py
添加hbase的依赖:
添加软连接:
7. 使用phoenix
# 登陆认证 source /opt/mrs_client/bigdata_env kinit dcf_user # 查找zookeeper服务器和端口 grep -E "zookeeper" /opt/mrs_client/HBase/hbase/conf/hbase-site.xml -A 1 # 使用phoenix sqlline.py node-ana-corelwjp:2181 sqlline.py
查找zookeeper服务器和端口:
登陆成功:
执行sql验证是否可用:
CREATE TABLE TEST (id VARCHAR PRIMARY KEY, name VARCHAR); UPSERT INTO TEST(id,name) VALUES ('1','hello world!'); SELECT * FROM TEST; DROP TABLE TEST;
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)