diff --git a/Set-GOFLAG-to-go-mod-vendor.patch b/Set-GOFLAG-to-go-mod-vendor.patch new file mode 100644 index 0000000000000000000000000000000000000000..584472a105ba060823fb4ab1423fca75a006d43a --- /dev/null +++ b/Set-GOFLAG-to-go-mod-vendor.patch @@ -0,0 +1,25 @@ +From 5abee7da185f4887d1596e216acce03929a42d1a Mon Sep 17 00:00:00 2001 +From: hht8 +Date: Fri, 20 Aug 2021 15:11:08 +0800 +Subject: [PATCH] 2 + +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index fc29d92..c36dc47 100644 +--- a/Makefile ++++ b/Makefile +@@ -26,7 +26,7 @@ path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH))):$(PWD)/tools/bin + export PATH := $(path_to_add):$(PATH) + + GO := GO111MODULE=on go +-GOBUILD := $(GO) build $(BUILD_FLAG) -tags codes ++GOBUILD := $(GO) build $(BUILD_FLAG) --mod=vendor -tags codes + GOBUILDCOVERAGE := GOPATH=$(GOPATH) cd tidb-server; $(GO) test -coverpkg="../..." -c . + GOTEST := $(GO) test -p $(P) + OVERALLS := GO111MODULE=on overalls +-- +2.30.0 + diff --git a/tidb-server.service b/tidb-server.service new file mode 100644 index 0000000000000000000000000000000000000000..e6773fa8496660d703953001896162889c257bc7 --- /dev/null +++ b/tidb-server.service @@ -0,0 +1,17 @@ +[Unit] +Description=TiDB is a distributed NewSQL database compatible with MySQL protocol +After=network-online.target +Wants=network-online.target + +[Service] +User=mysql +Group=mysql +EnvironmentFile=-/etc/sysconfig/tidb-server +ExecStart=/usr/bin/tidb-server \$OPTIONS +ExecReload=/bin/kill -HUP \$MAINPID +KillSignal=SIGINT +Restart=on-failure +LimitNOFILE=65536 + +[Install] +WantedBy=multi-user.target diff --git a/tidb-server.toml b/tidb-server.toml new file mode 100644 index 0000000000000000000000000000000000000000..2367009f306602fa99f0371ef91f99a7151de9f1 --- /dev/null +++ b/tidb-server.toml @@ -0,0 +1,302 @@ +# TiDB Configuration. + +# TiDB server host. +host = "0.0.0.0" + +# tidb server advertise IP. +advertise-address = "" + +# TiDB server port. +port = 4000 + +# Registered store name, [tikv, mocktikv] +store = "tikv" + +# TiDB storage path. +path = "127.0.0.1:2379" + +# The socket file to use for connection. +socket = "/var/lib/mysql/mysql.sock" + +# Run ddl worker on this tidb-server. +run-ddl = true + +# Schema lease duration, very dangerous to change only if you know what you do. +lease = "45s" + +# When create table, split a separated region for it. It is recommended to +# turn off this option if there will be a large number of tables created. +split-table = true + +# The limit of concurrent executed sessions. +token-limit = 1000 + +# Only print a log when out of memory quota. +# Valid options: ["log", "cancel"] +oom-action = "log" + +# Set the memory quota for a query in bytes. Default: 32GB +mem-quota-query = 34359738368 + +# Enable coprocessor streaming. +enable-streaming = false + +# Set system variable 'lower_case_table_names' +lower-case-table-names = 2 + +# Make "kill query" behavior compatible with MySQL. It's not recommend to +# turn on this option when TiDB server is behind a proxy. +compatible-kill-query = false + +# check mb4 value in utf8 is used to control whether to check the mb4 characters when the charset is utf8. +check-mb4-value-in-utf8 = true + +# treat-old-version-utf8-as-utf8mb4 use for upgrade compatibility. Set to true will treat old version table/column UTF8 charset as UTF8MB4. +treat-old-version-utf8-as-utf8mb4 = true + +[log] +# Log level: debug, info, warn, error, fatal. +level = "info" + +# Log format, one of json, text, console. +format = "text" + +# Disable automatic timestamp in output +disable-timestamp = false + +# Stores slow query log into separated files. +slow-query-file = "/var/log/tidb/tidb-slow.log" + +# Queries with execution time greater than this value will be logged. (Milliseconds) +slow-threshold = 300 + +# Queries with internal result greater than this value will be logged. +expensive-threshold = 10000 + +# Maximum query length recorded in log. +query-log-max-len = 2048 + +# File logging. +[log.file] +# Log file name. +filename = "/var/log/tidb/tidb.log" + +# Max log file size in MB (upper limit to 4096MB). +max-size = 300 + +# Max log file keep days. No clean up by default. +max-days = 0 + +# Maximum number of old log files to retain. No clean up by default. +max-backups = 0 + +# Rotate log by day +log-rotate = true + +[security] +# Path of file that contains list of trusted SSL CAs for connection with mysql client. +ssl-ca = "" + +# Path of file that contains X509 certificate in PEM format for connection with mysql client. +ssl-cert = "" + +# Path of file that contains X509 key in PEM format for connection with mysql client. +ssl-key = "" + +# Path of file that contains list of trusted SSL CAs for connection with cluster components. +cluster-ssl-ca = "" + +# Path of file that contains X509 certificate in PEM format for connection with cluster components. +cluster-ssl-cert = "" + +# Path of file that contains X509 key in PEM format for connection with cluster components. +cluster-ssl-key = "" + +[status] +# If enable status report HTTP service. +report-status = true + +# TiDB status host. +status-host = "0.0.0.0" + +# Prometheus pushgateway address, leaves it empty will disable prometheus push. +# TiDB status port. +status-port = 10080 + +# Prometheus pushgateway address, leaves it empty will disable prometheus push. +metrics-addr = "" + +# Prometheus client push interval in second, set \"0\" to disable prometheus push. +metrics-interval = 15 + +# Record statements qps by database name if it is enabled. +record-db-qps = false + +[performance] +# Max CPUs to use, 0 use number of CPUs in the machine. +max-procs = 0 + +# Max memory size to use, 0 use the total usable memory in the machine. +max-memory = 0 + +# StmtCountLimit limits the max count of statement inside a transaction. +stmt-count-limit = 5000 + +# Set keep alive option for tcp connection. +tcp-keep-alive = true + +# Whether support cartesian product. +cross-join = true + +# Stats lease duration, which influences the time of analyze and stats load. +stats-lease = "3s" + +# Run auto analyze worker on this tidb-server. +run-auto-analyze = true + +# Probability to use the query feedback to update stats, 0 or 1 for always false/true. +feedback-probability = 0.05 + +# The max number of query feedback that cache in memory. +query-feedback-limit = 1024 + +# Pseudo stats will be used if the ratio between the modify count and +# row count in statistics of a table is greater than it. +pseudo-estimate-ratio = 0.8 + +# Force the priority of all statements in a specified priority. +# The value could be "NO_PRIORITY", "LOW_PRIORITY", "HIGH_PRIORITY" or "DELAYED". +force-priority = "NO_PRIORITY" + +# Bind info lease duration, which influences the duration of loading bind info and handling invalid bind. +bind-info-lease = "3s" + +[proxy-protocol] +# PROXY protocol acceptable client networks. +# Empty string means disable PROXY protocol, * means all networks. +networks = "" + +# PROXY protocol header read timeout, unit is second +header-timeout = 5 + +[prepared-plan-cache] +enabled = false +capacity = 100 +memory-guard-ratio = 0.1 + +[opentracing] +# Enable opentracing. +enable = false + +# Whether to enable the rpc metrics. +rpc-metrics = false + +[opentracing.sampler] +# Type specifies the type of the sampler: const, probabilistic, rateLimiting, or remote +type = "const" + +# Param is a value passed to the sampler. +# Valid values for Param field are: +# - for "const" sampler, 0 or 1 for always false/true respectively +# - for "probabilistic" sampler, a probability between 0 and 1 +# - for "rateLimiting" sampler, the number of spans per second +# - for "remote" sampler, param is the same as for "probabilistic" +# and indicates the initial sampling rate before the actual one +# is received from the mothership +param = 1.0 + +# SamplingServerURL is the address of jaeger-agent's HTTP sampling server +sampling-server-url = "" + +# MaxOperations is the maximum number of operations that the sampler +# will keep track of. If an operation is not tracked, a default probabilistic +# sampler will be used rather than the per operation specific sampler. +max-operations = 0 + +# SamplingRefreshInterval controls how often the remotely controlled sampler will poll +# jaeger-agent for the appropriate sampling strategy. +sampling-refresh-interval = 0 + +[opentracing.reporter] +# QueueSize controls how many spans the reporter can keep in memory before it starts dropping +# new spans. The queue is continuously drained by a background go-routine, as fast as spans +# can be sent out of process. +queue-size = 0 + +# BufferFlushInterval controls how often the buffer is force-flushed, even if it's not full. +# It is generally not useful, as it only matters for very low traffic services. +buffer-flush-interval = 0 + +# LogSpans, when true, enables LoggingReporter that runs in parallel with the main reporter +# and logs all submitted spans. Main Configuration.Logger must be initialized in the code +# for this option to have any effect. +log-spans = false + +# LocalAgentHostPort instructs reporter to send spans to jaeger-agent at this address +local-agent-host-port = "" + +[tikv-client] +# Max gRPC connections that will be established with each tikv-server. +grpc-connection-count = 16 + +# After a duration of this time in seconds if the client doesn't see any activity it pings +# the server to see if the transport is still alive. +grpc-keepalive-time = 10 + +# After having pinged for keepalive check, the client waits for a duration of Timeout in seconds +# and if no activity is seen even after that the connection is closed. +grpc-keepalive-timeout = 3 + +# Max time for commit command, must be twice bigger than raft election timeout. +commit-timeout = "41s" + +# The max time a Txn may use (in seconds) from its startTS to commitTS. +# We use it to guarantee GC worker will not influence any active txn. Please make sure that this +# value is less than gc_life_time - 10s. +max-txn-time-use = 590 + +# Max batch size in gRPC. +max-batch-size = 128 +# Overload threshold of TiKV. +overload-threshold = 200 +# Max batch wait time in nanosecond to avoid waiting too long. 0 means disable this feature. +max-batch-wait-time = 0 +# Batch wait size, to avoid waiting too long. +batch-wait-size = 8 + +[txn-local-latches] +# Enable local latches for transactions. Enable it when +# there are lots of conflicts between transactions. +enabled = true +capacity = 2048000 + +[binlog] +# enable to write binlog. +enable = false + +# WriteTimeout specifies how long it will wait for writing binlog to pump. +write-timeout = "15s" + +# If IgnoreError is true, when writing binlog meets error, TiDB would stop writing binlog, +# but still provide service. +ignore-error = false + +# use socket file to write binlog, for compatible with kafka version tidb-binlog. +binlog-socket = "" + +# the strategy for sending binlog to pump, value can be "range" or "hash" now. +strategy = "range" + +[pessimistic-txn] +# enable pessimistic transaction. +enable = false + +# start pessimistic transaction by default. +default = false + +# max retry count for a statement in a pessimistic transaction. +max-retry-count = 256 + +# default TTL in milliseconds for pessimistic lock. +# The value must between "15s" and "60s". +ttl = "30s" diff --git a/tidb.spec b/tidb.spec new file mode 100644 index 0000000000000000000000000000000000000000..4dd87996d6aa241013e0fb8b1210705c7a1603b1 --- /dev/null +++ b/tidb.spec @@ -0,0 +1,55 @@ +Name: tidb +Version: 4.0.14 +Release: 1 +Summary: TiDB is a distributed NewSQL database compatible with MySQL protocol + +License: QL and STRUTIL +URL: https://github.com/pingcap/tidb +Source0: https://github.com/pingcap/tidb/archive/refs/tags/v4.0.14.tar.gz +Source1: tidb-server.service +Source2: tidb-server.toml +#Go mod for non-extranet environments +Source3: vendor.tar.gz +Patch0: Set-GOFLAG-to-go-mod-vendor.patch +BuildRequires: golang >= 1.10.0 +Requires(pre): shadow-utils +Requires(post): systemd + +%description +TiDB is a distributed NewSQL database compatible with MySQL protocol + +%prep +%autosetup -p1 +tar xvf %{SOURCE3} -C . + +%build +%make_build + +%install +mkdir -p %{buildroot}/var/log/tidb + +install -D -p -m 755 bin/tidb-server %{buildroot}%{_bindir}/tidb-server + +mkdir -p %{buildroot}%{_sysconfdir}/sysconfig +cat > %{buildroot}%{_sysconfdir}/sysconfig/tidb-server < +- Package init diff --git a/v4.0.14.tar.gz b/v4.0.14.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..eb49923269f4113e30efd179602a34746d4a6916 Binary files /dev/null and b/v4.0.14.tar.gz differ diff --git a/vendor.tar.gz b/vendor.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..c8d6ab4137b8f55cc8e34b3ef3add478f7ca4e80 Binary files /dev/null and b/vendor.tar.gz differ