2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 11:12:04 +00:00

mysqlsetup enhancements

This commit is contained in:
Mark Gurevich 2023-02-14 13:17:17 -05:00
parent 13b2f7d5ac
commit 570cda30b4
13 changed files with 4001 additions and 78 deletions

View File

@ -12,10 +12,10 @@ If you no longer want to use MySQL/MariaDB to maintain ``xcatdb``, and like to s
XCATBYPASS=1 restorexCATdb -p ~/xcat-dbback
* Change to PostgreSQL, following documentation: :doc:`/advanced/hierarchy/databases/postgres_install`
* To switch to PostgreSQL, follow: :doc:`/advanced/hierarchy/databases/postgres_install`
* Change back to default xCAT database, SQLite (**Note**: xCAT Hierarchy cluster will no longer work)
* To switch to default xCAT database, SQLite (**Note**: xCAT Hierarchy cluster will no longer work):
#. Stop the ``xcatd`` daemon on the management node. ::
@ -33,7 +33,7 @@ If you no longer want to use MySQL/MariaDB to maintain ``xcatdb``, and like to s
mysql> drop user xcatadm;
#. Move, or remove, the ``/etc/xcat/cfglog`` file as it points xCAT to MySQL/MariaDB. (without this file, xCAT defaults to SQLite): ::
#. Move, or remove, the ``/etc/xcat/cfgloc`` file as it points xCAT to MySQL/MariaDB. (without this file, xCAT defaults to SQLite): ::
rm /etc/xcat/cfgloc

View File

@ -32,9 +32,9 @@ To remove ``xcatdb`` completely from the PostgreSQL database and restore xCAT da
rm -rf *
exit
#. Move, or remove, the ``/etc/xcat/cfglog`` file as it points xCAT to PostgreSQL. (without this file, xCAT defaults to SQLite): ::
#. Move, or remove, the ``/etc/xcat/cfgloc`` file as it points xCAT to PostgreSQL. (without this file, xCAT defaults to SQLite): ::
mv /etc/xcat/cfgloc /etc/xcat/cfglog.postgres
mv /etc/xcat/cfgloc /etc/xcat/cfgloc.postgres
#. Restore the PostgreSQL database into SQLite: ::

View File

@ -37,11 +37,9 @@ DESCRIPTION
***********
\ **mysqlsetup**\ - Sets up the MySQL or MariaDB database (linux only for MariaDB) for xCAT to use. The mysqlsetup script is run on the Management Node as root after the MySQL code or MariaDB code has been installed. Before running the init option, the MySQL server should be stopped, if it is running. The xCAT daemon, xcatd, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL or MariaDB and restarting the xcatd daemon as well as the MySQL daemon. For full information on all the steps that will be done, read the "Configure MySQL and Migrate xCAT Data to MySQL" sections in
\ **mysqlsetup**\ - Sets up the MySQL or MariaDB database (linux only for MariaDB) for xCAT to use. The \ **mysqlsetup**\ script is run on the Management Node as root after the MySQL or MariaDB packages have been installed. Before running the \ **-**\ **-init**\ option, the MySQL server should be stopped, if it is running. The xCAT daemon, \ **xcatd**\ , must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL or MariaDB and restarting the \ **xcatd**\ daemon as well as the MySQL daemon. For more information, see https://xcat-docs.readthedocs.io/en/stable/advanced/hierarchy/databases/index.html#mysql-mariadb
\ **Setting_Up_MySQL_as_the_xCAT_DB**\
Two passwords must be supplied for the setup, a password for the xcatadmin id and a password for the root id in the MySQL database. These will be prompted for interactively, unless the environment variables XCATMYSQLADMIN_PW and XCATMYSQLROOT_PW are set to the passwords for the xcatadmin id and root id in the database,resp.
Two passwords must be supplied for the setup, a password for the xcatadmin id and a password for the root id in the MySQL database. These will be prompted for interactively, unless the environment variables \ **XCATMYSQLADMIN_PW**\ and \ **XCATMYSQLROOT_PW**\ are set to the passwords for the xcatadmin id and root id in the database,respectively.
Note below we refer to MySQL but it works the same for MariaDB.
@ -72,14 +70,14 @@ OPTIONS
\ **-i|-**\ **-init**\
The init option is used to setup a xCAT database on an installed MySQL or MariaDB server for xCAT to use. The mysqlsetup script will check for the installed MariaDB server rpm first and will use MariaDB if it is installed. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the my.cnf configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the /etc/xcat/cfgloc file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database.
On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL or MariaDB rpms shipped with the OS. You can chose the -f and/or the -o option, to run after the init.
The \ **-**\ **-init**\ option is used to setup a xCAT database on an installed MySQL or MariaDB server for xCAT to use. The \ **mysqlsetup**\ script will check for the installed MariaDB server rpm first and will use MariaDB if it is installed. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the \ **my.cnf**\ configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the \ **/etc/xcat/cfgloc**\ file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database.
On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL or MariaDB rpms shipped with the OS. You can chose the \ **-f**\ and/or the \ **-o**\ option, to run after the <-**\ **-init>.
\ **-u|-**\ **-update**\
To run the update option, you must first have run the -i option and have xcat successfully running on the MySQL database. You can chose the -f and/or the -o option, to update.
To run the update option, you must first have run the \ **-i**\ option and have xcat successfully running on the MySQL database. You can chose the \ **-f**\ and/or the \ **-o**\ option, to update.
@ -91,17 +89,13 @@ OPTIONS
\ **-o|-**\ **-odbc**\
This option sets up the ODBC /etc/../odbcinst.ini, /etc/../odbc.ini and the .odbc.ini file in roots home directory will be created and initialized to run off the xcatdb MySQL database.
See "Add ODBC Support" in
Setting_Up_MySQL_as_the_xCAT_DB
This option sets up the ODBC \ **/etc/../odbcinst.ini**\ , \ **/etc/../odbc.ini**\ and the \ **.odbc.ini**\ file in roots home directory will be created and initialized to run off the xcatdb MySQL database.
\ **-L|-**\ **-LL**\
Additional database configuration specifically for the LoadLeveler product.
See "Add ODBC Support" in
Setting_Up_MySQL_as_the_xCAT_DB

View File

@ -44,7 +44,7 @@ nodetype Attributes:
\ **os**\
The operating system deployed on this node. Valid values: AIX, rhels\*,rhelc\*, rhas\*,centos\*,rocky\*,SL\*, fedora\*, sles\* (where \* is the version #). As a special case, if this is set to "boottarget", then it will use the initrd/kernel/parameters specified in the row in the boottarget table in which boottarget.bprofile equals nodetype.profile.
The operating system deployed on this node. Valid values: AIX, rhels\*,rhelc\*, rhas\*,centos\*, alma\*, rocky\*,SL\*, fedora\*, sles\* (where \* is the version #). As a special case, if this is set to "boottarget", then it will use the initrd/kernel/parameters specified in the row in the boottarget table in which boottarget.bprofile equals nodetype.profile.

View File

@ -104,7 +104,7 @@ osimage Attributes:
\ **osvers**\
The Linux operating system deployed on this node. Valid values: rhels\*,rhelc\*, rhas\*,centos\*,rocky\*,SL\*, fedora\*, sles\* (where \* is the version #).
The Linux operating system deployed on this node. Valid values: rhels\*,rhelc\*, rhas\*,centos\*,alma\*, rocky\*,SL\*, fedora\*, sles\* (where \* is the version #).

View File

@ -50,7 +50,7 @@ passwd Attributes:
\ **password**\
The default password for this type of component. On Linux, a crypted form could be provided. Hashes starting with $1$, $5$ and $6$ (md5, sha256 and sha512 respectively) are supported.
The default password for this type of component. On Linux, a crypted form could be provided for the "system" component, which will be used during initial node provisioning. Hashes starting with $1$, $5$ and $6$ (md5, sha256 and sha512 respectively) are supported.

View File

@ -733,7 +733,7 @@ group Attributes:
\ **os**\ (nodetype.os)
The operating system deployed on this node. Valid values: AIX, rhels\*,rhelc\*, rhas\*,centos\*,rocky\*,SL\*, fedora\*, sles\* (where \* is the version #). As a special case, if this is set to "boottarget", then it will use the initrd/kernel/parameters specified in the row in the boottarget table in which boottarget.bprofile equals nodetype.profile.
The operating system deployed on this node. Valid values: AIX, rhels\*,rhelc\*, rhas\*,centos\*, alma\*, rocky\*,SL\*, fedora\*, sles\* (where \* is the version #). As a special case, if this is set to "boottarget", then it will use the initrd/kernel/parameters specified in the row in the boottarget table in which boottarget.bprofile equals nodetype.profile.

View File

@ -739,7 +739,7 @@ node Attributes:
\ **os**\ (nodetype.os)
The operating system deployed on this node. Valid values: AIX, rhels\*,rhelc\*, rhas\*,centos\*,rocky\*,SL\*, fedora\*, sles\* (where \* is the version #). As a special case, if this is set to "boottarget", then it will use the initrd/kernel/parameters specified in the row in the boottarget table in which boottarget.bprofile equals nodetype.profile.
The operating system deployed on this node. Valid values: AIX, rhels\*,rhelc\*, rhas\*,centos\*, alma\*, rocky\*,SL\*, fedora\*, sles\* (where \* is the version #). As a special case, if this is set to "boottarget", then it will use the initrd/kernel/parameters specified in the row in the boottarget table in which boottarget.bprofile equals nodetype.profile.

View File

@ -249,7 +249,7 @@ osimage Attributes:
\ **osvers**\ (osimage.osvers)
The Linux operating system deployed on this node. Valid values: rhels\*,rhelc\*, rhas\*,centos\*,rocky\*,SL\*, fedora\*, sles\* (where \* is the version #).
The Linux operating system deployed on this node. Valid values: rhels\*,rhelc\*, rhas\*,centos\*,alma\*, rocky\*,SL\*, fedora\*, sles\* (where \* is the version #).

View File

@ -165,7 +165,7 @@ if ($::RUNCMD_RC == 0) {
# check to see if mysql is installed
#
$cmd = "rpm -qa | grep -i perl-DBD-mysql";
my $msg = "\nMySQL perl DBD ";
my $msg = "\nperl-DBD-mysql ";
if ($::debianflag) {
if ($::MariaDB) {
$cmd = "dpkg -l | grep -i mariadb-server";
@ -184,39 +184,41 @@ if ($::RUNCMD_RC != 0)
exit(1);
}
# check to see if MySQL is running
# check to see if MySQL or MariaDB is running
$::mysqlrunning = 0;
$::xcatrunningmysql = 0;
my $cmd = "ps -ef | grep mysqld";
my @output = xCAT::Utils->runcmd($cmd, 0);
my $mysqlcheck = "mysql.sock"; # see if really running
if (grep(/$mysqlcheck/, @output))
{
if ($::INIT)
{
my $message =
"MySQL is running. Database initialization will not take place.";
xCAT::MsgUtils->message("I", "$message");
}
my $cmd = "pidof mysqld";
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC == 0) {
$::mysqlrunning = 1;
if ($::INIT) {
my $message = "MySQL is already running. Database initialization will not take place.";
xCAT::MsgUtils->message("I", "$message");
my $ret = xCAT::Utils->stopservice("mysql");
if ($ret != 0) {
xCAT::MsgUtils->message("E", " failed to stop MySQL.");
exit(1);
} else {
$::mysqlrunning = 0; # service was stopped
}
}
}
# Stop mysql in order to setup init xcat mysql
$cmd = "pidof mysqld";
xCAT::Utils->runcmd($cmd, -1);
if ($::RUNCMD_RC == 0)
{
if ($::INIT)
{
my $ret = xCAT::Utils->stopservice("mysql");
if ($ret != 0)
{
xCAT::MsgUtils->message("E", " failed to stop mysql/mariadb.");
$cmd = "pidof mariadbd";
xCAT::Utils->runcmd($cmd, 0);
if ($::RUNCMD_RC == 0) {
$::mysqlrunning = 1;
if ($::INIT) {
my $message = "MariaDB is already running. Database initialization will not take place.";
xCAT::MsgUtils->message("I", "$message");
my $ret = xCAT::Utils->stopservice("mariadb");
if ($ret != 0) {
xCAT::MsgUtils->message("E", " failed to stop MariaDB.");
exit(1);
}
} else {
$::mysqlrunning = 1;
} else {
$::mysqlrunning = 0; # service was stopped
}
}
}
@ -976,26 +978,26 @@ sub mysqlstart
exit(1);
}
# make sure running
$cmd = "ps -ef | grep mysqld | grep -v grep";
my $i;
for ($i = 0 ; $i < 12 ; $i++)
{
my @output = xCAT::Utils->runcmd($cmd, 0);
$mysqlcheck = "mysqld";
# make sure service has started. On some OSes, mariadb service starts mysql daemon
# on others, mariadb service starts mariadb daemon. Check a few times for one,
# then the other
my @db_service_name_list = ("mysqld", "mariadb");
foreach my $db_service_name (@db_service_name_list) {
$cmd = "ps -ef | grep $db_service_name | grep -v grep";
for (my $i = 0 ; $i < 6 ; $i++) {
my @output = xCAT::Utils->runcmd($cmd, 0);
my $mysqlcheck = $db_service_name;
if (grep(/$mysqlcheck/, @output))
{
sleep 10; # give a few extra seconds to be sure
return;
}
else
{
sleep 10; # wait for daemon
if (grep(/$mysqlcheck/, @output)) {
sleep 10; # give a few extra seconds to be sure
return;
} else {
sleep 10; # wait for daemon
}
}
}
xCAT::MsgUtils->message("E",
" Could not start the mysql daemon, in time allocated (2 minutes)");
" Could not start the mysql/mariadb daemon in time allocated (2 minutes)");
exit(1);
}

1969
xCAT-client/bin/mysqlsetup.mg Executable file

File diff suppressed because it is too large Load Diff

1964
xCAT-client/bin/mysqlsetup.orig Executable file

File diff suppressed because it is too large Load Diff

View File

@ -19,11 +19,9 @@ B<mysqlsetup> {B<-L>|B<--LL>} [B<-V>|B<--verbose>]
=head1 DESCRIPTION
B<mysqlsetup> - Sets up the MySQL or MariaDB database (linux only for MariaDB) for xCAT to use. The mysqlsetup script is run on the Management Node as root after the MySQL code or MariaDB code has been installed. Before running the init option, the MySQL server should be stopped, if it is running. The xCAT daemon, xcatd, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL or MariaDB and restarting the xcatd daemon as well as the MySQL daemon. For full information on all the steps that will be done, read the "Configure MySQL and Migrate xCAT Data to MySQL" sections in
B<mysqlsetup> - Sets up the MySQL or MariaDB database (linux only for MariaDB) for xCAT to use. The B<mysqlsetup> script is run on the Management Node as root after the MySQL or MariaDB packages have been installed. Before running the B<--init> option, the MySQL server should be stopped, if it is running. The xCAT daemon, B<xcatd>, must be running, do not stop it. No xCAT commands should be run during the init process, because we will be migrating the xCAT database to MySQL or MariaDB and restarting the B<xcatd> daemon as well as the MySQL daemon. For more information, see https://xcat-docs.readthedocs.io/en/stable/advanced/hierarchy/databases/index.html#mysql-mariadb
B<Setting_Up_MySQL_as_the_xCAT_DB>
Two passwords must be supplied for the setup, a password for the xcatadmin id and a password for the root id in the MySQL database. These will be prompted for interactively, unless the environment variables XCATMYSQLADMIN_PW and XCATMYSQLROOT_PW are set to the passwords for the xcatadmin id and root id in the database,resp.
Two passwords must be supplied for the setup, a password for the xcatadmin id and a password for the root id in the MySQL database. These will be prompted for interactively, unless the environment variables B<XCATMYSQLADMIN_PW> and B<XCATMYSQLROOT_PW> are set to the passwords for the xcatadmin id and root id in the database,respectively.
Note below we refer to MySQL but it works the same for MariaDB.
@ -45,12 +43,12 @@ Displays verbose messages.
=item B<-i|--init>
The init option is used to setup a xCAT database on an installed MySQL or MariaDB server for xCAT to use. The mysqlsetup script will check for the installed MariaDB server rpm first and will use MariaDB if it is installed. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the my.cnf configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the /etc/xcat/cfgloc file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database.
On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL or MariaDB rpms shipped with the OS. You can chose the -f and/or the -o option, to run after the init.
The B<--init> option is used to setup a xCAT database on an installed MySQL or MariaDB server for xCAT to use. The B<mysqlsetup> script will check for the installed MariaDB server rpm first and will use MariaDB if it is installed. This involves creating the xcatdb database, the xcatadmin id, allowing access to the xcatdb database by the Management Node. It customizes the B<my.cnf> configuration file for xcat and starts the MySQL server. It also backs up the current xCAT database and restores it into the newly setup xcatdb MySQL database. It creates the B</etc/xcat/cfgloc> file to point the xcatd daemon to the MySQL database and restarts the xcatd daemon using the database.
On AIX, it additionally setup the mysql id and group and corrects the permissions in the MySQL install directories. For AIX, you should be using the MySQL rpms available from the xCAT website. For Linux, you should use the MySQL or MariaDB rpms shipped with the OS. You can chose the B<-f> and/or the B<-o> option, to run after the <--init>.
=item B<-u|--update>
To run the update option, you must first have run the -i option and have xcat successfully running on the MySQL database. You can chose the -f and/or the -o option, to update.
To run the update option, you must first have run the B<-i> option and have xcat successfully running on the MySQL database. You can chose the B<-f> and/or the B<-o> option, to update.
=item B<-f|--hostfile>
@ -58,15 +56,11 @@ This option runs during update, it will take all the host from the input file (p
=item B<-o|--odbc>
This option sets up the ODBC /etc/../odbcinst.ini, /etc/../odbc.ini and the .odbc.ini file in roots home directory will be created and initialized to run off the xcatdb MySQL database.
See "Add ODBC Support" in
Setting_Up_MySQL_as_the_xCAT_DB
This option sets up the ODBC B</etc/../odbcinst.ini>, B</etc/../odbc.ini> and the B<.odbc.ini> file in roots home directory will be created and initialized to run off the xcatdb MySQL database.
=item B<-L|--LL>
Additional database configuration specifically for the LoadLeveler product.
See "Add ODBC Support" in
Setting_Up_MySQL_as_the_xCAT_DB
=back