TheRobotLearns Platform · ProxySQL: from first install to production
Router-Managed Writer, Reader, and Split Endpoints
Learning objectives
- Bootstrap ProxySQL Router with `mysql_router` using a privileged metadata account, secret descriptor, router name/bind/TLS settings, and real data directory.
- After bootstrap persists and exits, start the service and back up `proxysql.db` with `proxysql-plugin-secrets.key`.
- Select 6033 for operator-managed MySQL, 6446 for writers, 6447 for eligible readers, and 6450 for read/write split with query-rule/transaction tracking.
- Recognize 6446/6447 fast-forward switching on first matching `COM_QUERY`, and when compression or queued packets prevent it.
- Configure metadata TLS so `VERIFY_CA`/`VERIFY_IDENTITY` requires certificate trust inputs and rejects non-TLS servers before authentication.
- Explain quorum-based partition handling: reachable reports prevail, and cluster policy applies when no reachable member reports quorum.
- Diagnose router state via `runtime_mysql_router_*` and `stats_mysql_router_*` views, then issue `MYSQL ROUTER RECONCILE` after corrections.
Router endpoint guidance is absent
ProxySQL enables ClickHouse when started with --clickhouse-server. It listens on port 6090. It connects to ClickHouse on localhost. The backend login uses Default and an empty password.
That login is currently hardcoded. The module is compile-time gated by PROXYSQLCLICKHOUSE. It must also be selected at startup with --clickhouse-server. Backend target changes apply to new connections.
They do not rewrite an already-established connection. Router bootstrap commands do not appear. Router metadata account settings do not appear. Secret descriptors do not appear.
Router names do not appear. Bind settings do not appear. TLS settings do not appear. Real data directories do not appear.
Backups of proxysql.db do not appear. proxysql-plugin-secrets.key does not appear. Port 6033 does not appear. Port 6446 does not appear.
Port 6447 does not appear. Port 6450 does not appear. mysql_router does not appear. runtime_mysql_router_* views do not appear.
stats_mysql_router_* views do not appear. MYSQL ROUTER RECONCILE does not appear. ClickHouse startup facts still do not configure router routing.
Takeaway: The lesson teaches ClickHouse startup, not router endpoints.
ClickHouse variables change proxy behaviour
The ClickHouse module exposes four released global variables. Each variable has a default value, accepted values, and a runtime effect. clickhouse-mysql_ifaces defaults to 0.0.0.0:6090. Any non-empty interface string is accepted.
No general syntax or bind validation happens during LOAD. Reconciliation closes the old listener sockets before parsing and binding replacements. A malformed address or bind failure can leave the intended listener unavailable. Verify replacement listener access before SAVE CLICKHOUSE VARIABLES TO DISK.
clickhouse-hostname defaults to 127.0.0.1. Any non-empty string is accepted. Empty assignment returns success and leaves the current host unchanged. clickhouse-port defaults to 9000.
It accepts an integer from 1 to 65535. It sets the ClickHouse native protocol backend port used for new connections. clickhouse-read_only defaults to false. It accepts case-insensitive true or false, and also 1 or 0.
It enables or disables write-command rejection. These variables are dynamic once the module is running. They do not configure router writers, readers, or split endpoints.
Takeaway: The four ClickHouse variables affect the ClickHouse module, not router endpoint ports.
ClickHouse users move in layers
The clickhouse_users table manages client authentication credentials. Those credentials are separate from ClickHouse backend credentials. The table includes username and password. It also includes active and max_connections.
The username column is the primary key. The active column must be 0 or 1. It defaults to 1. The max_connections column must be at least 0.
It defaults to 10000. Three layers exist for this table. clickhouse_users is the in-memory row set. runtime_clickhouse_users is the active configuration.
disk.clickhouse_users is persistent storage. You can insert a sample user. Run INSERT INTO clickhouse_users VALUES ('clicku','clickp',1,100);. Then run LOAD CLICKHOUSE USERS TO RUNTIME;.
That makes the row active. Then run SAVE CLICKHOUSE USERS TO DISK;. That writes it to persistent storage. The admin command family moves rows and variables between layers.
Memory-to-runtime commands use LOAD ... TO RUNTIME. Runtime-to-memory commands use SAVE ... TO MEMORY. Disk-to-memory commands use LOAD ... FROM DISK. Memory-to-disk commands use SAVE ... TO DISK.
These commands cover ClickHouse users and ClickHouse variables. Only TEXT protocol is supported. Prepared statements are not available. INSERT VALUES syntax is rejected.
Only INSERT...SELECT syntax is permitted. These commands do not run router reconciliation.
Takeaway: clickhouse_users moves through ClickHouse layers, and router reconciliation is absent.
Router diagnostics remain unshown
The ClickHouse module is compile-time gated by PROXYSQLCLICKHOUSE. It must also be selected at startup with --clickhouse-server. That gate does not link to router endpoints. The module connects to ClickHouse on localhost.
Backend target changes apply to new connections. They do not rewrite an already-established connection. Router TLS settings do not appear. Metadata certificate trust inputs do not appear.
VERIFY_CA does not appear. VERIFY_IDENTITY does not appear. Rejection of non-TLS servers before authentication does not appear. Quorum-based partition handling does not appear.
Reachable reports prevailing does not appear. Cluster policy application does not appear. The case with no reachable member reporting quorum does not appear. Fast-forward switching does not appear.
COM_QUERY triggering does not appear. Compression effects do not appear. Queued packet effects do not appear. runtime_mysql_router_* state views do not appear.
stats_mysql_router_* statistics views do not appear. MYSQL ROUTER RECONCILE actions do not appear. Router endpoint checks remain unshown. ClickHouse variables still do not define router routing.
Takeaway: Router TLS, quorum, fast-forward, diagnostics, and reconcile actions are absent.
ClickHouse credential SQL is available
INSERT INTO clickhouse_users VALUES ('clicku','clickp',1,100);
LOAD CLICKHOUSE USERS TO RUNTIME;
SAVE CLICKHOUSE USERS TO DISK;INSERT INTO clickhouse_users VALUES ('clicku','clickp',1,100); adds a ClickHouse user row to the in-memory table. LOAD CLICKHOUSE USERS TO RUNTIME; makes that row the active ClickHouse user configuration. SAVE CLICKHOUSE USERS TO DISK; writes the row to persistent storage. These statements configure ClickHouse credentials. They do not bootstrap mysql_router or create router endpoints.
Try it: config_layer_sim
You run INSERT INTO clickhouse_users VALUES ('clicku','clickp',1,100);.
You run LOAD CLICKHOUSE USERS TO RUNTIME;.
You run SAVE CLICKHOUSE USERS TO DISK;.
You see that clickhouse_users names the in-memory row set. runtime_clickhouse_users names the active configuration. disk.clickhouse_users names persistent storage.
You see no mysql_router bootstrap command.
Sources
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
- ClickHouse Configuration
Do more with an account
- Graded quizzes is available on your account.
- Saving your progress is available on your account.
- Hands-on labs is available on your account.
- AI tutoring is available on your account.