GitHub user kiranchavala added a comment to the discussion: Issue with cloudstack-setup-databases
@DaanHoogland The options -u and --force-recreate were introduced only in 4.21 ``` Since 4.21, the databases (cloud, cloud_usage) are only created if they do not exist. This behavior prevents accidental recreation of existing databases. The databases recreation can still be invoked by passing the –force-recreate flag. ``` https://docs.cloudstack.apache.org/en/4.21.0.0/installguide/management-server/index.html#install-the-database-on-the-management-server-node The issue is not present with 4.20 ``` root@cs-intall420:/home/kiran# cloudstack-setup-databases --help Usage: cloudstack-setup-databases user:[password]@mysqlhost:[port] [--deploy-as=rootuser:[rootpassword]] [--auto=/path/to/server-setup.xml] [-e ENCRYPTIONTYPE] [-m MGMTSECRETKEY] [-k DBSECRETKEY] [-g ENCRYPTORVERSION] [--debug] This command sets up the CloudStack Management Server and CloudStack Usage Server database configuration (connection credentials and host information) based on the first argument. If the --deploy-as option is present, this command will also connect to the database using the administrative credentials specified as the value for the --deploy-as argument, construct the database environment needed to run the CloudStack Management Server, and alter the password specified for the user in the first argument. In this case, the user name specified in --deploy-as= cannot be the same as the user name specified for the connection credentials that the CloudStack Management Server will be set up with. If a server-setup.xml cloud setup information file is specified with the --auto option, this command will also construct a customized database environment according to the cloud setup information in the file. The port and the password are optional and can be left out.. If host is omitted altogether, it will default to localhost. The encryptor version is optional. The options are V1 and V2. If it is not set, the default encryptor will be used. Examples: cloudstack-setup-databases cloud:secret sets user cloud and password 'secret' up in /etc/cloudstack/management/db.properties, using localhost as the database server cloudstack-setup-databases sheng:[email protected] sets these credentials up in /etc/cloudstack/management/db.properties cloudstack-setup-databases alex:[email protected] --deploy-as=root:nonsense sets alex up as the MySQL user, then connects as the root user with password 'nonsense', and recreates the databases, creating the user alex with password 'founder' as necessary cloudstack-setup-databases alex:[email protected] --deploy-as=root:nonsense -e file -m password -k dbpassword -g V2 In addition actions performing in above example, using 'password' as management server encryption key and 'dbpassword' as database encryption key, saving management server encryption key to a file as the encryption type specified by -e is file. The credentials in /etc/cloudstack/management/db.properties are encrypted by encryptor V2 (AeadBase64Encryptor). The db.cloud.encryptor.version is also set to V2. Sensitive values in cloudstack databases will be encrypted by the encryptor V2 using the database encryption key. cloudstack-setup-databases alena:[email protected] --deploy-as=root:nonsense --auto=/root/server-setup.xml sets alena up as the MySQL user, then connects as the root user with password 'nonsense' to server 5.6.7.8, then recreates the databases and sets up the alena user, then performs an automated database setup using the information in server-setup.xml Options: -h, --help show this help message and exit -v, --debug If enabled, print the commands it will run as they run -d ROOTCREDS, --deploy-as=ROOTCREDS Colon-separated user name and password of a MySQL user with administrative privileges -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. -a SERVERSETUP, --auto=SERVERSETUP Path to an XML file describing an automated unattended cloud setup -e ENCRYPTIONTYPE, --encrypt-type=ENCRYPTIONTYPE Encryption method used for db password encryption. Valid values are file, web and env. Default is file. -m MGMTSECRETKEY, --managementserver-secretkey=MGMTSECRETKEY Secret key used to encrypt confidential parameters in db.properties. A string, default is password -k DBSECRETKEY, --database-secretkey=DBSECRETKEY Secret key used to encrypt sensitive database values. A string, default is password -i MSHOSTIP, --mshost=MSHOSTIP Cluster management server host IP. A string, by default it will try to detect a local IP -r REGIONID, --regionid=REGIONID Region Id for the management server cluster -c DBCONFPATH, --db-conf-path=DBCONFPATH The path to find db.properties which hold db properties -f DBFILESPATH, --db-files-path=DBFILESPATH The path to find sql files to create initial database(s) -j ENCRYPTIONJARPATH, --encryption-jar-path=ENCRYPTIONJARPATH The cloudstack jar to be used to encrypt the values in db.properties -n ENCRYPTIONKEYFILE, --encryption-key-file=ENCRYPTIONKEYFILE The name of the file in which encryption key to be generated -g ENCRYPTORVERSION, --encryptor-version=ENCRYPTORVERSION The encryptor version to be used to encrypt the values in db.properties -b MYSQLBINPATH, --mysql-bin-path=MYSQLBINPATH The mysql installed bin path ``` ``` root@cs-intall420:/home/kiran# cloudstack-setup-databases cloud:password@localhost -s -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 ] 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 ``` GitHub link: https://github.com/apache/cloudstack/discussions/11925#discussioncomment-14814146 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
