Skip to content
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
6 changes: 3 additions & 3 deletions doc/SeparatingVttabletMysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ The following adjustments need to be made to VTTablet command line parameters:

* Do not use `-mycnf_socket_file`. There is no local MySQL unix socket file.

* Specify the host and port of the MySQL daemon for the `-db-config-XXX-host`
and `-db-config-XXX-port` command line parameters. Do not specify
`-db-config-XXX-unixsocket` parameters.
* Specify the host and port of the MySQL daemon for the `-db\_host`
and `-db\_port` command line parameters. Do not specify
`-db\_socket` parameters.

* Disable restores / backups, by not passing any backup command line
parameters. Specifically, `-restore_from_backup` and
Expand Down
49 changes: 29 additions & 20 deletions doc/ServerConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,36 +256,45 @@ the binlogs in `/mnt/bin-logs`:

VTTablet requires multiple user credentials to perform its tasks. Since it's required to run on the same machine as MySQL, it’s most beneficial to use the more efficient unix socket connections.

**connection** parameters

* **db\_socket**: The unix socket to connect on. If this is specifed, host and port will not be used.
* **db\_host**: The host name for the tcp connection.
* **db\_port**: The tcp port to be used with the db\_host.
* **db\_charset**: Character set. Only utf8 or latin1 based character sets are supported.
* **db\_flags**: Flag values as defined by MySQL.
* **db\ssl\_ca, db\_ssl\_ca\_path, db\_ssl\_cert, db\_ssl\_key**: SSL flags.


**app** credentials are for serving app queries:

* **db-config-app-unixsocket**: MySQL socket name to connect to.
* **db-config-app-uname**: App username.
* **db-config-app-pass**: Password for the app username. If you need a more secure way of managing and supplying passwords, VTTablet does allow you to plug into a "password server" that can securely supply and refresh usernames and passwords. Please contact the Vitess team for help if you’d like to write such a custom plugin.
* **db-config-app-charset**: The only supported character set is utf8. Vitess still works with latin1, but it’s getting deprecated.
* **db\_app\_user**: App username.
* **db\_app\_password**: Password for the app username. If you need a more secure way of managing and supplying passwords, VTTablet does allow you to plug into a "password server" that can securely supply and refresh usernames and passwords. Please contact the Vitess team for help if you’d like to write such a custom plugin.
* **db\_app\_use\_ssl**: Set this flag to false if you don't want to use SSL for this connection. This will allow you to turn off SSL for all users except for `repl`, which may have to be turned on for replication that goes over open networks.

**appdebug** credentials are for the appdebug user:

* **db\_appdebug\_user**
* **db\_appdebug\_password**
* **db\_appdebug\_use\_ssl**

**dba** credentials will be used for housekeeping work like loading the schema or killing runaway queries:

* **db-config-dba-unixsocket**
* **db-config-dba-uname**
* **db-config-dba-pass**
* **db-config-dba-charset**
* **db\_dba\_user**
* **db\_dba\_password**
* **db\_dba\_use\_ssl**

**repl** credentials are for managing replication. Since repl connections can be used across machines, you can optionally turn on encryption:
**repl** credentials are for managing replication.

* **db-config-repl-uname**
* **db-config-repl-pass**
* **db-config-repl-charset**
* **db-config-repl-flags**: If you want to enable SSL, this must be set to 2048.
* **db-config-repl-ssl-ca**
* **db-config-repl-ssl-cert**
* **db-config-repl-ssl-key**
* **db\_repl\_user**
* **db\_repl\_password**
* **db\_repl\_use\_ssl**

**filtered** credentials are for performing resharding:

* **db-config-filtered-unixsocket**
* **db-config-filtered-uname**
* **db-config-filtered-pass**
* **db-config-filtered-charset**
* **db\_filtered\_user**
* **db\_filtered\_password**
* **db\_filtered\_use\_ssl**

### Monitoring

Expand Down
20 changes: 1 addition & 19 deletions examples/compose/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ if [ "$uid" = "1" ]; then
tablet_role='master'
fi

dbconfig_dba_flags="\
-db-config-dba-uname root \
-db-config-dba-charset utf8"

dbconfig_flags="$dbconfig_dba_flags \
-db-config-app-uname root \
-db-config-app-charset utf8 \
-db-config-appdebug-uname root \
-db-config-appdebug-charset utf8 \
-db-config-allprivs-uname root \
-db-config-allprivs-charset utf8 \
-db-config-repl-uname root \
-db-config-repl-charset utf8 \
-db-config-filtered-uname root \
-db-config-filtered-charset utf8"

init_db_sql_file="$VTROOT/init_db.sql"
echo "GRANT ALL ON *.* TO 'root'@'%';" > $init_db_sql_file

Expand All @@ -52,7 +36,6 @@ fi
$VTROOT/bin/mysqlctl \
-log_dir $VTDATAROOT/tmp \
-tablet_uid $uid \
$dbconfig_dba_flags \
-mysql_port 3306 \
$action &

Expand All @@ -78,5 +61,4 @@ exec $VTROOT/bin/vttablet \
-grpc_port $GRPC_PORT \
-service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \
-pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \
-vtctld_addr http://vtctld:$WEB_PORT/ \
$dbconfig_flags
-vtctld_addr "http://vtctld:$WEB_PORT/"
14 changes: 0 additions & 14 deletions examples/kubernetes/vttablet-pod-benchmarking-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ spec:
-init_shard {{shard}}
-init_tablet_type {{tablet_type}}
-mysqlctl_socket $VTDATAROOT/mysqlctl.sock
-db-config-app-uname vt_app
-db-config-app-dbname vt_{{keyspace}}
-db-config-app-charset utf8
-db-config-dba-uname vt_dba
-db-config-dba-dbname vt_{{keyspace}}
-db-config-dba-charset utf8
-db-config-repl-uname vt_repl
-db-config-repl-dbname vt_{{keyspace}}
-db-config-repl-charset utf8
-db-config-filtered-uname vt_filtered
-db-config-filtered-dbname vt_{{keyspace}}
-db-config-filtered-charset utf8
-queryserver-config-transaction-cap 300
-queryserver-config-schema-reload-time 1
-queryserver-config-pool-size 100
Expand Down Expand Up @@ -98,8 +86,6 @@ spec:
-alsologtostderr
-tablet_uid {{uid}}
-socket_file $VTDATAROOT/mysqlctl.sock
-db-config-dba-uname vt_dba
-db-config-dba-charset utf8
-init_db_sql_file $VTROOT/config/init_db.sql" vitess
env:
- name: EXTRA_MY_CNF
Expand Down
14 changes: 0 additions & 14 deletions examples/kubernetes/vttablet-pod-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ spec:
-init_tablet_type {{tablet_type}}
-health_check_interval 5s
-mysqlctl_socket $VTDATAROOT/mysqlctl.sock
-db-config-app-uname vt_app
-db-config-app-dbname vt_{{keyspace}}
-db-config-app-charset utf8
-db-config-dba-uname vt_dba
-db-config-dba-dbname vt_{{keyspace}}
-db-config-dba-charset utf8
-db-config-repl-uname vt_repl
-db-config-repl-dbname vt_{{keyspace}}
-db-config-repl-charset utf8
-db-config-filtered-uname vt_filtered
-db-config-filtered-dbname vt_{{keyspace}}
-db-config-filtered-charset utf8
-enable_semi_sync
-enable_replication_reporter
-orc_api_url http://orchestrator/api
Expand Down Expand Up @@ -107,8 +95,6 @@ spec:
-alsologtostderr
-tablet_uid {{uid}}
-socket_file $VTDATAROOT/mysqlctl.sock
-db-config-dba-uname vt_dba
-db-config-dba-charset utf8
-init_db_sql_file $VTROOT/config/init_db.sql" vitess
env:
- name: EXTRA_MY_CNF
Expand Down
1 change: 0 additions & 1 deletion examples/local/vttablet-down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ for uid_index in $uids; do

echo "Stopping MySQL for tablet $alias..."
$VTROOT/bin/mysqlctl \
-db-config-dba-uname vt_dba \
-tablet_uid $uid \
shutdown &
done
Expand Down
21 changes: 0 additions & 21 deletions examples/local/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,6 @@ fi
script_root=`dirname "${BASH_SOURCE}"`
source $script_root/env.sh

dbconfig_dba_flags="\
-db-config-dba-uname vt_dba \
-db-config-dba-charset utf8"
dbconfig_flags="$dbconfig_dba_flags \
-db-config-app-uname vt_app \
-db-config-app-dbname vt_$keyspace \
-db-config-app-charset utf8 \
-db-config-appdebug-uname vt_appdebug \
-db-config-appdebug-dbname vt_$keyspace \
-db-config-appdebug-charset utf8 \
-db-config-allprivs-uname vt_allprivs \
-db-config-allprivs-dbname vt_$keyspace \
-db-config-allprivs-charset utf8 \
-db-config-repl-uname vt_repl \
-db-config-repl-dbname vt_$keyspace \
-db-config-repl-charset utf8 \
-db-config-filtered-uname vt_filtered \
-db-config-filtered-dbname vt_$keyspace \
-db-config-filtered-charset utf8"
init_db_sql_file="$VTROOT/config/init_db.sql"

case "$MYSQL_FLAVOR" in
Expand Down Expand Up @@ -93,7 +74,6 @@ for uid_index in $uids; do
$VTROOT/bin/mysqlctl \
-log_dir $VTDATAROOT/tmp \
-tablet_uid $uid \
$dbconfig_dba_flags \
-mysql_port $mysql_port \
$action &
done
Expand Down Expand Up @@ -142,7 +122,6 @@ for uid_index in $uids; do
-pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \
-vtctld_addr http://$hostname:$vtctld_web_port/ \
$optional_auth_args \
$dbconfig_flags \
> $VTDATAROOT/$tablet_dir/vttablet.out 2>&1 &

echo "Access tablet $alias at http://$hostname:$port/debug/status"
Expand Down
20 changes: 7 additions & 13 deletions go/cmd/mysqlctl/mysqlctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,11 @@ var (
tabletAddr string
)

const (
// dbconfigFlags is only set to DbaConfig, as mysqlctl only
// starts and stops mysqld, and that is only done with the dba user.
dbconfigFlags = dbconfigs.DbaConfig
)

func initConfigCmd(subFlags *flag.FlagSet, args []string) error {
subFlags.Parse(args)

// Generate my.cnf from scratch and use it to find mysqld.
mysqld, err := mysqlctl.CreateMysqld(uint32(*tabletUID), *mysqlSocket, int32(*mysqlPort), dbconfigFlags)
mysqld, err := mysqlctl.CreateMysqld(uint32(*tabletUID), *mysqlSocket, int32(*mysqlPort))
if err != nil {
return fmt.Errorf("failed to initialize mysql config: %v", err)
}
Expand All @@ -71,7 +65,7 @@ func initCmd(subFlags *flag.FlagSet, args []string) error {
subFlags.Parse(args)

// Generate my.cnf from scratch and use it to find mysqld.
mysqld, err := mysqlctl.CreateMysqld(uint32(*tabletUID), *mysqlSocket, int32(*mysqlPort), dbconfigFlags)
mysqld, err := mysqlctl.CreateMysqld(uint32(*tabletUID), *mysqlSocket, int32(*mysqlPort))
if err != nil {
return fmt.Errorf("failed to initialize mysql config: %v", err)
}
Expand All @@ -87,7 +81,7 @@ func initCmd(subFlags *flag.FlagSet, args []string) error {

func reinitConfigCmd(subFlags *flag.FlagSet, args []string) error {
// There ought to be an existing my.cnf, so use it to find mysqld.
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID), dbconfigFlags)
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID))
if err != nil {
return fmt.Errorf("failed to find mysql config: %v", err)
}
Expand All @@ -104,7 +98,7 @@ func shutdownCmd(subFlags *flag.FlagSet, args []string) error {
subFlags.Parse(args)

// There ought to be an existing my.cnf, so use it to find mysqld.
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID), dbconfigFlags)
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID))
if err != nil {
return fmt.Errorf("failed to find mysql config: %v", err)
}
Expand All @@ -125,7 +119,7 @@ func startCmd(subFlags *flag.FlagSet, args []string) error {
subFlags.Parse(args)

// There ought to be an existing my.cnf, so use it to find mysqld.
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID), dbconfigFlags)
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID))
if err != nil {
return fmt.Errorf("failed to find mysql config: %v", err)
}
Expand All @@ -145,7 +139,7 @@ func teardownCmd(subFlags *flag.FlagSet, args []string) error {
subFlags.Parse(args)

// There ought to be an existing my.cnf, so use it to find mysqld.
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID), dbconfigFlags)
mysqld, err := mysqlctl.OpenMysqld(uint32(*tabletUID))
if err != nil {
return fmt.Errorf("failed to find mysql config: %v", err)
}
Expand Down Expand Up @@ -241,7 +235,7 @@ func main() {
fmt.Fprintf(os.Stderr, "\n")
}

dbconfigs.RegisterFlags(dbconfigFlags)
dbconfigs.RegisterFlags(dbconfigs.Dba)
flag.Parse()

tabletAddr = netutil.JoinHostPort("localhost", int32(*port))
Expand Down
7 changes: 3 additions & 4 deletions go/cmd/mysqlctld/mysqlctld.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ func main() {
defer logutil.Flush()

// mysqlctld only starts and stops mysql, only needs dba.
dbconfigFlags := dbconfigs.DbaConfig
dbconfigs.RegisterFlags(dbconfigFlags)
dbconfigs.RegisterFlags(dbconfigs.Dba)
servenv.ParseFlags("mysqlctld")

// We'll register this OnTerm handler before mysqld starts, so we get notified
Expand All @@ -75,7 +74,7 @@ func main() {
log.Infof("mycnf file (%s) doesn't exist, initializing", mycnfFile)

var err error
mysqld, err = mysqlctl.CreateMysqld(uint32(*tabletUID), *mysqlSocket, int32(*mysqlPort), dbconfigFlags)
mysqld, err = mysqlctl.CreateMysqld(uint32(*tabletUID), *mysqlSocket, int32(*mysqlPort))
if err != nil {
log.Errorf("failed to initialize mysql config: %v", err)
exit.Return(1)
Expand All @@ -91,7 +90,7 @@ func main() {
log.Infof("mycnf file (%s) already exists, starting without init", mycnfFile)

var err error
mysqld, err = mysqlctl.OpenMysqld(uint32(*tabletUID), dbconfigFlags)
mysqld, err = mysqlctl.OpenMysqld(uint32(*tabletUID))
if err != nil {
log.Errorf("failed to find mysql config: %v", err)
exit.Return(1)
Expand Down
10 changes: 4 additions & 6 deletions go/cmd/vtcombo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ func main() {
defer exit.Recover()

// flag parsing
dbconfigFlags := dbconfigs.AppConfig | dbconfigs.AllPrivsConfig | dbconfigs.DbaConfig |
dbconfigs.FilteredConfig | dbconfigs.ReplConfig
dbconfigs.RegisterFlags(dbconfigFlags)
dbconfigs.RegisterFlags(dbconfigs.All...)
mysqlctl.RegisterFlags()
servenv.ParseFlags("vtcombo")

Expand Down Expand Up @@ -102,15 +100,15 @@ func main() {
log.Errorf("mycnf read failed: %v", err)
exit.Return(1)
}
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile, dbconfigFlags)
dbcfgs, err := dbconfigs.Init(mycnf.SocketFile)
if err != nil {
log.Warning(err)
}
mysqld := mysqlctl.NewMysqld(mycnf, dbcfgs, dbconfigFlags)
mysqld := mysqlctl.NewMysqld(mycnf, dbcfgs)
servenv.OnClose(mysqld.Close)

// tablets configuration and init
if err := vtcombo.InitTabletMap(ts, tpb, mysqld, *dbcfgs, *schemaDir, mycnf); err != nil {
if err := vtcombo.InitTabletMap(ts, tpb, mysqld, dbcfgs, *schemaDir, mycnf); err != nil {
log.Errorf("initTabletMapProto failed: %v", err)
exit.Return(1)
}
Expand Down
11 changes: 8 additions & 3 deletions go/cmd/vtqueryserver/vtqueryserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ import (
)

var (
dbName string
mysqlSocketFile = flag.String("mysql-socket-file", "", "path to unix socket file to connect to mysql")
)

func init() {
servenv.RegisterDefaultFlags()
// TODO(demmer): remove once migrated to using db_name
flag.StringVar(&dbName, "db-config-app-dbname", "", "db connection dbname")
flag.StringVar(&dbName, "db_name", "", "db connection dbname")
}

func main() {
dbconfigFlags := dbconfigs.AppConfig | dbconfigs.AppDebugConfig
dbconfigs.RegisterFlags(dbconfigFlags)
dbconfigs.RegisterFlags(dbconfigs.App, dbconfigs.AppDebug)
flag.Parse()

if *servenv.Version {
Expand All @@ -57,10 +60,12 @@ func main() {

servenv.Init()

dbcfgs, err := dbconfigs.Init(*mysqlSocketFile, dbconfigFlags)
dbcfgs, err := dbconfigs.Init(*mysqlSocketFile)
if err != nil {
log.Fatal(err)
}
// DB name must be explicitly set.
dbcfgs.DBName.Set(dbName)

err = vtqueryserver.Init(dbcfgs)
if err != nil {
Expand Down
Loading