I manage /etc/my.cnf from a template id. Since I use servers in
pairs, all master-master setups, I need to ensure that the server
id is unique and consistent for the server mysql is running on.
Managing the id's is a pain in the ass, especially when servers
change roles. For instance rotating a server in from another
cluster, or recovering a server from backup.
So, I create a my.cnf.tmpl file and that is deployed to all
database instances.
The /etc/init.d/mysql script executes a perl script to generate
my.cnf from my.cnf.tmpl right before a start executes.
[Read more]
!/usr/bin/perl -w
#
#
use strict;
my $HOSTNAME = `hostname`;
chomp($HOSTNAME);
my ($name,$alias,$addrtype,$length,@addrs) = gethostbyname($HOSTNAME);
my ($a,$b,$c,$d) = unpack('C4',$addrs[0]);
my $cnfContents ='';
while(<>) {
$cnfContents .= $_; …