no more separate compose files for materialize mysql

This commit is contained in:
Yatsishin Ilya 2021-02-16 10:37:35 +03:00
parent 178d3fdba0
commit e4b3511d28
5 changed files with 25 additions and 22 deletions

View File

@ -1,10 +0,0 @@
version: '2.3'
services:
mysql1:
image: mysql:5.7
restart: 'no'
environment:
MYSQL_ROOT_PASSWORD: clickhouse
ports:
- 3308:3306
command: --server_id=100 --log-bin='mysql-bin-1.log' --default-time-zone='+3:00' --gtid-mode="ON" --enforce-gtid-consistency

View File

@ -1,10 +1,10 @@
version: '2.3' version: '2.3'
services: services:
mysql8_0: mysql80:
image: mysql:8.0 image: mysql:8.0
restart: 'no' restart: always
environment: environment:
MYSQL_ROOT_PASSWORD: clickhouse MYSQL_ROOT_PASSWORD: clickhouse
ports: ports:
- 33308:3306 - ${MYSQL8_EXTERNAL_PORT}:${MYSQL8_INTERNAL_PORT}
command: --server_id=100 --log-bin='mysql-bin-1.log' --default_authentication_plugin='mysql_native_password' --default-time-zone='+3:00' --gtid-mode="ON" --enforce-gtid-consistency command: --server_id=100 --log-bin='mysql-bin-1.log' --default_authentication_plugin='mysql_native_password' --default-time-zone='+3:00' --gtid-mode="ON" --enforce-gtid-consistency

View File

@ -5,7 +5,7 @@
<source> <source>
<mysql > <mysql >
<db>test</db> <db>test</db>
<host>mysql1</host> <host>mysql57</host>
<port>3306</port> <port>3306</port>
<user>root</user> <user>root</user>
<password>clickhouse</password> <password>clickhouse</password>
@ -41,7 +41,7 @@
<source> <source>
<mysql > <mysql >
<db>test</db> <db>test</db>
<host>mysql1</host> <host>mysql57</host>
<port>3306</port> <port>3306</port>
<user>root</user> <user>root</user>
<password>clickhouse</password> <password>clickhouse</password>

View File

@ -5,7 +5,7 @@
<source> <source>
<mysql > <mysql >
<db>test</db> <db>test</db>
<host>mysql1</host> <host>mysql57</host>
<port>3306</port> <port>3306</port>
<user>root</user> <user>root</user>
<password>clickhouse</password> <password>clickhouse</password>
@ -42,7 +42,7 @@
<source> <source>
<mysql > <mysql >
<db>test</db> <db>test</db>
<host>mysql1</host> <host>mysql57</host>
<port>3306</port> <port>3306</port>
<user>root</user> <user>root</user>
<password>clickhouse</password> <password>clickhouse</password>
@ -78,7 +78,7 @@
<source> <source>
<mysql > <mysql >
<db>test</db> <db>test</db>
<host>mysql1</host> <host>mysql57</host>
<port>3306</port> <port>3306</port>
<user>root</user> <user>root</user>
<password>clickhouse</password> <password>clickhouse</password>

View File

@ -2,6 +2,8 @@
import pymysql.cursors import pymysql.cursors
import pytest import pytest
from helpers.cluster import ClickHouseCluster from helpers.cluster import ClickHouseCluster
import time
import logging
CONFIG_FILES = ['configs/dictionaries/mysql_dict1.xml', 'configs/dictionaries/mysql_dict2.xml', CONFIG_FILES = ['configs/dictionaries/mysql_dict1.xml', 'configs/dictionaries/mysql_dict2.xml',
'configs/remote_servers.xml'] 'configs/remote_servers.xml']
@ -87,11 +89,22 @@ def prepare_mysql_table(table_name, index):
# Create CH Dictionary tables based on MySQL tables # Create CH Dictionary tables based on MySQL tables
query(create_clickhouse_dictionary_table_template.format(table_name + str(index), 'dict' + str(index))) query(create_clickhouse_dictionary_table_template.format(table_name + str(index), 'dict' + str(index)))
def get_mysql_conn(): def get_mysql_conn():
conn = pymysql.connect(user='root', password='clickhouse', host='127.0.0.10', port=cluster.mysql_port) errors = []
conn = None
for _ in range(5):
try:
if conn is None:
conn = pymysql.connect(user='root', password='clickhouse', host='127.0.0.1', port=cluster.mysql_port)
else:
conn.ping(reconnect=True)
logging.debug("MySQL Connection establised: 127.0.0.1:{}".format(cluster.mysql_port))
return conn return conn
except Exception as e:
errors += [str(e)]
time.sleep(1)
raise Exception("Connection not establised, {}".format(errors))
def create_mysql_table(conn, table_name): def create_mysql_table(conn, table_name):
with conn.cursor() as cursor: with conn.cursor() as cursor: