TiDBインストール

 

https://engineering.dena.com/blog/2022/01/infra-meetup-tidb/
https://www.publickey1.jp/blog/23/mysql7000linemysqlnewsqlpr.html
https://github.com/pingcap/tidb

https://docs.pingcap.com/tidb/stable/quick-start-with-tidb
https://docs.pingcap.com/tidb/stable/production-deployment-using-tiup

 


PD : メタデータ管理
TiKV : ストレージ層
TiDB : MySQL 互換の Interface

 

[1] Deploy a local test cluster
OS: CentOS7
CPUコア -> 1
メモリ -> 2G


-- 1. Download and install TiUP

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

source .bash_profile

-- 2. Start the cluster in the current session

tiup playground

-- 3. TiDBへの接続

tiup client


yum remove -y mariadb-libs
rm -rf /var/lib/mysql/
yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum search mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-client

mysql --comments --host 127.0.0.1 --port 4000 -u root

-- 4. Prometheus dashboard

http://127.0.0.1:9090


-- 5. TiDB Dashboard

http://127.0.0.1:2379/dashboard

root
パスワードなし

-- 6. Grafana dashboard

http://127.0.0.1:3000

admin/admin


-- 7. Clean up the cluster

Control+C

tiup clean --all

[2] Simulate production deployment on a single machine
OS: CentOS7

CPUコア -> 4
メモリ -> 8G


-- 1. Download and install TiUP

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

source .bash_profile

-- 2. Install the cluster component of TiUP

tiup cluster


vim /etc/ssh/sshd_config

#MaxSessions 10

MaxSessions 20

systemctl restart sshd

-- 3. Create and start the cluster

vim topo.yaml

# # Global variables are applied to all deployments and used as the default value of
# # the deployments if a specific deployment value is missing.
global:
 user: "tidb"
 ssh_port: 22
 deploy_dir: "/tidb-deploy"
 data_dir: "/tidb-data"

# # Monitored variables are applied to all the machines.
monitored:
 node_exporter_port: 9100
 blackbox_exporter_port: 9115

server_configs:
 tidb:
   log.slow-threshold: 300
 tikv:
   readpool.storage.use-unified-pool: false
   readpool.coprocessor.use-unified-pool: true
 pd:
   replication.enable-placement-rules: true
   replication.location-labels: ["host"]
 tiflash:
   logger.level: "info"

pd_servers:
 - host: 192.168.137.129

tidb_servers:
 - host: 192.168.137.129

tikv_servers:
 - host: 192.168.137.129
   port: 20160
   status_port: 20180
   config:
     server.labels: { host: "logic-host-1" }

 - host: 192.168.137.129
   port: 20161
   status_port: 20181
   config:
     server.labels: { host: "logic-host-2" }

 - host: 192.168.137.129
   port: 20162
   status_port: 20182
   config:
     server.labels: { host: "logic-host-3" }

tiflash_servers:
 - host: 192.168.137.129

monitoring_servers:
 - host: 192.168.137.129

grafana_servers:
 - host: 192.168.137.129
 

-- 4. Execute the cluster deployment
tiup list tidb

tiup cluster deploy cluster01 v7.1.0 ./topo.yaml --user root -p

-- 5. Start the cluster


tiup cluster start cluster01 --init

 


tiup cluster list
tiup cluster display cluster01


-- 6. Access the cluster

yum remove -y mariadb-libs
rm -rf /var/lib/mysql/
yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum search mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-client

mysql -h 192.168.137.129 -P 4000 -u root -p

-- 7. Grafana dashboard

http://192.168.137.129:3000

admin/admin

-- 8. TiDB Dashboard

http://192.168.137.129:2379/dashboard

root
パスワード-> クラスタ起動時に生成された値


-- 9. Stop the cluster

tiup cluster display cluster01
tiup cluster stop cluster01
tiup cluster display cluster01


[3] Deploy a TiDB Cluster Using TiUP
OS: CentOS7 9台
CPUコア -> 1
メモリ -> 2G

-- 1. Download and install TiUP

curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh

source .bash_profile
which tiup

-- 2. Install the cluster component of TiUP

tiup cluster
tiup --binary cluster


-- 3. Prepare the TiUP offline component package

https://www.pingcap.com/download/

offline mirror packageをダウンロード
(server package と toolkit packageの両方)

tidb-community-server-v7.1.0-linux-amd64.tar.gz
tidb-community-toolkit-v7.1.0-linux-amd64.tar.gz


-- 4. Deploy the offline TiUP component

tar xzvf tidb-community-server-v7.1.0-linux-amd64.tar.gz && \
sh tidb-community-server-v7.1.0-linux-amd64/local_install.sh && \
source /root/.bash_profile

-- 5. Merge offline packages

tar xf tidb-community-toolkit-v7.1.0-linux-amd64.tar.gz
ls -ld tidb-community-server-v7.1.0-linux-amd64 tidb-community-toolkit-v7.1.0-linux-amd64
cd tidb-community-server-v7.1.0-linux-amd64/
cp -rp keys ~/.tiup/
tiup mirror merge ../tidb-community-toolkit-v7.1.0-linux-amd64

 

-- 6. Initialize cluster topology file

tiup cluster template > topology.yaml

vi topology.yaml

global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-deploy"
  data_dir: "/tidb-data"
server_configs: {}
pd_servers:
  - host: 192.168.137.124
  - host: 192.168.137.125
  - host: 192.168.137.126
tidb_servers:
  - host: 192.168.137.121
  - host: 192.168.137.122

tikv_servers:
  - host: 192.168.137.127
  - host: 192.168.137.128
  - host: 192.168.137.129
monitoring_servers:
  - host: 192.168.137.123
grafana_servers:
  - host: 192.168.137.123
alertmanager_servers:
  - host: 192.168.137.123

 

-- 7. Run the deployment command

tiup cluster check ./topology.yaml --user root -p

tiup cluster check ./topology.yaml --apply --user root -p

tiup cluster check ./topology.yaml --user root -p

※ 下記エラーは無視
service irqbalance is not running
numactl not usable

 

tiup cluster deploy cluster01 v7.1.0 ./topology.yaml --user root -p

-- 8. Check the clusters managed by TiUP

tiup cluster list

tiup cluster display cluster01


-- 9. Start a TiDB cluster

tiup cluster start cluster01 --init


tiup cluster display cluster01


-- 10. Access the cluster

yum remove -y mariadb-libs
rm -rf /var/lib/mysql/
yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum search mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum install -y mysql-community-client

mysql -h 192.168.137.121 -P 4000 -u root -p

-- 11. Grafana dashboard

http://192.168.137.123:3000

admin/admin

-- 12. TiDB Dashboard

http://192.168.137.124:2379/dashboard

root
パスワード-> クラスタ起動時に生成された値


-- 13. Stop the cluster

tiup cluster display cluster01
tiup cluster stop cluster01
tiup cluster display cluster01