-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
problem
Getting an exception when I run the command
cloudstack-setup-databases cloud:password@localhost -s -u -v
versions
ACS 4.21, ubuntu 22.04
The steps to reproduce the bug
- Install mysql server
apt-get install mysql-server
- Set a root password
mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql>FLUSH PRIVILEGES;
- Configure InnoDB settings in mysql server’s /etc/mysql/mysql.conf.d/mysqld.cnf:
[mysqld]
server_id = 1
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_ENGINE_SUBSTITUTION"
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=1000
log-bin=mysql-bin
binlog-format = 'ROW'
-
systemctl restart mysql
-
Log in with root password and execute the following commands
mysql -u root -p
-- Create the cloud and cloud_usage databases
CREATE DATABASE `cloud`;
CREATE DATABASE `cloud_usage`;
-- Create the cloud user
CREATE USER cloud@`localhost` identified by 'password';
CREATE USER cloud@`%` identified by 'password';
-- Grant all privileges to the cloud user on the databases
GRANT ALL ON cloud.* to cloud@`localhost`;
GRANT ALL ON cloud.* to cloud@`%`;
GRANT ALL ON cloud_usage.* to cloud@`localhost`;
GRANT ALL ON cloud_usage.* to cloud@`%`;
-- Grant process list privilege for all other databases
GRANT process ON *.* TO cloud@`localhost`;
GRANT process ON *.* TO cloud@`%`;
- Check the settings
mysql> SHOW GRANTS FOR 'cloud'@'localhost';
+----------------------------------------------------------------+
| Grants for cloud@localhost |
+----------------------------------------------------------------+
| GRANT PROCESS ON *.* TO `cloud`@`localhost` |
| GRANT ALL PRIVILEGES ON `cloud`.* TO `cloud`@`localhost` |
| GRANT ALL PRIVILEGES ON `cloud_usage`.* TO `cloud`@`localhost` |
+----------------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> SHOW GRANTS FOR 'cloud'@'%';
+--------------------------------------------------------+
| Grants for cloud@% |
+--------------------------------------------------------+
| GRANT PROCESS ON *.* TO `cloud`@`%` |
| GRANT ALL PRIVILEGES ON `cloud`.* TO `cloud`@`%` |
| GRANT ALL PRIVILEGES ON `cloud_usage`.* TO `cloud`@`%` |
+--------------------------------------------------------+
3 rows in set (0.00 sec)
mysql> SELECT user, host FROM mysql.user WHERE user='cloud';
+-------+-----------+
| user | host |
+-------+-----------+
| cloud | % |
| cloud | localhost |
+-------+-----------+
2 rows in set (0.00 sec)
- Execute the command
cloudstack-setup-databases cloud:password@localhost -s -u -v
-s, --schema-only Creates the db schema without having to pass root
credentials - Please note: The databases (cloud,
cloud_usage) and user (cloud) has to be configured
manually prior to running this script when using this
flag.
--force-recreate Force recreation of the existing DB schemas. This
option is disabled by default.Please note: The
databases (cloud, cloud_usage) and its tables data
will be lost and recreated.
-u, --skip-users-auto-creation
Indicates whether to skip the auto-creation of users
in the database. Use this flag when your database
users are already configured and you only want to
populate the db.properties file.
-v, --debug If enabled, print the commands it will run as they run
root@test-cs-installation:~# cloudstack-setup-databases cloud:password@localhost -s -u -v
Mysql user name:cloud [ OK ]
Mysql user password:****** [ OK ]
Mysql server ip:localhost [ OK ]
Mysql server port:3306 [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Detected local IP address as 127.0.1.1, will use as cluster management server node IP[ OK ]
Preparing /etc/cloudstack/management/db.properties [ OK ]
We apologize for below error:
***************************************************************
Aborting script as the databases (cloud, cloud_usage) already exist.
Please use the --force-recreate parameter if you want to recreate the schemas.
***************************************************************
Please run:
cloudstack-setup-databases -h
for full help
A workaround is to use the parameter --force-recreate command
root@test-cs-installation:~# cloudstack-setup-databases cloud:password@localhost -s -u -v --force-recreate
Mysql user name:cloud [ OK ]
Mysql user password:****** [ OK ]
Mysql server ip:localhost [ OK ]
Mysql server port:3306 [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Detected local IP address as 127.0.1.1, will use as cluster management server node IP[ OK ]
Preparing /etc/cloudstack/management/db.properties [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/server-setup.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/templates.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ]
CloudStack has successfully initialized database, you can check your database configuration in /etc/cloudstack/management/db.properties
What to do about it?
The command should without --force-recreate option
cloudstack-setup-databases cloud:password@localhost -s -u -v