- Docs Home
- About TiDB
- Quick Start
- Develop
- Overview
- Quick Start
- Build a TiDB Cluster in TiDB Cloud (Developer Tier)
- CRUD SQL in TiDB
- Build a Simple CRUD App with TiDB
- Example Applications
- Connect to TiDB
- Design Database Schema
- Write Data
- Read Data
- Transaction
- Optimize
- Troubleshoot
- Reference
- Cloud Native Development Environment
- Third-party Support
- Deploy
- Software and Hardware Requirements
- Environment Configuration Checklist
- Plan Cluster Topology
- Install and Start
- Verify Cluster Status
- Test Cluster Performance
- Migrate
- Overview
- Migration Tools
- Migration Scenarios
- Migrate from Aurora
- Migrate MySQL of Small Datasets
- Migrate MySQL of Large Datasets
- Migrate and Merge MySQL Shards of Small Datasets
- Migrate and Merge MySQL Shards of Large Datasets
- Migrate from CSV Files
- Migrate from SQL Files
- Migrate from One TiDB Cluster to Another TiDB Cluster
- Migrate from TiDB to MySQL-compatible Databases
- Advanced Migration
- Integrate
- Maintain
- Monitor and Alert
- Troubleshoot
- TiDB Troubleshooting Map
- Identify Slow Queries
- Analyze Slow Queries
- SQL Diagnostics
- Identify Expensive Queries Using Top SQL
- Identify Expensive Queries Using Logs
- Statement Summary Tables
- Troubleshoot Hotspot Issues
- Troubleshoot Increased Read and Write Latency
- Save and Restore the On-Site Information of a Cluster
- Troubleshoot Cluster Setup
- Troubleshoot High Disk I/O Usage
- Troubleshoot Lock Conflicts
- Troubleshoot TiFlash
- Troubleshoot Write Conflicts in Optimistic Transactions
- Troubleshoot Inconsistency Between Data and Indexes
- Performance Tuning
- Tuning Guide
- Configuration Tuning
- System Tuning
- Software Tuning
- SQL Tuning
- Overview
- Understanding the Query Execution Plan
- SQL Optimization Process
- Overview
- Logic Optimization
- Physical Optimization
- Prepare Execution Plan Cache
- Control Execution Plans
- Tutorials
- TiDB Tools
- Overview
- Use Cases
- Download
- TiUP
- Documentation Map
- Overview
- Terminology and Concepts
- Manage TiUP Components
- FAQ
- Troubleshooting Guide
- Command Reference
- Overview
- TiUP Commands
- TiUP Cluster Commands
- Overview
- tiup cluster audit
- tiup cluster check
- tiup cluster clean
- tiup cluster deploy
- tiup cluster destroy
- tiup cluster disable
- tiup cluster display
- tiup cluster edit-config
- tiup cluster enable
- tiup cluster help
- tiup cluster import
- tiup cluster list
- tiup cluster patch
- tiup cluster prune
- tiup cluster reload
- tiup cluster rename
- tiup cluster replay
- tiup cluster restart
- tiup cluster scale-in
- tiup cluster scale-out
- tiup cluster start
- tiup cluster stop
- tiup cluster template
- tiup cluster upgrade
- TiUP DM Commands
- Overview
- tiup dm audit
- tiup dm deploy
- tiup dm destroy
- tiup dm disable
- tiup dm display
- tiup dm edit-config
- tiup dm enable
- tiup dm help
- tiup dm import
- tiup dm list
- tiup dm patch
- tiup dm prune
- tiup dm reload
- tiup dm replay
- tiup dm restart
- tiup dm scale-in
- tiup dm scale-out
- tiup dm start
- tiup dm stop
- tiup dm template
- tiup dm upgrade
- TiDB Cluster Topology Reference
- DM Cluster Topology Reference
- Mirror Reference Guide
- TiUP Components
- PingCAP Clinic Diagnostic Service
- TiDB Operator
- Dumpling
- TiDB Lightning
- TiDB Data Migration
- About TiDB Data Migration
- Architecture
- Quick Start
- Deploy a DM cluster
- Tutorials
- Advanced Tutorials
- Maintain
- Cluster Upgrade
- Tools
- Performance Tuning
- Manage Data Sources
- Manage Tasks
- Export and Import Data Sources and Task Configurations of Clusters
- Handle Alerts
- Daily Check
- Reference
- Architecture
- Command Line
- Configuration Files
- OpenAPI
- Compatibility Catalog
- Secure
- Monitoring and Alerts
- Error Codes
- Glossary
- Example
- Troubleshoot
- Release Notes
- Backup & Restore (BR)
- TiDB Binlog
- TiCDC
- Dumpling
- sync-diff-inspector
- TiSpark
- Reference
- Cluster Architecture
- Key Monitoring Metrics
- Secure
- Privileges
- SQL
- SQL Language Structure and Syntax
- SQL Statements
ADD COLUMN
ADD INDEX
ADMIN
ADMIN CANCEL DDL
ADMIN CHECKSUM TABLE
ADMIN CHECK [TABLE|INDEX]
ADMIN SHOW DDL [JOBS|QUERIES]
ADMIN SHOW TELEMETRY
ALTER DATABASE
ALTER INDEX
ALTER INSTANCE
ALTER PLACEMENT POLICY
ALTER TABLE
ALTER TABLE COMPACT
ALTER USER
ANALYZE TABLE
BACKUP
BATCH
BEGIN
CHANGE COLUMN
COMMIT
CHANGE DRAINER
CHANGE PUMP
CREATE [GLOBAL|SESSION] BINDING
CREATE DATABASE
CREATE INDEX
CREATE PLACEMENT POLICY
CREATE ROLE
CREATE SEQUENCE
CREATE TABLE LIKE
CREATE TABLE
CREATE USER
CREATE VIEW
DEALLOCATE
DELETE
DESC
DESCRIBE
DO
DROP [GLOBAL|SESSION] BINDING
DROP COLUMN
DROP DATABASE
DROP INDEX
DROP PLACEMENT POLICY
DROP ROLE
DROP SEQUENCE
DROP STATS
DROP TABLE
DROP USER
DROP VIEW
EXECUTE
EXPLAIN ANALYZE
EXPLAIN
FLASHBACK TABLE
FLUSH PRIVILEGES
FLUSH STATUS
FLUSH TABLES
GRANT <privileges>
GRANT <role>
INSERT
KILL [TIDB]
LOAD DATA
LOAD STATS
MODIFY COLUMN
PREPARE
RECOVER TABLE
RENAME INDEX
RENAME TABLE
REPLACE
RESTORE
REVOKE <privileges>
REVOKE <role>
ROLLBACK
SELECT
SET DEFAULT ROLE
SET [NAMES|CHARACTER SET]
SET PASSWORD
SET ROLE
SET TRANSACTION
SET [GLOBAL|SESSION] <variable>
SHOW ANALYZE STATUS
SHOW [BACKUPS|RESTORES]
SHOW [GLOBAL|SESSION] BINDINGS
SHOW BUILTINS
SHOW CHARACTER SET
SHOW COLLATION
SHOW [FULL] COLUMNS FROM
SHOW CONFIG
SHOW CREATE PLACEMENT POLICY
SHOW CREATE SEQUENCE
SHOW CREATE TABLE
SHOW CREATE USER
SHOW DATABASES
SHOW DRAINER STATUS
SHOW ENGINES
SHOW ERRORS
SHOW [FULL] FIELDS FROM
SHOW GRANTS
SHOW INDEX [FROM|IN]
SHOW INDEXES [FROM|IN]
SHOW KEYS [FROM|IN]
SHOW MASTER STATUS
SHOW PLACEMENT
SHOW PLACEMENT FOR
SHOW PLACEMENT LABELS
SHOW PLUGINS
SHOW PRIVILEGES
SHOW [FULL] PROCESSSLIST
SHOW PROFILES
SHOW PUMP STATUS
SHOW SCHEMAS
SHOW STATS_HEALTHY
SHOW STATS_HISTOGRAMS
SHOW STATS_META
SHOW STATUS
SHOW TABLE NEXT_ROW_ID
SHOW TABLE REGIONS
SHOW TABLE STATUS
SHOW [FULL] TABLES
SHOW [GLOBAL|SESSION] VARIABLES
SHOW WARNINGS
SHUTDOWN
SPLIT REGION
START TRANSACTION
TABLE
TRACE
TRUNCATE
UPDATE
USE
WITH
- Data Types
- Functions and Operators
- Overview
- Type Conversion in Expression Evaluation
- Operators
- Control Flow Functions
- String Functions
- Numeric Functions and Operators
- Date and Time Functions
- Bit Functions and Operators
- Cast Functions and Operators
- Encryption and Compression Functions
- Locking Functions
- Information Functions
- JSON Functions
- Aggregate (GROUP BY) Functions
- Window Functions
- Miscellaneous Functions
- Precision Math
- Set Operations
- List of Expressions for Pushdown
- TiDB Specific Functions
- Clustered Indexes
- Constraints
- Generated Columns
- SQL Mode
- Table Attributes
- Transactions
- Garbage Collection (GC)
- Views
- Partitioning
- Temporary Tables
- Cached Tables
- Character Set and Collation
- Placement Rules in SQL
- System Tables
mysql
- INFORMATION_SCHEMA
- Overview
ANALYZE_STATUS
CLIENT_ERRORS_SUMMARY_BY_HOST
CLIENT_ERRORS_SUMMARY_BY_USER
CLIENT_ERRORS_SUMMARY_GLOBAL
CHARACTER_SETS
CLUSTER_CONFIG
CLUSTER_HARDWARE
CLUSTER_INFO
CLUSTER_LOAD
CLUSTER_LOG
CLUSTER_SYSTEMINFO
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
DATA_LOCK_WAITS
DDL_JOBS
DEADLOCKS
ENGINES
INSPECTION_RESULT
INSPECTION_RULES
INSPECTION_SUMMARY
KEY_COLUMN_USAGE
METRICS_SUMMARY
METRICS_TABLES
PARTITIONS
PLACEMENT_POLICIES
PROCESSLIST
REFERENTIAL_CONSTRAINTS
SCHEMATA
SEQUENCES
SESSION_VARIABLES
SLOW_QUERY
STATISTICS
TABLES
TABLE_CONSTRAINTS
TABLE_STORAGE_STATS
TIDB_HOT_REGIONS
TIDB_HOT_REGIONS_HISTORY
TIDB_INDEXES
TIDB_SERVERS_INFO
TIDB_TRX
TIFLASH_REPLICA
TIKV_REGION_PEERS
TIKV_REGION_STATUS
TIKV_STORE_STATUS
USER_PRIVILEGES
VIEWS
METRICS_SCHEMA
- UI
- TiDB Dashboard
- Overview
- Maintain
- Access
- Overview Page
- Cluster Info Page
- Top SQL Page
- Key Visualizer Page
- Metrics Relation Graph
- SQL Statements Analysis
- Slow Queries Page
- Cluster Diagnostics
- Search Logs Page
- Instance Profiling
- Session Management and Configuration
- FAQ
- CLI
- Command Line Flags
- Configuration File Parameters
- System Variables
- Storage Engines
- Telemetry
- Errors Codes
- Table Filter
- Schedule Replicas by Topology Labels
- FAQs
- Release Notes
- All Releases
- Release Timeline
- TiDB Versioning
- v6.1
- v6.0
- v5.4
- v5.3
- v5.2
- v5.1
- v5.0
- v4.0
- v3.1
- v3.0
- v2.1
- v2.0
- v1.0
- Glossary
TiDB Environment and System Configuration Check
This document describes the environment check operations before deploying TiDB. The following steps are ordered by priorities.
Mount the data disk ext4 filesystem with options on the target machines that deploy TiKV
For production deployments, it is recommended to use NVMe SSD of EXT4 filesystem to store TiKV data. This configuration is the best practice, whose reliability, security, and stability have been proven in a large number of online scenarios.
Log in to the target machines using the root
user account.
Format your data disks to the ext4 filesystem and add the nodelalloc
and noatime
mount options to the filesystem. It is required to add the nodelalloc
option, or else the TiUP deployment cannot pass the precheck. The noatime
option is optional.
If your data disks have been formatted to ext4 and have added the mount options, you can uninstall it by running the umount /dev/nvme0n1p1
command, skip directly to the fifth step below to edit the /etc/fstab
file, and add the options again to the filesystem.
Take the /dev/nvme0n1
data disk as an example:
View the data disk.
fdisk -l
Disk /dev/nvme0n1: 1000 GB
Create the partition.
parted -s -a optimal /dev/nvme0n1 mklabel gpt -- mkpart primary ext4 1 -1
NoteUse the
lsblk
command to view the device number of the partition: for a NVMe disk, the generated device number is usuallynvme0n1p1
; for a regular disk (for example,/dev/sdb
), the generated device number is usuallysdb1
.Format the data disk to the ext4 filesystem.
mkfs.ext4 /dev/nvme0n1p1
View the partition UUID of the data disk.
In this example, the UUID of nvme0n1p1 is
c51eb23b-195c-4061-92a9-3fad812cc12f
.lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT sda ├─sda1 ext4 237b634b-a565-477b-8371-6dff0c41f5ab /boot ├─sda2 swap f414c5c0-f823-4bb1-8fdf-e531173a72ed └─sda3 ext4 547909c1-398d-4696-94c6-03e43e317b60 / sr0 nvme0n1 └─nvme0n1p1 ext4 c51eb23b-195c-4061-92a9-3fad812cc12f
Edit the
/etc/fstab
file and add thenodelalloc
mount options.vi /etc/fstab
UUID=c51eb23b-195c-4061-92a9-3fad812cc12f /data1 ext4 defaults,nodelalloc,noatime 0 2
Mount the data disk.
mkdir /data1 && \ mount -a
Check using the following command.
mount -t ext4
/dev/nvme0n1p1 on /data1 type ext4 (rw,noatime,nodelalloc,data=ordered)
If the filesystem is ext4 and
nodelalloc
is included in the mount options, you have successfully mount the data disk ext4 filesystem with options on the target machines.
Check and disable system swap
TiDB needs sufficient memory space for operation. When memory is insufficient, using swap as a buffer might degrade performance. Therefore, it is recommended to disable the system swap permanently by executing the following commands:
echo "vm.swappiness = 0">> /etc/sysctl.conf
swapoff -a && swapon -a
sysctl -p
Executing
swapoff -a
and thenswapon -a
is to refresh swap by dumping data to memory and cleaning up swap. If you drop the swappiness change and execute onlyswapoff -a
, swap will be enabled again after you restart the system.sysctl -p
is to make the configuration effective without restarting the system.
Check and stop the firewall service of target machines
In TiDB clusters, the access ports between nodes must be open to ensure the transmission of information such as read and write requests and data heartbeats. In common online scenarios, the data interaction between the database and the application service and between the database nodes are all made within a secure network. Therefore, if there are no special security requirements, it is recommended to stop the firewall of the target machine. Otherwise, refer to the port usage and add the needed port information to the allowlist of the firewall service.
The rest of this section describes how to stop the firewall service of a target machine.
Check the firewall status. Take CentOS Linux release 7.7.1908 (Core) as an example.
sudo firewall-cmd --state sudo systemctl status firewalld.service
Stop the firewall service.
sudo systemctl stop firewalld.service
Disable automatic start of the firewall service.
sudo systemctl disable firewalld.service
Check the firewall status.
sudo systemctl status firewalld.service
Check and install the NTP service
TiDB is a distributed database system that requires clock synchronization between nodes to guarantee linear consistency of transactions in the ACID model.
At present, the common solution to clock synchronization is to use the Network Time Protocol (NTP) services. You can use the pool.ntp.org
timing service on the Internet, or build your own NTP service in an offline environment.
To check whether the NTP service is installed and whether it synchronizes with the NTP server normally, take the following steps:
Run the following command. If it returns
running
, then the NTP service is running.sudo systemctl status ntpd.service
ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled) Active: active (running) since 一 2017-12-18 13:13:19 CST; 3s ago
If it returns
Unit ntpd.service could not be found.
, then try the following command to see whether your system is configured to usechronyd
instead ofntpd
to perform clock synchronization with NTP:sudo systemctl status chronyd.service
chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2021-04-05 09:55:29 EDT; 3 days ago
If the result shows that neither
chronyd
norntpd
is configured, it means that neither of them is installed in your system. You should first installchronyd
orntpd
and ensure that it can be automatically started. By default,ntpd
is used.If your system is configured to use
chronyd
, proceed to step 3.
Run the
ntpstat
command to check whether the NTP service synchronizes with the NTP server.NoteFor the Ubuntu system, you need to install the
ntpstat
package.ntpstat
If it returns
synchronised to NTP server
(synchronizing with the NTP server), then the synchronization process is normal.synchronised to NTP server (85.199.214.101) at stratum 2 time correct to within 91 ms polling server every 1024 s
The following situation indicates the NTP service is not synchronizing normally:
unsynchronised
The following situation indicates the NTP service is not running normally:
Unable to talk to NTP daemon. Is it running?
Run the
chronyc tracking
command to check wheter the Chrony service synchronizes with the NTP server.NoteThis only applies to systems that use Chrony instead of NTPd.
chronyc tracking
If the command returns
Leap status : Normal
, the synchronization process is normal.Reference ID : 5EC69F0A (ntp1.time.nl) Stratum : 2 Ref time (UTC) : Thu May 20 15:19:08 2021 System time : 0.000022151 seconds slow of NTP time Last offset : -0.000041040 seconds RMS offset : 0.000053422 seconds Frequency : 2.286 ppm slow Residual freq : -0.000 ppm Skew : 0.012 ppm Root delay : 0.012706812 seconds Root dispersion : 0.000430042 seconds Update interval : 1029.8 seconds Leap status : Normal
If the command returns the following result, an error occurs in the synchronization:
Leap status : Not synchronised
If the command returns the following result, the
chronyd
service is not running normally:506 Cannot talk to daemon
To make the NTP service start synchronizing as soon as possible, run the following command. Replace pool.ntp.org
with your NTP server.
sudo systemctl stop ntpd.service && \
sudo ntpdate pool.ntp.org && \
sudo systemctl start ntpd.service
To install the NTP service manually on the CentOS 7 system, run the following command:
sudo yum install ntp ntpdate && \
sudo systemctl start ntpd.service && \
sudo systemctl enable ntpd.service
Check and configure the optimal parameters of the operating system
For TiDB in the production environment, it is recommended to optimize the operating system configuration in the following ways:
- Disable THP (Transparent Huge Pages). The memory access pattern of databases tends to be sparse rather than consecutive. If the high-level memory fragmentation is serious, higher latency will occur when THP pages are allocated.
- Set the I/O Scheduler of the storage media to
noop
. For the high-speed SSD storage media, the kernel's I/O scheduling operations can cause performance loss. After the Scheduler is set tonoop
, the performance is better because the kernel directly sends I/O requests to the hardware without other operations. Also, the noop Scheduler is better applicable. - Choose the
performance
mode for the cpufrequ module which controls the CPU frequency. The performance is maximized when the CPU frequency is fixed at its highest supported operating frequency without dynamic adjustment.
Take the following steps to check the current operating system configuration and configure optimal parameters:
Execute the following command to see whether THP is enabled or disabled:
cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
NoteIf
[always] madvise never
is output, THP is enabled. You need to disable it.Execute the following command to see the I/O Scheduler of the disk where the data directory is located. Assume that you create data directories on both sdb and sdc disks:
cat /sys/block/sd[bc]/queue/scheduler
noop [deadline] cfq noop [deadline] cfq
NoteIf
noop [deadline] cfq
is output, the I/O Scheduler for the disk is in thedeadline
mode. You need to change it tonoop
.Execute the following command to see the
ID_SERIAL
of the disk:udevadm info --name=/dev/sdb | grep ID_SERIAL
E: ID_SERIAL=36d0946606d79f90025f3e09a0c1f9e81 E: ID_SERIAL_SHORT=6d0946606d79f90025f3e09a0c1f9e81
NoteIf multiple disks are allocated with data directories, you need to execute the above command several times to record the
ID_SERIAL
of each disk.Execute the following command to see the power policy of the cpufreq module:
cpupower frequency-info --policy
analyzing CPU 0: current policy: frequency should be within 1.20 GHz and 3.10 GHz. The governor "powersave" may decide which speed to use within this range.
NoteIf
The governor "powersave"
is output, the power policy of the cpufreq module ispowersave
. You need to modify it toperformance
. If you use a virtual machine or a cloud host, the output is usuallyUnable to determine current policy
, and you do not need to change anything.Configure optimal parameters of the operating system:
Method one: Use tuned (Recommended)
Execute the
tuned-adm list
command to see the tuned profile of the current operating system:tuned-adm list
Available profiles: - balanced - General non-specialized tuned profile - desktop - Optimize for the desktop use-case - hpc-compute - Optimize for HPC compute workloads - latency-performance - Optimize for deterministic performance at the cost of increased power consumption - network-latency - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance - network-throughput - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks - powersave - Optimize for low power consumption - throughput-performance - Broadly applicable tuning that provides excellent performance across a variety of common server workloads - virtual-guest - Optimize for running inside a virtual guest - virtual-host - Optimize for running KVM guests Current active profile: balanced
The output
Current active profile: balanced
means that the tuned profile of the current operating system isbalanced
. It is recommended to optimize the configuration of the operating system based on the current profile.Create a new tuned profile:
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=36d0946606d79f90025f3e09a0c1fc035)|(ID_SERIAL=36d0946606d79f90025f3e09a0c1f9e81) elevator=noop
The output
include=balanced
means to add the optimization configuration of the operating system to the currentbalanced
profile.Apply the new tuned profile:
tuned-adm profile balanced-tidb-optimal
Method two: Configure using scripts. Skip this method if you already use method one.
Execute the
grubby
command to see the default kernel version:NoteInstall the
grubby
package first before you executegrubby
.grubby --default-kernel
/boot/vmlinuz-3.10.0-957.el7.x86_64
Execute
grubby --update-kernel
to modify the kernel configuration:grubby --args="transparent_hugepage=never" --update-kernel /boot/vmlinuz-3.10.0-957.el7.x86_64
Note--update-kernel
is followed by the actual default kernel version.Execute
grubby --info
to see the modified default kernel configuration:grubby --info /boot/vmlinuz-3.10.0-957.el7.x86_64
Note--info
is followed by the actual default kernel version.index=0 kernel=/boot/vmlinuz-3.10.0-957.el7.x86_64 args="ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet LANG=en_US.UTF-8 transparent_hugepage=never" root=/dev/mapper/centos-root initrd=/boot/initramfs-3.10.0-957.el7.x86_64.img title=CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
Modify the current kernel configuration to immediately disable THP:
echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
Configure the I/O Scheduler in the udev script:
vi /etc/udev/rules.d/60-tidb-schedulers.rules
ACTION=="add|change", SUBSYSTEM=="block", ENV{ID_SERIAL}=="36d0946606d79f90025f3e09a0c1fc035", ATTR{queue/scheduler}="noop" ACTION=="add|change", SUBSYSTEM=="block", ENV{ID_SERIAL}=="36d0946606d79f90025f3e09a0c1f9e81", ATTR{queue/scheduler}="noop"
Apply the udev script:
udevadm control --reload-rules udevadm trigger --type=devices --action=change
Create a service to configure the CPU power policy:
cat >> /etc/systemd/system/cpupower.service << EOF [Unit] Description=CPU performance [Service] Type=oneshot ExecStart=/usr/bin/cpupower frequency-set --governor performance [Install] WantedBy=multi-user.target EOF
Apply the CPU power policy configuration service:
systemctl daemon-reload systemctl enable cpupower.service systemctl start cpupower.service
Execute the following command to verify the THP status:
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
Execute the following command to verify the I/O Scheduler of the disk where the data directory is located:
cat /sys/block/sd[bc]/queue/scheduler
[noop] deadline cfq [noop] deadline cfq
Execute the following command to see the power policy of the cpufreq module:
cpupower frequency-info --policy
analyzing CPU 0: current policy: frequency should be within 1.20 GHz and 3.10 GHz. The governor "performance" may decide which speed to use within this range.
Execute the following commands to modify the
sysctl
parameters: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
Execute the following command to configure the user's
limits.conf
file:cat << EOF >>/etc/security/limits.conf tidb soft nofile 1000000 tidb hard nofile 1000000 tidb soft stack 32768 tidb hard stack 32768 EOF
Manually configure the SSH mutual trust and sudo without password
This section describes how to manually configure the SSH mutual trust and sudo without password. It is recommended to use TiUP for deployment, which automatically configure SSH mutual trust and login without password. If you deploy TiDB clusters using TiUP, ignore this section.
Log in to the target machine respectively using the
root
user account, create thetidb
user and set the login password.useradd tidb && \ passwd tidb
To configure sudo without password, run the following command, and add
tidb ALL=(ALL) NOPASSWD: ALL
to the end of the file:visudo
tidb ALL=(ALL) NOPASSWD: ALL
Use the
tidb
user to log in to the control machine, and run the following command. Replace10.0.1.1
with the IP of your target machine, and enter thetidb
user password of the target machine as prompted. After the command is executed, SSH mutual trust is already created. This applies to other machines as well. Newly createdtidb
users do not have the.ssh
directory. To create such a directory, execute the command that generates the RSA key. To deploy TiDB components on the control machine, configure mutual trust for the control machine and the control machine itself.ssh-keygen -t rsa ssh-copy-id -i ~/.ssh/id_rsa.pub 10.0.1.1
Log in to the control machine using the
tidb
user account, and log in to the IP of the target machine usingssh
. If you do not need to enter the password and can successfully log in, then the SSH mutual trust is successfully configured.ssh 10.0.1.1
[tidb@10.0.1.1 ~]$
After you log in to the target machine using the
tidb
user, run the following command. If you do not need to enter the password and can switch to theroot
user, then sudo without password of thetidb
user is successfully configured.sudo -su root
[root@10.0.1.1 tidb]#
Install the numactl
tool
This section describes how to install the NUMA tool. In online environments, because the hardware configuration is usually higher than required, to better plan the hardware resources, multiple instances of TiDB or TiKV can be deployed on a single machine. In such scenarios, you can use NUMA tools to prevent the competition for CPU resources which might cause reduced performance.
- Binding cores using NUMA is a method to isolate CPU resources and is suitable for deploying multiple instances on highly configured physical machines.
- After completing deployment using
tiup cluster deploy
, you can use theexec
command to perform cluster level management operations.
To install the NUMA tool, take either of the following two methods:
Method 1: Log in to the target node to install NUMA. Take CentOS Linux release 7.7.1908 (Core) as an example.
sudo yum -y install numactl
Method 2: Install NUMA on an existing cluster in batches by running the tiup cluster exec
command.
Follow Deploy a TiDB Cluster Using TiUP to deploy a cluster
tidb-test
. If you have installed a TiDB cluster, you can skip this step.tiup cluster deploy tidb-test v6.1.0 ./topology.yaml --user root [-p] [-i /home/root/.ssh/gcp_rsa]
Run the
tiup cluster exec
command using thesudo
privilege to install NUMA on all the target machines in thetidb-test
cluster:tiup cluster exec tidb-test --sudo --command "yum -y install numactl"
To get help information of the
tiup cluster exec
command, run thetiup cluster exec --help
command.
- Mount the data disk ext4 filesystem with options on the target machines that deploy TiKV
- Check and disable system swap
- Check and stop the firewall service of target machines
- Check and install the NTP service
- Check and configure the optimal parameters of the operating system
- Manually configure the SSH mutual trust and sudo without password
- Install the numactl tool