summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMassimiliano Torromeo2017-10-19 14:26:38 +0200
committerMassimiliano Torromeo2017-10-19 15:22:34 +0200
commiteb6a54afa5b638b8041fb86856c99068b7fb3b08 (patch)
treed1877d1ead2bf9d44fea48da25b1bfd1a6fc5fcc
parent93248bb7da33f7a292568f9bfcb46e55b5ce38c1 (diff)
downloadaur-eb6a54afa5b638b8041fb86856c99068b7fb3b08.tar.gz
Updated for 1.0 with systemd service file, dedicated user, config file and data directory
-rw-r--r--.SRCINFO15
-rw-r--r--PKGBUILD45
-rw-r--r--config.toml121
-rw-r--r--socket-perms.patch22
-rw-r--r--tidb.service20
-rw-r--r--tidb.tmpfile1
-rw-r--r--tidb.user1
7 files changed, 210 insertions, 15 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 5007db6181d5..aaca2d5741dd 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,10 +1,10 @@
# Generated by mksrcinfo v8
-# Wed Dec 28 10:33:08 UTC 2016
+# Thu Oct 19 12:26:44 UTC 2017
pkgbase = tidb-git
pkgdesc = Distributed SQL database inspired by the desing of Google F1
- pkgver = rc1.23.g5a309947
+ pkgver = 1.0.0.17.gb45890ab6
pkgrel = 1
- url = https://github.com/pingcap/tidb
+ url = https://pingcap.com/
arch = i686
arch = x86_64
license = APACHE
@@ -12,8 +12,17 @@ pkgbase = tidb-git
makedepends = godep
makedepends = git
depends = glibc
+ backup = etc/tidb/config.toml
source = git+https://github.com/pingcap/tidb.git
+ source = config.toml
+ source = tidb.service
+ source = tidb.user
+ source = tidb.tmpfile
sha256sums = SKIP
+ sha256sums = 0651e419f27961ccb85bf5ea7ef9576bbc433f7211aa8a77e2b6139f7dba8c7e
+ sha256sums = 66c85143faeec8b136a71dbf1d400afa041eace57271dbfce0edfccca3874402
+ sha256sums = e8e60176eca71d4f930828e9e152c3bae4db70cff409a7557f12e145700e4a03
+ sha256sums = 30ce83fbec8f102c30e438282bb5b18c026d08480f2386d68f1116c12481bf66
pkgname = tidb-git
diff --git a/PKGBUILD b/PKGBUILD
index 2fad1d80c249..be28fc41b911 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,20 +1,31 @@
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
pkgname=tidb-git
-pkgver=rc1.23.g5a309947
+pkgver=1.0.0.17.gb45890ab6
pkgrel=1
pkgdesc="Distributed SQL database inspired by the desing of Google F1"
arch=('i686' 'x86_64')
-url="https://github.com/pingcap/tidb"
+url="https://pingcap.com/"
license=('APACHE')
depends=('glibc')
makedepends=('go' 'godep' 'git')
-source=(git+https://github.com/pingcap/tidb.git)
-sha256sums=('SKIP')
+source=(git+https://github.com/pingcap/tidb.git
+ config.toml
+ tidb.service
+ tidb.user
+ tidb.tmpfile
+ socket-perms.patch)
+backup=(etc/tidb/config.toml)
+sha256sums=('SKIP'
+ '0651e419f27961ccb85bf5ea7ef9576bbc433f7211aa8a77e2b6139f7dba8c7e'
+ '66c85143faeec8b136a71dbf1d400afa041eace57271dbfce0edfccca3874402'
+ 'e8e60176eca71d4f930828e9e152c3bae4db70cff409a7557f12e145700e4a03'
+ '30ce83fbec8f102c30e438282bb5b18c026d08480f2386d68f1116c12481bf66'
+ 'a7827d1c75ee57a52a5e60b930ef1619a6cd580d98730a59bc6a49e358affbe6')
pkgver() {
- cd "$srcdir/tidb"
- git describe --tags --always | sed 's|-|.|g'
+ cd "$srcdir"/tidb
+ git describe --tags --always | sed 's/-/./g;s/^v//'
}
prepare() {
@@ -22,6 +33,10 @@ prepare() {
cd src/github.com/pingcap
rm -f tidb
ln -s "$srcdir/tidb"
+
+ cd "$srcdir"/tidb
+ patch -p1 -i "$srcdir"/socket-perms.patch
+ sed 's|/tmp/tidb|/var/lib/tidb|g' -i tidb-server/main.go config/config.go
}
build() {
@@ -31,16 +46,22 @@ build() {
LDFLAGS= make
}
-check() {
- export GOPATH="$srcdir"
- export PATH="$PATH:$GOPATH/bin"
- cd src/github.com/pingcap/tidb
- make test
-}
+#check() {
+# export GOPATH="$srcdir"
+# export PATH="$PATH:$GOPATH/bin"
+# cd src/github.com/pingcap/tidb
+# make test
+#}
package() {
export GOPATH="$srcdir"
export PATH="$PATH:$GOPATH/bin"
+
+ install -Dm644 config.toml "$pkgdir"/etc/tidb/config.toml
+ install -Dm644 tidb.service "$pkgdir"/usr/lib/systemd/system/tidb.service
+ install -Dm644 tidb.user "$pkgdir"/usr/lib/sysusers.d/tidb.conf
+ install -Dm644 tidb.tmpfile "$pkgdir"/usr/lib/tmpfiles.d/tidb.conf
+
cd src/github.com/pingcap/tidb
install -Dm755 bin/tidb-server "$pkgdir"/usr/bin/tidb-server
}
diff --git a/config.toml b/config.toml
new file mode 100644
index 000000000000..b8a600312401
--- /dev/null
+++ b/config.toml
@@ -0,0 +1,121 @@
+# TiDB Configuration.
+
+# TiDB server host.
+host = "127.0.0.1"
+
+# TiDB server port.
+port = 4000
+
+# Registered store name, [memory, goleveldb, boltdb, tikv, mocktikv]
+store = "mocktikv"
+
+# TiDB storage path.
+path = "/var/lib/tidb"
+
+# The socket file to use for connection.
+socket = "/run/tidb/tidb.sock"
+
+# Socket file to write binlog.
+#binlog-socket = ""
+
+# 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 = "10s"
+
+# When create table, split a separated region for it.
+# split-table = false
+
+[log]
+# Log level: info, debug, warn, error, fatal.
+level = "info"
+
+# Log format, one of json, text, console.
+format = "text"
+
+# Disable automatic timestamps in output
+disable-timestamp = false
+
+# Queries with execution time greater than this value will be logged. (Milliseconds)
+slow-threshold = 300
+
+# Maximum query length recorded in log.
+query-log-max-len = 2048
+
+# File logging.
+[log.file]
+# Log file name.
+filename = ""
+
+# Max log file size in MB.
+#max-size = 300
+
+# Max log file keep days.
+#max-days = 28
+
+# Maximum number of old log files to retain.
+#max-backups = 7
+
+# Rotate log by day
+log-rotate = true
+
+[security]
+# Path of file that contains list of trusted SSL CAs.
+ssl-ca = ""
+
+# Path of file that contains X509 certificate in PEM format.
+ssl-cert = ""
+
+# Path of file that contains X509 key in PEM format.
+ssl-key = ""
+
+[status]
+# If enable status report HTTP service.
+report-status = true
+
+# 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
+
+[performance]
+# Set keep alive option for tcp connection.
+tcp-keep-alive = true
+
+# The maximum number of retries when commit a transaction.
+retry-limit = 10
+
+# The number of goroutines that participate joining.
+join-concurrency = 5
+
+# Whether support cartesian product.
+cross-join = true
+
+# Stats lease duration, which inflences the time of analyze and stats load.
+stats-lease = "3s"
+
+# Run auto analyze worker on this tidb-server.
+run-auto-analyze = true
+
+[xprotocol]
+# Start TiDB x server.
+xserver = false
+
+# TiDB x protocol server host.
+xhost = "0.0.0.0"
+
+# TiDB x protocol server port.
+xport = 14000
+
+# The socket file to use for x protocol connection.
+xsocket = ""
+
+[plan-cache]
+plan-cache-enabled = false
+plan-cache-capacity = 2560
+plan-cache-shards = 256
diff --git a/socket-perms.patch b/socket-perms.patch
new file mode 100644
index 000000000000..1ee509678518
--- /dev/null
+++ b/socket-perms.patch
@@ -0,0 +1,22 @@
+diff --git a/server/server.go b/server/server.go
+index df0f24197..5f515a42e 100644
+--- a/server/server.go
++++ b/server/server.go
+@@ -35,6 +35,7 @@ import (
+ "io/ioutil"
+ "math/rand"
+ "net"
++ "os"
+ "sync"
+ "sync/atomic"
+ "time"
+@@ -156,6 +157,9 @@ func NewServer(cfg *config.Config, driver IDriver) (*Server, error) {
+ if s.listener, err = net.Listen("unix", cfg.Socket); err == nil {
+ log.Infof("Server is running MySQL Protocol through Socket [%s]", cfg.Socket)
+ }
++ if err := os.Chmod(cfg.Socket, 0777); err != nil {
++ log.Fatal("Couldn't change socket permission for %s", cfg.Socket)
++ }
+ } else {
+ addr := fmt.Sprintf("%s:%d", s.cfg.Host, s.cfg.Port)
+ if s.listener, err = net.Listen("tcp", addr); err == nil {
diff --git a/tidb.service b/tidb.service
new file mode 100644
index 000000000000..cfc3e187b60c
--- /dev/null
+++ b/tidb.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=TiDB
+Documentation=https://pingcap.com/docs
+Wants=network.target
+After=network.target
+
+[Service]
+Type=simple
+RuntimeDirectory=tidb
+PIDFile=/run/tidb/tidb.pid
+WorkingDirectory=/var/lib/tidb
+
+User=tidb
+Group=tidb
+
+ExecStart=/usr/bin/tidb-server -config /etc/tidb/config.toml
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tidb.tmpfile b/tidb.tmpfile
new file mode 100644
index 000000000000..95753f6fc615
--- /dev/null
+++ b/tidb.tmpfile
@@ -0,0 +1 @@
+d /var/lib/tidb 0755 tidb tidb -
diff --git a/tidb.user b/tidb.user
new file mode 100644
index 000000000000..7ca9d30d7123
--- /dev/null
+++ b/tidb.user
@@ -0,0 +1 @@
+u tidb - "TiDB user"