scline / docker-cacti

Cacti version 1+ under Docker
113 stars 57 forks source link

Problem with DB initialization #75

Open xbolshe opened 4 years ago

xbolshe commented 4 years ago
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 commented 4 years ago

After manual command execution in mysql container (from https://github.com/scline/docker-cacti/blob/e347c2052517fcba388b580bce1ba5820ef38feb/start.sh#L74 to https://github.com/scline/docker-cacti/blob/e347c2052517fcba388b580bce1ba5820ef38feb/start.sh#L86), it works,

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

scline commented 4 years ago

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 commented 4 years ago

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.