服务器配置属于小白级别

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

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

安装:

    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/refsfatal: 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.svggo-torch -u http://localhost:8080/debug/pprof/heap -p > heap-local.svg


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