DevOps之grafana的部署

此次部署的grafana使用postgres數(shù)據(jù)庫(kù)來(lái)存放數(shù)據(jù)

安裝postgresql

服務(wù)器

ip 系統(tǒng) 配置 目錄 部署版本
172.24.32.200 centos7.7 2c4g /var/lib/pgsql/12/ 12
  • 1、官網(wǎng)
https://www.postgresql.org/download/linux/redhat/
  • 2、下載rpm源
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
  • 3、安裝客戶端
yum install -y postgresql12
  • 4、安裝服務(wù)端
yum install postgresql12-server
  • 5、初始化并且開(kāi)機(jī)自啟動(dòng)
/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12
  • 6、創(chuàng)建賬號(hào)密碼
sudo su postgres  
psql postgres
ALTER USER postgres WITH PASSWORD 'test123'
執(zhí)行結(jié)果
[root@test01 ~]# sudo su postgres  
bash-4.2$ psql postgres
could not change directory to "/root": Permission denied
psql (12.3)
Type "help" for help.

postgres=# ALTER USER postgres WITH PASSWORD 'test123';
ALTER ROLE

  • 7、修改配置文件和登陸權(quán)限
echo >>/var/lib/pgsql/12/data/pg_hba.conf<<EOF
host    all             all             172.24.32.200/32        trust
EOF
sed -i "s| listen_addresses = 'localhost' |listen_addresses = '*'|g" /var/lib/pgsql/12/data/postgresql.conf
  • 8、重啟下數(shù)據(jù)庫(kù)
systemctl start postgresql-12

安裝grafana

服務(wù)器

ip 系統(tǒng) 配置 目錄 部署版本
172.24.32.200 centos7.7 2c4g /etc/grafana/grafana.ini 6.7.3

安裝

官網(wǎng)

https://grafana.com/docs/grafana/latest/installation/debian/
cd /usr/local/src
wget https://dl.grafana.com/oss/release/grafana-6.7.3-1.x86_64.rpm
yum install -y grafana-6.7.3-1.x86_64.rpm

修改配置文件

主要修改端口、數(shù)據(jù)庫(kù)(sqlite改成postgresql)、告警郵箱

echo >>/etc/grafana/grafana.ini<<EOF
[paths]
[server]
http_port = 3001
[database]
type = postgres
host = 172.24.32.200:5432
name = grafana
user = postgres
password = test123
[remote_cache]
[dataproxy]
[analytics]
[security]
[snapshots]
[dashboards]
[users]
[auth]
[auth.anonymous]
[auth.github]
[auth.gitlab]
[auth.google]
[auth.grafana_com]
[auth.azuread]
[auth.generic_oauth]
[auth.saml] # Enterprise only
[auth.basic]
[auth.proxy]
[auth.ldap]
[smtp]
enabled = true
host = smtp.exmail.qq.com:465
user = lugo@test.com
password = test33
skip_verify = true
from_address = lugo@test.com
from_name = Grafana
[emails]
[log]
[log.console]
[log.file]
[log.syslog]
[quota]
[alerting]
[explore]
[metrics]
[metrics.graphite]
[grafana_com]
[tracing.jaeger]
[external_image_storage]
[external_image_storage.s3]
[external_image_storage.webdav]
[external_image_storage.gcs]
[external_image_storage.azure_blob]
[external_image_storage.local]
[rendering]
[panels]
[plugins]
[enterprise]
[feature_toggles]

EOF

啟動(dòng)和開(kāi)機(jī)自啟動(dòng)

systemctl enable grafana-server
systemctl start grafana-server

登陸,初始密碼admin、admin

http://172.24.32.200:3001/login

改密碼 test123

添加餅圖插件

grafana-cli plugins install grafana-piechart-panel

重啟服務(wù)生效

service grafana-server restart
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容