array(2) { ["docs"]=> array(10) { [0]=> array(10) { ["id"]=> string(3) "428" ["text"]=> string(77) "Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(8) "DonetRen" ["tagsname"]=> string(55) "Visual Studio 2017|MSDN帮助|C#程序|.NET|Help Viewer" ["tagsid"]=> string(23) "[401,402,403,"300",404]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400964" ["_id"]=> string(3) "428" } [1]=> array(10) { ["id"]=> string(3) "427" ["text"]=> string(42) "npm -v;报错 cannot find module "wrapp"" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "zzty" ["tagsname"]=> string(50) "node.js|npm|cannot find module "wrapp“|node" ["tagsid"]=> string(19) "[398,"239",399,400]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400760" ["_id"]=> string(3) "427" } [2]=> array(10) { ["id"]=> string(3) "426" ["text"]=> string(54) "说说css中pt、px、em、rem都扮演了什么角色" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(12) "zhengqiaoyin" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511400640" ["_id"]=> string(3) "426" } [3]=> array(10) { ["id"]=> string(3) "425" ["text"]=> string(83) "深入学习JS执行--创建执行上下文(变量对象,作用域链,this)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "Ry-yuan" ["tagsname"]=> string(33) "Javascript|Javascript执行过程" ["tagsid"]=> string(13) "["169","191"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511399901" ["_id"]=> string(3) "425" } [4]=> array(10) { ["id"]=> string(3) "424" ["text"]=> string(30) "C# 排序技术研究与对比" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "vveiliang" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(8) ".Net Dev" ["catesid"]=> string(5) "[199]" ["createtime"]=> string(10) "1511399150" ["_id"]=> string(3) "424" } [5]=> array(10) { ["id"]=> string(3) "423" ["text"]=> string(72) "【算法】小白的算法笔记:快速排序算法的编码和优化" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(9) "penghuwan" ["tagsname"]=> string(6) "算法" ["tagsid"]=> string(7) "["344"]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511398109" ["_id"]=> string(3) "423" } [6]=> array(10) { ["id"]=> string(3) "422" ["text"]=> string(64) "JavaScript数据可视化编程学习(二)Flotr2,雷达图" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "chengxs" ["tagsname"]=> string(28) "数据可视化|前端学习" ["tagsid"]=> string(9) "[396,397]" ["catesname"]=> string(18) "前端基本知识" ["catesid"]=> string(5) "[198]" ["createtime"]=> string(10) "1511397800" ["_id"]=> string(3) "422" } [7]=> array(10) { ["id"]=> string(3) "421" ["text"]=> string(36) "C#表达式目录树(Expression)" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(4) "wwym" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(4) ".NET" ["catesid"]=> string(7) "["119"]" ["createtime"]=> string(10) "1511397474" ["_id"]=> string(3) "421" } [8]=> array(10) { ["id"]=> string(3) "420" ["text"]=> string(47) "数据结构 队列_队列实例:事件处理" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(7) "idreamo" ["tagsname"]=> string(40) "C语言|数据结构|队列|事件处理" ["tagsid"]=> string(23) "["246","247","248",395]" ["catesname"]=> string(12) "数据结构" ["catesid"]=> string(7) "["133"]" ["createtime"]=> string(10) "1511397279" ["_id"]=> string(3) "420" } [9]=> array(10) { ["id"]=> string(3) "419" ["text"]=> string(47) "久等了,博客园官方Android客户端发布" ["intro"]=> string(288) "目录 ECharts 异步加载 ECharts 数据可视化在过去几年中取得了巨大进展。开发人员对可视化产品的期望不再是简单的图表创建工具,而是在交互、性能、数据处理等方面有更高的要求。 chart.setOption({ color: [ " ["username"]=> string(3) "cmt" ["tagsname"]=> string(0) "" ["tagsid"]=> string(2) "[]" ["catesname"]=> string(0) "" ["catesid"]=> string(2) "[]" ["createtime"]=> string(10) "1511396549" ["_id"]=> string(3) "419" } } ["count"]=> int(200) } 222 skywalking对nginx的支持 - 爱码网

转载自博客:https://blog.csdn.net/qq_24267619/article/details/106622434

skywalking要支持nginx:

skywalking对nginx的采集的agent插件是基于lua来编写的,所以要采集nginx,nginx安装的时候必须要支持lua插件

  • 默认情况下Nginx不支持Lua模块,需要安装LuaJIT解释器,并且重新编译Nginx,或者可使用国人开发的openrestry
  • 需要的模块:LuaJIT,Ngx_devellua-nginx-module
  • Luajit官网:https://luajit.or

 

第一种方式nginx安装lua插件

第二种方式使用国人已经编写好的openrestry,这个openrestry里面就封装好了nginx+lua

第一种方式nginx安装支持lua查看:https://blog.csdn.net/qq_31725371/article/details/85226116

 

 

  • 默认情况下Nginx不支持Lua模块,需要安装LuaJIT解释器,并且重新编译Nginx,或者可使用国人开发的openrestry
  • 需要的模块:LuaJIT,Ngx_devellua-nginx-module
  • Luajit官网:https://luajit.org

1. 环境准备

[root@nginx_lua ~]# yum install -y gcc gcc-c++ make pcre-devel zlib-devel openssl-devel
  • 1

2. 下载最新的luajitngx_devel_kit以及lua-nginx-module解压

[root@nginx_lua ~]# mkdir -p /soft/src 
[root@nginx_lua ~]# cd /soft/src/
wget https://luajit.org/download/LuaJIT-2.0.4.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz
  • 1
  • 2
  • 3
  • 4
  • 5

3. 解压ngx_devel_kit以及lua-nginx-module

[root@nginx_lua src]# tar xf v0.2.19.tar.gz
[root@nginx_lua src]# tar xf v0.10.13.tar.gz
  • 1
  • 2

4. 编译安装LuaJIT,即Lua及时编译器

[root@nginx_lua src]# tar xf LuaJIT-2.0.4.tar.gz
[root@nginx_lua src]# cd LuaJIT-2.0.4/
[root@nginx_lua LuaJIT-2.0.4]# make && make install

  • 1
  • 2
  • 3
  • 4

5. 编译安装Nginx

[root@nginx_lua src]# wget http://nginx.org/download/nginx-1.14.2.tar.gz
[root@nginx_lua src]# tar xf nginx-1.14.2.tar.gz
[root@nginx_lua src]# cd nginx-1.14.2
[root@nginx_lua nginx-1.14.2]# ./configure --prefix=/soft/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_dav_module --with-file-aio --with-http_dav_module --add-module=../ngx_devel_kit-0.2.19/ --add-module=../lua-nginx-module-0.10.13/
[root@nginx_lua nginx-1.14.2]# make && make install
[root@nginx_lua nginx-1.14.2]# ln -s /soft/nginx/sbin/nginx /usr/bin/nginx
[root@nginx_lua conf]# vim nginx.conf  #简单配置写nginx测试Nginx是否已经支持Lua(lua指令方式)
...
server {
 location /test_lua {
                default_type text/html;
                content_by_lua_block {
                        ngx.say("Hello Lua!") 
                }
        }
...
}

#lua指令方式

#在server 中添加一个localtion

location /hello {

            default_type 'text/plain';

            content_by_lua 'ngx.say("hello, lua")';

        }

#lua文件方式

#在server 中添加一个localtion

location /lua {

    default_type 'text/html';

    content_by_lua_file conf/lua/test.lua; #相对于nginx安装目录

}

#test.lua文件内容
ngx.say("hello world");

//建立软连接,如果不建立软链接,则会出现share object错误
[root@nginx_lua conf]# nginx -t
/soft/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
[root@nginx_lua conf]# 

[root@nginx_lua lib64]# ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2
[root@nginx_lua lib64]# ll libluajit-5.1.so.2
lrwxrwxrwx 1 root root 33 Dec 21 20:52 libluajit-5.1.so.2 -> /usr/local/lib/libluajit-5.1.so.2
[root@nginx_lua lib64]#

#//加载lua库,加入到ld.so.conf文件(暂时不执行这一步)
#[root@nginx_lua nginx-1.14.2]# echo "/usr/local/LuaJIT/lib" >> /etc/ld.so.conf

[root@nginx_lua conf]# nginx -t
nginx: the configuration file /soft/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /soft/nginx/conf/nginx.conf test is successful
[root@nginx_lua conf]# nginx -s reload
 
  • 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

6. 测试安装Lua成功

skywalking对nginx的支持

 

点击上方蓝色字体,开始关注


Skywalking 支持 HTTP 1.1 的 PR 折腾了我好久,E2E 端到端测试是真的把我搞“怕”了···

OpenResty 是什么?

OpenResty是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。

因此,很多公司都会使用 OpenResty 开发出适合自己业务的高性能 web Server 模块。

那么它和 Skywalking 有什么关心呢?我们得先知道Skywalking是什么,Skywalking 是由Java 语言开发的一套APM系统,主要监控服务与服务之间的调用链路以及服务应用指标。官方的介绍是:分布式系统的应用程序性能监视工具,专为微服务、云原生架构和基于容器(Docker、K8s、Mesos)架构而设计。具体可以移步 Github: https://github.com/apache/skywalking

假设,当我们的使用Nginx/OpenResty 为我们的微服务做负载均衡的时候,怎样才能将整条链路通过请求串起来,以及怎样保证整个链路的拓扑图正确呢?目前的解决方案是在 Nginx 中支持链路信息的上报,同时能够将请求链路关键信息传递给上游应用。

Apache Skywalking Nginx Lua 项目

Githu项目地址:https://github.com/apache/skywalking-nginx-lua,该项目是吴晟采用 Lua 实现的 Nginx/OpenResty SDK。主要就是实现将 Nginx 作为一个节点注册至Skywalking,同时将链路 TraceId 传递给上游服务,并将链路上报给 Skywalking。

Skywalking 7.x 开始支持 HTTP 1.1

具体PR请参考: https://github.com/apache/skywalking/pull/4399

Skywalking 监控 Java、Golang、Node、.NET 语言的链路都是采用了 SDK 或者 Agent 的方式将数据上报到 Skyalking 后端。不过都是采用 gRPC 的方式和后端交互,Apache Nginx Lua 考虑到 Nginx 足以胜任 10K 以上并发连接响应,并没有采用 Nginx gRPC的方式,因此需要 Skywalking 支持 HTTP 1.1 的通信接口。

怎么玩起来?

这里先画一个怎么玩的逻辑图:

skywalking对nginx的支持skywalking_nginx_lua

怎么搭建Skywalkng 的流程就不再赘述了,不是本文的重点,着重介绍怎么跑Skywalking Nginx Lua。 可以查看发布在哔哩哔哩上面的教程:https://www.bilibili.com/video/av35990012/

  • 首先安装 Openresty 参照官网:https://openresty.org/cn/download.html

Macos 系统采用 Homebrew 安装:

  1.  
    > brew install openresty/brew/openresty
  2.  
     
  3.  
    ==> Summary
  4.  
    ???? /usr/local/Cellar/openresty/1.15.8.2: 303 files, 6.5MB, built in 1 minute
  5.  
    ==> Caveats
  6.  
    ==> openresty-openssl
  7.  
    openresty-openssl is keg-only, which means it was not symlinked into /usr/local,
  8.  
    because only for use with OpenResty.
  9.  
     
  10.  
    If you need to have openresty-openssl first in your PATH run:
  11.  
    echo 'export PATH="/usr/local/opt/openresty-openssl/bin:$PATH"' >> ~/.zshrc
  12.  
     
  13.  
    For compilers to find openresty-openssl you may need to set:
  14.  
    export LDFLAGS="-L/usr/local/opt/openresty-openssl/lib"
  15.  
    export CPPFLAGS="-I/usr/local/opt/openresty-openssl/include"
  16.  
     
  17.  
    ==> openresty
  18.  
    To have launchd start openresty/brew/openresty now and restart at login:
  19.  
    brew services start openresty/brew/openresty
  20.  
    Or, if you don't want/need a background service you can just run:
  21.  
    openresty
  22.  
     
  • 克隆或者下载 Apache Nginx Lua库

  1.  
    git clone https://github.com/apache/skywalking-nginx-lua.git
  2.  
    cd skywalking-nginx-lua/examples/

该目录存放了关于Nginx的样例配置,如下是部分内容:

  • nginx.conf:

  1.  
    http {
  2.  
    # 这里指向刚刚克隆下来的 skywalking nginx lua项目
  3.  
    lua_package_path "path/to/skywalking-nginx-lua/lib/skywalking/?.lua;;";
  4.  
    # Buffer represents the register inform and the queue of the finished segment
  5.  
    lua_shared_dict tracing_buffer 100m;
  6.  
     
  7.  
    init_worker_by_lua_block {
  8.  
    local metadata_buffer = ngx.shared.tracing_buffer
  9.  
     
  10.  
    metadata_buffer:set('serviceName', 'User Service Name')
  11.  
    -- Instance means the number of Nginx deloyment, does not mean the worker instances
  12.  
    metadata_buffer:set('serviceInstanceName', 'User Service Instance Name')
  13.  
     
  14.  
    # 这里需要指定上报Skywalking 的后端地址。端口默认是12800
  15.  
    require("client"):startBackendTimer("http://127.0.0.1:12800")
  16.  
    }
  17.  
     
  18.  
    server {
  19.  
    listen 8080;
  20.  
    location /test {
  21.  
    default_type text/html;
  22.  
     
  23.  
    rewrite_by_lua_block {
  24.  
    require("tracer"):start("upstream service")
  25.  
    }
  26.  
    # 这里则是 上图中 nginx 上游服务的地址
  27.  
    proxy_pass http://127.0.0.1:8080/upstream/test;
  28.  
    body_filter_by_lua_block {
  29.  
    if ngx.arg[2] then
  30.  
    require("tracer"):finish()
  31.  
    end
  32.  
    }
  33.  
    log_by_lua_block {
  34.  
    require("tracer"):prepareForReport()
  35.  
    }
  36.  
    }
  37.  
    }
  38.  
    }
  • 直接启动 OpenResty 即可,并指定配置文件,例如:

openresty -c /Users/tanjian/gitprojects/skywalking-nginx-lua/examples/nginx.conf

相关文章: