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

Changind DB credentials fails #80

Open
CampbellBruce opened this issue Nov 15, 2020 · 4 comments
Open

Changind DB credentials fails #80

CampbellBruce opened this issue Nov 15, 2020 · 4 comments

Comments

@CampbellBruce
Copy link

Can you explain the proper way to change our db credentials but keep the data already collected?
I tested the default docker compose succesfuly,collected data and then after backing up with your script the data i deployed a new docker-compose file with different creds to a new VM and restored.It didnt start.

Then i copied the volumes and it starts correctly,thing is although the env vars are different i found its still using the default creds from your example and thats why its getting data.

The common error is Access denied for user 'cactiuser'@'172.21.0.3' (using password: YES)

Also i tried to change from inside the cacti docker manually the creds for the root and cactiuser users in the DB.I then noticed config.php kept the old creds so i changed it there too.Ofcourse im doing docker-compose down and up -d for my changes.

Still it keeps throwing the error and wont update the spine poller results.
SPINE: Poller[Main Poller] PID[1286] FATAL: Connection Failed, Error:'1045', Message:'Access denied for user 'cactiuser'@'172.21.0.3' (using password: YES)' (Spine parent)

I made combinations with initialize_db values but no luck.

Im missing something here,maybe another file that needs changing?Could you please reproduce and present the correct order of actions we need to do to change the DB credentials but keep the data?

@scline
Copy link
Owner

scline commented Jan 29, 2021

I may have to attempt to replicate this when I get time. At the top of my head, I want to say those database env variables are only used when installing a new instance of cacti.

To change an existing password you would need to edit the cacti configuration file manually, take a look at cacti/include/config.php the credentials are stored and used there post-install.

It will look something like:

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cacti";

@scline
Copy link
Owner

scline commented Jan 29, 2021

If you can share your compose file (passwords and what not removed) I can also use that as a base to replicate :)

@CampbellBruce
Copy link
Author

Here is the docker-compose file:

version: '3.5'
services:

cacti:
image: "smcline06/cacti"
container_name: cacti
restart: unless-stopped
ports:
- "8080:80"
- "5443:443"
env_file:
- cacti.env
volumes:
- cacti-data:/cacti
- cacti-spine:/spine
- cacti-backups:/backups
- /home/localadmin/projects/certs/mydomain.crt:/etc/ssl/certs/cacti.crt
- /home/localadmin/projects/certs/mydomain.key:/etc/ssl/certs/cacti.key
links:
- db

db:
image: "mariadb:10.3"
container_name: cacti_db
restart: unless-stopped
ports:
- "3306:3306"
command:
- mysqld
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --max_connections=200
- --max_heap_table_size=128M
- --max_allowed_packet=32M
- --tmp_table_size=128M
- --join_buffer_size=128M
- --innodb_buffer_pool_size=1G
- --innodb_doublewrite=ON
- --innodb_flush_log_at_timeout=3
- --innodb_read_io_threads=32
- --innodb_write_io_threads=16
- --innodb_buffer_pool_instances=9
- --innodb_file_format=Barracuda
- --innodb_large_prefix=1
- --innodb_io_capacity=200
- --innodb_io_capacity_max=2000
env_file:
- cacti_db.env
volumes:
- cacti-db:/var/lib/mysql

volumes:
cacti-db:
cacti-data:
cacti-spine:
cacti-backups:

cacti.env file:

DB_NAME=cacti_master
DB_USER=cactiuser
DB_PASS=my2ndpass
DB_HOST=cacti_db
DB_PORT=3306
DB_ROOT_PASS=my2ndpass
INITIALIZE_DB=0
TZ=Europe/Athens

cacti_db.env file:

MYSQL_ROOT_PASSWORD=my2ndpass
TZ=Europe/Athens

Although you can simply put them all in the compose file no need to split it.

If you run the compose file initially with my1stpass,then copy volumes or backup elsewhere and rerun with my2ndpass in the compose file i believe it will work but will have in fact keep the first pass.

thx for your efforts!

@CampbellBruce
Copy link
Author

Also its impossible to keep the identation correct in the post, sorry about that.

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