From 19d355752e340eeaaf8a0c5d178838f22edaeccb Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 19 Dec 2024 11:42:06 +0800 Subject: [PATCH 1/4] fix: start with config file --- config/wescale/test/vtgate.cnf | 62 ++++++++++++ config/wescale/test/vttablet.cnf | 58 +++++++++++ examples/wesql-server/vtgate.sh | 61 +++++++++--- examples/wesql-server/vtgate_using_flags.sh | 31 ++++++ examples/wesql-server/vttablet.sh | 96 ++++++++++++------- examples/wesql-server/vttablet_using_flags.sh | 55 +++++++++++ go/cmd/vtgate/vtgate.go | 2 +- go/cmd/vttablet/vttablet.go | 2 +- 8 files changed, 318 insertions(+), 49 deletions(-) create mode 100644 config/wescale/test/vtgate.cnf create mode 100644 config/wescale/test/vttablet.cnf create mode 100644 examples/wesql-server/vtgate_using_flags.sh create mode 100644 examples/wesql-server/vttablet_using_flags.sh diff --git a/config/wescale/test/vtgate.cnf b/config/wescale/test/vtgate.cnf new file mode 100644 index 0000000000..5a4d3c7ae2 --- /dev/null +++ b/config/wescale/test/vtgate.cnf @@ -0,0 +1,62 @@ +[vtgate] +v=100 +tablet_types_to_wait=PRIMARY +gateway_initial_tablet_timeout=3s +healthcheck_timeout=2s +srv_topo_timeout=1s +grpc_keepalive_time=10s +grpc_keepalive_timeout=10s +tablet_refresh_interval=1m +read_write_splitting_policy=disable +read_write_splitting_ratio=100 +read_after_write_consistency=SESSION +read_after_write_timeout=30.0 +enable_buffer=true +buffer_size=10000 +buffer_window=180s +buffer_max_failover_duration=360s +buffer_min_time_between_failovers=0s +mysql_auth_server_impl=none +mysql_auth_server_static_file= +mysql_server_require_secure_transport=false +ddl_strategy=direct +enable_display_sql_execution_vttablets=false +enable_read_write_split_for_read_only_txn=false +enable_interception_for_dml_without_where=true +mysql_server_ssl_ca= +mysql_server_ssl_cert= +mysql_server_ssl_key= + +enable_interception_for_dml_without_where=false + +# AutoScale & AutoSuspend Params +enable_auto_suspend=false +auto_suspend_timeout=5m + +enable_auto_scale=false +auto_scale_decision_making_interval=5s +auto_scale_compute_unit_lower_bound=0.5 +auto_scale_compute_unit_upper_bound=10 +auto_scale_cpu_ratio=0.9 +auto_scale_memory_ratio=0.75 +auto_scale_use_relaxed_cpu_memory_ratio=false + +auto_scale_cluster_namespace=default +auto_scale_data_node_pod_name=mycluster-wesql-0-0 +auto_scale_data_node_stateful_set_name=mycluster-wesql-0 +auto_scale_logger_node_pod_name=mycluster-wesql-1-0,mycluster-wesql-2-0 +auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 + +topo_implementation=etcd2 +topo_global_server_address=127.0.0.1:2379 +topo_global_root=/vitess/global +alsologtostderr=true +log_queries_to_file=vtdataroot/vtgate/vtgate_querylog.txt +port=15001 +grpc_port=15991 +mysql_server_port=15306 +mysql_server_socket_path=/tmp/mysql.sock +cell=zone1 +cells_to_watch=zone1 +service_map=grpc-vtgateservice +pid_file=vtdataroot/vtgate/vtgate.pid \ No newline at end of file diff --git a/config/wescale/test/vttablet.cnf b/config/wescale/test/vttablet.cnf new file mode 100644 index 0000000000..890ad9bd7d --- /dev/null +++ b/config/wescale/test/vttablet.cnf @@ -0,0 +1,58 @@ +[vttablet] +health_check_interval=1s +shard_sync_retry_delay=1s +remote_operation_timeout=1s +db_connect_timeout_ms=500 +table_acl_config_mode=simple +enable_logs=true +enable_query_log=true +table_acl_config= +queryserver_config_strict_table_acl=false +table_acl_config_reload_interval=5s +enforce_tableacl_config=false + +queryserver_config_transaction_cap=20 +queryserver_config_pool_size=16 +queryserver_config_stream_pool_size=4 +dba_pool_size=5 +queryserver_pool_autoscale_enable=true +queryserver_pool_autoscale_tx_pool_percentage=70 + +non_transactional_dml_database_pool_size=3 +non_transactional_dml_default_batch_size=2000 +non_transactional_dml_default_batch_interval=1 +non_transactional_dml_table_gc_interval=24 +non_transactional_dml_job_manager_running_interval=24 +non_transactional_dml_throttle_check_interval=250 +non_transactional_dml_batch_size_threshold=10000 +non_transactional_dml_batch_size_threshold_ratio=0.5 + + + +topo_implementation=etcd2 +topo_global_server_address=127.0.0.1:2379 +topo_global_root=/vitess/global +alsologtostderr=true +log_queries_to_file=vtdataroot/vttablet/vttablet_0000000000_querylog.txt +tablet-path=zone1-0000000000 +tablet_hostname=127.0.0.1 +init_tablet_type=replica +enable_replication_reporter=true +backup_storage_implementation=file +file_backup_storage_root=vtdataroot/vttablet/backups +port=15100 +db_port=3306 +db_host=127.0.0.1 +db_allprivs_user=root +db_allprivs_password=passwd +db_dba_user=root +db_dba_password=passwd +db_app_user=root +db_app_password=passwd +db_filtered_user=root +db_filtered_password=passwd +grpc_port=16100 +service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream +pid_file=vtdataroot/vttablet/vttablet.pid +vtctld_addr=http://127.0.0.1:15000/ +disable_active_reparents=true \ No newline at end of file diff --git a/examples/wesql-server/vtgate.sh b/examples/wesql-server/vtgate.sh index d01e449386..03e0c4cb0e 100755 --- a/examples/wesql-server/vtgate.sh +++ b/examples/wesql-server/vtgate.sh @@ -12,20 +12,51 @@ config_path=${CONFIG_PATH} topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} VTDATAROOT=$VTDATAROOT/vtgate -mkdir -p $VTDATAROOT +mkdir -p "$VTDATAROOT" +original_config="$config_path/vtgate.cnf" +temp_config="$config_path/vtgate.cnf.tmp" + +# 检查原始配置文件是否存在 +if [ ! -f "$original_config" ]; then + echo "配置文件 $original_config 不存在。请确保 CONFIG_PATH 设置正确并且配置文件存在。" + exit 1 +fi + +# 拷贝原始配置文件到临时文件 +cp "$original_config" "$temp_config" + +# 将 topology_flags 转换为 key=value 并追加到临时配置文件 +for flag in $topology_flags; do + # 去掉前缀 -- + key=${flag%%=*} + key=${key#--} + value=${flag#*=} + # 如果没有 '=', 则为布尔值 + if [ "$key" = "$flag" ]; then + value=true + fi + echo "$key=$value" >> "$temp_config" +done + +# 追加其他标志到临时配置文件 +cat <> "$temp_config" +alsologtostderr=true +log_dir=$VTDATAROOT +log_queries_to_file=$VTDATAROOT/vtgate_querylog.txt +port=$web_port +grpc_port=$grpc_port +mysql_server_port=$mysql_server_port +mysql_server_socket_path=$mysql_server_socket_path +cell=$cell +cells_to_watch=$cell +service_map=grpc-vtgateservice +pid_file=$VTDATAROOT/vtgate.pid +EOL + +# 替换原始配置文件 +mv "$temp_config" "$original_config" + +# 启动 vtgate,仅使用 --config_path 参数 vtgate \ - $topology_flags \ - --v 100 \ - --alsologtostderr \ - --log_dir $VTDATAROOT \ - --log_queries_to_file $VTDATAROOT/vtgate_querylog.txt \ - --port $web_port \ - --grpc_port $grpc_port \ - --mysql_server_port $mysql_server_port \ - --mysql_server_socket_path $mysql_server_socket_path \ - --cell $cell \ - --cells_to_watch $cell \ - --service_map 'grpc-vtgateservice' \ - --pid_file $VTDATAROOT/vtgate.pid \ - --config_path $config_path + --config_path "$config_path" diff --git a/examples/wesql-server/vtgate_using_flags.sh b/examples/wesql-server/vtgate_using_flags.sh new file mode 100644 index 0000000000..d01e449386 --- /dev/null +++ b/examples/wesql-server/vtgate_using_flags.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +echo "Starting vtgate..." + +cell=${CELL:-'zone1'} +web_port=${VTGATE_WEB_PORT:-'15001'} +grpc_port=${VTGATE_GRPC_PORT:-'15991'} +mysql_server_port=${VTGATE_MYSQL_PORT:-'15306'} +mysql_server_socket_path="/tmp/mysql.sock" +config_path=${CONFIG_PATH} + +topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} + +VTDATAROOT=$VTDATAROOT/vtgate +mkdir -p $VTDATAROOT + +vtgate \ + $topology_flags \ + --v 100 \ + --alsologtostderr \ + --log_dir $VTDATAROOT \ + --log_queries_to_file $VTDATAROOT/vtgate_querylog.txt \ + --port $web_port \ + --grpc_port $grpc_port \ + --mysql_server_port $mysql_server_port \ + --mysql_server_socket_path $mysql_server_socket_path \ + --cell $cell \ + --cells_to_watch $cell \ + --service_map 'grpc-vtgateservice' \ + --pid_file $VTDATAROOT/vtgate.pid \ + --config_path $config_path diff --git a/examples/wesql-server/vttablet.sh b/examples/wesql-server/vttablet.sh index 2ca3385a81..1cbbbc15fb 100755 --- a/examples/wesql-server/vttablet.sh +++ b/examples/wesql-server/vttablet.sh @@ -15,41 +15,73 @@ vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'} tablet_hostname='127.0.0.1' config_path=${CONFIG_PATH} -printf -v alias '%s-%010d' $cell $uid -printf -v tablet_dir 'vt_%010d' $uid -printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid +printf -v alias '%s-%010d' "$cell" "$uid" +printf -v tablet_dir 'vt_%010d' "$uid" +printf -v tablet_logfile 'vttablet_%010d_querylog.txt' "$uid" topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} VTDATAROOT=$VTDATAROOT/vttablet -mkdir -p $VTDATAROOT +mkdir -p "$VTDATAROOT" +# 定义配置文件路径 +original_config="$config_path/vttablet.cnf" +temp_config="$config_path/vttablet.cnf.tmp" + +# 检查原始配置文件是否存在 +if [ ! -f "$original_config" ]; then + echo "配置文件 $original_config 不存在。请确保 CONFIG_PATH 设置正确并且配置文件存在。" + exit 1 +fi + +# 拷贝原始配置文件到临时文件 +cp "$original_config" "$temp_config" + +# 将 topology_flags 转换为 key=value 并追加到临时配置文件 +for flag in $topology_flags; do + # 去掉前缀 -- + key=${flag%%=*} + key=${key#--} + value=${flag#*=} + # 如果没有 '=', 则为布尔值 + if [ "$key" = "$flag" ]; then + value=true + fi + echo "$key=$value" >> "$temp_config" +done + +# 追加其他标志到临时配置文件 +cat <> "$temp_config" +alsologtostderr=true +log_dir=$VTDATAROOT +log_queries_to_file=$VTDATAROOT/$tablet_logfile +tablet_path=$alias +tablet_hostname=$tablet_hostname +init_tablet_type=replica +enable_replication_reporter=true +backup_storage_implementation=file +file_backup_storage_root=$VTDATAROOT/backups +port=$port +db_port=$mysql_port +db_host=$mysql_host +db_allprivs_user=$mysql_root +db_allprivs_password=$mysql_root_passwd +db_dba_user=$mysql_root +db_dba_password=$mysql_root_passwd +db_app_user=$mysql_root +db_app_password=$mysql_root_passwd +db_filtered_user=$mysql_root +db_filtered_password=$mysql_root_passwd +grpc_port=$grpc_port +service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream +pid_file=$VTDATAROOT/vttablet.pid +vtctld_addr=http://$vtctld_host:$vtctld_web_port/ +disable_active_reparents=true +EOL + +# 替换原始配置文件 +mv "$temp_config" "$original_config" + +# 启动 vttablet,仅使用 --config_path 参数 vttablet \ - $topology_flags \ - --v 100 \ - --alsologtostderr \ - --log_dir $VTDATAROOT \ - --log_queries_to_file $VTDATAROOT/$tablet_logfile \ - --tablet-path $alias \ - --tablet_hostname "$tablet_hostname" \ - --init_tablet_type replica \ - --enable_replication_reporter \ - --backup_storage_implementation file \ - --file_backup_storage_root $VTDATAROOT/backups \ - --port $port \ - --db_port $mysql_port \ - --db_host $mysql_host \ - --db_allprivs_user $mysql_root \ - --db_allprivs_password $mysql_root_passwd \ - --db_dba_user $mysql_root \ - --db_dba_password $mysql_root_passwd \ - --db_app_user $mysql_root \ - --db_app_password $mysql_root_passwd \ - --db_filtered_user $mysql_root \ - --db_filtered_password $mysql_root_passwd \ - --grpc_port $grpc_port \ - --service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \ - --pid_file $VTDATAROOT/vttablet.pid \ - --vtctld_addr http://$vtctld_host:$vtctld_web_port/ \ - --disable_active_reparents \ - --config_path $config_path + --config_path "$config_path" diff --git a/examples/wesql-server/vttablet_using_flags.sh b/examples/wesql-server/vttablet_using_flags.sh new file mode 100644 index 0000000000..2ca3385a81 --- /dev/null +++ b/examples/wesql-server/vttablet_using_flags.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +echo "Starting vttablet..." + +cell=${CELL:-'zone1'} +uid="${VTTABLET_ID:-0}" +mysql_root=${MYSQL_ROOT_USER:-'root'} +mysql_root_passwd=${MYSQL_ROOT_PASSWORD:-'passwd'} +mysql_host=${MYSQL_HOST:-'127.0.0.1'} +mysql_port=${MYSQL_PORT:-'3306'} +port=${VTTABLET_PORT:-'15100'} +grpc_port=${VTTABLET_GRPC_PORT:-'16100'} +vtctld_host=${VTCTLD_HOST:-'127.0.0.1'} +vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'} +tablet_hostname='127.0.0.1' +config_path=${CONFIG_PATH} + +printf -v alias '%s-%010d' $cell $uid +printf -v tablet_dir 'vt_%010d' $uid +printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid + +topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} + +VTDATAROOT=$VTDATAROOT/vttablet +mkdir -p $VTDATAROOT + +vttablet \ + $topology_flags \ + --v 100 \ + --alsologtostderr \ + --log_dir $VTDATAROOT \ + --log_queries_to_file $VTDATAROOT/$tablet_logfile \ + --tablet-path $alias \ + --tablet_hostname "$tablet_hostname" \ + --init_tablet_type replica \ + --enable_replication_reporter \ + --backup_storage_implementation file \ + --file_backup_storage_root $VTDATAROOT/backups \ + --port $port \ + --db_port $mysql_port \ + --db_host $mysql_host \ + --db_allprivs_user $mysql_root \ + --db_allprivs_password $mysql_root_passwd \ + --db_dba_user $mysql_root \ + --db_dba_password $mysql_root_passwd \ + --db_app_user $mysql_root \ + --db_app_password $mysql_root_passwd \ + --db_filtered_user $mysql_root \ + --db_filtered_password $mysql_root_passwd \ + --grpc_port $grpc_port \ + --service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \ + --pid_file $VTDATAROOT/vttablet.pid \ + --vtctld_addr http://$vtctld_host:$vtctld_web_port/ \ + --disable_active_reparents \ + --config_path $config_path diff --git a/go/cmd/vtgate/vtgate.go b/go/cmd/vtgate/vtgate.go index 35f11536b3..0371a15e4e 100644 --- a/go/cmd/vtgate/vtgate.go +++ b/go/cmd/vtgate/vtgate.go @@ -138,8 +138,8 @@ func main() { defer exit.Recover() servenv.ParseFlags("vtgate") - servenv.Init() vtGateViperConfig.LoadAndWatchConfigFile() + servenv.Init() ts := topo.Open() defer ts.Close() diff --git a/go/cmd/vttablet/vttablet.go b/go/cmd/vttablet/vttablet.go index 85ce11673b..da95a269d8 100644 --- a/go/cmd/vttablet/vttablet.go +++ b/go/cmd/vttablet/vttablet.go @@ -97,8 +97,8 @@ func main() { mysqlctl.RegisterFlags() servenv.ParseFlags("vttablet") - servenv.Init() vtTabletViperConfig.LoadAndWatchConfigFile() + servenv.Init() if tableACLMode != global.TableACLModeSimple && tableACLMode != global.TableACLModeMysqlBased { log.Exit("require table-acl-config-mode") From b495560473187ad480fad7656617c9c61737dd93 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 19 Dec 2024 12:36:50 +0800 Subject: [PATCH 2/4] fix: fix start script --- config/wescale/bak/vtgate.cnf | 48 +++++++++++++++++++++++++++++ config/wescale/bak/vttablet.cnf | 28 +++++++++++++++++ config/wescale/default/vtgate.cnf | 16 +++++++++- config/wescale/default/vttablet.cnf | 31 ++++++++++++++++++- config/wescale/test/vttablet.cnf | 1 - examples/wesql-server/vtgate.sh | 45 ++++++++++++++++++--------- examples/wesql-server/vttablet.sh | 47 ++++++++++++++++++---------- 7 files changed, 182 insertions(+), 34 deletions(-) create mode 100644 config/wescale/bak/vtgate.cnf create mode 100644 config/wescale/bak/vttablet.cnf diff --git a/config/wescale/bak/vtgate.cnf b/config/wescale/bak/vtgate.cnf new file mode 100644 index 0000000000..f5d9bb85a3 --- /dev/null +++ b/config/wescale/bak/vtgate.cnf @@ -0,0 +1,48 @@ +[vtgate] +v=100 +tablet_types_to_wait=PRIMARY +gateway_initial_tablet_timeout=3s +healthcheck_timeout=2s +srv_topo_timeout=1s +grpc_keepalive_time=10s +grpc_keepalive_timeout=10s +tablet_refresh_interval=1m +read_write_splitting_policy=disable +read_write_splitting_ratio=100 +read_after_write_consistency=SESSION +read_after_write_timeout=30.0 +enable_buffer=true +buffer_size=10000 +buffer_window=180s +buffer_max_failover_duration=360s +buffer_min_time_between_failovers=0s +mysql_auth_server_impl=none +mysql_auth_server_static_file= +mysql_server_require_secure_transport=false +ddl_strategy=direct +enable_display_sql_execution_vttablets=false +enable_read_write_split_for_read_only_txn=false +enable_interception_for_dml_without_where=true +mysql_server_ssl_ca= +mysql_server_ssl_cert= +mysql_server_ssl_key= + +enable_interception_for_dml_without_where=false + +# AutoScale & AutoSuspend Params +enable_auto_suspend=false +auto_suspend_timeout=5m + +enable_auto_scale=false +auto_scale_decision_making_interval=5s +auto_scale_compute_unit_lower_bound=0.5 +auto_scale_compute_unit_upper_bound=10 +auto_scale_cpu_ratio=0.9 +auto_scale_memory_ratio=0.75 +auto_scale_use_relaxed_cpu_memory_ratio=false + +auto_scale_cluster_namespace=default +auto_scale_data_node_pod_name=mycluster-wesql-0-0 +auto_scale_data_node_stateful_set_name=mycluster-wesql-0 +auto_scale_logger_node_pod_name=mycluster-wesql-1-0,mycluster-wesql-2-0 +auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 \ No newline at end of file diff --git a/config/wescale/bak/vttablet.cnf b/config/wescale/bak/vttablet.cnf new file mode 100644 index 0000000000..a699013fac --- /dev/null +++ b/config/wescale/bak/vttablet.cnf @@ -0,0 +1,28 @@ +[vttablet] +health_check_interval=1s +shard_sync_retry_delay=1s +remote_operation_timeout=1s +db_connect_timeout_ms=500 +table_acl_config_mode=simple +enable_logs=true +enable_query_log=true +table_acl_config= +queryserver_config_strict_table_acl=false +table_acl_config_reload_interval=5s +enforce_tableacl_config=false + +queryserver_config_transaction_cap=20 +queryserver_config_pool_size=16 +queryserver_config_stream_pool_size=4 +dba_pool_size=5 +queryserver_pool_autoscale_enable=true +queryserver_pool_autoscale_tx_pool_percentage=70 + +non_transactional_dml_database_pool_size=3 +non_transactional_dml_default_batch_size=2000 +non_transactional_dml_default_batch_interval=1 +non_transactional_dml_table_gc_interval=24 +non_transactional_dml_job_manager_running_interval=24 +non_transactional_dml_throttle_check_interval=250 +non_transactional_dml_batch_size_threshold=10000 +non_transactional_dml_batch_size_threshold_ratio=0.5 \ No newline at end of file diff --git a/config/wescale/default/vtgate.cnf b/config/wescale/default/vtgate.cnf index f5d9bb85a3..fdd2e8d3c0 100644 --- a/config/wescale/default/vtgate.cnf +++ b/config/wescale/default/vtgate.cnf @@ -45,4 +45,18 @@ auto_scale_cluster_namespace=default auto_scale_data_node_pod_name=mycluster-wesql-0-0 auto_scale_data_node_stateful_set_name=mycluster-wesql-0 auto_scale_logger_node_pod_name=mycluster-wesql-1-0,mycluster-wesql-2-0 -auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 \ No newline at end of file +auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 + +topo_implementation=etcd2 +topo_global_server_address=127.0.0.1:2379 +topo_global_root=/vitess/global +alsologtostderr=true +log_queries_to_file=vtdataroot/vtgate/vtgate_querylog.txt +port=15001 +grpc_port=15991 +mysql_server_port=15306 +mysql_server_socket_path=/tmp/mysql.sock +cell=zone1 +cells_to_watch=zone1 +service_map=grpc-vtgateservice +pid_file=vtdataroot/vtgate/vtgate.pid diff --git a/config/wescale/default/vttablet.cnf b/config/wescale/default/vttablet.cnf index a699013fac..caae96c28e 100644 --- a/config/wescale/default/vttablet.cnf +++ b/config/wescale/default/vttablet.cnf @@ -25,4 +25,33 @@ non_transactional_dml_table_gc_interval=24 non_transactional_dml_job_manager_running_interval=24 non_transactional_dml_throttle_check_interval=250 non_transactional_dml_batch_size_threshold=10000 -non_transactional_dml_batch_size_threshold_ratio=0.5 \ No newline at end of file +non_transactional_dml_batch_size_threshold_ratio=0.5 + +topo_implementation=etcd2 +topo_global_server_address=127.0.0.1:2379 +topo_global_root=/vitess/global +alsologtostderr=true +log_dir=/vttablet +log_queries_to_file=vtdataroot/vttablet/vttablet_0000000000_querylog.txt +tablet-path=zone1-0000000000 +tablet_hostname=127.0.0.1 +init_tablet_type=replica +enable_replication_reporter=true +backup_storage_implementation=file +file_backup_storage_root=vtdataroot/vttablet/backups +port=15100 +db_port=3306 +db_host=127.0.0.1 +db_allprivs_user=root +db_allprivs_password=passwd +db_dba_user=root +db_dba_password=passwd +db_app_user=root +db_app_password=passwd +db_filtered_user=root +db_filtered_password=passwd +grpc_port=16100 +service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream +pid_file=vtdataroot/vttablet/vttablet.pid +vtctld_addr=http://127.0.0.1:15000/ +disable_active_reparents=true diff --git a/config/wescale/test/vttablet.cnf b/config/wescale/test/vttablet.cnf index 890ad9bd7d..2455012120 100644 --- a/config/wescale/test/vttablet.cnf +++ b/config/wescale/test/vttablet.cnf @@ -28,7 +28,6 @@ non_transactional_dml_batch_size_threshold=10000 non_transactional_dml_batch_size_threshold_ratio=0.5 - topo_implementation=etcd2 topo_global_server_address=127.0.0.1:2379 topo_global_root=/vitess/global diff --git a/examples/wesql-server/vtgate.sh b/examples/wesql-server/vtgate.sh index 03e0c4cb0e..b4d5ceff41 100755 --- a/examples/wesql-server/vtgate.sh +++ b/examples/wesql-server/vtgate.sh @@ -14,8 +14,8 @@ topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_serv VTDATAROOT=$VTDATAROOT/vtgate mkdir -p "$VTDATAROOT" -original_config="$config_path/vtgate.cnf" -temp_config="$config_path/vtgate.cnf.tmp" +original_config="$config_path/../bak/vtgate.cnf" +temp_config="$config_path/vtgate.cnf" # 检查原始配置文件是否存在 if [ ! -f "$original_config" ]; then @@ -26,17 +26,35 @@ fi # 拷贝原始配置文件到临时文件 cp "$original_config" "$temp_config" -# 将 topology_flags 转换为 key=value 并追加到临时配置文件 -for flag in $topology_flags; do - # 去掉前缀 -- - key=${flag%%=*} - key=${key#--} - value=${flag#*=} - # 如果没有 '=', 则为布尔值 - if [ "$key" = "$flag" ]; then - value=true +printf "\n\n" >> "$temp_config" + +# 解析 topology_flags 并转换为 key=value 形式追加到临时配置文件 +# 使用数组来正确处理带有空格的值 +IFS=' ' read -r -a flags_array <<< "$topology_flags" + +i=0 +while [ $i -lt ${#flags_array[@]} ]; do + flag="${flags_array[$i]}" + if [[ "$flag" == --* ]]; then + key="${flag#--}" + # 检查是否为 --key=value 形式 + if [[ "$key" == *"="* ]]; then + key="${key%%=*}" + value="${flag#*=}" + else + # 检查下一个参数是否存在且不是另一个 flag + next_index=$((i + 1)) + if [ $next_index -lt ${#flags_array[@]} ] && [[ "${flags_array[$next_index]}" != --* ]]; then + value="${flags_array[$next_index]}" + i=$next_index + else + # 布尔值标志 + value=true + fi + fi + echo "$key=$value" >> "$temp_config" fi - echo "$key=$value" >> "$temp_config" + i=$((i + 1)) done # 追加其他标志到临时配置文件 @@ -54,9 +72,6 @@ service_map=grpc-vtgateservice pid_file=$VTDATAROOT/vtgate.pid EOL -# 替换原始配置文件 -mv "$temp_config" "$original_config" - # 启动 vtgate,仅使用 --config_path 参数 vtgate \ --config_path "$config_path" diff --git a/examples/wesql-server/vttablet.sh b/examples/wesql-server/vttablet.sh index 1cbbbc15fb..deb55022c2 100755 --- a/examples/wesql-server/vttablet.sh +++ b/examples/wesql-server/vttablet.sh @@ -25,8 +25,8 @@ VTDATAROOT=$VTDATAROOT/vttablet mkdir -p "$VTDATAROOT" # 定义配置文件路径 -original_config="$config_path/vttablet.cnf" -temp_config="$config_path/vttablet.cnf.tmp" +original_config="$config_path/../bak/vttablet.cnf" +temp_config="$config_path/vttablet.cnf" # 检查原始配置文件是否存在 if [ ! -f "$original_config" ]; then @@ -37,17 +37,35 @@ fi # 拷贝原始配置文件到临时文件 cp "$original_config" "$temp_config" -# 将 topology_flags 转换为 key=value 并追加到临时配置文件 -for flag in $topology_flags; do - # 去掉前缀 -- - key=${flag%%=*} - key=${key#--} - value=${flag#*=} - # 如果没有 '=', 则为布尔值 - if [ "$key" = "$flag" ]; then - value=true +printf "\n\n" >> "$temp_config" + +# 解析 topology_flags 并转换为 key=value 形式追加到临时配置文件 +# 使用数组来正确处理带有空格的值 +IFS=' ' read -r -a flags_array <<< "$topology_flags" + +i=0 +while [ $i -lt ${#flags_array[@]} ]; do + flag="${flags_array[$i]}" + if [[ "$flag" == --* ]]; then + key="${flag#--}" + # 检查是否为 --key=value 形式 + if [[ "$key" == *"="* ]]; then + key="${key%%=*}" + value="${flag#*=}" + else + # 检查下一个参数是否存在且不是另一个 flag + next_index=$((i + 1)) + if [ $next_index -lt ${#flags_array[@]} ] && [[ "${flags_array[$next_index]}" != --* ]]; then + value="${flags_array[$next_index]}" + i=$next_index + else + # 布尔值标志 + value=true + fi + fi + echo "$key=$value" >> "$temp_config" fi - echo "$key=$value" >> "$temp_config" + i=$((i + 1)) done # 追加其他标志到临时配置文件 @@ -55,7 +73,7 @@ cat <> "$temp_config" alsologtostderr=true log_dir=$VTDATAROOT log_queries_to_file=$VTDATAROOT/$tablet_logfile -tablet_path=$alias +tablet-path=$alias tablet_hostname=$tablet_hostname init_tablet_type=replica enable_replication_reporter=true @@ -79,9 +97,6 @@ vtctld_addr=http://$vtctld_host:$vtctld_web_port/ disable_active_reparents=true EOL -# 替换原始配置文件 -mv "$temp_config" "$original_config" - # 启动 vttablet,仅使用 --config_path 参数 vttablet \ --config_path "$config_path" From 8aa6d59034706dfbc34dac5ccdfa4abfb5d43628 Mon Sep 17 00:00:00 2001 From: newborn22 <953950914@qq.com> Date: Thu, 19 Dec 2024 13:18:21 +0800 Subject: [PATCH 3/4] fix: remove log dir --- config/wescale/test/vtgate.cnf | 62 ------------------------------- config/wescale/test/vttablet.cnf | 57 ---------------------------- examples/wesql-server/vtgate.sh | 1 - examples/wesql-server/vttablet.sh | 1 - 4 files changed, 121 deletions(-) delete mode 100644 config/wescale/test/vtgate.cnf delete mode 100644 config/wescale/test/vttablet.cnf diff --git a/config/wescale/test/vtgate.cnf b/config/wescale/test/vtgate.cnf deleted file mode 100644 index 5a4d3c7ae2..0000000000 --- a/config/wescale/test/vtgate.cnf +++ /dev/null @@ -1,62 +0,0 @@ -[vtgate] -v=100 -tablet_types_to_wait=PRIMARY -gateway_initial_tablet_timeout=3s -healthcheck_timeout=2s -srv_topo_timeout=1s -grpc_keepalive_time=10s -grpc_keepalive_timeout=10s -tablet_refresh_interval=1m -read_write_splitting_policy=disable -read_write_splitting_ratio=100 -read_after_write_consistency=SESSION -read_after_write_timeout=30.0 -enable_buffer=true -buffer_size=10000 -buffer_window=180s -buffer_max_failover_duration=360s -buffer_min_time_between_failovers=0s -mysql_auth_server_impl=none -mysql_auth_server_static_file= -mysql_server_require_secure_transport=false -ddl_strategy=direct -enable_display_sql_execution_vttablets=false -enable_read_write_split_for_read_only_txn=false -enable_interception_for_dml_without_where=true -mysql_server_ssl_ca= -mysql_server_ssl_cert= -mysql_server_ssl_key= - -enable_interception_for_dml_without_where=false - -# AutoScale & AutoSuspend Params -enable_auto_suspend=false -auto_suspend_timeout=5m - -enable_auto_scale=false -auto_scale_decision_making_interval=5s -auto_scale_compute_unit_lower_bound=0.5 -auto_scale_compute_unit_upper_bound=10 -auto_scale_cpu_ratio=0.9 -auto_scale_memory_ratio=0.75 -auto_scale_use_relaxed_cpu_memory_ratio=false - -auto_scale_cluster_namespace=default -auto_scale_data_node_pod_name=mycluster-wesql-0-0 -auto_scale_data_node_stateful_set_name=mycluster-wesql-0 -auto_scale_logger_node_pod_name=mycluster-wesql-1-0,mycluster-wesql-2-0 -auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 - -topo_implementation=etcd2 -topo_global_server_address=127.0.0.1:2379 -topo_global_root=/vitess/global -alsologtostderr=true -log_queries_to_file=vtdataroot/vtgate/vtgate_querylog.txt -port=15001 -grpc_port=15991 -mysql_server_port=15306 -mysql_server_socket_path=/tmp/mysql.sock -cell=zone1 -cells_to_watch=zone1 -service_map=grpc-vtgateservice -pid_file=vtdataroot/vtgate/vtgate.pid \ No newline at end of file diff --git a/config/wescale/test/vttablet.cnf b/config/wescale/test/vttablet.cnf deleted file mode 100644 index 2455012120..0000000000 --- a/config/wescale/test/vttablet.cnf +++ /dev/null @@ -1,57 +0,0 @@ -[vttablet] -health_check_interval=1s -shard_sync_retry_delay=1s -remote_operation_timeout=1s -db_connect_timeout_ms=500 -table_acl_config_mode=simple -enable_logs=true -enable_query_log=true -table_acl_config= -queryserver_config_strict_table_acl=false -table_acl_config_reload_interval=5s -enforce_tableacl_config=false - -queryserver_config_transaction_cap=20 -queryserver_config_pool_size=16 -queryserver_config_stream_pool_size=4 -dba_pool_size=5 -queryserver_pool_autoscale_enable=true -queryserver_pool_autoscale_tx_pool_percentage=70 - -non_transactional_dml_database_pool_size=3 -non_transactional_dml_default_batch_size=2000 -non_transactional_dml_default_batch_interval=1 -non_transactional_dml_table_gc_interval=24 -non_transactional_dml_job_manager_running_interval=24 -non_transactional_dml_throttle_check_interval=250 -non_transactional_dml_batch_size_threshold=10000 -non_transactional_dml_batch_size_threshold_ratio=0.5 - - -topo_implementation=etcd2 -topo_global_server_address=127.0.0.1:2379 -topo_global_root=/vitess/global -alsologtostderr=true -log_queries_to_file=vtdataroot/vttablet/vttablet_0000000000_querylog.txt -tablet-path=zone1-0000000000 -tablet_hostname=127.0.0.1 -init_tablet_type=replica -enable_replication_reporter=true -backup_storage_implementation=file -file_backup_storage_root=vtdataroot/vttablet/backups -port=15100 -db_port=3306 -db_host=127.0.0.1 -db_allprivs_user=root -db_allprivs_password=passwd -db_dba_user=root -db_dba_password=passwd -db_app_user=root -db_app_password=passwd -db_filtered_user=root -db_filtered_password=passwd -grpc_port=16100 -service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream -pid_file=vtdataroot/vttablet/vttablet.pid -vtctld_addr=http://127.0.0.1:15000/ -disable_active_reparents=true \ No newline at end of file diff --git a/examples/wesql-server/vtgate.sh b/examples/wesql-server/vtgate.sh index b4d5ceff41..5714cf0e53 100755 --- a/examples/wesql-server/vtgate.sh +++ b/examples/wesql-server/vtgate.sh @@ -60,7 +60,6 @@ done # 追加其他标志到临时配置文件 cat <> "$temp_config" alsologtostderr=true -log_dir=$VTDATAROOT log_queries_to_file=$VTDATAROOT/vtgate_querylog.txt port=$web_port grpc_port=$grpc_port diff --git a/examples/wesql-server/vttablet.sh b/examples/wesql-server/vttablet.sh index deb55022c2..afa94c7238 100755 --- a/examples/wesql-server/vttablet.sh +++ b/examples/wesql-server/vttablet.sh @@ -71,7 +71,6 @@ done # 追加其他标志到临时配置文件 cat <> "$temp_config" alsologtostderr=true -log_dir=$VTDATAROOT log_queries_to_file=$VTDATAROOT/$tablet_logfile tablet-path=$alias tablet_hostname=$tablet_hostname From 240cfd959d77818935eb995bef016e93e366b803 Mon Sep 17 00:00:00 2001 From: earayu Date: Thu, 19 Dec 2024 17:49:50 +0800 Subject: [PATCH 4/4] fix: fix start script --- config/wescale/bak/vtgate.cnf | 48 -------- config/wescale/bak/vttablet.cnf | 28 ----- config/wescale/default/vtgate.cnf | 16 +-- config/wescale/default/vttablet.cnf | 31 +---- examples/wesql-server/vtgate.sh | 75 +++--------- examples/wesql-server/vtgate_using_flags.sh | 31 ----- examples/wesql-server/vttablet.sh | 110 +++++------------- examples/wesql-server/vttablet_using_flags.sh | 55 --------- 8 files changed, 49 insertions(+), 345 deletions(-) delete mode 100644 config/wescale/bak/vtgate.cnf delete mode 100644 config/wescale/bak/vttablet.cnf delete mode 100644 examples/wesql-server/vtgate_using_flags.sh delete mode 100644 examples/wesql-server/vttablet_using_flags.sh diff --git a/config/wescale/bak/vtgate.cnf b/config/wescale/bak/vtgate.cnf deleted file mode 100644 index f5d9bb85a3..0000000000 --- a/config/wescale/bak/vtgate.cnf +++ /dev/null @@ -1,48 +0,0 @@ -[vtgate] -v=100 -tablet_types_to_wait=PRIMARY -gateway_initial_tablet_timeout=3s -healthcheck_timeout=2s -srv_topo_timeout=1s -grpc_keepalive_time=10s -grpc_keepalive_timeout=10s -tablet_refresh_interval=1m -read_write_splitting_policy=disable -read_write_splitting_ratio=100 -read_after_write_consistency=SESSION -read_after_write_timeout=30.0 -enable_buffer=true -buffer_size=10000 -buffer_window=180s -buffer_max_failover_duration=360s -buffer_min_time_between_failovers=0s -mysql_auth_server_impl=none -mysql_auth_server_static_file= -mysql_server_require_secure_transport=false -ddl_strategy=direct -enable_display_sql_execution_vttablets=false -enable_read_write_split_for_read_only_txn=false -enable_interception_for_dml_without_where=true -mysql_server_ssl_ca= -mysql_server_ssl_cert= -mysql_server_ssl_key= - -enable_interception_for_dml_without_where=false - -# AutoScale & AutoSuspend Params -enable_auto_suspend=false -auto_suspend_timeout=5m - -enable_auto_scale=false -auto_scale_decision_making_interval=5s -auto_scale_compute_unit_lower_bound=0.5 -auto_scale_compute_unit_upper_bound=10 -auto_scale_cpu_ratio=0.9 -auto_scale_memory_ratio=0.75 -auto_scale_use_relaxed_cpu_memory_ratio=false - -auto_scale_cluster_namespace=default -auto_scale_data_node_pod_name=mycluster-wesql-0-0 -auto_scale_data_node_stateful_set_name=mycluster-wesql-0 -auto_scale_logger_node_pod_name=mycluster-wesql-1-0,mycluster-wesql-2-0 -auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 \ No newline at end of file diff --git a/config/wescale/bak/vttablet.cnf b/config/wescale/bak/vttablet.cnf deleted file mode 100644 index a699013fac..0000000000 --- a/config/wescale/bak/vttablet.cnf +++ /dev/null @@ -1,28 +0,0 @@ -[vttablet] -health_check_interval=1s -shard_sync_retry_delay=1s -remote_operation_timeout=1s -db_connect_timeout_ms=500 -table_acl_config_mode=simple -enable_logs=true -enable_query_log=true -table_acl_config= -queryserver_config_strict_table_acl=false -table_acl_config_reload_interval=5s -enforce_tableacl_config=false - -queryserver_config_transaction_cap=20 -queryserver_config_pool_size=16 -queryserver_config_stream_pool_size=4 -dba_pool_size=5 -queryserver_pool_autoscale_enable=true -queryserver_pool_autoscale_tx_pool_percentage=70 - -non_transactional_dml_database_pool_size=3 -non_transactional_dml_default_batch_size=2000 -non_transactional_dml_default_batch_interval=1 -non_transactional_dml_table_gc_interval=24 -non_transactional_dml_job_manager_running_interval=24 -non_transactional_dml_throttle_check_interval=250 -non_transactional_dml_batch_size_threshold=10000 -non_transactional_dml_batch_size_threshold_ratio=0.5 \ No newline at end of file diff --git a/config/wescale/default/vtgate.cnf b/config/wescale/default/vtgate.cnf index fdd2e8d3c0..f5d9bb85a3 100644 --- a/config/wescale/default/vtgate.cnf +++ b/config/wescale/default/vtgate.cnf @@ -45,18 +45,4 @@ auto_scale_cluster_namespace=default auto_scale_data_node_pod_name=mycluster-wesql-0-0 auto_scale_data_node_stateful_set_name=mycluster-wesql-0 auto_scale_logger_node_pod_name=mycluster-wesql-1-0,mycluster-wesql-2-0 -auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 - -topo_implementation=etcd2 -topo_global_server_address=127.0.0.1:2379 -topo_global_root=/vitess/global -alsologtostderr=true -log_queries_to_file=vtdataroot/vtgate/vtgate_querylog.txt -port=15001 -grpc_port=15991 -mysql_server_port=15306 -mysql_server_socket_path=/tmp/mysql.sock -cell=zone1 -cells_to_watch=zone1 -service_map=grpc-vtgateservice -pid_file=vtdataroot/vtgate/vtgate.pid +auto_scale_logger_node_stateful_set_name=mycluster-wesql-1,mycluster-wesql-2 \ No newline at end of file diff --git a/config/wescale/default/vttablet.cnf b/config/wescale/default/vttablet.cnf index caae96c28e..a699013fac 100644 --- a/config/wescale/default/vttablet.cnf +++ b/config/wescale/default/vttablet.cnf @@ -25,33 +25,4 @@ non_transactional_dml_table_gc_interval=24 non_transactional_dml_job_manager_running_interval=24 non_transactional_dml_throttle_check_interval=250 non_transactional_dml_batch_size_threshold=10000 -non_transactional_dml_batch_size_threshold_ratio=0.5 - -topo_implementation=etcd2 -topo_global_server_address=127.0.0.1:2379 -topo_global_root=/vitess/global -alsologtostderr=true -log_dir=/vttablet -log_queries_to_file=vtdataroot/vttablet/vttablet_0000000000_querylog.txt -tablet-path=zone1-0000000000 -tablet_hostname=127.0.0.1 -init_tablet_type=replica -enable_replication_reporter=true -backup_storage_implementation=file -file_backup_storage_root=vtdataroot/vttablet/backups -port=15100 -db_port=3306 -db_host=127.0.0.1 -db_allprivs_user=root -db_allprivs_password=passwd -db_dba_user=root -db_dba_password=passwd -db_app_user=root -db_app_password=passwd -db_filtered_user=root -db_filtered_password=passwd -grpc_port=16100 -service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream -pid_file=vtdataroot/vttablet/vttablet.pid -vtctld_addr=http://127.0.0.1:15000/ -disable_active_reparents=true +non_transactional_dml_batch_size_threshold_ratio=0.5 \ No newline at end of file diff --git a/examples/wesql-server/vtgate.sh b/examples/wesql-server/vtgate.sh index 5714cf0e53..d01e449386 100755 --- a/examples/wesql-server/vtgate.sh +++ b/examples/wesql-server/vtgate.sh @@ -12,65 +12,20 @@ config_path=${CONFIG_PATH} topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} VTDATAROOT=$VTDATAROOT/vtgate -mkdir -p "$VTDATAROOT" +mkdir -p $VTDATAROOT -original_config="$config_path/../bak/vtgate.cnf" -temp_config="$config_path/vtgate.cnf" - -# 检查原始配置文件是否存在 -if [ ! -f "$original_config" ]; then - echo "配置文件 $original_config 不存在。请确保 CONFIG_PATH 设置正确并且配置文件存在。" - exit 1 -fi - -# 拷贝原始配置文件到临时文件 -cp "$original_config" "$temp_config" - -printf "\n\n" >> "$temp_config" - -# 解析 topology_flags 并转换为 key=value 形式追加到临时配置文件 -# 使用数组来正确处理带有空格的值 -IFS=' ' read -r -a flags_array <<< "$topology_flags" - -i=0 -while [ $i -lt ${#flags_array[@]} ]; do - flag="${flags_array[$i]}" - if [[ "$flag" == --* ]]; then - key="${flag#--}" - # 检查是否为 --key=value 形式 - if [[ "$key" == *"="* ]]; then - key="${key%%=*}" - value="${flag#*=}" - else - # 检查下一个参数是否存在且不是另一个 flag - next_index=$((i + 1)) - if [ $next_index -lt ${#flags_array[@]} ] && [[ "${flags_array[$next_index]}" != --* ]]; then - value="${flags_array[$next_index]}" - i=$next_index - else - # 布尔值标志 - value=true - fi - fi - echo "$key=$value" >> "$temp_config" - fi - i=$((i + 1)) -done - -# 追加其他标志到临时配置文件 -cat <> "$temp_config" -alsologtostderr=true -log_queries_to_file=$VTDATAROOT/vtgate_querylog.txt -port=$web_port -grpc_port=$grpc_port -mysql_server_port=$mysql_server_port -mysql_server_socket_path=$mysql_server_socket_path -cell=$cell -cells_to_watch=$cell -service_map=grpc-vtgateservice -pid_file=$VTDATAROOT/vtgate.pid -EOL - -# 启动 vtgate,仅使用 --config_path 参数 vtgate \ - --config_path "$config_path" + $topology_flags \ + --v 100 \ + --alsologtostderr \ + --log_dir $VTDATAROOT \ + --log_queries_to_file $VTDATAROOT/vtgate_querylog.txt \ + --port $web_port \ + --grpc_port $grpc_port \ + --mysql_server_port $mysql_server_port \ + --mysql_server_socket_path $mysql_server_socket_path \ + --cell $cell \ + --cells_to_watch $cell \ + --service_map 'grpc-vtgateservice' \ + --pid_file $VTDATAROOT/vtgate.pid \ + --config_path $config_path diff --git a/examples/wesql-server/vtgate_using_flags.sh b/examples/wesql-server/vtgate_using_flags.sh deleted file mode 100644 index d01e449386..0000000000 --- a/examples/wesql-server/vtgate_using_flags.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -echo "Starting vtgate..." - -cell=${CELL:-'zone1'} -web_port=${VTGATE_WEB_PORT:-'15001'} -grpc_port=${VTGATE_GRPC_PORT:-'15991'} -mysql_server_port=${VTGATE_MYSQL_PORT:-'15306'} -mysql_server_socket_path="/tmp/mysql.sock" -config_path=${CONFIG_PATH} - -topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} - -VTDATAROOT=$VTDATAROOT/vtgate -mkdir -p $VTDATAROOT - -vtgate \ - $topology_flags \ - --v 100 \ - --alsologtostderr \ - --log_dir $VTDATAROOT \ - --log_queries_to_file $VTDATAROOT/vtgate_querylog.txt \ - --port $web_port \ - --grpc_port $grpc_port \ - --mysql_server_port $mysql_server_port \ - --mysql_server_socket_path $mysql_server_socket_path \ - --cell $cell \ - --cells_to_watch $cell \ - --service_map 'grpc-vtgateservice' \ - --pid_file $VTDATAROOT/vtgate.pid \ - --config_path $config_path diff --git a/examples/wesql-server/vttablet.sh b/examples/wesql-server/vttablet.sh index afa94c7238..2ca3385a81 100755 --- a/examples/wesql-server/vttablet.sh +++ b/examples/wesql-server/vttablet.sh @@ -15,87 +15,41 @@ vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'} tablet_hostname='127.0.0.1' config_path=${CONFIG_PATH} -printf -v alias '%s-%010d' "$cell" "$uid" -printf -v tablet_dir 'vt_%010d' "$uid" -printf -v tablet_logfile 'vttablet_%010d_querylog.txt' "$uid" +printf -v alias '%s-%010d' $cell $uid +printf -v tablet_dir 'vt_%010d' $uid +printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} VTDATAROOT=$VTDATAROOT/vttablet -mkdir -p "$VTDATAROOT" +mkdir -p $VTDATAROOT -# 定义配置文件路径 -original_config="$config_path/../bak/vttablet.cnf" -temp_config="$config_path/vttablet.cnf" - -# 检查原始配置文件是否存在 -if [ ! -f "$original_config" ]; then - echo "配置文件 $original_config 不存在。请确保 CONFIG_PATH 设置正确并且配置文件存在。" - exit 1 -fi - -# 拷贝原始配置文件到临时文件 -cp "$original_config" "$temp_config" - -printf "\n\n" >> "$temp_config" - -# 解析 topology_flags 并转换为 key=value 形式追加到临时配置文件 -# 使用数组来正确处理带有空格的值 -IFS=' ' read -r -a flags_array <<< "$topology_flags" - -i=0 -while [ $i -lt ${#flags_array[@]} ]; do - flag="${flags_array[$i]}" - if [[ "$flag" == --* ]]; then - key="${flag#--}" - # 检查是否为 --key=value 形式 - if [[ "$key" == *"="* ]]; then - key="${key%%=*}" - value="${flag#*=}" - else - # 检查下一个参数是否存在且不是另一个 flag - next_index=$((i + 1)) - if [ $next_index -lt ${#flags_array[@]} ] && [[ "${flags_array[$next_index]}" != --* ]]; then - value="${flags_array[$next_index]}" - i=$next_index - else - # 布尔值标志 - value=true - fi - fi - echo "$key=$value" >> "$temp_config" - fi - i=$((i + 1)) -done - -# 追加其他标志到临时配置文件 -cat <> "$temp_config" -alsologtostderr=true -log_queries_to_file=$VTDATAROOT/$tablet_logfile -tablet-path=$alias -tablet_hostname=$tablet_hostname -init_tablet_type=replica -enable_replication_reporter=true -backup_storage_implementation=file -file_backup_storage_root=$VTDATAROOT/backups -port=$port -db_port=$mysql_port -db_host=$mysql_host -db_allprivs_user=$mysql_root -db_allprivs_password=$mysql_root_passwd -db_dba_user=$mysql_root -db_dba_password=$mysql_root_passwd -db_app_user=$mysql_root -db_app_password=$mysql_root_passwd -db_filtered_user=$mysql_root -db_filtered_password=$mysql_root_passwd -grpc_port=$grpc_port -service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream -pid_file=$VTDATAROOT/vttablet.pid -vtctld_addr=http://$vtctld_host:$vtctld_web_port/ -disable_active_reparents=true -EOL - -# 启动 vttablet,仅使用 --config_path 参数 vttablet \ - --config_path "$config_path" + $topology_flags \ + --v 100 \ + --alsologtostderr \ + --log_dir $VTDATAROOT \ + --log_queries_to_file $VTDATAROOT/$tablet_logfile \ + --tablet-path $alias \ + --tablet_hostname "$tablet_hostname" \ + --init_tablet_type replica \ + --enable_replication_reporter \ + --backup_storage_implementation file \ + --file_backup_storage_root $VTDATAROOT/backups \ + --port $port \ + --db_port $mysql_port \ + --db_host $mysql_host \ + --db_allprivs_user $mysql_root \ + --db_allprivs_password $mysql_root_passwd \ + --db_dba_user $mysql_root \ + --db_dba_password $mysql_root_passwd \ + --db_app_user $mysql_root \ + --db_app_password $mysql_root_passwd \ + --db_filtered_user $mysql_root \ + --db_filtered_password $mysql_root_passwd \ + --grpc_port $grpc_port \ + --service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \ + --pid_file $VTDATAROOT/vttablet.pid \ + --vtctld_addr http://$vtctld_host:$vtctld_web_port/ \ + --disable_active_reparents \ + --config_path $config_path diff --git a/examples/wesql-server/vttablet_using_flags.sh b/examples/wesql-server/vttablet_using_flags.sh deleted file mode 100644 index 2ca3385a81..0000000000 --- a/examples/wesql-server/vttablet_using_flags.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -echo "Starting vttablet..." - -cell=${CELL:-'zone1'} -uid="${VTTABLET_ID:-0}" -mysql_root=${MYSQL_ROOT_USER:-'root'} -mysql_root_passwd=${MYSQL_ROOT_PASSWORD:-'passwd'} -mysql_host=${MYSQL_HOST:-'127.0.0.1'} -mysql_port=${MYSQL_PORT:-'3306'} -port=${VTTABLET_PORT:-'15100'} -grpc_port=${VTTABLET_GRPC_PORT:-'16100'} -vtctld_host=${VTCTLD_HOST:-'127.0.0.1'} -vtctld_web_port=${VTCTLD_WEB_PORT:-'15000'} -tablet_hostname='127.0.0.1' -config_path=${CONFIG_PATH} - -printf -v alias '%s-%010d' $cell $uid -printf -v tablet_dir 'vt_%010d' $uid -printf -v tablet_logfile 'vttablet_%010d_querylog.txt' $uid - -topology_flags=${TOPOLOGY_FLAGS:-'--topo_implementation etcd2 --topo_global_server_address 127.0.0.1:2379 --topo_global_root /vitess/global'} - -VTDATAROOT=$VTDATAROOT/vttablet -mkdir -p $VTDATAROOT - -vttablet \ - $topology_flags \ - --v 100 \ - --alsologtostderr \ - --log_dir $VTDATAROOT \ - --log_queries_to_file $VTDATAROOT/$tablet_logfile \ - --tablet-path $alias \ - --tablet_hostname "$tablet_hostname" \ - --init_tablet_type replica \ - --enable_replication_reporter \ - --backup_storage_implementation file \ - --file_backup_storage_root $VTDATAROOT/backups \ - --port $port \ - --db_port $mysql_port \ - --db_host $mysql_host \ - --db_allprivs_user $mysql_root \ - --db_allprivs_password $mysql_root_passwd \ - --db_dba_user $mysql_root \ - --db_dba_password $mysql_root_passwd \ - --db_app_user $mysql_root \ - --db_app_password $mysql_root_passwd \ - --db_filtered_user $mysql_root \ - --db_filtered_password $mysql_root_passwd \ - --grpc_port $grpc_port \ - --service_map 'grpc-queryservice,grpc-tabletmanager,grpc-updatestream' \ - --pid_file $VTDATAROOT/vttablet.pid \ - --vtctld_addr http://$vtctld_host:$vtctld_web_port/ \ - --disable_active_reparents \ - --config_path $config_path