This file is indexed.

/usr/bin/mysqlreplicate is in mysql-utilities 1.3.5-2.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#! /usr/bin/python
#
# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

"""
This file contains the replicate utility. It is used to establish a
master/slave replication topology among two servers.
"""

from mysql.utilities.common.tools import check_python_version

# Check Python version compatibility
check_python_version()

import os.path
import sys

from mysql.utilities.command.setup_rpl import setup_replication
from mysql.utilities.common.ip_parser import parse_connection
from mysql.utilities.common.messages import (PARSE_ERR_OPTS_REQ,
                                             WARN_OPT_USING_DEFAULT)
from mysql.utilities.common.options import setup_common_options
from mysql.utilities.common.options import add_verbosity, add_rpl_user
from mysql.utilities.common.server import check_hostname_alias
from mysql.utilities.common.tools import check_connector_python
from mysql.utilities.exception import FormatError
from mysql.utilities.exception import UtilError

# Constants
NAME = "MySQL Utilities - mysqlreplicate "
DESCRIPTION = "mysqlreplicate - establish replication with a master"
USAGE = "%prog --master=root@localhost:3306 --slave=root@localhost:3310 " \
        "--rpl-user=rpl:passwd "

# Check for connector/python
if not check_connector_python():
    sys.exit(1)

# Setup the command parser
parser = setup_common_options(os.path.basename(sys.argv[0]),
                              DESCRIPTION, USAGE, True, False)

# Setup utility-specific options:

# Connection information for the source server
parser.add_option('--master', action="store", dest="master",
                  type="string", default=None,
                  help="connection information for master server in "
                  "the form: <user>[:<password>]@<host>[:<port>][:<socket>] or"
                  " <login-path>[:<port>][:<socket>].")

# Connection information for the destination server
parser.add_option('--slave', action="store", dest="slave",
                  type="string", default=None,
                  help="connection information for slave server in "
                  "the form: <user>[:<password>]@<host>[:<port>][:<socket>] or"
                  " <login-path>[:<port>][:<socket>].")

# Replication user and password
add_rpl_user(parser)

# Pedantic mode for failing if storage engines differ
parser.add_option("-p", "--pedantic", action="store_true", default=False,
                  dest="pedantic", help="fail if storage engines differ "
                  "among master and slave.")

# Test replication option
parser.add_option("--test-db", action="store", dest="test_db",
                  type="string", help="database name to use in testing "
                  "replication setup (optional)")

# Add master log file option
parser.add_option("--master-log-file", action="store", dest="master_log_file",
                  type="string", help="use this master log file to initiate "
                  "the slave.", default=None)

# Add master log position option
parser.add_option("--master-log-pos", action="store", dest="master_log_pos",
                  type="int", help="use this position in the master log file "
                  "to initiate the slave.", default=-1)

# Add start from beginning option
parser.add_option("-b", "--start-from-beginning", action="store_true",
                  default=False, dest="from_beginning",
                  help="start replication from the first event recorded in "
                  "the binary logging of the master."
                  "Not valid with --master-log-file or --master-log-pos.")

# Add verbosity
add_verbosity(parser)

# Now we process the rest of the arguments.
opt, args = parser.parse_args()

# option --master is required (mandatory)
if not opt.master:
    default_val = 'root@localhost:3306'
    print(WARN_OPT_USING_DEFAULT.format(default=default_val, opt='--master'))
    # Print the WARNING to force determinism if a parser error occurs.
    sys.stdout.flush()

# option --slave is required (mandatory)
if not opt.slave:
    parser.error(PARSE_ERR_OPTS_REQ.format(opt='--slave'))

# Parse source connection values
try:
    m_values = parse_connection(opt.master, None, opt)
except FormatError:
    _, err, _ = sys.exc_info()
    parser.error("Master connection values invalid: %s." % err)
except UtilError:
    _, err, _ = sys.exc_info()
    parser.error("Master connection values invalid: %s." % err.errmsg)


# Parse source connection values
try:
    s_values = parse_connection(opt.slave, None, opt)
except FormatError:
    _, err, _ = sys.exc_info()
    parser.error("Slave connection values invalid: %s." % err)
except UtilError:
    _, err, _ = sys.exc_info()
    parser.error("Slave connection values invalid: %s." % err.errmsg)

# Check hostname alias
if check_hostname_alias(m_values, s_values):
    parser.error("The master and slave are the same host and port.")

# Check required --master-log-file for --master-log-pos
if (opt.master_log_pos >= 0 and opt.master_log_file is None):
    parser.error("You must specify a master log file to use the master "
                 "log file position option.")

if ((opt.master_log_pos >= 0) or (opt.master_log_file is not None)) and \
   opt.from_beginning:
    parser.error("The --start-from-beginning option is not valid in "
                 "combination with --master-log-file or --master-log-pos.")

# Create dictionary of options
options = {
    'verbosity'       : opt.verbosity,
    'pedantic'        : opt.pedantic,
    'quiet'           : False,
    'master_log_file' : opt.master_log_file,
    'master_log_pos'  : opt.master_log_pos,
    'from_beginning'  : opt.from_beginning,
}

try:
    res = setup_replication(m_values, s_values, opt.rpl_user,
                            options, opt.test_db)
except UtilError:
    _, e, _ = sys.exc_info()
    print("ERROR: %s" % e.errmsg)
    sys.exit(1)

sys.exit()