Now the local examples use 'zk2' topology.

Instead of the soon-to-be-deprecated 'zookeeper' one.
This commit is contained in:
Alain Jobart 2017-01-05 10:51:56 -08:00
Родитель b9bc473b69
Коммит 98e7aafeb5
8 изменённых файлов: 29 добавлений и 15 удалений

Просмотреть файл

@ -102,7 +102,7 @@ sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
possible to use another lock server, but plugins currently exist only possible to use another lock server, but plugins currently exist only
for ZooKeeper and etcd. for ZooKeeper and etcd.
- ZooKeeper 3.3.5 is included by default. - ZooKeeper 3.3.5 is included by default.
- [Install etcd v2.0+](https://github.com/coreos/etcd/releases). - [Install etcd v3.0+](https://github.com/coreos/etcd/releases).
If you use etcd, remember to include the `etcd` command If you use etcd, remember to include the `etcd` command
on your path. on your path.
@ -399,9 +399,10 @@ lock service. ZooKeeper is included in the Vitess distribution.
Vitess process how to connect to ZooKeeper. Then, each process can Vitess process how to connect to ZooKeeper. Then, each process can
find all of the other Vitess processes by coordinating via ZooKeeper. find all of the other Vitess processes by coordinating via ZooKeeper.
Each of our scripts automatically sets the `ZK_CLIENT_CONFIG` environment Each of our scripts automatically uses the `TOPOLOGY_FLAGS` environment
variable to point to the `zk-client-conf.json` file, which contains the variable to point to the global ZooKeeper instance. The global instance in
ZooKeeper server addresses for each cell. turn is configured to point to the local instance. In our sample scripts,
they are both hosted in the same ZooKeeper service.
1. **Start vtctld** 1. **Start vtctld**

Просмотреть файл

@ -1,4 +1,5 @@
hostname=`hostname -f` hostname=`hostname -f`
vtctld_web_port=15000
# Each ZooKeeper server needs a list of all servers in the quorum. # Each ZooKeeper server needs a list of all servers in the quorum.
# Since we're running them all locally, we need to give them unique ports. # Since we're running them all locally, we need to give them unique ports.
@ -27,9 +28,9 @@ if [ -z "$VT_MYSQL_ROOT" ]; then
export VT_MYSQL_ROOT=$(dirname `dirname $mysql_path`) export VT_MYSQL_ROOT=$(dirname `dirname $mysql_path`)
fi fi
# We expect to find zk-client-conf.json in the same folder as this script. # Set topology environment parameters.
env_script_root=`dirname "${BASH_SOURCE}"` ZK_SERVER="localhost:21811,localhost:21812,localhost:21813"
export ZK_CLIENT_CONFIG=$env_script_root/zk-client-conf.json TOPOLOGY_FLAGS="-topo_implementation zk2 -topo_global_server_address $ZK_SERVER -topo_global_root /vitess/global"
mkdir -p $VTDATAROOT/tmp mkdir -p $VTDATAROOT/tmp

Просмотреть файл

@ -9,6 +9,7 @@ source $script_root/env.sh
echo "Starting vtworker..." echo "Starting vtworker..."
exec $VTROOT/bin/vtworker \ exec $VTROOT/bin/vtworker \
$TOPOLOGY_FLAGS \
-cell test \ -cell test \
-log_dir $VTDATAROOT/tmp \ -log_dir $VTDATAROOT/tmp \
-alsologtostderr \ -alsologtostderr \

Просмотреть файл

@ -5,7 +5,6 @@
set -e set -e
cell='test' cell='test'
web_port=15000
grpc_port=15999 grpc_port=15999
script_root=`dirname "${BASH_SOURCE}"` script_root=`dirname "${BASH_SOURCE}"`
@ -13,6 +12,7 @@ source $script_root/env.sh
echo "Starting vtctld..." echo "Starting vtctld..."
$VTROOT/bin/vtctld \ $VTROOT/bin/vtctld \
$TOPOLOGY_FLAGS \
-cell $cell \ -cell $cell \
-web_dir $VTTOP/web/vtctld \ -web_dir $VTTOP/web/vtctld \
-web_dir2 $VTTOP/web/vtctld2/app \ -web_dir2 $VTTOP/web/vtctld2/app \
@ -22,12 +22,11 @@ $VTROOT/bin/vtctld \
-backup_storage_implementation file \ -backup_storage_implementation file \
-file_backup_storage_root $VTDATAROOT/backups \ -file_backup_storage_root $VTDATAROOT/backups \
-log_dir $VTDATAROOT/tmp \ -log_dir $VTDATAROOT/tmp \
-port $web_port \ -port $vtctld_web_port \
-grpc_port $grpc_port \ -grpc_port $grpc_port \
-pid_file $VTDATAROOT/tmp/vtctld.pid \ -pid_file $VTDATAROOT/tmp/vtctld.pid \
> $VTDATAROOT/tmp/vtctld.out 2>&1 & > $VTDATAROOT/tmp/vtctld.out 2>&1 &
disown -a disown -a
echo "Access vtctld web UI at http://$hostname:$web_port" echo "Access vtctld web UI at http://$hostname:$vtctld_web_port"
echo "Send commands with: vtctlclient -server $hostname:$grpc_port ..." echo "Send commands with: vtctlclient -server $hostname:$grpc_port ..."

Просмотреть файл

@ -13,6 +13,7 @@ source $script_root/env.sh
# Start vtgate. # Start vtgate.
$VTROOT/bin/vtgate \ $VTROOT/bin/vtgate \
$TOPOLOGY_FLAGS \
-log_dir $VTDATAROOT/tmp \ -log_dir $VTDATAROOT/tmp \
-port $web_port \ -port $web_port \
-grpc_port $grpc_port \ -grpc_port $grpc_port \

Просмотреть файл

@ -98,6 +98,7 @@ for uid_index in $uids; do
echo "Starting vttablet for $alias..." echo "Starting vttablet for $alias..."
$VTROOT/bin/vttablet \ $VTROOT/bin/vttablet \
$TOPOLOGY_FLAGS \
-log_dir $VTDATAROOT/tmp \ -log_dir $VTDATAROOT/tmp \
-tablet-path $alias \ -tablet-path $alias \
-tablet_hostname "$tablet_hostname" \ -tablet_hostname "$tablet_hostname" \
@ -114,6 +115,7 @@ for uid_index in $uids; do
-grpc_port $grpc_port \ -grpc_port $grpc_port \
-service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \ -service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \
-pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \ -pid_file $VTDATAROOT/$tablet_dir/vttablet.pid \
-vtctld_addr http://$hostname:$vtctld_web_port/ \
$dbconfig_flags \ $dbconfig_flags \
> $VTDATAROOT/$tablet_dir/vttablet.out 2>&1 & > $VTDATAROOT/$tablet_dir/vttablet.out 2>&1 &

Просмотреть файл

@ -1,4 +0,0 @@
{
"test": "localhost:21811,localhost:21812,localhost:21813",
"global": "localhost:21811,localhost:21812,localhost:21813"
}

Просмотреть файл

@ -35,3 +35,16 @@ for zkid in $zkids; do
done done
echo "Started zk servers." echo "Started zk servers."
# Now create the toplevel directories we'll need, if not there.
$VTROOT/bin/zk -server $ZK_SERVER touch -p /vitess/global
$VTROOT/bin/zk -server $ZK_SERVER touch -p /vitess/test
# And also add the CellInfo description for the 'test' cell.
# If the node already exists, it's fine, means we used existing data.
$VTROOT/bin/vtctl $TOPOLOGY_FLAGS AddCellInfo \
-root /vitess/test \
-server_address $ZK_SERVER \
test || /bin/true
echo "Configured zk servers."