CentOS7 安装 Archiver Appliance 的 Grafana服务

1. 安装 Grafana 7

采用rpm的安装方式:

$ wget https://dl.grafana.com/enterprise/release/grafana-enterprise-7.5.13-1.x86_64.rpm
$ sudo rpm -Uvh grafana-enterprise-7.5.13-1.x86_64.rpm 

开启Grafana服务(默认服务端口3000)

$ systemctl daemon-reload
$ systemctl start grafana-server
$ systemctl status grafana-server

安装的详细细节:
Installs binary to /usr/sbin/grafana-server
Copies init.d script to /etc/init.d/grafana-server
Installs default file (environment vars) to /etc/sysconfig/grafana-server
Copies configuration file to /etc/grafana/grafana.ini
Installs systemd service (if systemd is available) name grafana-server.service to /usr/lib/systemd/system/grafana-server.service
The default configuration uses a log file at /var/log/grafana/grafana.log
The default configuration specifies an sqlite3 database at /var/lib/grafana/grafana.db

Grafana的介绍与使用
Install on RPM-based Linux (CentOS, Fedora, OpenSuse, Red Hat)

2. 安装 Go
$ wget https://studygolang.com/dl/golang/go1.17.6.linux-amd64.tar.gz
$ tar -xvf go1.17.6.linux-amd64.tar.gz
$ mkdir -p $HOME/gopath		//用于存放go get的安装包
$ vim ~/.bashrc
添加
GOROOT=$HOME/go
GOPATH=$HOME/gopath
export PATH=$GOROOT/bin:$PATH
export GOPATH
$ . ~/.bashrc

查看go版本:

$ go version
go version go1.17.6 linux/amd64

CentOS7安装Go环境
Go语言Centos7安装

3. 安装nodejs和yarn

安装nodejs 14:

$ wget https://nodejs.org/download/release/v14.9.0/node-v14.9.0-linux-x64.tar.gz
$ tar -xvf node-v14.9.0-linux-x64.tar.gz
$ wget https://github.com/yarnpkg/yarn/releases/download/v1.22.17/yarn-v1.22.17.tar.gz
$ tar -zxvf yarn-v1.22.17.tar.gz
$ vim ~/.bashrc
添加
NODEJS=$HOME/node-v14.9.0-linux-x64
YARN_HOME=$HOME/yarn-v1.22.17
export PATH=$YARN_HOME/bin:$NODEJS/bin:$PATH
$ . ~/.bashrc

查看nodejs、npm和yarn版本:

$ node -v
v14.9.0
$ npm -v
6.14.8
$ yarn -v
1.22.17

CentOS7 安装 nodejs
在centos7下安装nodejs14
centos7 安装nodejs和yarn最新版本

4. 下载grafana-plugin-sdk-go
$ go get -u github.com/grafana/grafana-plugin-sdk-go

直接执行以上命令会报错go get: module github.com/grafana/grafana-plugin-sdk-go: Get "https://proxy.golang.org/github.com/grafana/grafana-plugin-sdk-go/@v/list": dial tcp 142.251.42.241:443: i/o timeout
因为默认的GOPROXY指定的网站无法访问:

$ go env GOPROXY
GOPROXY="https://proxy.golang.org,direct"

更改GOPROXY为国内代理,并再次执行该命令:

$ go env -w GOPROXY=https://goproxy.cn
$ go get -u github.com/grafana/grafana-plugin-sdk-go
go: downloading github.com/grafana/grafana-plugin-sdk-go v0.125.0
go: downloading github.com/magefile/mage v1.11.0
go: downloading github.com/magefile/mage v1.12.1

Go proxy 设置
go get命令——一键获取代码、编译并安装
go get
go安装依赖包(go get, go module)

5. 安装mage

由于上一步骤中已经下载了mage安装包,所以可直接安装:

$ cd ~/gopath/pkg/mod/github.com/magefile/mage@v1.12.1
$ go run bootstrap.go 

报错Error: error creating generated mainfile: open mage_output_file.go: permission denied exit status 1
这是因为mage@v1.12.1文件夹及其中的文件只有可读属性:

$ ll ~/gopath/pkg/mod/github.com/magefile
dr-xr-xr-x.  9 dongxw dongxw 4096 Feb  8 16:22 mage@v1.11.0
dr-xr-xr-x. 10 dongxw dongxw 4096 Feb  8 16:40 mage@v1.12.1

为其添加可写属性后,即可执行成功:

$ go run bootstrap.go 
Running target: Install
exec: go "env" "GOBIN"
exec: go "env" "GOPATH"
exec: git "rev-parse" "--short" "HEAD"
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
exec: git "describe" "--tags"
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
exec: go "build" "-o" "/home/dongxw/gopath/bin/mage" "-ldflags=-X \"github.com/magefile/mage/mage.timestamp=2022-02-08T16:40:51+08:00\" -X \"github.com/magefile/mage/mage.commitHash=\" -X \"github.com/magefile/mage/mage.gitTag=dev\"" "github.com/magefile/mage"

此时mage的可执行文件已经安装在$GOPATH/bin路径下。在~/.bashrc文件中更改PATH:

PATH=$GOPATH/bin:$PATH

https://github.com/magefile/mage

6. 下载datasource plugin到Grafana的plugins文件夹下

测试了两种datasource plugin,分别为keck-observatory-epics-grafana-datasourcesasaki77-archiverappliance-datasource

6.1 下载keck-observatory-epics-grafana-datasource
$ wget https://github.com/KeckObservatory/epics-grafana-datasource.zip
$ sudo unzip epics-grafana-datasource-master.zip -d /var/lib/grafana/plugins
6.2 下载sasaki77-archiverappliance-datasource
$ wget https://github.com/sasaki77/archiverappliance-datasource/releases/archiverappliance-datasource-1.3.3.tar.gz
$ tar -zxvh archiverappliance-datasource-1.3.3.tar.gz
$ cd /var/lib/grafana/plugins
$ sudo mv /home/dongxw/archiverappliance-datasource-1.3.3 .
7. 构建plugin
7.1 使用keck-observatory-epics-grafana-datasource
$ cd /var/lib/grafana/plugins/epics-grafana-datasource-master/
$ mage -v

$ yarn install --ignore-engines
yarn install v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "@grafana/toolkit > @grafana/eslint-config@1.0.0-rc1" has incorrect peer dependency 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值