[MXS-184] init script issues in CentOS 7 Created: 2015-06-08  Updated: 2015-08-21  Resolved: 2015-08-21

Status: Closed
Project: MariaDB MaxScale
Component/s: Core
Affects Version/s: 1.1.1
Fix Version/s: 1.3.0

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: markus makela
Resolution: Fixed Votes: 1
Labels: None


 Description   

This is actually in version 1.1.1, but I don't see that as an option in the "Affects Version/s" drop-down.

Maybe it's due to its use of systemd, but MaxScale's init script doesn't work very well on CentOS 7. The output seems to be wrong or confusing much of the time.

"start" says it succeeds even if it fails:

[gmontee@localhost ~]$ sudo /etc/init.d/maxscale start
Starting maxscale (via systemctl):                         [  OK  ]
[gmontee@localhost ~]$ ps -elf | grep "maxscale"
0 R gmontee  12149 10911  0  80   0 - 28160 -      16:32 pts/0    00:00:00 grep --color=auto maxscale

"status" output is kind of confusing. it seems to indicate that the process is running when it isn't, and also tries to start the process again if it isn't running:

[gmontee@localhost ~]$ sudo /etc/init.d/maxscale status
Checking MaxScale status: maxscale.service - LSB: The maxscale database proxy
   Loaded: loaded (/etc/rc.d/init.d/maxscale)
   Active: active (exited) since Mon 2015-06-08 15:59:03 EDT; 34min ago
  Process: 4747 ExecStart=/etc/rc.d/init.d/maxscale start (code=exited, status=0/SUCCESS)
 
Jun 08 15:59:01 localhost.localdomain systemd[1]: Starting LSB: The maxscale database proxy...
Jun 08 15:59:01 localhost.localdomain MaxScale[4751]: Warning : Failed to read the configuration file /usr/local/mariadb-maxscale/etc/MaxScale.cnf due to 2, No such file or directory.
Jun 08 15:59:03 localhost.localdomain maxscale[4747]: Starting MaxScale: [FAILED]
Jun 08 15:59:03 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 15:59:07 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:24:05 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:32:10 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:32:50 localhost.localdomain systemd[1]: Started L[  OK  ]maxscale database proxy.
[gmontee@localhost ~]$ ps -elf | grep "maxscale"
0 R gmontee  12175 10911  0  80   0 - 28160 -      16:34 pts/0    00:00:00 grep --color=auto maxscale

Adding the configuration and trying again:

[gmontee@localhost ~]$ sudo cp /usr/local/mariadb-maxscale/etc/MaxScale_template.cnf /usr/local/mariadb-maxscale/etc/MaxScale.cnf 
[gmontee@localhost ~]$ sudo /etc/init.d/maxscale start
Starting maxscale (via systemctl):                         [  OK  ]
[gmontee@localhost ~]$ sudo /etc/init.d/maxscale status
Checking MaxScale status: maxscale.service - LSB: The maxscale database proxy
   Loaded: loaded (/etc/rc.d/init.d/maxscale)
   Active: active (exited) since Mon 2015-06-08 15:59:03 EDT; 40min ago
  Process: 4747 ExecStart=/etc/rc.d/init.d/maxscale start (code=exited, status=0/SUCCESS)
 
Jun 08 15:59:01 localhost.localdomain systemd[1]: Starting LSB: The maxscale database proxy...
Jun 08 15:59:01 localhost.localdomain MaxScale[4751]: Warning : Failed to read the configuration file /usr/local/mariadb-maxscale/etc/MaxScale.cnf due to 2, No such file or directory.
Jun 08 15:59:03 localhost.localdomain maxscale[4747]: Starting MaxScale: [FAILED]
Jun 08 15:59:03 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 15:59:07 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:24:05 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:32:10 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:32:50 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:37:49 localhost.localdomain systemd[1]: Started LSB: The maxscale database proxy.
Jun 08 16:39:04 localhost.localdomain systemd[1]: Started L[  OK  ]maxscale database proxy.
[gmontee@localhost ~]$ sudo ls -l /usr/local/mariadb-maxscale/etc/
total 20
-rw-r--r--. 1 root root 3322 May 15 09:47 MaxScale_BinlogServer_template.cnf
-rw-r--r--. 1 root root 8050 Jun  8 16:38 MaxScale.cnf
-rw-r--r--. 1 root root 8050 May 15 09:47 MaxScale_template.cnf
[gmontee@localhost ~]$ ps -elf | grep "maxscale"
0 R gmontee  12350 10911  0  80   0 - 28160 -      16:40 pts/0    00:00:00 grep --color=auto maxscale



 Comments   
Comment by Timofey Turenko [ 2015-06-15 ]

currently works in following way:

[root@localhost ~]# service maxscale start
Starting maxscale (via systemctl): [ OK ]
[root@localhost ~]# service maxscale status
Checking MaxScale status: maxscale.service - MariaDB MaxScale Database Proxy
Loaded: loaded (/usr/lib/systemd/system/maxscale.service; disabled)
Active: active (running) since Mon 2015-06-15 20:27:42 EEST; 3s ago
Process: 9333 ExecStart=/usr/bin/maxscale --user=maxscale (code=exited, status=0/SUCCESS)
Main PID: 9334 (maxscale)
CGroup: /system.slice/maxscale.service
└─9334 /usr/bin/maxscale --user=maxscale

Jun 15 20:27:42 localhost.localdomain systemd[1]: PID file /var/run/maxscale/maxscale.pid not readable (yet?) after start.
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Error log : /var/log/maxscale/error1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Message log : /var/log/maxscale/messages1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Trace log : /var/log/maxscale/trace1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Debug log : /var/log/maxscale/debug1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Opened /var/log/maxscale/error1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Opened /var/log/maxscale/messages1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Opened /var/log/maxscale/trace1.log
Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Opened /var/log/maxscale/debug1.log
Jun 15 20:27:42 localhost.localdomain systemd[1]: Started M[ OK ]axScale Database Proxy.
[root@localhost ~]# service maxscale stop
Stopping maxscale (via systemctl): [ OK ]
[root@localhost ~]# service maxscale status
Checking MaxScale status: maxscale.service - MariaDB MaxScale Database Proxy
Loaded: loaded (/usr/lib/systemd/system/maxscale.service; disabled)
Active: inactive (dead)

Jun 15 20:27:42 localhost.localdomain maxscale[9333]: Opened /var/log/maxscale/debug1.log
Jun 15 20:27:42 localhost.localdomain systemd[1]: Started MariaDB MaxScale Database Proxy.
Jun 15 20:28:33 localhost.localdomain systemd[1]: Stopping MariaDB MaxScale Database Proxy...
Jun 15 20:28:33 localhost.localdomain maxscale[9333]: Closed /var/log/maxscale/error1.log
Jun 15 20:28:33 localhost.localdomain maxscale[9333]: Closed /var/log/maxscale/messages1.log
Jun 15 20:28:33 localhost.localdomain maxscale[9333]: Closed /var/log/maxscale/trace1.log
Jun 15 20:28:33 localhost.localdomain maxscale[9333]: Closed /var/log/maxscale/debug1.log
Jun 15 20:28:33 localhost.localdomain maxscale[9333]: Running MaxScale as: maxscale 998:997
Jun 15 20:28:33 localhost.localdomain maxscale[9333]: Syslog logging is disabled.
Jun 15 20:28:33 localhost.localdomain systemd[1]: Stopped M[FAILED]axScale Database Proxy.
[root@localhost ~]#

Comment by Timofey Turenko [ 2015-06-15 ]

if config file is missing Maxscale fails to start:

[root@localhost ~]# rm /etc/maxscale.cnf
rm: remove regular file ‘/etc/maxscale.cnf’? y
[root@localhost ~]# service maxscale start
Starting maxscale (via systemctl): Job for maxscale.service failed. See 'systemctl status maxscale.service' and 'journalctl -xn' for details.
[FAILED]

[root@localhost ~]# service maxscale status
Checking MaxScale status: maxscale.service - MariaDB MaxScale Database Proxy
Loaded: loaded (/usr/lib/systemd/system/maxscale.service; disabled)
Active: failed (Result: resources) since Mon 2015-06-15 20:31:47 EEST; 1min 35s ago
Process: 9450 ExecStart=/usr/bin/maxscale --user=maxscale (code=exited, status=0/SUCCESS)

Jun 15 20:31:47 localhost.localdomain maxscale[9450]: MariaDB Corporation MaxScale 1.1.1 Mon Jun 15 20:31:47 2015
Jun 15 20:31:47 localhost.localdomain maxscale[9450]: ------------------------------------------------------
Jun 15 20:31:47 localhost.localdomain maxscale[9450]: Info : MaxScale will be run in a daemon process.
Jun 15 20:31:47 localhost.localdomain maxscale[9450]: See the log from the following log files :
Jun 15 20:31:47 localhost.localdomain maxscale[9450]: Running MaxScale as: maxscale 998:997
Jun 15 20:31:47 localhost.localdomain systemd[1]: PID file /var/run/maxscale/maxscale.pid not readable (yet?) after start.
Jun 15 20:31:47 localhost.localdomain maxscale[9450]: Running MaxScale as: maxscale 998:997
Jun 15 20:31:47 localhost.localdomain systemd[1]: maxscale.service never wrote its PID file. Failing.
Jun 15 20:31:47 localhost.localdomain systemd[1]: Failed to start MariaDB MaxScale Database Proxy.
Jun 15 20:31:47 localhost.localdomain systemd[1]: Unit maxs[FAILED]vice entered failed state.

Comment by Timofey Turenko [ 2015-06-16 ]

GeoffMontee
please try with latest code from http://jenkins.engskysql.com/repo/develop-test/centos7.0_x86_64/

(change baseurl line in the /etc/yum.repos.d/maxscale.repo file to baseurl=http://jenkins.engskysql.com/repo/develop-test/centos7.0_x86_64/ and then execute 'yum clean all; yum reinstall maxscale')

after it
service maxscale start
service maxscale stop
service maxscale status
should work

Comment by Geoff Montee (Inactive) [ 2015-06-16 ]

Hi tturenko,

I followed your directions, and now the output of that version of the init script seems to be working much better. Thanks!

Unfortunately, maxscale won't seem to start with it.

[gmontee@localhost ~]$ sudo service maxscale start
Starting maxscale (via systemctl):  Job for maxscale.service failed. See 'systemctl status maxscale.service' and 'journalctl -xn' for details.
                                                           [FAILED]
[gmontee@localhost ~]$ systemctl status maxscale.service
maxscale.service - MariaDB MaxScale Database Proxy
   Loaded: loaded (/usr/lib/systemd/system/maxscale.service; disabled)
   Active: failed (Result: resources) since Tue 2015-06-16 12:44:05 EDT; 12s ago
  Process: 5440 ExecStart=/usr/bin/maxscale --user=maxscale (code=exited, status=0/SUCCESS)

/var/log/messages shows:

Jun 16 12:44:05 localhost systemd: Starting MariaDB MaxScale Database Proxy...
Jun 16 12:44:05 localhost maxscale: MariaDB Corporation MaxScale 1.1.1  Tue Jun 16 12:44:05 2015
Jun 16 12:44:05 localhost maxscale: ------------------------------------------------------
Jun 16 12:44:05 localhost maxscale: Info :  MaxScale will be run in a daemon process.
Jun 16 12:44:05 localhost maxscale: See the log from the following log files :
Jun 16 12:44:05 localhost maxscale: Running MaxScale as: maxscale 990:988
Jun 16 12:44:05 localhost systemd: PID file /var/run/maxscale/maxscale.pid not readable (yet?) after start.
Jun 16 12:44:05 localhost maxscale: Running MaxScale as: maxscale 990:988
Jun 16 12:44:05 localhost systemd: maxscale.service never wrote its PID file. Failing.
Jun 16 12:44:05 localhost systemd: Failed to start MariaDB MaxScale Database Proxy.
Jun 16 12:44:05 localhost systemd: Unit maxscale.service entered failed state.

/var/log/maxscale is empty.

[gmontee@localhost ~]$ ls -l /var/log/maxscale/
total 0

It looks like the RPM didn't create the /var/run/maxscale directory where it places the PID file. Maybe that's related?

[gmontee@localhost ~]$ ls -l /var/run/maxscale/
ls: cannot access /var/run/maxscale/: No such file or directory
[gmontee@localhost ~]$ sudo mkdir /var/run/maxscale/
[gmontee@localhost ~]$ sudo chown maxscale:maxscale /var/run/maxscale

But even after manually creating the directory, it still won't start. If I try to skip the init script and run it manually, that also fails:

[gmontee@localhost ~]$ sudo /usr/bin/maxscale --user=maxscale
 
 
MariaDB Corporation MaxScale 1.1.1      Tue Jun 16 12:53:16 2015
------------------------------------------------------
Running MaxScale as: maxscale 990:988
Info :  MaxScale will be run in a daemon process.
        See the log from the following log files : 

So maybe this particular problem is unrelated to the init script now?

Comment by Geoff Montee (Inactive) [ 2015-06-17 ]

It started up for me after I copied the template configuration file to /etc/.

If it fails to start because the configuration file isn't present, it should probably say so, right?

[root@localhost ~]# cp /usr/share/maxscale/maxscale_template.cnf /etc/maxscale.cnf
[root@localhost ~]# service maxscale start
Starting maxscale (via systemctl):                         [  OK  ]
[root@localhost ~]# service maxscale status
Checking MaxScale status: maxscale.service - MariaDB MaxScale Database Proxy
   Loaded: loaded (/usr/lib/systemd/system/maxscale.service; disabled)
   Active: active (running) since Tue 2015-06-16 19:06:00 EDT; 5s ago
  Process: 5778 ExecStart=/usr/bin/maxscale --user=maxscale (code=exited, status=0/SUCCESS)
 Main PID: 5779 (maxscale)
   CGroup: /system.slice/maxscale.service
           ââ5779 /usr/bin/maxscale --user=maxscale
 
Jun 16 19:06:00 localhost.localdomain systemd[1]: PID file /var/run/maxscale/maxscale.pid not readable (yet?) after start.
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Error log        : /var/log/maxscale/error1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Message log        : /var/log/maxscale/messages1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Trace log        : /var/log/maxscale/trace1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Debug log        : /var/log/maxscale/debug1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Opened /var/log/maxscale/error1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Opened /var/log/maxscale/messages1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Opened /var/log/maxscale/trace1.log
Jun 16 19:06:00 localhost.localdomain maxscale[5778]: Opened /var/log/maxscale/debug1.log
Jun 16 19:06:00 localhost.localdomain systemd[1]: Started M[  OK  ]axScale Database Proxy.

Comment by Dipti Joshi (Inactive) [ 2015-06-17 ]

Thanks GeoffMontee, we will make this enhancement in next release. For now I am making this minor.

Comment by Geoff Montee (Inactive) [ 2015-06-17 ]

Thanks, dshjoshi! It looks like "start" and "status" return correct information with tturenko's build, so I agree that the most serious issue has been fixed. Would you prefer if that enhancement were moved to a new JIRA issue?

Comment by markus makela [ 2015-07-08 ]

GeoffMontee Could you verify that this is solved with the introduction of systemd service files?

Comment by Geoff Montee (Inactive) [ 2015-07-09 ]

markus makela,

I just installed MaxScale 1.2.0 and the systemd service is working great. Thanks!

After upgrading from MaxScale 1.1.1 and trying to use the service description for the first time, I did receive a message to run {{systemctl daemon-reload}. Should that step be added to the upgrade documentation? Or maybe the RPM's postinst script should handle that?

[gmontee@localhost ~]$ sudo systemctl start maxscale.service
Warning: Unit file of maxscale.service changed on disk, 'systemctl daemon-reload' recommended.

Comment by markus makela [ 2015-07-22 ]

Added systemctl daemon-reoad to the post-install script.

Comment by Guillaume Lefranc [ 2015-07-29 ]

Hi Markus,

if you create a directory such as /var/run/maxscale/ in the package, this won't work since /run is on a tmpfs in CentOS 7, so you have to create those directories in the systemd file.

We had it working on CentOS 7 by adding the following commands:
ExecStartPre=-/usr/bin/mkdir /run/maxscale
ExecStartPre=/usr/bin/chown maxscale:maxscale /run/maxscale

Comment by Dipti Joshi (Inactive) [ 2015-07-29 ]

Please see previous comments from Guillaume.

Comment by Guillaume Lefranc [ 2015-07-29 ]

Pull request in https://github.com/mariadb-corporation/MaxScale/pull/88

Comment by Guillaume Lefranc [ 2015-07-30 ]

The issue is similar in Ubuntu and Debian, because /var/run is also on a tmpfs. for systemv init, directory creation must also be added in the init.d script.

Comment by Guillaume Lefranc [ 2015-07-30 ]

Pull request in https://github.com/mariadb-corporation/MaxScale/pull/89

Comment by Dipti Joshi (Inactive) [ 2015-08-06 ]

markus makela Have we merged this pull request ?

Dipti

Comment by Dipti Joshi (Inactive) [ 2015-08-18 ]

markus makela Do we have update on this pull request

Comment by markus makela [ 2015-08-21 ]

Fixed by re-creating the folder on script startup.

Generated at Thu Feb 08 03:57:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.