0


Ambari安装phoenix-hbase5.X(适配phoenix-queryserver)

背景

phoenix-hbase4.15及5.X版本后,phoenix-hbase安装包中就不带phoenix-queryserver,phoenix-queryserver需要单独安装。

Apache官方已给出:   

In the 4.4-4.14 and 5.0 releases the query server and its JDBC client are part of the standard Phoenix distribution. They require no additional dependencies or installation.

After the 4.15 and 5.1 release, the query server has been unbundled into the phoenix-queryserver repository, and its version number has been reset to 6.0.

   由于Ambari安装phoenix-hbase默认带着phoenix-queryserver,若安装phoenix-hbase4.15及5.X版本,phoenix会启动失败,因此本文对安装脚本进行修改,已令Ambari能够适配phoenix-hbase高版本,并启动成功。

   本文将从手动安装跟Ambari安装两种方式出发适配phoenix-hbase高版本,本文选用phoenix-hbase-2.2-5.1.2-bin.tar.gz、phoenix-queryserver-6.0.0-bin.tar.gz,下载地址如下:

https://dlcdn.apache.org/phoenix/phoenix-5.1.2/phoenix-hbase-2.2-5.1.2-bin.tar.gz

https://dlcdn.apache.org/phoenix/phoenix-queryserver-6.0.0/phoenix-queryserver-6.0.0-bin.tar.gz

手动安装

  • 下载安装phoenix-hbase

      下载phoenix-hbase-2.2-5.1.2-bin.tar.gz
    
wget https://dlcdn.apache.org/phoenix/phoenix-5.1.2/phoenix-hbase-2.2-5.1.2-bin.tar.gz
    解压
tar –zxvf phoenix-hbase-2.2-5.1.2-bin.tar.gz
  • 下载安装phoenix-queryserver

      下载phoenix-queryserver-6.0.0-bin.tar.gz
    
wget https://dlcdn.apache.org/phoenix/phoenix-queryserver-6.0.0/phoenix-queryserver-6.0.0-bin.tar.gz
    解压
tar –zxvf phoenix-queryserver-6.0.0-bin.tar.gz
     将phoenix-queryserver-6.0.0/bin目录下的phoenix_queryserver_utils.py、queryserver.py、sqlline-thin.py拷贝至phoenix-hbase-2.2-5.1.2-bin/bin下。

cp phoenix-queryserver-6.0.0/bin/phoenix_queryserver_utils.py phoenix-queryserver-6.0.0/bin/queryserver.py phoenix-queryserver-6.0.0/bin/sqlline-thin.py phoenix-hbase-2.2-5.1.2-bin/bin
    将phoenix-queryserver-6.0.0目录下的lib目录、maven目录、phoenix-queryserver-6.0.0.jar、phoenix-queryserver-client-6.0.0.jar拷贝至phoenix-hbase-2.2-5.1.2-bin目录下。

cp –r phoenix-queryserver-6.0.0/lib phoenix-queryserver-6.0.0/maven phoenix-queryserver-6.0.0/phoenix-queryserver-6.0.0.jar phoenix-queryserver-6.0.0/ phoenix-queryserver-client-6.0.0.jar phoenix-hbase-2.2-5.1.2-bin/
  • 启动服务

      解压后的queryserver.py和sqlline-thin.py没有执行权限,需要chmod +x 赋予执行权限。
    
chmod +x phoenix-hbase-2.2-5.1.2-bin/bin/queryserver.py
chmod +x phoenix-hbase-2.2-5.1.2-bin/bin/sqlline-thin.py
    启动queryserver:
python phoenix-hbase-2.2-5.1.2-bin/bin/queryserver.py start
    启动phoenix:
python phoenix-hbase-2.2-5.1.2-bin/bin/sqlline-thin.py localhost:8765

Ambari安装

    在本地yum源中添加phoenix-queryserver-6.0.0-bin.tar.gz包,例如:

    需要修改stacks下HBASE中对应的phoenix_service.py,另外添加phoenix_queryserver.sh脚本.
cd services/HBASE/package/scripts
vi phoenix_queryserver.sh
#!/bin/bash
cd /usr/lib/
content=`cat /etc/yum.repos.d/bigtop.repo| grep baseurl | grep -v '#'`
baseurl=${content#*=}
path="phoenix/noarch/phoenix-queryserver-6.0.0-bin.tar.gz"
url=${baseurl}${path}
echo $url
wget $url
sleep 3
pwd
chmod 777 phoenix-queryserver-6.0.0-bin.tar.gz
tar -zxvf phoenix-queryserver-6.0.0-bin.tar.gz
sleep 3
chmod -R 777 phoenix-queryserver-6.0.0
cd phoenix-queryserver-6.0.0
cp bin/phoenix_queryserver_utils.py bin/queryserver.py bin/sqlline-thin.py /usr/lib/phoenix/bin/
cp -r lib/ maven/ phoenix-queryserver-* /usr/lib/phoenix
chmod -R 777 /usr/lib/phoenix
sleep 3
    在phoenix_service.py修改(安装phoenix-queryserver部分):
#!/usr/bin/env python
"""
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.

"""
import os
import errno
from resource_management.core.logger import Logger
from resource_management.core.resources.system import Execute
from resource_management.core.resources.system import File
from resource_management.libraries.functions import check_process_status, format

# Note: Phoenix Query Server is only applicable to phoenix version stacks and above.
def phoenix_service(action = 'start'): # 'start', 'stop', 'status'
    # Note: params should already be imported before calling phoenix_service()
    import status_params
    pid_file = status_params.phoenix_pid_file
    no_op_test = format("ls {pid_file} >/dev/null 2>&1 && ps -p `cat {pid_file}` >/dev/null 2>&1")

    if action == "status":
      check_process_status(pid_file)
    else:
      env = {'JAVA_HOME': format("{java64_home}"), 'HBASE_CONF_DIR': format("{hbase_conf_dir}")}
      daemon_cmd = format("{phx_daemon_script} {action}")
      if action == 'start':
        # 安装phoenix-queryserver
        os.system('pwd')
        os.system('sh cache/stacks/BGTP/1.0/services/HBASE/package/scripts/phoenix_queryserver.sh')
        # 启动phoenix
        Execute(daemon_cmd,
                user=format("{hbase_user}"),
                environment=env)
  
      elif action == 'stop':
        Execute(daemon_cmd,
                user=format("{hbase_user}"),
                environment=env
        )
        try:
          File(pid_file, action = "delete")
        except OSError as exc:
          # OSError: [Errno 2] No such file or directory
          if exc.errno == errno.ENOENT:
            Logger.info("Did not remove '{0}' as it did not exist".format(pid_file))
          else:
            raise
    重启Ambari:
ambari-server restart

欢迎关注“程序杂货铺”公众号,里面有精彩内容,欢迎大家收看^_^

标签: ambari hadoop 大数据

本文转载自: https://blog.csdn.net/u013473512/article/details/123329128
版权归原作者 Emmitte 所有, 如有侵权,请联系我们删除。

“Ambari安装phoenix-hbase5.X(适配phoenix-queryserver)”的评论:

还没有评论