集群部署

iTracing的collector收集数据并存入hbase,所以iTracing集群部署其实也就是hbase集群的部署

一、Hbase集群部署

部署前准备工作

主机规划

主机地址 HostName Zookeeper HDFS HBase
10.45.61.61 hbase1 server NameNode Master
10.45.61.62 hbase2 server DataNode,SecondaryNameNode RegionServer
10.45.61.63 hbase3 server DataNode RegionServer
10.45.61.64 hbase4 DataNode RegionServer

这里是将hbase1选做主节点,hbase2、hbase3、hbase4作为从节点

下载安装包

habse集群的部署需要先部署Hadoop集群,因此需要下载以下安装包:

  1. Hadoophttps://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-2.7.6/hadoop-2.7.6.tar.gz
  2. zookeeperhttps://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz
  3. Hbasehttp://archive.apache.org/dist/hbase/1.2.6/hbase-1.2.6-bin.tar.gz

修改主机host信息

在每台主机上使用命令:sudo vi /etc/hosts

并增加以下信息:

  • 10.45.61.61 hbase1
  • 10.45.61.62 hbase2
  • 10.45.61.63 hbase3
  • 10.45.61.64 hbase4

配置环境变量

将下载好的Hadoop,zookeeper,Hbase分别解压缩到/hbase/hadoop,/hbase/zookeeper,/hbase/hbase处;

并且在每台主机使用命令:vi /etc/profile 打开配置文件,在里面增加以下配置信息:

  • export HADOOP_HOME=/hbase/hadoop
  • export HBASE_HOME=/hbase/hbase
  • export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin
  • export HBASE_MANAGES_ZK=false

最后使用命令:source /etc/profile使配置文件生效。

配置无密码访问

在hbase1主机上执行:

  • ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
  • scp~/.ssh/id_rsa.pub root@hbase2:~/
  • scp~/.ssh/id_rsa.pub root@hbase3:~/
  • scp~/.ssh/id_rsa.pub root@hbase4:~/

在其余主机上执行:

  • cat ~/id_rsa.pub >> ~/.ssh/authorized_keys

检查是否配置成功:在hbase1主机上执行命令:ssh root@hbase2如果出现“password"则说明配置成功。

集群部署

部署zookeeper

在hbase1、hbase2、hbase3上执行命令:

  • cd /hbase/zookeeper;
  • cp zoo_sample.cfg zoo.cfg ;
  • vi zoo.cfg

并在打开的zoo.cfg文件中增加如下配置:

  • dataDir=/hbase/zookeeper/data
  • server.1=hbase1:2888:3888
  • server.2=hbase2:2888:3888
  • server.3=hbase3:2888:3888

/hbase/zookeeper下创建data目录,使用命令:echo "1">/hbase/zookeeper/data/myid 添加myid(其中hbase2,myid为2;hbase3,myid为3)

在bin目录下使用命令:./zkServer.sh启动zookeeper

部署Hadoop集群

在每台主机/habse/hadoop/etc/hadoop目录下,分别找到如下配置文件并增加配置信息:
1. core-site.xml

1
2
3
4
5
6
<configuration> 
<property>
<name>fs.defaultFS</name>
<value>hdfs://hbase1:9000</value>
</property>
</configuration>

2.hdfs-site.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<configuration> 
<property>
<name>dfs.namenode.name.dir</name>
<value>/namedata</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/blockdata</value>
</property>
<property>
<name>dfs.namenode.secondary.http-address</name>
<value>hbase2:50090</value>
</property>
</configuration>

3.slaves

hbase2

hbase3

hbase4

创建文件目录:

  • 在hbase1上执行:mkdir -p /namedata
  • 在hbase2~4上执行:mkdir -p /blockdata

在hbase1上执行命令:

  • hdfs namenode -format 格式化namenode元数据
  • start-dfs.sh 启动hadoop集群

访问http://hbase1:50070/看是否启动正常

部署Hbase集群

/hbase/hbase/conf路径下找到如下配置文件,并添加配置信息;

1.hbase-site.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<configuration> 
<property>
<name>hbase.rootdir</name>
<value>hdfs://hbase1:9000/hbasedata</value>
</property>
<property>
<name>hbase.master</name>
<value>hbase1:60000</value>
</property>
<property>
<name>hbase.master.info.port</name>
<value>60010</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>hbase1:2181,hbase2:2181,hbase3:2181</value>
</property>
</configuration>

2.regionservers

hbase2

hbase3

hbase4

在hbase1进入bin目录执行命令:./start-hbase.sh 启动hbase集群

访问http://hbase1:60010 查看集群是否启动成功,到此为止,集群才部署结束。

二、iTracing部署

Hbase表创建

有两个脚本可用于为Pinpoint创建表:hbase-create.hbase和hbase-create-snappy.hbase。使用hbase-create-snappy.hbase进行快速压缩存储,否则请使用hbase-create.hbase。

使用命令:/hbase/hbase/bin/hbase shell hbase-create.hbase 将执行脚本创建hbase表

Collector部署

在任一主机上下载pinpoint-collector-1.7.3.war文件,并将该war包部署在tomcat中执行;

执行结束后,找到collector.propertieshbase.properties两个配置文件:

1.collector.properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# base data receiver config  ---------------------------------------------------------------------
collector.receiver.base.ip=0.0.0.0
collector.receiver.base.port=9994

# number of tcp worker threads
collector.receiver.base.worker.threadSize=8
# capacity of tcp worker queue
collector.receiver.base.worker.queueSize=1024
# monitoring for tcp worker
collector.receiver.base.worker.monitor=true

# stat receiver config ---------------------------------------------------------------------
collector.receiver.stat.udp=true
collector.receiver.stat.udp.ip=0.0.0.0
collector.receiver.stat.udp.port=9995
collector.receiver.stat.udp.receiveBufferSize=4194304

# Should keep in mind that TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet)
collector.receiver.stat.tcp=false
collector.receiver.stat.tcp.ip=0.0.0.0
collector.receiver.stat.tcp.port=9995

# number of udp statworker threads
collector.receiver.stat.worker.threadSize=8
# capacity of udp statworker queue
collector.receiver.stat.worker.queueSize=64
# monitoring for udp stat worker
collector.receiver.stat.worker.monitor=true


# span receiver config ---------------------------------------------------------------------
collector.receiver.span.udp=true
collector.receiver.span.udp.ip=0.0.0.0
collector.receiver.span.udp.port=9996
collector.receiver.span.udp.receiveBufferSize=4194304

# Should keep in mind that TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet)
collector.receiver.span.tcp=false
collector.receiver.span.tcp.ip=0.0.0.0
collector.receiver.span.tcp.port=9996

# number of udp statworker threads
collector.receiver.span.worker.threadSize=32
# capacity of udp statworker queue
collector.receiver.span.worker.queueSize=256
# monitoring for udp stat worker
collector.receiver.span.worker.monitor=true


# configure l4 ip address to ignore health check logs
collector.l4.ip=

# change OS level read/write socket buffer size (for linux)
#sudo sysctl -w net.core.rmem_max=
#sudo sysctl -w net.core.wmem_max=
# check current values using:
#$ /sbin/sysctl -a | grep -e rmem -e wmem

# number of agent event worker threads
collector.agentEventWorker.threadSize=4
# capacity of agent event worker queue
collector.agentEventWorker.queueSize=1024

statistics.flushPeriod=1000

# -------------------------------------------------------------------------------------------------
# The cluster related options are used to establish connections between the agent, collector, and web in order to send/receive data between them in real time.
# You may enable additional features using this option (Ex : RealTime Active Thread Chart).
# -------------------------------------------------------------------------------------------------
# Usage : Set the following options for collector/web components that reside in the same cluster in order to enable this feature.
# 1. cluster.enable (pinpoint-web.properties, pinpoint-collector.properties) - "true" to enable
# 2. cluster.zookeeper.address (pinpoint-web.properties, pinpoint-collector.properties) - address of the ZooKeeper instance that will be used to manage the cluster
# 3. cluster.web.tcp.port (pinpoint-web.properties) - any available port number (used to establish connection between web and collector)
# -------------------------------------------------------------------------------------------------
# Please be aware of the following:
#1. If the network between web, collector, and the agents are not stable, it is advisable not to use this feature.
#2. We recommend using the cluster.web.tcp.port option. However, in cases where the collector is unable to establish connection to the web, you may reverse this and make the web establish connection to the collector.
# In this case, you must set cluster.connect.address (pinpoint-web.properties); and cluster.listen.ip, cluster.listen.port (pinpoint-collector.properties) accordingly.
cluster.enable=false
cluster.zookeeper.address=localhost
cluster.zookeeper.sessiontimeout=30000
cluster.listen.ip=
cluster.listen.port=

#collector.admin.password=
#collector.admin.api.rest.active=
#collector.admin.api.jmx.active=

collector.spanEvent.sequence.limit=10000

# Flink configuration
flink.cluster.enable=true
flink.cluster.zookeeper.address=hbase1
flink.cluster.zookeeper.sessiontimeout=3000

2.hbase.properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
hbase.client.host=hbase1,hbase2,hbase3
hbase.client.port=2181

# hbase default:/hbase
hbase.zookeeper.znode.parent=/hbase

# hbase namespace to use default:default
hbase.namespace=default

# hbase timeout option==================================================================================
# hbase default:true
hbase.ipc.client.tcpnodelay=true
# hbase default:60000
hbase.rpc.timeout=10000
# hbase default:Integer.MAX_VALUE
hbase.client.operation.timeout=10000

# hbase socket read timeout. default: 200000
hbase.ipc.client.socket.timeout.read=20000
# socket write timeout. hbase default: 600000
hbase.ipc.client.socket.timeout.write=60000

# ==================================================================================
# hbase client thread pool option
hbase.client.thread.max=64
hbase.client.threadPool.queueSize=5120
# prestartAllCoreThreads
hbase.client.threadPool.prestart=false

# enable hbase async operation. default: false
hbase.client.async.enable=false
# the max number of the buffered asyncPut ops for each region. default:10000
hbase.client.async.in.queuesize=10000
# periodic asyncPut ops flush time. default:100
hbase.client.async.flush.period.ms=100
# the max number of the retry attempts before dropping the request. default:10
hbase.client.async.max.retries.in.queue=10

###

web部署

在任一主机上下载pinpoint-web-1.7.3.war 文件,并将该war包部署在tomcat中执行;

这里只需要修改hbase.properties配置文件,且内容与collector中的hbase.properties文件内容相同

###

agent部署

下载pinpoint-agent-1.7.3.tar.gz文件,并解压;

Pinpoint Agent作为附加到要分析的应用程序的Java代理运行(例如Tomcat)。

要连接代理,请在运行应用程序时将$ AGENT_PATH/pinpoint-bootstrap-1.7.3.jar传递给-javaagent JVM参数:

  • -javaagent:$AGENT_PATH/pinpoint-bootstrap-1.7.3.jar

此外,Pinpoint Agent需要2个命令行参数才能在分布式系统中识别自身:

  • -Dpinpoint.agentId - 唯一标识运行代理程序的应用程序实例
  • -Dpinpoint.applicationName - 将多个相同的应用程序实例组合为一个服务

请注意,pinpoint.agentId必须全局唯一以标识应用程序实例,并且共享相同pinpoint.applicationName的所有应用程序都被视为单个服务的多个实例。

在Tomcat启动脚本(catalina.sh)中将-javaagent-Dpinpoint.agentId-Dpinpoint.applicationName添加到CATALINA_OPTS,看如下示例:

1
2
3
4
5
6
AGENT_PATH="/Users/heyongjin/Documents/soft/pinpoint-agent-1.7.2-SNAPSHOT"
AGENT_ID="crm-tomcat01"
APPLICATION_NAME="crm-tomcat"
CATALINA_OPTS =“$ CATALINA_OPTS -javaagent:$ AGENT_PATH / pinpoint-bootstrap-1.7.3.jar”
CATALINA_OPTS =“$ CATALINA_OPTS -Dpinpoint.agentId = $ AGENT_ID”
CATALINA_OPTS =“$ CATALINA_OPTS -Dpinpoint.applicationName = $ APPLICATION_NAME”

针对$ AGENT_PATH / pinpoint.config中的 Pinpoint Agent提供了各种配置选项。
大多数这些选项都是不言自明的,但您必须检查的最重要的配置选项是收集器IP地址和TCP / UDP端口。这些值是代理建立到收集器的连接并正常工作所必需的值。

pinpoint.config中适当地设置这些值:

  • profiler.collector.ip (默认:127.0.0.1,建议使用域名)
  • profiler.collector.tcp.port(collector's collector.tcpListenPort - 默认值:9994)
  • profiler.collector.stat.port(collector's collector.udpStatListenPort - 默认:9995)
  • profiler.collector.span.port(collector's collector.udpSpanListenPort - 默认值:9996)