时间:2021-07-01 10:21:17 帮助过:17人阅读
用户访问ClickHouse,需要默认的客户端clickhouse-client,但是这个工具不够友好:
- 需要额外安装,并且使用上,不是那么nice
- clickhouse-client其实是clickhouse的软连接,即要么全装,要么不用
啥最普及啊?
答:MySQL基本所有的服务器都装了mysql,注意,这里指的是mysql-client,就是那个让你用命令行连接到MySQL服务的那个命令
ProxySQL是众多MySQL中间件中的佼佼者,一直被Percona推崇,最近他们也放出了支持ClickHouse的版本
因此,今天的话题就是:
ClickHouse+ProxySQL = Using ClickHouse like MySQL
https://github.com/sysown/proxysql/releases/tag/v1.4.3
注意下载ClickHouse打头的包
安装依赖
1 | yum -y install perl-DBD-MySQL |
12345678910 | # 默认配置文件是这个:/etc/proxysql.cnf # 默认是没有这个数据目录的:mkdir /var/lib/proxysql# 启动proxysql --clickhouse-server# ProxySQL默认会以daemon的方式在后台 |
12345678910111213141516171819202122232425262728 | # 登陆本地的ProxySQL# ProxySQL端口是6032,默认用户名密码在配置文件里写有root@10.x.x.x.x:/root # mysql -h 127.0.0.1 -P 6032 -uadmin -padminWelcome to the MariaDB monitor. Commands end with ; or g.Your MySQL connection id is 3Server version: 5.5.30 (ProxySQL Admin Module)Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.MySQL [(none)]> INSERT INTO clickhouse_users VALUES ('clicku','clickp',1,100);Query OK, 1 row affected (0.00 sec)MySQL [(none)]> select * from clickhouse_users ; +----------+----------+--------+-----------------+| username | password | active | max_connections |+----------+----------+--------+-----------------+| clicku | clickp | 1 | 100 |+----------+----------+--------+-----------------+1 row in set (0.00 sec)MySQL [(none)]> LOAD CLICKHOUSE USERS TO RUNTIME;Query OK, 0 rows affected (0.00 sec)MySQL [(none)]> SAVE CLICKHOUSE USERS TO DISK;Query OK, 0 rows affected (0.00 sec) |
12345678910111213 | # 使用上面的用户名和密码# 如果是不同机器,记得改IProot@10.x.x.x.x:/root # mysql -h 127.0.0.1 -P 6090 -uclicku -pclickp --prompt "ProxySQL-ClickHouse> " Welcome to the MariaDB monitor. Commands end with ; or g.Your MySQL connection id is 13Server version: 5.5.30 (ProxySQL ClickHouse Module)Copyright (c) 2000 大专栏 Using ClickHouse like MySQL by ProxySQL, 2017, Oracle, MariaDB Corporation Ab and others.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.ProxySQL-ClickHouse> |
123456789101112131415161718192021222324252627282930313233343536373839404142 | MySQL [(none)]> select version(); +-------------------+| version |+-------------------+| 5.5.30-clickhouse |+-------------------+1 row in set (0.00 sec)MySQL [(none)]> select now();+---------------------+| now() |+---------------------+| 2017-12-19 15:45:26 |+---------------------+1 row in set (0.00 sec)MySQL [(none)]> select today(); +------------+| today() |+------------+| 2017-12-19 |+------------+1 row in set (0.00 sec)# 我们的某个表 600多亿ProxySQL-ClickHouse> select count(*) from XXXXX ; +-------------+| count() |+-------------+| 62699641362 |+-------------+1 row in set (11.20 sec)# 另一个表 1300多亿ProxySQL-ClickHouse> select count(*) from edge_msg_all;+--------------+| count() |+--------------+| 131929726359 |+--------------+1 row in set (5.30 sec) |
select CONCAT(DATE_FORMAT(current_timestamp, '%Y-%m-%d %H:%i:%S.%f' ), ' ', @@system_time_zone);
,这做不到啊Using ClickHouse like MySQL by ProxySQL
标签:select one sel mysql协议 需求 and mysql ranch pre