https://github.com/percona-lab/pt-mysql-config-diff
A tool like pt-config-diff written in Go
https://github.com/percona-lab/pt-mysql-config-diff
Last synced: 9 months ago
JSON representation
A tool like pt-config-diff written in Go
- Host: GitHub
- URL: https://github.com/percona-lab/pt-mysql-config-diff
- Owner: Percona-Lab
- Created: 2017-05-11T12:54:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-07-10T23:28:14.000Z (over 5 years ago)
- Last Synced: 2025-05-05T22:16:36.354Z (9 months ago)
- Language: Go
- Size: 55.7 KB
- Stars: 11
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MySQL Config Diff
This program can compare configurations and default values from different MySQL config sources like cnf files, SHOW VARIABLES and MySQL defaults parsed from `mysqld` help.
## Usage
```
pt-mysql-config-diff [--format=text/json]
```
where `src` could be a file name pointing to a `.cnf` file or to a file having MySQL default values from `mysqld` help or a dsn in the form of a default pt-tool dsn parameter: `h=,P=,u=,p=`.
## Usage examples
### Comparing .cnf vs .cnf files.
When comparing 2 `cnf` files, the program will show all keys having differences between the 2 files, including missing keys in both files.
```
pt-mysql-config-diff file1.cnf file2.cnf
```
**Example:**
`cnf1.cnf`
```
[mysqld]
key1=value1
key2= 2
key3= true
```
`cnf2.cnf`
```
[mysqld]
key1=value1
key2=3
key4=true
```
`./pt-mysql-config-diff --format=text cnf1.cnf cnf2.cnf`
```
key2: 2 <-> 3
key3: true <->
key4: <-> true
```
### Comparing .cnf vs SHOW VARIABLES
When comparing `.cnf` files vs `SHOW VARIABLES`, only configuration variables that exist in the cnf file are compared.
**Example: comparing a cnf vs a MySQL 5.7 instance**
`cnf3.cnf`
```
[mysqld]
innodb_buffer_pool_size=512M
log_slow_rate_limit=100.1234
log_slow_verbosity=full
```
`./pt-mysql-config-diff --format=text ~/cnf3.cnf h=127.1,P=3306,u=root`
```
log_slow_verbosity: full <->
innodb_buffer_pool_size: 536870912 <-> 134217728
log_slow_rate_limit: 100.1234 <->
```
### Comparing SHOW VARIABLES vs SHOW VARIABLES
When comparing the same type of configs (SHOW VARIABLES on both sides), the program will show all keys having differences between the 2 instances, including missing keys in both sides.
**Example: Comparing MySQL 5.7 vs MySQL 5.6**
*Note: the output has been truncated and only a few values are here as an example*
Having MySQL 5.7 on port `3306` and MySQL 5.6 on port `3308`:
`./pt-mysql-config-diff --format=text h=127.1,P=3306,u=root h=127.1,P=3308,u=root`
```
innodb_version: 5.7.20 <-> 5.6.38
innodb_buffer_pool_load_at_startup: 1 <-> 0
session_track_schema: ON <->
ssl_cert: server-cert.pem <->
performance_schema_setup_actors_size: -1 <-> 100
timed_mutexes: <-> OFF
performance_schema_max_mutex_instances: -1 <-> 15906
innodb_undo_directory: ./ <-> .
simplified_binlog_gtid_recovery: <-> OFF
session_track_gtids: OFF <->
sha256_password_proxy_users: OFF <->
rbr_exec_mode: STRICT <->
performance_schema_max_table_handles: -1 <-> 4000
performance_schema_max_metadata_locks: -1 <->
log_statements_unsafe_for_binlog: ON <->
```
### Getting the list of variables having non-default values
To achieve this, you first need to generate a list of defaults for the MySQL version you are running:
`touch /tmp/my.cnf`
`/mysqld --verbose --defaults-file=/tmp/my.cnf --help > ~/my-5.7.defaults`
and then you can compare the values from `SHOW VARIABLES` against the defaults:
`pt-mysql-config-diff --format=text h=127.1,P=3306,u=root ~/my-5.7.defaults`
```
daemonize: <-> FALSE
federated: <-> ON
general_log_file: /var/lib/mysql/fa5f51a13d1a.log <-> /usr/local/mysql/data/karl-OMEN.log
log_warnings: 2 <-> 0
performance_schema_consumer_events_waits_history_long: <-> FALSE
skip_grant_tables: <-> FALSE
blackhole: <-> ON
socket: /var/run/mysqld/mysqld.sock <-> /tmp/mysql.sock
open_files_limit: 1048576 <-> 5000
performance_schema_digests_size: 10000 <-> -1
log_tc_size: <-> 24576
myisam_block_size: <-> 1024
datadir: /var/lib/mysql/ <-> /usr/local/mysql/data/
performance_schema_consumer_events_statements_history: <-> TRUE
log_short_format: <-> FALSE
```
### TODO
- [ ] Add option to skip missing values on right/left side
- [ ] Add option to skip certain variables
- [ ] Add option to show big numbers in human readable format (1K, 1M)