期货行情数据gpload并行加载到Greenplum数据库

###期货行情数据gpload并行加载到Greenplum数据库


####Greenplum数据库创建期货行情表

创建一个序列,作为id

1
2
3
4
5
6
7
8
9
10
11
12
-- Sequence: hffd.tdb_futureab_seq

-- DROP SEQUENCE hffd.tdb_futureab_seq;

CREATE SEQUENCE hffd.tdb_futureab_seq
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
ALTER TABLE hffd.tdb_futureab_seq
  OWNER TO gpadmin;

创建期货行情表

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
-- Table: hffd.tdb_futureab

-- DROP TABLE hffd.tdb_futureab;

CREATE TABLE hffd.tdb_futureab
(
  id integer NOT NULL DEFAULT nextval('hffd.tdb_futureab_seq'::regclass),
  windcode character(20),
  code character(20),
  date double precision,
  "time" double precision,
  volume double precision,
  turover double precision,
  settle double precision,
  "position" double precision,
  curdelta double precision,
  tradeflag character(50),
  accvolume double precision,
  accturover double precision,
  open double precision,
  high double precision,
  low double precision,
  price double precision,
  askprice double precision,
  askvolume double precision,
  bidprice double precision,
  bidvolume double precision,
  preclose double precision,
  presettle double precision,
  preposition double precision
)
WITH (
  OIDS=FALSE
)
DISTRIBUTED BY (id);
ALTER TABLE hffd.tdb_futureab
  OWNER TO gpadmin;
GRANT ALL ON TABLE hffd.tdb_futureab TO gpadmin;
GRANT SELECT ON TABLE hffd.tdb_futureab TO fitl;

####编写gpload配置文件

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
VERSION: 1.0.0.1
DATABASE: fitl
USER: gpadmin
HOST: mdw
PORT: 5432
GPLOAD:
   INPUT:
    - SOURCE:
         LOCAL_HOSTNAME:
           - mdw
         PORT: 8090
         FILE:
           - /fitl/TDB_FURTURE/futureab/2015_csv/*.csv
    - COLUMNS:
           -  WindCode : text
           -  Code : text
           -  Date : float4
           -  Time : float4
           -  Volume : float4
           -  Turover : float4
           -  Settle : float4
           -  Position : float4
           -  CurDelta : float4
           -  TradeFlag : text
           -  AccVolume : float4
           -  AccTurover : float4
           -  Open : float4
           -  High : float4
           -  Low : float4
           -  Price : float4
           -  AskPrice : float4
           -  AskVolume : float4
           -  BidPrice : float4
           -  BidVolume : float4
           -  PreClose : float4
           -  PreSettle : float4
           -  PrePosition : float4
    - FORMAT: csv
    - DELIMITER: ','
    - QUOTE: '"'
    - HEADER: false
    - ERROR_LIMIT: 50
    - ERROR_TABLE: hffd.tdb_futureab_err
   OUTPUT:
    - TABLE: hffd.tdb_futureab
    - MODE: INSERT

####gpload并行加载数据

1
gpload -f futureab_2015.yml > 2015ab.log &

21分钟,完成1亿6千万条数据(2015年1月到10月的股指期货)的并行装载,速度还是挺快的

1
2
3
4
5
6
7
8
2015-11-30 10:11:31|INFO|gpload session started 2015-11-30 10:11:31
2015-11-30 10:11:32|INFO|started gpfdist -p 8090 -P 8091 -f "/fitl/TDB_FURTURE/futureab/2015_csv/*.csv" -t 30
2015-11-30 10:33:23|WARN|207 bad rows
2015-11-30 10:33:23|INFO|running time: 1312.12 seconds
2015-11-30 10:33:24|INFO|rows Inserted          = 167573149
2015-11-30 10:33:24|INFO|rows Updated           = 0
2015-11-30 10:33:24|INFO|data formatting errors = 0
2015-11-30 10:33:24|INFO|gpload succeeded with warnings
基于Piovtal HD3.0添加HAWQ和PXF服务

###基于Piovtal HD3.0添加HAWQ和PXF服务


####已有PivotalHD3.0的集群 可以看这一篇文档

PHD3.0集群部署文档

####下载对应的部署包 官方下载以下安装包

  • 1
    
    PADS-1.3.0.2-14421-rhel5_x86_64.tar.gz
    
  • 1
    
    hawq-plugin-phd-1.2-99.tgz
    

####准备 将上面两个文件,放到

1
/staging/
下,解压缩,配置本地Repository,最后重启Ambari-server

1
2
3
4
5
6
7
8
tar -xvf hawq-plugin-phd-1.2-99.tgz
cd hawq-plugin-phd-1.2-99
./setup_repo.sh
yum install hawq-plugin -y
tar -xvf PADS-1.3.0.2-14421-rhel5_x86_64.tar.gz
cd PADS-1.3.0.2
./setup_repo.sh
/etc/init.d/ambari-server restart

hosts准备

  • 使用admin用户登陆到Ambari首页
  • 首先添加几个hosts

添加新的hosts

添加新的hosts

添加新的hosts

添加新的hosts

添加新的hosts

添加新的hosts

添加新的hosts

安装HAWQ和PXF组件

安装hawq

安装hawq

安装hawq

安装hawq

安装hawq

安装hawq

安装hawq

安装hawq

安装hawq

使用Docker创建自己专属翻墙服务

###使用Docker创建自己专属翻墙服务


####首先需要一台云主机

  • 我用的是首都在线的位于美国达拉斯的云主机
  • 系统:centos7.0-64bit
  • 配置:4CPU 4G内存,60G硬盘

####安装docker运行的环境

1
2
curl -sSL https://get.docker.com/ | sh
service docker start

####安装shadowsocks的docker镜像

1
docker pull oddrationale/docker-shadowsocks

####运行shadowsocks镜像

1
docker run -d -p 7777:7777 oddrationale/docker-shadowsocks -s 0.0.0.0 -p 7777 -k xxxx -m aes-256-cfb
  • shadowsocks的端口是7777
  • -k 后面是密码 至此一个shadowsocks的docker镜像已经成功运行了,docker给我们带来的太多的方便和快捷,有木有

####本地客户端配置ss客户端 根据你的本机环境,安装shadowsocks客户端,官方的下载已经被和谐了 可以从我的百度云盘共享下载 我的是macbook,安装后,添加一个服务器配置 vpn配置

####享受一下把

google twitter

速度还是很快的,10M独享带宽

Hue安装配置

###Hue安装配置


Hue是一个开源的Apache Hadoop UI系统,最早是由Cloudera Desktop演化而来,由Cloudera贡献给开源社区,它是基于Python Web框架Django实现的。通过使用Hue我们可以在浏览器端的Web控制台上与Hadoop集群进行交互来分析处理数据,例如操作HDFS上的数据,运行MapReduce Job等

Hue所支持的功能特性集合:

  • 默认基于轻量级sqlite数据库管理会话数据,用户认证和授权,可以自定义为MySQL、Postgresql,以及Oracle
  • 基于文件浏览器(File Browser)访问HDFS
  • 基于Hive编辑器来开发和运行Hive查询
  • 支持基于Solr进行搜索的应用,并提供可视化的数据视图,以及仪表板(Dashboard)
  • 支持基于Impala的应用进行交互式查询
  • 支持Spark编辑器和仪表板(Dashboard)
  • 支持Pig编辑器,并能够提交脚本任务
  • 支持Oozie编辑器,可以通过仪表板提交和监控Workflow、Coordinator和Bundle
  • 支持HBase浏览器,能够可视化数据、查询数据、修改HBase表
  • 支持Metastore浏览器,可以访问Hive的元数据,以及HCatalog
  • 支持Job浏览器,能够访问MapReduce Job(MR1/MR2-YARN)
  • 支持Job设计器,能够创建MapReduce/Streaming/Java Job
  • 支持Sqoop 2编辑器和仪表板(Dashboard)
  • 支持ZooKeeper浏览器和编辑器
  • 支持MySql、PostGresql、Sqlite和Oracle数据库查询编辑器

####已有的环境说明 CentOS release 6.6 (Final) phd3.0 client

pivotal hadoop 3.0

####环境准备

  • 安装maven
1
2
3
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
tar -zxvf apache-maven-3.3.3-bin.tar.gz
cp -r apache-maven-3.3.3 /usr/local/

编辑

1
/etc/profile
,添加环境变量

1
2
3
export M2_HOME=/usr/local/apache-maven-3.3.3
export JAVA_HOME=/usr/java/jdk1.7.0_80
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin
  • 下载hue的所有rpm包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
wget https://www.dropbox.com/s/v7o5mxybvuhy4l4/hue-all-3.7.1-1.el6.x86_64.zip
[root@phd3-c hue-all]# ll
总用量 44292
-rwxr-xr-x 1 root root     1936 10月 16 11:28 hue-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root   273664 10月 16 11:28 hue-beeswax-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root 39078380 10月 16 11:28 hue-common-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root  1264868 10月 16 11:28 hue-doc-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root   474732 10月 16 11:28 hue-hbase-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root    36320 10月 16 11:28 hue-impala-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root   355576 10月 16 11:28 hue-pig-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root    41228 10月 16 11:28 hue-rdbms-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root  3580276 10月 16 11:28 hue-search-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root    62324 10月 16 11:28 hue-security-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root     4220 10月 16 11:28 hue-server-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root    45964 10月 16 11:28 hue-spark-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root    67244 10月 16 11:28 hue-sqoop-3.7.1-1.el6.x86_64.rpm
-rwxr-xr-x 1 root root    40724 10月 16 11:28 hue-zookeeper-3.7.1-1.el6.x86_64.rpm	
  • 安装依赖包
1
yum -y install cyrus-sasl-gssapi cyrus-sasl-plain libxml2 libxslt zlib python sqlite python-psycopg2
1
2
3
4
5
6
7
8
9
sudo yum -y install ./hue-common-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-server-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-rdbms-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-zookeeper-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-pig-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-hbase-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-beeswax-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-sqoop-3.7.1-1.el6.x86_64.rpm
sudo yum -y install ./hue-impala-3.7.1-1.el6.x86_64.rpm

####启动hue服务

1
/etc/init.d/hue start

默认是8888端口访问

hue-ui首页 提示您先创建一个管理严账户 然后进入主界面,但是因为没有配置信息,所以界面提示要修改配置

hue-config

####配置hue-server 修改配置文件

1
/etc/hue/conf/hue.ini
我的配置信息如下,改过的部分,其他都是默认,配置需要根据实际的Hadoop环境来变更

desktop的配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[desktop]

  # Set this to a random string, the longer the better.
  # This is used for secure hashing in the session store.
  secret_key=huangjie

  # Webserver listens on this address and port
  http_host=0.0.0.0
  http_port=8888

  # Time zone name
  time_zone=Asia/Shanghai
  
  # Comma separated list of apps to not load at server startup.
  # e.g.: pig,zookeeper
  # Bigtop does not bundle impala
  app_blacklist=impala,indexer,pig

rdbms的配置:

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
[librdbms]
  # The RDBMS app can have any number of databases configured in the databases
  # section. A database is known by its section name
  # (IE sqlite, mysql, psql, and oracle in the list below).

  [[databases]]
      # mysql, oracle, or postgresql configuration.
    ## [[[mysql]]]
      # Name to show in the UI.
      nice_name="hue server db"

      # For MySQL and PostgreSQL, name is the name of the database.
      # For Oracle, Name is instance of the Oracle server. For express edition
      # this is 'xe' by default.
      name=hue

      # Database backend to use. This can be:
      # 1. mysql
      # 2. postgresql
      # 3. oracle
      engine=mysql

      # IP or hostname of the database to connect to.
      host=10.2.29.70

      # Port the database server is listening to. Defaults are:
      # 1. MySQL: 3306
      # 2. PostgreSQL: 5432
      # 3. Oracle Express Edition: 1521
      port=3306

      # Username to authenticate with when connecting to the database.
      user=hue

      # Password matching the username to authenticate with when
      # connecting to the database.
      password=xxxxxx

hadoop配置部分:

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
[hadoop]

  # Configuration for HDFS NameNode
  # ------------------------------------------------------------------------
  [[hdfs_clusters]]
    # HA support by using HttpFs

    [[[default]]]
      # Enter the filesystem uri
      fs_defaultfs=hdfs://phd3-m1.xxb.cn:8020

      # Use WebHdfs/HttpFs as the communication mechanism.
      # Domain should be the NameNode or HttpFs host.
      # Default port is 14000 for HttpFs.
      webhdfs_url=http://phd3-m1.xxb.cn:50070/webhdfs/v1

 # Configuration for YARN (MR2)
  # ------------------------------------------------------------------------
  [[yarn_clusters]]

    [[[default]]]
      # Enter the host on which you are running the ResourceManager
      resourcemanager_host=phd3-m1.xxb.cn

      # The port where the ResourceManager IPC listens on
      resourcemanager_port=8030

      # Whether to submit jobs to this cluster
      submit_to=True

      # Resource Manager logical name (required for HA)
      ## logical_name=

      # Change this if your YARN cluster is Kerberos-secured
      ## security_enabled=false

      # URL of the ResourceManager API
      resourcemanager_api_url=http://phd3-m1.xxb.cn:8088

      # URL of the ProxyServer API
      ## proxy_api_url=http://localhost:8088
      
      # URL of the HistoryServer API
      # history_server_api_url=http://phd3-m3.xxb.cn:19888
      

liboozie配置:

1
2
3
4
5
6
7
8
9
10
[liboozie]
  # The URL where the Oozie service runs on. This is required in order for
  # users to submit jobs. Empty value disables the config check.
  oozie_url=http://phd3-m3.xxb.cn:11000/oozie

  # Requires FQDN in oozie_url if enabled
  ## security_enabled=false

  # Location on HDFS where the workflows/coordinator are deployed when submitted.
  ## remote_deployement_dir=/user/hue/oozie/deployments

beeswax配置(hive):

1
2
3
4
5
6
7
8
9
10
11
[beeswax]

  # Host where HiveServer2 is running.
  # If Kerberos security is enabled, use fully-qualified domain name (FQDN).
  hive_server_host=phd3-m2.xxb.cn

  # Port where HiveServer2 Thrift server runs on.
  hive_server_port=10000

  # Hive configuration directory, where hive-site.xml is located
  hive_conf_dir=/etc/hive/conf

hbase配置:

1
2
3
4
[hbase]
  # Comma-separated list of HBase Thrift servers for clusters in the format of '(name|host:port)'.
  # Use full hostname with security.
  hbase_clusters=(Cluster|phd3-m3.xxb.cn:9090)

zookeeper配置:

1
2
3
4
5
6
7
8
9
10
11
[zookeeper]

  [[clusters]]

    [[[default]]]
      # Zookeeper ensemble. Comma separated list of Host/Port.
      # e.g. localhost:2181,localhost:2182,localhost:2183
      host_ports=phd3-m1.xxb.cn:2181,phd3-m2.xxb.cn,phd3-m3.xxb.cn

      # The URL of the REST contrib service (required for znode browsing)
      rest_url=http://phd3-m1.xxb.cn:9998

####hadoop需要修改的配置

  • 通过Ambari修改hdfs配置,对应修改的文件是
    1
    
    core-site.xml
    
    添加一下内容 ambari-config
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
    <property>
      <name>hadoop.proxyuser.hive.groups</name>
      <value>*</value>
    </property>

    <property>
      <name>hadoop.proxyuser.hive.hosts</name>
      <value>*</value>
    </property>

    <property>
      <name>hadoop.proxyuser.hue.groups</name>
      <value>*</value>
    </property>

    <property>
      <name>hadoop.proxyuser.hue.hosts</name>
      <value>*</value>
    </property>

    <property>
      <name>hadoop.proxyuser.oozie.groups</name>
      <value>*</value>
    </property>

    <property>
      <name>hadoop.proxyuser.oozie.hosts</name>
      <value>*</value>
    </property>

####配置完成后

  • 重启hue-server,然后再次check configuration,看看是否还有报错信息
1
/etc/init.d/hue restart
  • 如果没有别的异常,则会看到如下界面

hue-all-ok

  • 安装自带的example程序 hue-example

  • 最后测试一下hive的job是否能够成功执行 hue-hive

####常见错误处理

  • hue中创建hdfs用户,并授予管理员权限,否则有可能在安装hive-example的时候没有写hdfs文件系统的权限,
    1
    
    Permission denied: user=admin, access=WRITE, inode="/user":hdfs:hdfs:drwxr-xr-x
    
  • 通过Ambari管理的hadoop,一定要通过ambari修改配置信息,否则会遇到
    1
    
    The Oozie server is not available
    
    之类的错误
  • 如果使用hbase的话,一定要在hbase服务器上,启动thrift server,
    1
    
    nohup /usr/bin/hbase thrift start &
    
Tomcat CPU100%故障排查

Tomcat CPU100%故障排查


####现象描述

  • 线上环境异常,无法正常访问
  • 系统负载高cpu长时间超过90%,系统吞吐率低

####排查是否是安全攻击问题导致(否)

####排查是否是数据库问题导致(否)

####排查是否是云平台异常导致(否)

####排查是否是tomcat本身异常导致(是)

  • 通过top命令查询系统负载情况
  • 发现2173这个java进程负载较高,持续时间较长,出现故障 top
  • 进一步查看线程,确定是java进程出现异常,
    1
    
    top -H -p 2173
    
  • 耗时较高的java线程,cpu占用情况很高 thread
  • 进一步打印线程堆栈信息,
    1
    
    jstack 2173 |grep db7 -A 30
    
    ,
    1
    
    printf "%x\n" 3511
    
    线程堆栈
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
[root@portal-app-2 logs]# jstack 2173 |grep db7 -A 30
"catalina-exec-282" daemon prio=10 tid=0x00007f838f7cf000 nid=0xdb7 waiting on condition [0x00007f83716d5000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-274" daemon prio=10 tid=0x00007f839005f000 nid=0xdb6 waiting on condition [0x00007f8370dcc000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-278" daemon prio=10 tid=0x00007f8398027000 nid=0xdb2 waiting on condition [0x00007f83710cf000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
[root@portal-app-2 logs]# jstack 2173 |grep db7 -A 60
"catalina-exec-282" daemon prio=10 tid=0x00007f838f7cf000 nid=0xdb7 waiting on condition [0x00007f83716d5000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-274" daemon prio=10 tid=0x00007f839005f000 nid=0xdb6 waiting on condition [0x00007f8370dcc000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-278" daemon prio=10 tid=0x00007f8398027000 nid=0xdb2 runnable [0x00007f83710cf000]
   java.lang.Thread.State: RUNNABLE
 at java.net.SocketInputStream.socketRead0(Native Method)
 at java.net.SocketInputStream.read(SocketInputStream.java:150)
 at java.net.SocketInputStream.read(SocketInputStream.java:121)
 at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:516)
 at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501)
 at org.apache.coyote.http11.Http11Processor.setRequestLineReadTimeout(Http11Processor.java:173)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:929)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
 - locked <0x0000000799c676f8> (a org.apache.tomcat.util.net.SocketWrapper)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-279" daemon prio=10 tid=0x00007f83840c6000 nid=0xdb1 waiting on condition [0x00007f8371bda000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-277" daemon prio=10 tid=0x00007f83b4017000 nid=0xdb0 waiting on condition [0x00007f83711d0000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
[root@portal-app-2 logs]# jstack 2173 |grep db7 -A60
"catalina-exec-282" daemon prio=10 tid=0x00007f838f7cf000 nid=0xdb7 waiting on condition [0x00007f83716d5000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-274" daemon prio=10 tid=0x00007f839005f000 nid=0xdb6 waiting on condition [0x00007f8370dcc000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-278" daemon prio=10 tid=0x00007f8398027000 nid=0xdb2 runnable [0x00007f83710cf000]
   java.lang.Thread.State: RUNNABLE
 at java.net.SocketInputStream.socketRead0(Native Method)
 at java.net.SocketInputStream.read(SocketInputStream.java:150)
 at java.net.SocketInputStream.read(SocketInputStream.java:121)
 at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:516)
 at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501)
 at org.apache.coyote.http11.Http11Processor.setRequestLineReadTimeout(Http11Processor.java:173)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:929)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
 - locked <0x0000000799c676f8> (a org.apache.tomcat.util.net.SocketWrapper)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-279" daemon prio=10 tid=0x00007f83840c6000 nid=0xdb1 waiting on condition [0x00007f8371bda000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
 - parking to wait for  <0x00000006150ac5c0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
 at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
 at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
 at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:104)
 at org.apache.tomcat.util.threads.TaskQueue.take(TaskQueue.java:32)
 at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:724)


"catalina-exec-277" daemon prio=10 tid=0x00007f83b4017000 nid=0xdb0 waiting on condition [0x00007f83711d0000]
   java.lang.Thread.State: WAITING (parking)
 at sun.misc.Unsafe.park(Native Method)
  • 线程信息转储
1
kill -3 3511
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
95
96
97
"FD_SOCK client connection handler,LIFERAY-TRANSPORT-CHANNEL-0,portal-app-2-53253" daemon prio=10 tid=0x00007f8388088800 nid=0x4204 runnable [0x00007f835edec000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:150)
        at java.net.SocketInputStream.read(SocketInputStream.java:121)
        at java.net.SocketInputStream.read(SocketInputStream.java:203)
        at org.jgroups.protocols.FD_SOCK$ClientConnectionHandler.run(FD_SOCK.java:1116)
        at java.lang.Thread.run(Thread.java:724)


"liferay/scheduler_engine-4" daemon prio=10 tid=0x00007f83800a0800 nid=0x4202 waiting on condition [0x00007f84105f9000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000060aac2ba8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at com.liferay.portal.kernel.concurrent.TaskQueue.take(TaskQueue.java:254)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor._getTask(ThreadPoolExecutor.java:490)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor.access$8(ThreadPoolExecutor.java:469)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:598)
        at java.lang.Thread.run(Thread.java:724)


"jigsaw/permission/dataextuser/initDataExtUser-23" daemon prio=10 tid=0x00007f83980a6800 nid=0x40d8 waiting on condition [0x00007f83d905c000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000060a86a7d0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
        at com.liferay.portal.kernel.concurrent.TaskQueue.poll(TaskQueue.java:194)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor._getTask(ThreadPoolExecutor.java:486)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor.access$8(ThreadPoolExecutor.java:469)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:598)
        at java.lang.Thread.run(Thread.java:724)


"jigsaw/permission/dataextuser/initDataExtUser-22" daemon prio=10 tid=0x00007f83bc041800 nid=0x3f27 waiting for monitor entry [0x00007f83d8f5b000]
   java.lang.Thread.State: BLOCKED (on object monitor)
        at com.ekingstar.jigsaw.permission.messaging.DataExtUserInitMessageListener.receive(DataExtUserInitMessageListener.java:36)
        - waiting to lock <0x000000060d0e8678> (a java.lang.Object)
        at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:72)
        at com.liferay.portal.kernel.messaging.ParallelDestination$1.run(ParallelDestination.java:69)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:682)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:593)
        at java.lang.Thread.run(Thread.java:724)


"jigsaw/permission/dataextuser/initDataExtUser-21" daemon prio=10 tid=0x00007f83a8409000 nid=0x3f26 runnable [0x00007f83d8b56000]
/nid
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000006142d3d88> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at com.liferay.portal.kernel.concurrent.TaskQueue.take(TaskQueue.java:254)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor._getTask(ThreadPoolExecutor.java:490)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor.access$8(ThreadPoolExecutor.java:469)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:598)
        at java.lang.Thread.run(Thread.java:724)


"jigsaw/permission/dataextuser/initDataExtUser-18" daemon prio=10 tid=0x00007f84144c7000 nid=0x7e8f waiting on condition [0x00007f8365695000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000060a86a7d0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
        at com.liferay.portal.kernel.concurrent.TaskQueue.poll(TaskQueue.java:194)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor._getTask(ThreadPoolExecutor.java:486)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor.access$8(ThreadPoolExecutor.java:469)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:598)
        at java.lang.Thread.run(Thread.java:724)


"jigsaw/permission/dataextuser/initDataExtUser-17" daemon prio=10 tid=0x00007f8394079800 nid=0x7e8e waiting on condition [0x00007f8364e8d000]
   java.lang.Thread.State: TIMED_WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x000000060a86a7d0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
        at com.liferay.portal.kernel.concurrent.TaskQueue.poll(TaskQueue.java:194)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor._getTask(ThreadPoolExecutor.java:486)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor.access$8(ThreadPoolExecutor.java:469)
        at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:598)
        at java.lang.Thread.run(Thread.java:724)


"FD_SOCK client connection handler,LIFERAY-TRANSPORT-CHANNEL-0,portal-app-2-53253" daemon prio=10 tid=0x00007f8388027800 nid=0x5622 runnable [0x00007f841aef7000]
   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:150)
        at java.net.SocketInputStream.read(SocketInputStream.java:121)
        at java.net.SocketInputStream.read(SocketInputStream.java:203)
        at org.jgroups.protocols.FD_SOCK$ClientConnectionHandler.run(FD_SOCK.java:1116)
        at java.lang.Thread.run(Thread.java:724)


"FD_SOCK client connection handler,liferay-multi-vm-clustered,portal-app-2-23624" daemon prio=10 tid=0x00007f83a8091000 nid=0x5620 runnable [0x00007f835d8d7000]

####分析

  • NEW:线程创建尚未启动。
  • RUNNABLE:包括操作系统线程状态中的Ready和Running,可能在等待时间片或者正在执行。
  • BLOCKED:线程被阻塞。
  • WAITING:不会分配CPU执行时间,直到别的线程显示的唤醒,否者无限期等待。LockSupport.park(),没有设置Timeout参数的Object.wait()和Thread.join(),会导致此现象。
  • TIMED_WAITING:不会分配CPU执行时间,直到系统自动唤醒,不需要别的线程显示唤醒。Thread.sleep(),LockSupport.parkNanos(),LockSupport.parkUntil(),设置了超时时间的Object.wait()和Thread.join(),会让线程进入有限期等待。
  • TERMINATED:线程执行结束。

从上面的线程信息可以初步判定为死循环