Grafana基础配置手册

snow chuai汇总、整理、撰写—2020/2/28


1. 安装Grafana
1) Grafana WEB面板
[root@srv1 ~]# cat > /etc/yum.repos.d/grafana.repo <<'EOF'
[grafana]
name=grafana
baseurl=https://mirror.tuna.tsinghua.edu.cn/grafana/yum/el7
gpgkey=https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana
enabled=0
gpgcheck=1
EOF
[root@srv1 ~]# yum --enablerepo=grafana install grafana initscripts fontconfig -y
2) 配置Grafana [root@srv1 ~]# vim /etc/grafana/grafana.ini # 修改32行,取消注释并指定所使用的协议http/https protocol = http
# 修改38行,指定监听的端口 http_port = 3000
# 修改41行,指定本机的FQDN domain = srv1.1000cc.net
[root@srv1 ~]# systemctl enable --now grafana-server
3) 配置防火墙 [root@srv1 ~]# firewall-cmd --add-port=3000/tcp --permanent success [root@srv1 ~]# firewall-cmd --reload success
2. 准备数据源--Graphite
1) 安装httpd
[root@srv1 ~]# yum install httpd -y
[root@srv1 ~]# systemctl enable --now httpd
[root@srv1 ~]# firewall-cmd --add-service=http --permanent success [root@srv1 ~]# firewall-cmd --reload success
2) 创建特权用户 [root@srv1 ~]# echo -e 'Defaults:snow !requiretty\nsnow ALL = (root) NOPASSWD:ALL' > /etc/sudoers.d/graphite
[root@srv1 ~]# cat /etc/sudoers.d/graphite Defaults:snow !requiretty snow ALL = (root) NOPASSWD:ALL
3) 安装Graphite [root@srv1 ~]# yum --enablerepo=epel install graphite-web python-carbon -y
4) 配置Graphite [root@srv ~]# vim /etc/graphite-web/local_settings.py # 取消13行注释并指定秘钥 SECRET_KEY = '/1000cc_key' # 取消23行注释并指定时区 TIME_ZONE = 'Asia/Shanghai'
[root@srv1 ~]# vim /etc/httpd/conf.d/graphite-web.conf # 于30行新建一行,添加允许访问Graphite的网络地址或IP地址 Require local Require ip 192.168.10.0/24
5) 初始化Graphite数据库 [root@srv1 ~]# /usr/lib/python2.7/site-packages/graphite/manage.py syncdb Creating tables ... Creating table account_profile Creating table account_variable Creating table account_view Creating table account_window Creating table account_mygraph Creating table dashboard_dashboard_owners Creating table dashboard_dashboard Creating table events_event Creating table url_shortener_link Creating table auth_permission Creating table auth_group_permissions Creating table auth_group Creating table auth_user_groups Creating table auth_user_user_permissions Creating table auth_user Creating table django_session Creating table django_admin_log Creating table django_content_type Creating table tagging_tag Creating table tagging_taggeditem
You just installed Django's auth system, which means you don't have any superusers defined. Would you like to create one now? (yes/no): yes Username (leave blank to use 'root'): snow Email address: snow@localhost Password: # 输入snow的密码 Password (again): Superuser created successfully. Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s)
[root@srv1 ~]# chown -R apache. /var/lib/graphite-web [root@srv1 ~]# systemctl enable --now carbon-cache [root@srv1 ~]# systemctl restart httpd
6) SELinux设定 [root@srv1 ~]# setsebool -P httpd_can_network_connect on
3. 访问并在WEB Dashboard上配置Grafana
[浏览器]====>http://srv1.1000cc.net:3000===>账户名:admin=====>密码:admin












 

如对您有帮助,请随缘打个赏。^-^

gold