在使用docker-compose部署grafana过程中,启动正常,但是容器不存活也没有进程。
1,启动以后,docker ps,发现没有容器存在。
[root@NengLi grafana]
[+] Running 1/1
? Container grafana Started 0.3s
[root@NengLi grafana]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@NengLi grafana]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8c9eae149bc3 grafana/grafana-oss:9.2.4-ubuntu "/run.sh" 14 seconds ago Exited (2) 12 seconds ago grafana
2,ps -ef 没有进程
[root@NengLi grafana]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f810559100e grafana/grafana-oss:9.2.4-ubuntu "/run.sh" 4 seconds ago Exited (2) 3 seconds ago grafana
[root@NengLi grafana]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@NengLi grafana]
root 155239 148663 0 09:38 pts/0 00:00:00 grep --color=auto grafana
3,检查grafana容器日志,发现了报错 “权限被拒绝”
[root@NengLi ~]
logger=settings t=2023-04-24T09:37:06.577161863+08:00 level=info msg="Starting Grafana" version=9.2.4 commit=64017e8ca6 branch=HEAD compiled=2022-11-08T18:38:42+08:00
logger=settings t=2023-04-24T09:37:06.577435839+08:00 level=info msg="Config loaded from" file=/usr/share/grafana/conf/defaults.ini
logger=settings t=2023-04-24T09:37:06.577455935+08:00 level=info msg="Config loaded from" file=/etc/grafana/grafana.ini
logger=settings t=2023-04-24T09:37:06.577464121+08:00 level=info msg="Config overridden from command line" arg="default.paths.data=/var/lib/grafana"
logger=settings t=2023-04-24T09:37:06.577471515+08:00 level=info msg="Config overridden from command line" arg="default.paths.logs=/var/log/grafana"
logger=settings t=2023-04-24T09:37:06.577477778+08:00 level=info msg="Config overridden from command line" arg="default.paths.plugins=/var/lib/grafana/plugins"
logger=settings t=2023-04-24T09:37:06.577483298+08:00 level=info msg="Config overridden from command line" arg="default.paths.provisioning=/etc/grafana/provisioning"
logger=settings t=2023-04-24T09:37:06.577488379+08:00 level=info msg="Config overridden from command line" arg="default.log.mode=console"
logger=settings t=2023-04-24T09:37:06.577493597+08:00 level=info msg="Config overridden from Environment variable" var="GF_PATHS_DATA=/var/lib/grafana"
logger=settings t=2023-04-24T09:37:06.577499934+08:00 level=info msg="Config overridden from Environment variable" var="GF_PATHS_LOGS=/var/log/grafana"
logger=settings t=2023-04-24T09:37:06.577504804+08:00 level=info msg="Config overridden from Environment variable" var="GF_PATHS_PLUGINS=/var/lib/grafana/plugins"
logger=settings t=2023-04-24T09:37:06.577510024+08:00 level=info msg="Config overridden from Environment variable" var="GF_PATHS_PROVISIONING=/etc/grafana/provisioning"
logger=settings t=2023-04-24T09:37:06.577516162+08:00 level=info msg="Path Home" path=/usr/share/grafana
logger=settings t=2023-04-24T09:37:06.577521225+08:00 level=info msg="Path Data" path=/var/lib/grafana
logger=settings t=2023-04-24T09:37:06.577525238+08:00 level=info msg="Path Logs" path=/var/log/grafana
logger=settings t=2023-04-24T09:37:06.57752922+08:00 level=info msg="Path Plugins" path=/var/lib/grafana/plugins
logger=settings t=2023-04-24T09:37:06.577534348+08:00 level=info msg="Path Provisioning" path=/etc/grafana/provisioning
logger=settings t=2023-04-24T09:37:06.577542001+08:00 level=info msg="App mode production"
logger=sqlstore t=2023-04-24T09:37:06.57765469+08:00 level=info msg="Connecting to DB" dbtype=sqlite3
logger=migrator t=2023-04-24T09:37:06.59664109+08:00 level=info msg="Starting DB migrations"
logger=migrator t=2023-04-24T09:37:06.603010671+08:00 level=info msg="migrations completed" performed=0 skipped=452 duration=646.33?s
logger=plugin.loader t=2023-04-24T09:37:06.673145309+08:00 level=info msg="Plugin registered" pluginID=input
logger=plugin.loader t=2023-04-24T09:37:07.016827855+08:00 level=info msg="Plugin registered" pluginID=alexanderzobnin-zabbix-triggers-panel
logger=plugin.loader t=2023-04-24T09:37:07.016871232+08:00 level=info msg="Plugin registered" pluginID=alexanderzobnin-zabbix-app
logger=plugin.loader t=2023-04-24T09:37:07.016879099+08:00 level=info msg="Plugin registered" pluginID=alexanderzobnin-zabbix-datasource
logger=plugin.alexanderzobnin-zabbix-datasource t=2023-04-24T09:37:07.026684969+08:00 level=info msg=Profiler enabled=false
logger=secrets t=2023-04-24T09:37:07.028726158+08:00 level=info msg="Envelope encryption state" enabled=true currentprovider=secretKey.v1
logger=query_data t=2023-04-24T09:37:07.031756928+08:00 level=info msg="Query Service initialization"
logger=live.push_http t=2023-04-24T09:37:07.036084811+08:00 level=info msg="Live Push Gateway initialization"
logger=ngalert.multiorg.alertmanager t=2023-04-24T09:37:07.037407039+08:00 level=error msg="unable to create Alertmanager for org" org=1 err="error writing file notifications: open /var/lib/grafana/alerting/1/notifications: permission denied"
logger=cli t=2023-04-24T09:37:07.038750725+08:00 level=error msg="Critical error" reason="runtime error: invalid memory address or nil pointer dereference" stackTrace="goroutine 1 [running]:\nruntime/debug.Stack()\n\t/usr/local/go/src/runtime/debug/stack.go:24 +0x65\ngithub.com/grafana/grafana/pkg/cmd/grafana-server/commands.executeServer.func2()\n\t/drone/src/pkg/cmd/grafana-server/commands/cli.go:143 +0x94\npanic({0x3120600, 0x5a54d10})\n\t/usr/local/go/src/runtime/panic.go:884 +0x212\ngithub.com/grafana/grafana/pkg/services/ngalert/notifier.(*Alertmanager).ApplyConfig(0x0, 0xc000e14e70?)\n\t/drone/src/pkg/services/ngalert/notifier/alertmanager.go:318 +0xae\ngithub.com/grafana/grafana/pkg/services/ngalert/notifier.(*MultiOrgAlertmanager).SyncAlertmanagersForOrgs(0xc0013f4b40, {0x3f0c440, 0xc00012c000}, {0xc000bf1ca8, 0x1, 0x3f0d9e8?})\n\t/drone/src/pkg/services/ngalert/notifier/multiorg_alertmanager.go:208 +0x772\ngithub.com/grafana/grafana/pkg/services/ngalert/notifier.(*MultiOrgAlertmanager).LoadAndSyncAlertmanagersForOrgs(0xc0013f4b40, {0x3f0c440, 0xc00012c000})\n\t/drone/src/pkg/services/ngalert/notifier/multiorg_alertmanager.go:140 +0xd8\ngithub.com/grafana/grafana/pkg/services/ngalert.(*AlertNG).init(0xc0016da160)\n\t/drone/src/pkg/services/ngalert/ngalert.go:138 +0x3ac\ngithub.com/grafana/grafana/pkg/services/ngalert.ProvideService(0xc000a9d500, {0x3efe0d8?, 0xc000b078c0}, {0x3f2b940?, 0xc000c4caa0}, {0x3f25a60?, _}, _, {0x3f116a0, 0xc0009bd5a0}, ...)\n\t/drone/src/pkg/services/ngalert/ngalert.go:73 +0x4a9\ngithub.com/grafana/grafana/pkg/server.Initialize({{0x7ffd98cfbd45, 0x18}, {0x7ffd98cfbd29, 0x12}, {0xc00012a040, 0x5, 0x5}}, {{0x0, 0x0}, {0x0, ...}, ...}, ...)\n\t/drone/src/pkg/server/wire_gen.go:366 +0x41cb\ngithub.com/grafana/grafana/pkg/cmd/grafana-server/commands.executeServer({0x7ffd98cfbd45, 0x18}, {0x7ffd98cfbd29, 0x12}, {0x0, 0x0}, {0x7ffd98cfbd6a, 0x6}, 0x203000?, {{0x3ed5f5c, ...}, ...})\n\t/drone/src/pkg/cmd/grafana-server/commands/cli.go:188 +0x7a5\ngithub.com/grafana/grafana/pkg/cmd/grafana-server/commands.RunServer({{0x3ed5f5c, 0x5}, {0x3ed7210, 0xa}, {0x3ed5f54, 0x4}, {0x3ed7200, 0xa}})\n\t/drone/src/pkg/cmd/grafana-server/commands/cli.go:111 +0x758\nmain.main()\n\t/drone/src/pkg/cmd/grafana-server/main.go:16 +0xb7\n"
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x23075ce]
goroutine 1 [running]:
4,检查一下挂载目录的权限
发现都是root,之前有过类似情况,后来经过百度,需要给 472 的权限,
[root@NengLi var]
[root@NengLi grafana]
total 5228
drwxr-x--- 3 root root 15 Nov 11 10:42 alerting
drwx------ 2 root root 6 Nov 11 10:42 csv
-rw-r----- 1 root root 5353472 Apr 23 16:24 grafana.db
drwxr-xr-x 3 root root 40 Mar 30 14:01 plugins
drwx------ 2 root root 6 Nov 11 10:42 png
5,重新授权
[root@NengLi grafana]
[root@NengLi grafana]
total 5228
drwxr-x--- 3 472 root 15 Nov 11 10:42 alerting
drwx------ 2 472 root 6 Nov 11 10:42 csv
-rw-r----- 1 472 root 5353472 Apr 23 16:24 grafana.db
drwxr-xr-x 3 472 root 40 Mar 30 14:01 plugins
drwx------ 2 472 root 6 Nov 11 10:42 png
6,docker-compose启动grafana,启动成功
[root@NengLi grafana]
[+] Running 1/1
? Container grafana Started 0.5s
[root@NengLi grafana]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d82a9ff97a16 192.168.10.233:5050/base/grafana/grafana-oss:9.2.4-ubuntu "/run.sh" 10 seconds ago Up 9 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp grafana