Skip to content

Instantly share code, notes, and snippets.

@BlackMaria
Created May 24, 2013 20:15
Show Gist options
  • Save BlackMaria/5646213 to your computer and use it in GitHub Desktop.
Save BlackMaria/5646213 to your computer and use it in GitHub Desktop.
Configure xcat to use mysql rather than sqlite. Note if you haven't changed your mysql root passwd you should read code for more info.
#!/bin/sh
MANAGMENTNODE=xcat
# passwords used in script
# root password for mysql
# ( if using user other than root modify below )
SQL_ROOT_PASS=rootpw
# The password used by xcat
# ( you dont need to know this unless you decied to debug mysql )
XCAT_PASS=xcat_user_passwd
#
# source xcat env just in case :)
source /etc/profile.d/xcat.sh
# install mysql bits
yum -y install mysql perl-DBD-MySQL mysql-server
#
# Configure & customize server
mysql_install_db --user=mysql
cat <<EOF>>/etc/my.cnf
sql-mode=ANSI_QUOTES
max_connections=300
EOF
service mysqld start
chkconfig --level 345 mysqld on
# Uncomment this if this is the first time you have installed mysql
# mysqladmin -u root password $SQLPASS
# create mysql database and add xcat grants to use DB
mysql -u root -p${SQL_ROOT_PASS} -e " create database xcatdb; "
mysql -u root -p${SQL_ROOT_PASS} -e " grant all on xcatdb.* to xcatadmin@'$MANAGMENTNODE' identified by '${XCAT_PASS}';"
mysql -u root -p${SQL_ROOT_PASS} -e " grant all on xcatdb.* to xcatadmin@'localhost' identified by '${XCAT_PASS}';"
# make a backup before moving on
mkdir --p /tmp/xcatbak
dumpxCATdb --p /tmp/xcatbak
# configure xcat to use mysql rather than sqllite in /etc/xcat
# rm -f /etc/xcat/cfgloc to revert
echo "mysql:dbname=xcatdb;host=$MANAGMENTNODE|xcatadmin|${XCAT_PASS}" >/etc/xcat/cfgloc
chmod 600 /etc/xcat/cfgloc
# now that the config is speaking to mysql, the restore will be made to mysql :)
XCATBYPASS=1 restorexCATdb --p /tmp/xcatbak
# and then confirm
service xcatd restart
#
# if this all fails
#
# rm -f /etc/xcat/cfgloc
# service xcatd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment