Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am setting up a mysql slave on a Fedora 16 system, and the server_id is not being set properly. My /etc/my.cnf is:

[mysqld]
server-id=16
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
read-only = 1
symbolic-links=0
max_allowed_packet = 100000000

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

However, after systemctl restart mysqld.service, show variables like "server_id" indicates that server_id is 0, which causes replication to fail.

/var/log/mysqld.log was last modified when I last restarted the server, but there are no log entries from then (I did the restart today, and the last entry is from yesterday).

Why doesn't server-id=16 work? Does it need to be set in some other file? Alternatively, is there a way to edit the systemd unit file such that mysqld starts with the --server-id= command line option, or get mysqld to run an SQL statement to set the server_id on startup?

share|improve this question
    
What is your master server id? Or do you have another mysql server using same id? They all have to be different. –  John Siu Dec 31 '12 at 2:34
    
The master server id is 1. The replication works when server_id on the slave is not 0; the trouble is that the slave server_id is reset to 0 when the slave restarts. –  cpast Dec 31 '12 at 2:51
2  
On your slave box, turn off and on mysqld, then check /var/log/syslog(you may not have this) or /var/log/messages to see if there is some error or warning messages on mysqld startup process. –  John Siu Dec 31 '12 at 2:54
1  
There's an SELinux read error on my.cnf. –  cpast Dec 31 '12 at 3:12
    
What is the permission on my.cnf? Is it 777 now? maybe change it to 660 or 644, should be own by root. –  John Siu Dec 31 '12 at 3:15
show 3 more comments

1 Answer 1

up vote 2 down vote accepted

Use check selinux contexts, they may be wrong

For mysqld startup, shutdown messages, other than /var/log/mysqld.log, also check /var/log/messages.

If the messages(warn/error) show sealert suggestion, check mysqld selinux contexts, they may be wrong or out of date. Update accordingly may fix the issue.

To use --server-id= in mysqld startup script, check following locations

/etc/sysconfig/

There maybe a mysqld file which you can customize startup option.

/etc/rc.d/init.d/

mysqld startup script reside here. You can hard code the option in the script. But you will have to apply the changes each time your up grade.

PS: You may want to consider switching slave box OS to debian/ubuntu so system knowledge will apply to both machines. Additionally, (IMHO) Fedora is not a good choice for a production/server box due to the distro short life span (6mo shelf life + 6mo update support). If RedHat related OS is preferred, use RedHat or CentOS.

share|improve this answer
    
Running an sealert command suggested in messages gave the way to solve the problem, which was an incorrect context. If you add in "check selinux contexts, they may be wrong", I'll accept this answer. –  cpast Dec 31 '12 at 3:55
    
Suggestion added. –  John Siu Dec 31 '12 at 4:00
    
It is new year, why you spending so much time on the server? LOL. HAPPY NEW YEAR!! –  John Siu Dec 31 '12 at 4:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.