背景
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
歡迎關注“程式雜貨鋪”公眾號,里面有精彩內容,歡迎大家收看^_^
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/439237.html
標籤:其他
