pinpoint-v1.8.3系列(零)之pinpoint部署安裝①

首先列出幾個網(wǎng)址:
pinpoint code github地址
pinpoint wiki github地址
pinpoint v1.8.3 official homepage

在這里我推薦的是,通過編譯源碼的方式來獲取部署要用到的jar包。因為之后我們需要開發(fā)pinpoint的插件,同樣需要搭建開發(fā)環(huán)境,那就在這里把這個搭建的步驟做了就完了。

Step 1. clone源碼

pinpoint code github地址 下clone即可。

git clone  https://github.com/naver/pinpoint.git
cd pinpoint

這個時候用命令git branch -a看一下分支:

* 1.8.x
  master
  remotes/origin/#4558_support_grpc_transport
  remotes/origin/1.0.x
  remotes/origin/1.1.x
  remotes/origin/1.5.x
  remotes/origin/1.6.x
  remotes/origin/1.7.x
  remotes/origin/1.8.x
  remotes/origin/HEAD -> origin/master
  remotes/origin/gh-pages
  remotes/origin/master

默認情況下當前分支是master分支,可以用git checkout -b dev(本地分支名) origin/dev(遠程分支名)的方式,將當前分支切換為1.8.x

Step 2. 編譯

1. 設(shè)置環(huán)境變量:

# JAVA_HOMES for pinpoint
export JAVA_6_HOME=/opt/pinpoint/jdks/jdk1.6.0_45
export JAVA_7_HOME=/opt/pinpoint/jdks/jdk1.7.0_80
export JAVA_8_HOME=/opt/pinpoint/jdks/jdk1.8.0_201
export JAVA_9_HOME=/opt/pinpoint/jdks/java-se-9-ri/jdk-9

在這里說明一下為啥要設(shè)置這四個環(huán)境變量。pinpoint的agent(用于收集宿主應(yīng)用性能數(shù)據(jù)的組件)需要針對不同版本的jdk進行一些有針對性的表現(xiàn),區(qū)別在于以下目錄:

image.png

而這四個環(huán)境變量指定的jdk類庫,就作為這部分代碼編譯所需要的依賴。當然,如果不編譯profiler-optional-jdk9這個module,將其移除,則JAVA_9_HOME可以不設(shè)置。其他三個同理。

2. maven 編譯

在編譯之前,推薦先設(shè)置maven倉庫為阿里云倉庫,否則編譯過程可能會很慢。可參考:三、配置阿里云鏡像
編譯過程很簡單,直接cd 到pinpoint根目錄,然后./mvnw install -DskipTests=true。

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: osx
[INFO] os.detected.arch: x86_64
[INFO] os.detected.version: 10.14
.........................略.........
.........................略.........

然后就是漫長的等待,如果以上環(huán)境變量都設(shè)置了的話,應(yīng)該沒什么問題。
插一句,如果沒見過mvnw命令對其有疑問,可以查看mvnw文件內(nèi)容,其實就是設(shè)置一大堆環(huán)境變量,然后到最后還是mvn 執(zhí)行的。

282 exec "$JAVACMD" \
283   $MAVEN_OPTS \
284   -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
285   "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \

其中MAVEN_OPTS 的解釋為:MAVEN_OPTS - parameters passed to the Java VM when running Maven

Step3. 部署啟動

1. 說明

首先來簡單說一下pinpoint的組成。
數(shù)據(jù)收集:agent -> collector -> hbase(存儲)
數(shù)據(jù)查詢:webUI -> hbase
其中,pinpoint又使用flink預(yù)統(tǒng)計數(shù)據(jù)來優(yōu)化查詢性能,flink作為目前最先進的流式處理框架,性能優(yōu)秀,一致性保證,輕量級容錯。

pinpoint部署的官方文檔,分為QuickStart和Installation兩部分。參照:pinpoint v1.8.3 official homepage
如果只是為了在自己機器上嘗嘗鮮,了解一下pinpoint,那用QuickStart是沒問題的。QuickStart是使用的mvn 自帶的tomcat插件來啟動的webUI和collector。隨著部署的服務(wù)增多,數(shù)據(jù)量上來之后,難免需要進行一些參數(shù)設(shè)置,這個時候麻煩就來了。因此如果最終目的是生產(chǎn)的話,直接按照Installation進行。其中部署的思路推薦后從往前,也就是按照上述數(shù)據(jù)收集數(shù)據(jù)查詢的箭頭反向進行。

2. 部署hbase

①下載hbase

在pinpoint的官方首頁中,quickStart中并沒有指出linux機器需要下載hbase,那是因為在quickstart/bin/start-hbase.sh 中會自動下載安裝,見func_download_hbase方法:

[root@im-test-cpr-1 bin]# cat start-hbase.sh
#!/usr/bin/env bash

HBASE_VERSION=hbase-1.0.3
HBASE_FILE=$HBASE_VERSION-bin.tar.gz
HBASE_DL_URL=http://apache.mirror.cdnetworks.com/hbase/$HBASE_VERSION/$HBASE_FILE
HBASE_ARCHIVE_DL_URL=http://archive.apache.org/dist/hbase/$HBASE_VERSION/$HBASE_FILE

function func_download_hbase
{
    if type curl > /dev/null 2>&1; then
        if [[ `curl -s --head $HBASE_DL_URL | head -n 1 2>&1 | grep "HTTP/1.[01] [23].."` ]]; then
            curl -O $HBASE_DL_URL
        else
            curl -O $HBASE_ARCHIVE_DL_URL
        fi
        echo "true"
    elif type wget > /dev/null 2>&1; then
        if [[ `wget -S --spider $FAIL_URL 2>&1 | grep "HTTP/1.[01] [23].."` ]]; then
            wget $HBASE_DL_URL
        else
            wget $HBASE_ARCHIVE_DL_URL
        fi
        echo "true"
    else
        echo "false"
    fi
}

但是經(jīng)過驗證,這個自動下載經(jīng)常失敗,而且失敗之后需要手動刪除下載了一半的文件,否則它會視為已經(jīng)下載過了然后去解壓,導(dǎo)致報錯,十分頭疼。所以干脆我們就自己裝一個,裝在哪無所謂。但是推薦版本1.0.3,官方教程中就是這個版本。

②安裝配置hbase

在安裝之前,推薦看一下hbase quickstart中的standalone部分,因為我裝的是單機版的。集群版本按照官方教程也可解決。
這是我的安裝目錄:

[root@im-test-cpr-1 hbase]# pwd
/opt/pinpoint/pinpoint/quickstart/hbase

下載解壓:

wget http://archive.apache.org/dist/hbase/hbase-1.0.3/hbase-1.0.3-bin.tar.gz
tar -xzvf  hbase-1.0.3-bin.tar.gz

hbase 啟動時,可以根據(jù)實際情況選擇集群或者單機方式進行;如果選擇集群,可以選擇自帶ZooKeeper或者外置ZK。在這里我們安裝單機版。

如果安裝的是hbase集群,推薦選擇外置ZK。這時候需要配置hbase_dir/conf/hbase-env.sh中的export HBASE_MANAGES_ZK=false
貼一下我的hbase_dir/conf/hbase-site.xml配置文件

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
 *
 * 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.
 */
-->
<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/testuser/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/testuser/zookeeper</value>
  </property>
  <property>
    <name>hbase.unsafe.stream.capability.enforce</name>
    <value>false</value>
    <description>
      Controls whether HBase will check for stream capabilities (hflush/hsync).

      Disable this if you intend to run on LocalFileSystem, denoted by a rootdir
      with the 'file://' scheme, but be mindful of the NOTE below.

      WARNING: Setting this to false blinds you to potential data loss and
      inconsistent system state in the event of process and/or node failures. If
      HBase is complaining of an inability to use hsync or hflush it's most
      likely not a false positive.
    </description>
  </property>
</configuration>

③ 運行hbase

然后運行pinpoint/quickstart/bin/start-hbase.sh,根據(jù)提示,hbase的啟動log會被重定向到一個log文件中,cat一下如果是空的,說明啟動成功。如果輸出的是error,那好吧,根據(jù)提示解決問題吧...

logging to /opt/pinpoint/pinpoint/quickstart/hbase/hbase-1.0.3/bin/../logs/hbase-root-master-im-test-cpr-1.out

hbase啟動成功后,會有一個hbase的進程出現(xiàn)。

[root@im-test-cpr-1 bin]# jps -l -v |grep hbase
91262 org.apache.hadoop.hbase.master.HMaster -Dproc_master -XX:OnOutOfMemoryError=kill -9 %p -XX:+UseConcMarkSweepGC -Dhbase.log.dir=/opt/pinpoint/pinpoint/quickstart/hbase/hbase-1.0.3/logs -Dhbase.log.file=hbase-root-master-im-test-cpr-1.log -Dhbase.home.dir=/opt/pinpoint/pinpoint/quickstart/hbase/hbase-1.0.3 -Dhbase.id.str=root -Dhbase.root.logger=INFO,RFA -Dhbase.security.logger=INFO,RFAS

關(guān)于這個進程需要補充說明的是,它包含了以下職能(摘自官網(wǎng)quickstart):

A standalone instance has all HBase daemons?—?the Master, RegionServers, and ZooKeeper?—?running in a single JVM persisting to the local filesystem.

因此如果不考慮集群的情況下,無需安裝其他zookeeper,即可默認監(jiān)聽2181端口,為collectorweb-ui提供服務(wù)注冊。

④初始化hbase

運行pinpoint/quickstart/bin/init-hbase.sh,如果報錯找不到hbase目錄,修改init-hbase.sh
為如下內(nèi)容后重新執(zhí)行。原因在于默認的init腳本中hbase路徑不帶版本號。

#!/usr/bin/env bash

quickstart_bin=`dirname "${BASH_SOURCE-$0}"`
quickstart_bin=`cd "$quickstart_bin">/dev/null; pwd`
quickstart_base=$quickstart_bin/..
quickstart_base=`cd "$quickstart_base">/dev/null; pwd`

"$quickstart_bin"/../hbase/hbase-1.0.3/bin/hbase shell $quickstart_base/conf/hbase/init-hbase.txt

init腳本會初始化hbase中存儲性能數(shù)據(jù)所需要的數(shù)據(jù)表。

⑤hbase運行驗證

運行hbase shell客戶端,鍵入list命令,看到列出所有表之后,hbase搭建完成。

[root@im-test-cpr-1 pinpoint]# cd quickstart/bin/
[root@im-test-cpr-1 bin]# cd ..
[root@im-test-cpr-1 quickstart]# cd hbase/hbase-1.0.3/bin/
[root@im-test-cpr-1 bin]# ls
draining_servers.rb   hbase             hbase-common.sh   hbase-daemon.sh   hirb.rb                 local-regionservers.sh  regionservers.sh  rolling-restart.sh        start-hbase.sh  test
get-active-master.rb  hbase-cleanup.sh  hbase-config.cmd  hbase-daemons.sh  hs_err_pid79021.log     master-backup.sh        region_status.rb  shutdown_regionserver.rb  stop-hbase.cmd  thread-pool.rb
graceful_stop.sh      hbase.cmd         hbase-config.sh   hbase-jruby       local-master-backup.sh  region_mover.rb         replication       start-hbase.cmd           stop-hbase.sh   zookeepers.sh
[root@im-test-cpr-1 bin]# ./hbase shell
2019-07-10 17:23:08,819 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.0.3, rf1e1312f9790a7c40f6a4b5a1bab2ea1dd559890, Tue Jan 19 19:26:53 PST 2016

hbase(main):001:0> list
TABLE
AgentEvent
AgentInfo
AgentLifeCycle
AgentStatV2
ApiMetaData
ApplicationIndex
ApplicationMapStatisticsCallee_Ver2
ApplicationMapStatisticsCaller_Ver2
ApplicationMapStatisticsSelf_Ver2
ApplicationStatAggre
ApplicationTraceIndex
HostApplicationMap_Ver2
SqlMetaData_Ver2
StringMetaData
TraceV2
15 row(s) in 0.3500 seconds

=> ["AgentEvent", "AgentInfo", "AgentLifeCycle", "AgentStatV2", "ApiMetaData", "ApplicationIndex", "ApplicationMapStatisticsCallee_Ver2", "ApplicationMapStatisticsCaller_Ver2", "ApplicationMapStatisticsSelf_Ver2", "ApplicationStatAggre", "ApplicationTraceIndex", "HostApplicationMap_Ver2", "SqlMetaData_Ver2", "StringMetaData", "TraceV2"]
hbase(main):002:0>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容