Koozali.org: home of the SME Server

Obsolete Releases => SME Server 7.x => Topic started by: LANMonkey on March 05, 2010, 12:36:47 AM

Title: [RESOLVED] Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: LANMonkey on March 05, 2010, 12:36:47 AM
I would like to make some of the databases in my SME server slaves to a master on my LAN.

Towards this end, I am trying to edit the etc/my.cnf file and add "bin-log" to initiate binary logging.  But I see the warning there:

Quote
#------------------------------------------------------------
#          !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://www.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation

And I've seen some documentation discussing templates which suggest this file can be rewritten by a template.

Is slaving SME's MySQL server for replication possible?  Is binary logging possible?  If so, do you edit the my.cnf file or some file to initiate binary logging?

I have examined the following links for clues to this end:

http://wiki.contribs.org/SME_Server:Documentation:Developers_Manual#Using_the_MySQL_database

http://wiki.contribs.org/MySQL

http://forums.contribs.org/index.php/topic,40023.msg184376.html#msg184376

http://wiki.contribs.org/SME_Server:Documentation:FAQ#MySQL_Database

Any tips or clues would be appreciated.
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: janet on March 05, 2010, 02:26:16 AM
LANMonkey

Quote
Is slaving SME's MySQL server for replication possible?  Is binary logging possible?  If so, do you edit the my.cnf file or some file to initiate binary logging?

I don't think you will find answers for those questions on contribs.org.
First step is to go to the mysql web site and research what you want to do.
http://dev.mysql.com/doc/
When you find out what needs to be added to the /etc/my.cnf file, you can then make appropriate changes via a sme server custom template.

Look in
/etc/e-smith/templates/etc/my.cnf
Determine which fragment your revised code needs to go into. See the 000readme fragment for info.
If no fragment is suitable you will need to create a new fragment.
Generally speaking do
mkdir -p /etc/e-smith/templates-custom/etc/my.cnf
cp /etc/e-smith/templates/etc/my.cnf/005mysqld /etc/e-smith/templates-custom/etc/my.cnf/005mysqld
pico -w /etc/e-smith/templates-custom/etc/my.cnf/005mysqld
make your required additions & changes
Ctrl o (to save)
Ctrl x (to exit)
expand-template /etc/my.cnf
sv t /service/mysqld
sv s /service/mysqld
(to check status)
(In the above replace 005mysql with the appropriate existing or new fragment name)

Keep in mind you may need to change access permissions to your mysql databases, refer
http://wiki.contribs.org/SME_Server:Documentation:FAQ#Access_MySQL_from_the_local_network
and
http://wiki.contribs.org/SME_Server:Documentation:FAQ#Access_MySQL_from_a_remote_network
and
http://wiki.contribs.org/SME_Server:Documentation:FAQ#Create_MySQL_user.28s.29_with_access_from_other_computers
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: janet on March 05, 2010, 02:45:42 AM
LANMonkey

You might also refer to this Howto
http://wiki.contribs.org/Template_Tutorial

Please peruse the Howtos as well when searching.

I see your example has been added.
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: CharlieBrady on March 05, 2010, 02:49:36 AM
I would like to make some of the databases in my SME server slaves to a master on my LAN.

Why? Why not just configure whatever application uses those databases use the master db directly?

Quote
Towards this end, I am trying to edit the etc/my.cnf file and add "bin-log" to initiate binary logging.

My understanding is that the binary logging needs to be done on the master server, not the slave.

I suggest that you do a lot of reading so that you have a reasonable understanding of the whole process before you start meddling.
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: cactus on March 05, 2010, 11:35:16 AM
My understanding is that the binary logging needs to be done on the master server, not the slave.
True, but a unique server_id needs to be set both on master as well as on the slave, so a little modification is needed for SME Server in any case.
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: cactus on March 05, 2010, 11:37:33 AM
Why? Why not just configure whatever application uses those databases use the master db directly?
It is sometimes used to make a backup without locking tables on the master if that takes a lot off time. Other examples are simple load balancing by having the application read data from (several) slaves and only execute update and insert queries on the master. However the latter is most of the times only applicable for very write intensive applications.
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: LANMonkey on March 05, 2010, 11:53:05 PM
I am still working on this and will report back when I have successfully replicated on my SME server.  Thanks to all who posted and especially mary with the excellent instructions.  It is also possible to use WinSCP to create and edit the custom-template file.  I might add that you have to create a directory templates-custom/etc/my.cnf in this part:

Quote
cp /etc/e-smith/templates/etc/my.cnf/005mysqld /etc/e-smith/templates-custom/etc/my.cnf/005mysqld

For those who need a reference to replication in MySQL, the online manual is quite good,  http://dev.mysql.com/doc/refman/5.0/en/replication.html
Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: janet on March 06, 2010, 03:21:06 AM
LANMonkey

Quote
I might add that you have to create a directory templates-custom/etc/my.cnf

Yes of course, where the directory does not already exist.
I have edited the original post to include the mkdir command.

Keep in mind that for quickness & easiness you can edit the /etc/my.cnf file (and restart mysqld) while testing the correctness of your configuration change (as derived from mysql documentation). Do not make any other changes to sme though as you will undo the temporary changes you made to /etc/my.cnf
When happy with the effectiveness of your change, you can then incorporate it into a custom template for permanency.

Title: Re: Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: LANMonkey on March 06, 2010, 07:25:55 PM
Success!  I have seen a test table created in the master duplicated in the SME server as slave.

Since the adminstration of SME seems to depend on MySQL, (horde, at least) I am applyiing selective replication of only certain databases from the master.  I use 'replicate-do-db = <mydatabase>' in the appropriate my.cnf fragment.  Interested readers should be sure to read the documentation on this option.  I am also seeing some warnings about table type, I think it has to do with restrictions to table type in SME server.  But for purposes of this thread, the issue is RESOLVED.

It might help an interested reader to know the data directory for MySQL is /var/lib/mysql and this is typical for linux.

Thanks again to all who posted information and suggestions.
Title: Re: [RESOLVED] Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: pfloor on March 06, 2010, 08:35:45 PM
LANMonkey

It would be helpful to others if you posted the steps you took to achieve your results.  At least post the exact code/configuration required to duplicate your results.
Title: Re: [RESOLVED] Editing my.cnf for MySQL; Making SME a slave in MySQL replication
Post by: LANMonkey on March 07, 2010, 06:04:33 AM
I believe that mary's instructions are all you really need to handle SME's unique way of locating and handling the my.cnf file.  All the rest is MySQL and not really the subject of a forum like this.  The link I provided above is an excellent resource on the subject of replication in MySQL.