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

change -mysql_server_bind_address #5386

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/demo/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def start_vitess():
'--proto_topo', text_format.MessageToString(topology,
as_one_line=True),
'--web_dir', os.path.join(vttop, 'web/vtctld'),
'--schema_dir', os.path.join(vttop, 'examples/demo/schema')]
'--schema_dir', os.path.join(vttop, 'examples/demo/schema'),
'--mysql_server_bind_address', '0.0.0.0']
sp = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

# This load will make us wait for vitess to come up.
Expand Down
8 changes: 6 additions & 2 deletions py/vttest/local_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self,
extra_my_cnf=None,
web_dir2=None,
snapshot_file=None,
charset='utf8'):
charset='utf8',
mysql_server_bind_address=None):
"""Initializes an object of this class.

Args:
Expand All @@ -59,6 +60,7 @@ def __init__(self,
flag in run_local_database.py
snapshot_file: A MySQL DB snapshot file.
charset: MySQL charset.
mysql_server_bind_address: MySQL server bind address.
"""

self.topology = topology
Expand All @@ -71,6 +73,7 @@ def __init__(self,
self.web_dir2 = web_dir2
self.snapshot_file = snapshot_file
self.charset = charset
self.mysql_server_bind_address = mysql_server_bind_address

def setup(self):
"""Create a MySQL instance and all Vitess processes."""
Expand All @@ -92,7 +95,8 @@ def setup(self):
vt_processes.start_vt_processes(self.directory, self.topology,
self.mysql_db, self.schema_dir,
charset=self.charset, web_dir=self.web_dir,
web_dir2=self.web_dir2)
web_dir2=self.web_dir2,
mysql_server_bind_address=self.mysql_server_bind_address)

def teardown(self):
"""Kill all Vitess processes and wait for them to end.
Expand Down
6 changes: 5 additions & 1 deletion py/vttest/run_local_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def main(cmdline_options):
default_schema_dir=cmdline_options.default_schema_dir,
extra_my_cnf=extra_my_cnf,
charset=cmdline_options.charset,
snapshot_file=cmdline_options.snapshot_file) as local_db:
snapshot_file=cmdline_options.snapshot_file,
mysql_server_bind_address=cmdline_options.mysql_server_bind_address) as local_db:
print json.dumps(local_db.config())
sys.stdout.flush()
try:
Expand Down Expand Up @@ -189,6 +190,9 @@ def main(cmdline_options):
parser.add_option(
'-f', '--extra_my_cnf',
help='extra files to add to the config, separated by ":"')
parser.add_option(
'--mysql_server_bind_address',
help='mysql server bind address ":"')
parser.add_option(
'-v', '--verbose', action='store_true',
help='Display extra error messages.')
Expand Down
16 changes: 11 additions & 5 deletions py/vttest/vt_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class VtcomboProcess(VtProcess):
]

def __init__(self, directory, topology, mysql_db, schema_dir, charset,
web_dir=None, web_dir2=None):
web_dir=None, web_dir2=None,mysql_server_bind_address=None):
VtProcess.__init__(self, 'vtcombo-%s' % os.environ['USER'], directory,
environment.vtcombo_binary, port_name='vtcombo')
self.extraparams = [
Expand All @@ -164,17 +164,21 @@ def __init__(self, directory, topology, mysql_db, schema_dir, charset,
['-db_host', mysql_db.hostname(),
'-db_port', str(mysql_db.port())])
self.vtcombo_mysql_port = environment.get_port('vtcombo_mysql_port')
if mysql_server_bind_address:
# Binding to 0.0.0.0 instead of localhost makes it possible to connect to vtgate from outside a docker container
self.extraparams.extend(['-mysql_server_bind_address', mysql_server_bind_address])
else:
self.extraparams.extend(['-mysql_server_bind_address', 'localhost'])
self.extraparams.extend(
['-mysql_auth_server_impl', 'none',
'-mysql_server_port', str(self.vtcombo_mysql_port),
'-mysql_server_bind_address', 'localhost'])
'-mysql_server_port', str(self.vtcombo_mysql_port)])


vtcombo_process = None


def start_vt_processes(directory, topology, mysql_db, schema_dir,
charset='utf8', web_dir=None, web_dir2=None):
charset='utf8', web_dir=None, web_dir2=None, mysql_server_bind_address=None):
"""Start the vt processes.

Args:
Expand All @@ -185,13 +189,15 @@ def start_vt_processes(directory, topology, mysql_db, schema_dir,
charset: the character set for the database connections.
web_dir: contains the web app for vtctld side of vtcombo.
web_dir2: contains the web app for vtctld side of vtcombo.
mysql_server_bind_address: MySQL server bind address for vtcombo.
"""
global vtcombo_process

logging.info('start_vt_processes(directory=%s,vtcombo_binary=%s)',
directory, environment.vtcombo_binary)
vtcombo_process = VtcomboProcess(directory, topology, mysql_db, schema_dir,
charset, web_dir=web_dir, web_dir2=web_dir2)
charset, web_dir=web_dir, web_dir2=web_dir2,
mysql_server_bind_address=mysql_server_bind_address)
vtcombo_process.wait_start()


Expand Down