官网
磁盘
1 2 3 4 5
| vi /etc/fstab UUID=c51eb23b-195c-4061-92a9-3fad812cc12f /data ext4 defaults,nodelalloc,noatime 0 2 mkdir /data mount -a mount -t ext4
|
Swap
1 2 3 4 5 6 7 8
| echo "vm.swappiness = 0">> /etc/sysctl.conf swapoff -a && swapon -a sysctl -p
vi /etc/fstab # 注释掉swap一行 swapoff -a
free # 验证
|
ntp
1 2 3 4
| yum install ntp ntpdate -y systemctl start ntpd.service systemctl enable ntpd.service ntpstat
|
操作系统优化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/block/vdc/queue/scheduler cat /sys/block/vdd/queue/scheduler
udevadm info --name=/dev/vdc | grep ID_SERIAL udevadm info --name=/dev/vdd | grep ID_SERIAL
cpupower frequency-info --policy
-----------------
tuned-adm list mkdir /etc/tuned/balanced-tidb-optimal/ vi /etc/tuned/balanced-tidb-optimal/tuned.conf [main] include=balanced
[cpu] governor=performance
[vm] transparent_hugepages=never
[disk] devices_udev_regex=(ID_SERIAL=vos-5ef7r1pv)|(ID_SERIAL=vos-od1sacxs) elevator=noop
tuned-adm profile balanced-tidb-optimal
echo "fs.file-max = 1000000">> /etc/sysctl.conf echo "net.core.somaxconn = 32768">> /etc/sysctl.conf echo "net.ipv4.tcp_tw_recycle = 0">> /etc/sysctl.conf echo "net.ipv4.tcp_syncookies = 0">> /etc/sysctl.conf echo "vm.overcommit_memory = 1">> /etc/sysctl.conf sysctl -p
cat << EOF >>/etc/security/limits.conf tidb soft nofile 1000000 tidb hard nofile 1000000 tidb soft stack 32768 tidb hard stack 32768 EOF
echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
yum install numactl -y
yum install irqbalance -y systemctl enable irqbalance && systemctl start irqbalance
|
ssh互信
1 2 3
| ssh-copy-id root@10.193.50.17 ssh-copy-id root@10.193.50.18 ssh-copy-id root@10.193.50.19
|
TiUP
1 2 3 4 5
| curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh which tiup tiup cluster tiup update --self && tiup update cluster tiup --binary cluster
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| tiup cluster template > topology.yaml vi topology.yaml
global: user: "tidb" ssh_port: 22 deploy_dir: "/data/tidb-deploy" data_dir: "/data/tidb-data"
pd_servers: - host: 10.193.50.17 - host: 10.193.50.18 - host: 10.193.50.19
tidb_servers: - host: 10.193.50.17 - host: 10.193.50.18 - host: 10.193.50.19
tikv_servers: - host: 10.193.50.17 - host: 10.193.50.18 - host: 10.193.50.19
monitoring_servers: - host: 10.193.50.17
grafana_servers: - host: 10.193.50.17
alertmanager_servers: - host: 10.193.50.17
tiup cluster check ./topology.yaml --user root tiup cluster check ./topology.yaml --apply --user root
tiup cluster deploy tidb-eip v5.3.0 ./topology.yaml --user root
|
HaProxy
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| yum install haproxy -y
vi /etc/haproxy/haproxy.cfg
global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4096 user haproxy group haproxy daemon stats socket /var/lib/haproxy/stats
defaults log global retries 2 timeout connect 2s timeout client 30000s timeout server 30000s
listen admin_stats bind 0.0.0.0:8080 mode http option httplog maxconn 10 stats refresh 30s stats uri /haproxy stats realm HAProxy stats auth admin:pingcap123 stats hide-version stats admin if TRUE
listen tidb-cluster bind 0.0.0.0:3390 mode tcp balance leastconn server tidb-1 10.193.50.17:4000 check inter 2000 rise 2 fall 3 server tidb-2 10.193.50.18:4000 check inter 2000 rise 2 fall 3 server tidb-3 10.193.50.19:4000 check inter 2000 rise 2 fall 3
haproxy -f /etc/haproxy/haproxy.cfg systemctl enable haproxy systemctl start haproxy
|
启动
1 2 3
| tiup cluster list tiup cluster display tidb-eip tiup cluster start tidb-eip
|
验证
PD
http://10.193.50.17:2379/dashboard
Grafana
http://10.193.50.17:3000
MySQL
mysql -uroot -p -h10.193.50.17 -P3390
select tidb_version()\G