Service (grafana-server) does not start automatically on Ubuntu 16.04
I have a problem with autostarting Grafana on Ubuntu 16.04 (while it starts automatically on 14.04, also other added services on 16.04 configured in a similar way do start automatically).
I ran configuration as below:
$ sudo update-rc.d grafana-server defaultsNo output from the command (running multiple times does not print any new information):
$ sudo update-rc.d grafana-server defaults
$ sudo update-rc.d grafana-server defaults
$
$ sudo rebootAfter restart the service is stopped (if I delete /var/log/grafana/grafana.log before reboot, it is not created). The status is:
$ sudo service grafana-server status
● grafana-server.service - Starts and stops a single grafana instance on this system Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: And the service starts up when called manually:
$ sudo service grafana-server status
● grafana-server.service - Starts and stops a single grafana instance on this system Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled) Active: active (running) since Sun 2016-07-17 23:07:33 JST; 1s ago Docs: Main PID: 2658 (grafana-server) Tasks: 7 (limit: 512) Memory: 23.0M CPU: 105ms CGroup: / └─2658 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile= cfg:default.paths.logs=/var/log/grafana cfg:deAfter another reboot, it does not start.
Startup scripts in init.d are present:
$ ls -l /etc/rc3.d/*grafana*
lrwxrwxrwx 1 root 24 Jul 17 22:58 /etc/rc3.d/S04grafana-server -> ../init.d/grafana-server*
$ ls -l /etc/init.d/grafana-server
-rwxr-xr-x 1 root 3291 Jul 12 19:57 /etc/init.d/grafana-server*What might be wrong?
3 Answers
check if /etc/systemd/system/grafana-server.service if a correct link to /lib/systemd/system/grafana-server.service
If not, create /lib/systemd/system/grafana-server.servicethe source file is here :
Then create the correct link :
sudo ln -s /lib/systemd/system/grafana-server.service /etc/systemd/system/grafana-server.serviceThen enable grafana-server
sudo systemctl enable grafana-serverThen start grafana-server
sudo systemctl start grafana-server 0 Try running this command:
sudo systemctl enable grafana-server.service I was having same issue as you (clean install of 16.04) Notice the output from your service status:
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabledWhich is indicating that the service is disabled. The command above fixed the issue for me.
I ran into this on Ubuntu 18.04 today and it was because grafana-server.service is After=network-online.target and the system hadn't reached network-online.target because systemd-networkd-wait-online.service was still running and hadn't timed out yet.
I got around this with systemctl mask systemd-networkd-wait-online.service as my grafana instance and my InfluxDB instance are on the same server.