安装golang 火焰图

服务器配置属于小白级别

安装个火焰图费了一天半的时间,配置路径的问题【扎心到不行的说】

总结一下安装过程和遇到的问题

安装:

    1、 安装go-torch【遇到各种问题,心塞】

            go get github.com/uber/go-torch

    2、安装FlameGraph

           cd $GOPATH && git clone https://github.com/brendangregg/FlameGraph.git

         export PATH=$PATH:$GOPATH/FlameGraph 【这步一定要设置,生成火焰图时会用到】

    3、安装graphviz (CentOS, Redhat) 【并不知道有什么用,但是我还是装了,了解的大神可以帮忙科普一下】

          yum install graphviz

使用:

package main
import (
    "net/http"
    "net/http/pprof"
)
func main() {
    // 主函数中添加
        http.HandleFunc("/debug/pprof/block", pprof.Index)
        http.HandleFunc("/debug/pprof/goroutine", pprof.Index)
        http.HandleFunc("/debug/pprof/heap", pprof.Index)
        http.ListenAndServe("0.0.0.0:8888", nil) //注意此处,遇到错误
    }()
    //你的代码
}

遇到的问题:

    1、安装go-torch 报错【因为git版本太低,更新git版本,参考

    https://blog.csdn.net/ei__nino/article/details/73504313

[root@iZbp19x98x8whxmbtfudqsZ ~]# go get github.com/uber/go-torch
# cd .; git clone https://github.com/uber/go-torch /usr/local/gopath/src/github.com/uber/go-torch
Initialized empty Git repository in /usr/local/gopath/src/github.com/uber/go-torch/.git/
error:  while accessing https://github.com/uber/go-torch/info/refs
fatal: HTTP request failed
package github.com/uber/go-torch: exit status 128
[root@iZbp19x98x8whxmbtfudqsZ ~]# git --version
git version 1.7.1

    2、更新git版本之后 【开始错误https】

[root@iZbp19x98x8whxmbtfudqsZ git-2.13.1]# git --version
git version 2.13.1
[root@iZbp19x98x8whxmbtfudqsZ git-2.13.1]# go get github.com/uber/go-torch
# cd .; git clone https://github.com/uber/go-torch /usr/local/gopath/src/github.com/uber/go-torch
Cloning into '/usr/local/gopath/src/github.com/uber/go-torch'...
fatal: Unable to find remote helper for 'https'
package github.com/uber/go-torch: exit status 128
     在~/.bash_profile或者/etc/profile中设置环境变量 
    export PATH=$PATH:/usr/libexec/git-core

    然后 source一下该文件使其生效

    3、配置环境变量之后【更新nss: yum update nss

[root@iZbp19x98x8whxmbtfudqsZ git-2.13.1]# go get github.com/uber/go-torch
# cd .; git clone https://github.com/uber/go-torch /usr/local/gopath/src/github.com/uber/go-torch
Cloning into '/usr/local/gopath/src/github.com/uber/go-torch'...
error:  while accessing https://github.com/uber/go-torch/info/refs

fatal: HTTP request failed
package github.com/uber/go-torch: exit status 128

    4、go get github.com/uber/go-torch 成功了

但是bin下面怎么没go-torch【因为我的环境变量配置到其他路径了,这就是粗心的后果,浪费了一天半的时间】

Complete!

然后压测的时候你去运行,开森啦

go-torch -u http://localhost:8080/debug/pprof/ -p > profile-local.svg

go-torch -u http://localhost:8080/debug/pprof/heap -p > heap-local.svg


哎,优化方向看不到头的说【背起我的小背囊继续前行】




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值