Page 1 of 1

MySQL service in Solaris 10

Posted: Mon Nov 24, 2008 6:14 pm
by cah
I found some information on the internet regarding the MySQL service in Solaris 10's SMF (Service Management Facility).

http://www.sun.com/bigadmin/content/sub ... f_tip.html

Two key files: /lib/svc/method/svc-mysql and /var/svc/manifest/network/mysql.xml.

Now fix the permissions for the two files created:

Code: Select all

%chown root:bin /lib/svc/method/svc-mysql
%chmod 555 /lib/svc/method/svc-mysql
%chown root:sys /var/svc/manifest/network/mysql.xml
%chmod 444 /var/svc/manifest/network/mysql.xml
Fix permissions on the MySQL data directory:

Code: Select all

%chown -R mysql:mysql /var/mysql
%chmod -R 700 /var/mysql
Import the service into the service repository:

Code: Select all

%svccfg import /var/svc/manifest/network/mysql.xml
Enable the service:

Code: Select all

%svcadm -v enable mysql
However, I kept getting the "maintenance" state:

Code: Select all

%svcs -v mysql     
STATE          NSTATE        STIME    CTID   FMRI
maintenance    -             16:09:34      - svc:/network/mysql:default
Notice: When in maintenance state, a "clear" command from svcadm will try to start the service.

Code: Select all

%svcadm -v clear mysql 
After some troubleshooting, I found some information from the error log file complaining:

Code: Select all

081124 16:20:28  mysqld started
ld.so.1: mysqld_w_tcp_wrapper.5.0.51b: fatal: libstdc++.so.6: open failed: No such file or directory
081124 16:20:28  mysqld ended
BTW, mysqld resides in /usr/local/libexec.

I checked and found libstdc++.so.6 in /usr/local/lib and this path is in LD_LIBRARY_PATH.
Out of curiosity, I created a symbolic link from /usr/local/lib/libstdc++.so.6 to /usr/lib/libstdc++.so.6 and this error message stopped.

However, it created a new problem:

Code: Select all

081124 17:50:27  mysqld started
081124 17:50:27 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

081124 17:50:27 [ERROR] Aborting

081124 17:50:27 [Note] /usr/local/libexec/mysqld: Shutdown complete

081124 17:50:27  mysqld ended
It does not matter whether or not I specify "--user=mysql" in /lib/svc/method/svc-mysql, it always tries to start as root user.

I then realized that there is no /etc/my.cnf file in place.
I copied my-medium.cnf from support-files directory from the application source to /etc/my.cnf. I then added "user = mysql" in /etc/my.cnf under [mysqld] section.

Then, I was able to start MySQL as a service by issuing the following command:

Code: Select all

%svcadm -v enable mysql 
svc:/network/mysql:default enabled.

%svcs -v mysql
STATE          NSTATE        STIME    CTID   FMRI
online         -             18:05:41   3875 svc:/network/mysql:default

%svcs -p mysql                  
STATE          STIME    FMRI
online         18:05:41 svc:/network/mysql:default
               18:05:41    22709 mysqld_safe
               18:05:41    22729 mysqld_w_tcp_wr

%svcs -l mysql
fmri         svc:/network/mysql:default
enabled      true
state        online
next_state   none
state_time   November 24, 2008  6:05:41 PM EST
logfile      /var/svc/log/network-mysql:default.log
restarter    svc:/system/svc/restarter:default
contract_id  3875 
dependency   require_all/none svc:/system/filesystem/local (online)
dependency   require_all/none svc:/network/loopback (online)
Disabling MySQL service works too:

Code: Select all

%svcadm -v disable mysql
svc:/network/mysql:default disabled.

%svcs -v mysql
STATE          NSTATE        STIME    CTID   FMRI
disabled       -             17:51:55      - svc:/network/mysql:default
Finally, I got it to work!