Hawkular安装

Hawkular安装

以下内容介绍Hawkular安装步骤,在安装过程中不要使用root用户,使用其他非root用户进行安装。

Apache Cassandra安装

安装 ccm(Cassandra Cluster Manager)

ccm是用于在本地主机上创建、启动和删除Apache Cassandra。

预先准备

  • 安装Python(本次环境是Python2.7版本)。

  • 安装pyYAML:sudo easy_install pyYaml
    若出现sudo: easy_install: command not found错误,则执行:

    sudo apt-get install python-setuptools
    

    完成后再执行命令:

    sudo easy_install pyYaml
    
  • 安装six :sudo easy_install six

  • 安装ant:sudo apt-get install ant

  • 安装psutil。

  • 安装Java(>=Java7)。

  • ccm只适用于localhost。如果要创建多个节点集群,需要使用别名。在现代linux发行版上,不需要做任何事情,但在Mac OS X中,您将需要创建别名:

    sudo ifconfig lo0 alias 127.0.0.2 up
    sudo ifconfig lo0 alias 127.0.0.3 up
    ...
    

    之后127.0.0.1,127.0.0.2和127.0.0.3都为可用的。

安装

执行命令:

pip install ccm

为Hawkular创建Cassandra集群

执行命令:

ccm create hawkular -v 3.0.12 -n 1
ccm updateconf "start_rpc: true"
ccm start

现在Cassandra在机器上的默认端口上运行。
常用命令:

ccm stop                                #停止当前集群的节点
ccm start                               #启动当前集群未启动的节点
ccm create                              #创建集群
ccm list                                #查看所有的集群
ccm switch  cluster_name                #切换集群
ccm status                              #查看当前集群状态
ccm remove                              #删除当前集群或者指定的集群(删除所有数据)

Hawkular Services安装

  1. 下载安装包hawkular-services
    下载名为:hawkular-services-dist-x.y.z.Final.zip (或者是 .tar.gz)的安装包,请下载0.35.0及之前的版本,因为0.36.0版本中存在未修复的问题。

  2. 解压安装包,解压目录根据需要选取(以下将Hawkular 解压目录称为$HS_HOME)。本次下载的安装包为: hawkular-services-dist-0.35.0.Final.zip,解压命令如下:

    sudo unzip hawkular-services-dist-0.35.0.Final.zip
    
  3. 进入hawkular-services-dist-0.35.0.Final目录,创建用户(替换命令中的myUsername和myPassword)。

    sudo sh ./bin/add-user.sh -a -u myUsername -p myPassword -g read-write,read-only
    
  4. 启动Hawkular Services:
    a.简单启动,命令如下:

    sh $HS_HOME/bin/standalone.sh
    

    b.使用嵌入式WildFly代理启动Hawkular Services(此功能用于监控自身,因为Hawkular Services基于WildFly,嵌入式代理可将指标和库存推送至Hawkular Services)。将myUsername和myPassword替换为步骤3中定义的用户名、密码,命令如下:

    sh $HS_HOME/bin/standalone.sh -Dhawkular.rest.user=myUsername -Dhawkular.rest.password=myPassword -Dhawkular.agent.enabled=true
    
  5. 启动成功后,访问 http://localhost:8080,界面如下所示:

    Hawkular安装_第1张图片
    Hawkular Services状态页面

  6. 访问http://localhost:8080/hawkular/metrics可查看Metrics服务状态,如下图:

    Hawkular安装_第2张图片
    Metrics Services状态页面

快速入门

示例流程:hawkular中添加Metrics,然后使用grafana读取所创建的Metrics,以下将介绍详细的实现。

添加Metrics

在hawkular的解压目录下新建文件metrics_day_1.json,内容如下:

[
  {"timestamp": 1468533600000, "value": 10},
  {"timestamp": 1468535400000, "value": 10},
  {"timestamp": 1468537200000, "value": 9.7},
  {"timestamp": 1468539000000, "value": 9.6},
  {"timestamp": 1468540800000, "value": 9.6},
  {"timestamp": 1468542600000, "value": 9.6},
  {"timestamp": 1468544400000, "value": 9.5},
  {"timestamp": 1468546200000, "value": 9.5},
  {"timestamp": 1468548000000, "value": 9.5},
  {"timestamp": 1468549800000, "value": 9.5},
  {"timestamp": 1468551600000, "value": 9.5},
  {"timestamp": 1468553400000, "value": 9.5},
  {"timestamp": 1468555200000, "value": 9.6},
  {"timestamp": 1468557000000, "value": 9.6},
  {"timestamp": 1468558800000, "value": 9.7},
  {"timestamp": 1468560600000, "value": 9.7},
  {"timestamp": 1468562400000, "value": 9.8},
  {"timestamp": 1468564200000, "value": 10},
  {"timestamp": 1468566000000, "value": 10.2},
  {"timestamp": 1468567800000, "value": 10.3},
  {"timestamp": 1468569600000, "value": 10},
  {"timestamp": 1468571400000, "value": 9.9},
  {"timestamp": 1468573200000, "value": 10.1},
  {"timestamp": 1468575000000, "value": 9.7},
  {"timestamp": 1468576800000, "value": 9.2},
  {"timestamp": 1468578600000, "value": 9.2},
  {"timestamp": 1468580400000, "value": 9.9},
  {"timestamp": 1468582200000, "value": 11},
  {"timestamp": 1468584000000, "value": 12.4},
  {"timestamp": 1468585800000, "value": 13.3},
  {"timestamp": 1468587600000, "value": 14.3},
  {"timestamp": 1468589400000, "value": 13.6},
  {"timestamp": 1468591200000, "value": 11},
  {"timestamp": 1468593000000, "value": 10.2},
  {"timestamp": 1468594800000, "value": 10.1},
  {"timestamp": 1468596600000, "value": 10.3},
  {"timestamp": 1468598400000, "value": 10.9},
  {"timestamp": 1468600200000, "value": 11.4},
  {"timestamp": 1468602000000, "value": 11.7},
  {"timestamp": 1468603800000, "value": 11.5},
  {"timestamp": 1468605600000, "value": 11.1},
  {"timestamp": 1468607400000, "value": 10.6},
  {"timestamp": 1468609200000, "value": 10.1},
  {"timestamp": 1468611000000, "value": 9.6},
  {"timestamp": 1468612800000, "value": 9.2},
  {"timestamp": 1468614600000, "value": 9.1},
  {"timestamp": 1468616400000, "value": 9.1},
  {"timestamp": 1468618200000, "value": 9.1}
]

执行命令:

cd hawkular-services-dist-0.35.0.Final/
curl -u myUsername:myPassword -X POST http://localhost:8080/hawkular/metrics/gauges/temperature/raw -d @metrics_day_1.json -H "Content-Type: application/json" -H "Hawkular-Tenant: myTenant"

至此已经添加了组织:myTenant,Metric:temperature

直接使用REST API查看

结果如下:

[root@localhost hawkular-services-dist-0.35.0.Final]# curl -u admin:admin123 \
> -X GET "http://localhost:8080/hawkular/metrics/gauges/temperature/raw?start=1468578600000&end=1468594800001&order=ASC" \
>   -H "Content-Type: application/json" -H "Hawkular-Tenant: myTenant"
[{"timestamp":1468578600000,"value":9.2},{"timestamp":1468578600000,"value":9.2},{"timestamp":1468580400000,"value":9.9},{"timestamp":1468580400000,"value":9.9},{"timestamp":1468582200000,"value":11.0},{"timestamp":1468582200000,"value":11.0},{"timestamp":1468584000000,"value":12.4},{"timestamp":1468584000000,"value":12.4},{"timestamp":1468585800000,"value":13.3},{"timestamp":1468585800000,"value":13.3},{"timestamp":1468587600000,"value":14.3},{"timestamp":1468587600000,"value":14.3},{"timestamp":1468589400000,"value":13.6},{"timestamp":1468589400000,"value":13.6},{"timestamp":1468591200000,"value":11.0},{"timestamp":1468591200000,"value":11.0},{"timestamp":1468593000000,"value":10.2},{"timestamp":1468593000000,"value":10.2},{"timestamp":1468594800000,"value":10.1},{"timestamp":1468594800000,"value":10.1}]

给grafana安装hawkular-datasource插件

详细教程参见官方文档。

  • 使用grafana-cli直接安装,命令如下:

    grafana-cli plugins install hawkular-datasource
    

    插件会安装在grafana的plugins目录下,默认是在/var/lib/grafana/plugins里。

  • 手动安装,直接下载[插件安装包]( download the .zip file)到grafana/data/plugins目录下,然后解压。

配置数据源

示例配置如下图所示:

Hawkular安装_第3张图片
配置hawkular数据源

Tenant填写创建的组织名,Token不用填写。

配置面板

新建面板之后,做如下配置:

Hawkular安装_第4张图片

配置完成后,调整查询时间(此次测试数据产生的时间在2016年7月15日),然后就可以在面板中查看测试数据了,如下图:

Hawkular安装_第5张图片

Troubleshooting

使用hawkular-services-dist-0.36.0.Final.zip包安装,启动hawkular时出现问题:

10:33:47,567 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-7) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/hawkular/inventory/status
        at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:75)
        at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)
        at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:257)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:194)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)

访问 http://localhost:8080,界面如下:

Hawkular安装_第6张图片

解决办法:使用hawkular-services-dist-0.35.0.Final.zip(.tar.zip)及之前的安装包。

补充
配置hawkular连接manageiq步骤:

  1. 拉取manageiq镜像:

    sudo docker pull manageiq/manageiq:fine-2
    
  2. 运行manageiq:

    sudo docker run --privileged -d -p 8443:443   manageiq/manageiq:fine-2
    
  3. 连接manageiq和hawkular:
    详细步骤参见官方配置文档中的ADDING HAWKULAR AS PROVIDER IN MANAGEIQ部分,注意此处访问的是https://localhost:8443。
    在配置中出现不能连接hawkular时可运行如下命令:

    iptables -I INPUT 1 -i docker0 -j ACCEPT
    
  4. 连接成功之后可以如下图所示:

    Hawkular安装_第7张图片

你可能感兴趣的:(Hawkular安装)