Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with DB initialization #75

Open
xbolshe opened this issue Aug 16, 2020 · 3 comments
Open

Problem with DB initialization #75

xbolshe opened this issue Aug 16, 2020 · 3 comments

Comments

@xbolshe
Copy link

xbolshe commented Aug 16, 2020

2020-08-16_21:09 [New Install] Database is up! - configuring DB located at mysql.mysql.svc.cluster.local:3306 (this can take a few minutes).
2020-08-16_21:09 [New Install] Container has been instructed to create new Database on remote system.
2020-08-16_21:09 [New Install] CREATE DATABASE cacti /*\!40100 DEFAULT CHARACTER SET utf8 */;
ERROR 1007 (HY000) at line 1: Can't create database 'cacti'; database exists
2020-08-16_21:09 [New Install] GRANT ALL ON cacti.* TO 'cacti' IDENTIFIED BY '*******';
ERROR 1044 (42000) at line 1: Access denied for user 'root'@'%' to database 'cacti'
2020-08-16_21:09 [New Install] GRANT SUPER ON *.* TO 'cacti'@'%';
ERROR 1045 (28000) at line 1: Access denied for user 'root'@'%' (using password: YES)
2020-08-16_21:09 [New Install] GRANT SELECT ON mysql.time_zone_name TO 'cacti' IDENTIFIED BY '*******';
ERROR 1142 (42000) at line 1: GRANT command denied to user 'root'@'10.244.131.232' for table 'time_zone_name'
2020-08-16_21:09 [New Install] Merging vanilla cacti.sql file to database.
ERROR 1045 (28000): Access denied for user 'cacti'@'10.244.131.232' (using password: YES)
2020-08-16_21:09 [New Install] Installing supporting template files.
2020-08-16_21:09 [New Install] Installing plugins.
2020-08-16_21:09 [New Install] Installing template file /templates/cacti_host_template_cacti_stats.xml
2020-08-16_21:09 [New Install] Installing template file /templates/cacti_host_template_cisco_router.xml
2020-08-16_21:09 [New Install] Installing template file /templates/cacti_host_template_f5_bigip_v11.xml
2020-08-16_21:09 [New Install] Installing template file /templates/cacti_host_template_juniper_networks.xml
2020-08-16_21:09 [New Install] Importing settings file /settings/boost.sql
ERROR 1045 (28000): Access denied for user 'cacti'@'10.244.131.232' (using password: YES)
2020-08-16_21:09 [New Install] Importing settings file /settings/data_source_profiles.sql
ERROR 1045 (28000): Access denied for user 'cacti'@'10.244.131.232' (using password: YES)
2020-08-16_21:09 [New Install] Importing settings file /settings/poller.sql
ERROR 1045 (28000): Access denied for user 'cacti'@'10.244.131.232' (using password: YES)
2020-08-16_21:09 [New Install] Importing settings file /settings/spine.sql
ERROR 1045 (28000): Access denied for user 'cacti'@'10.244.131.232' (using password: YES)
2020-08-16_21:09 [New Install] Removing temp Cacti and Spine installation files.

But there is an access to MySQL from this container:

[root@cacti /]# mysql -h mysql.mysql.svc.cluster.local -u 'root' -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 75
Server version: 5.7.31 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>
@xbolshe
Copy link
Author

xbolshe commented Aug 16, 2020

After manual command execution in mysql container (from

echo "$(date +%F_%R) [New Install] Container has been instructed to create new Database on remote system."
to
mysql -h ${DB_HOST} --port=${DB_PORT} -uroot -p${DB_ROOT_PASS} -e "GRANT SELECT ON mysql.time_zone_name TO '${DB_USER}' IDENTIFIED BY '${DB_PASS}';"
), it works,

It seems that commands with ${INITIALIZE_DB} = 1 are not optimal in case of 2 separated containers.

@scline
Copy link
Owner

scline commented Aug 16, 2020

Hrmm most of my installations are using multiple containers and I have not seen this. Looking at those logs it does not install the cacti database because one already exists on with the same name on mysql.mysql.svc.cluster.local. The INITIALIZE_DB hook is for green-field databases only, so if an existing installation is present it will do odd things.

2020-08-16_21:09 [New Install] CREATE DATABASE cacti /*\!40100 DEFAULT CHARACTER SET utf8 */;
ERROR 1007 (HY000) at line 1: Can't create database 'cacti'; database exists
2020-08-16_21:09 [New Install] GRANT ALL ON cacti.* TO 'cacti' IDENTIFIED BY '*******';
ERROR 1044 (42000) at line 1: Access denied for user 'root'@'%' to database 'cacti'

Can you verify this is the case here? Running the commands manually is a bit odd, as they should error out with access denied unless the MySQL root password was different between runs.

If this is via docker-compose mind sharing so I can attempt to reproduce locally?

@xbolshe
Copy link
Author

xbolshe commented Aug 16, 2020

I use Kubernetes (not docker-compose). I have tried to delete all conatainers 3 times. And have the same issue. There is no problem, when mysql and cacti containers are in the same namespace of Kubernetes. But there is a problem, when namespaces are different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants