今天在安装完grafana后,想去修改它启动的默认端口为3003,找到配置文件如下:
我尝试修改grafana.ini
[root@node haproxy]# cd /etc/grafana/
[root@node grafana]# ll
总用量 36
-rw-r----- 1 root grafana 27260 7月 27 23:41 grafana.ini
-rw-r----- 1 root grafana 2289 7月 27 23:26 ldap.toml
drwxr-xr-x 6 root grafana 4096 7月 27 23:26 provisioning
里面的
[server]
# Protocol (http, https, h2, socket)
;protocol = http
# The ip address to bind to, empty will bind to all interfaces
;http_addr =
# The http port to use
;http_port = 3000
但是修改3000为3003后,还是不行,根本无法访问,所以尝试使用haproxy做一个代理。
下载haproxy后(yum install -y haproxy 即可),修改配置文件,如下(注释以上都是官方默认的,只展示代理的信息):
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend mysql_front
bind *:3003
mode tcp
default_backend grafana
backend grafana
mode tcp
balance leastconn
server grafana 内网IP:3000
再次访问3003端口即可!

reference:
https://grafana.com/docs/grafana/latest/administration/configuration/
网友评论