Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiup: Update THP docs #20070

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 1 addition & 83 deletions check-before-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ Take the `/dev/nvme0n1` data disk as an example:

1. View the data disk.

{{< copyable "shell-root" >}}

```bash
fdisk -l
```
Expand All @@ -36,8 +34,6 @@ Take the `/dev/nvme0n1` data disk as an example:

2. Create the partition.

{{< copyable "shell-root" >}}

```bash
parted -s -a optimal /dev/nvme0n1 mklabel gpt -- mkpart primary ext4 1 -1
```
Expand All @@ -55,8 +51,6 @@ Take the `/dev/nvme0n1` data disk as an example:

3. Format the data disk to the ext4 filesystem.

{{< copyable "shell-root" >}}

```bash
mkfs.ext4 /dev/nvme0n1p1
```
Expand All @@ -65,8 +59,6 @@ Take the `/dev/nvme0n1` data disk as an example:

In this example, the UUID of nvme0n1p1 is `c51eb23b-195c-4061-92a9-3fad812cc12f`.

{{< copyable "shell-root" >}}

```bash
lsblk -f
```
Expand All @@ -84,8 +76,6 @@ Take the `/dev/nvme0n1` data disk as an example:

5. Edit the `/etc/fstab` file and add the `nodelalloc` mount options.

{{< copyable "shell-root" >}}

```bash
vi /etc/fstab
```
Expand All @@ -96,8 +86,6 @@ Take the `/dev/nvme0n1` data disk as an example:

6. Mount the data disk.

{{< copyable "shell-root" >}}

```bash
mkdir /data1 && \
systemctl daemon-reload && \
Expand All @@ -106,8 +94,6 @@ Take the `/dev/nvme0n1` data disk as an example:

7. Check using the following command.

{{< copyable "shell-root" >}}

```bash
mount -t ext4
```
Expand Down Expand Up @@ -178,33 +164,25 @@ The rest of this section describes how to stop the firewall service of a target

1. Check the firewall status. Take CentOS Linux release 7.7.1908 (Core) as an example.

{{< copyable "shell-regular" >}}

```shell
sudo firewall-cmd --state
sudo systemctl status firewalld.service
```

2. Stop the firewall service.

{{< copyable "shell-regular" >}}

```bash
sudo systemctl stop firewalld.service
```

3. Disable automatic start of the firewall service.

{{< copyable "shell-regular" >}}

```bash
sudo systemctl disable firewalld.service
```

4. Check the firewall status.

{{< copyable "shell-regular" >}}

```bash
sudo systemctl status firewalld.service
```
Expand All @@ -219,8 +197,6 @@ To check whether the NTP service is installed and whether it synchronizes with t

1. Run the following command. If it returns `running`, then the NTP service is running.

{{< copyable "shell-regular" >}}

```bash
sudo systemctl status ntpd.service
```
Expand All @@ -233,8 +209,6 @@ To check whether the NTP service is installed and whether it synchronizes with t

- If it returns `Unit ntpd.service could not be found.`, then try the following command to see whether your system is configured to use `chronyd` instead of `ntpd` to perform clock synchronization with NTP:

{{< copyable "shell-regular" >}}

```bash
sudo systemctl status chronyd.service
```
Expand All @@ -255,8 +229,6 @@ To check whether the NTP service is installed and whether it synchronizes with t
>
> For the Ubuntu system, you need to install the `ntpstat` package.

{{< copyable "shell-regular" >}}

```bash
ntpstat
```
Expand Down Expand Up @@ -287,8 +259,6 @@ To check whether the NTP service is installed and whether it synchronizes with t
>
> This only applies to systems that use Chrony instead of NTPd.

{{< copyable "shell-regular" >}}

```bash
chronyc tracking
```
Expand Down Expand Up @@ -325,8 +295,6 @@ To check whether the NTP service is installed and whether it synchronizes with t

To make the NTP service start synchronizing as soon as possible, run the following command. Replace `pool.ntp.org` with your NTP server.

{{< copyable "shell-regular" >}}

```bash
sudo systemctl stop ntpd.service && \
sudo ntpdate pool.ntp.org && \
Expand All @@ -335,8 +303,6 @@ sudo systemctl start ntpd.service

To install the NTP service manually on the CentOS 7 system, run the following command:

{{< copyable "shell-regular" >}}

```bash
sudo yum install ntp ntpdate && \
sudo systemctl start ntpd.service && \
Expand All @@ -359,8 +325,6 @@ Take the following steps to check the current operating system configuration and

1. Execute the following command to see whether THP is enabled or disabled:

{{< copyable "shell-regular" >}}

```bash
cat /sys/kernel/mm/transparent_hugepage/enabled
```
Expand Down Expand Up @@ -407,8 +371,6 @@ Take the following steps to check the current operating system configuration and

3. Execute the following command to see the `ID_SERIAL` of the disk:

{{< copyable "shell-regular" >}}

```bash
udevadm info --name=/dev/sdb | grep ID_SERIAL
```
Expand All @@ -425,8 +387,6 @@ Take the following steps to check the current operating system configuration and

4. Execute the following command to see the power policy of the cpufreq module:

{{< copyable "shell-regular" >}}

```bash
cpupower frequency-info --policy
```
Expand All @@ -447,8 +407,6 @@ Take the following steps to check the current operating system configuration and

1. Execute the `tuned-adm list` command to see the tuned profile of the current operating system:

{{< copyable "shell-regular" >}}

```bash
tuned-adm list
```
Expand All @@ -472,8 +430,6 @@ Take the following steps to check the current operating system configuration and

2. Create a new tuned profile:

{{< copyable "shell-regular" >}}

```bash
mkdir /etc/tuned/balanced-tidb-optimal/
vi /etc/tuned/balanced-tidb-optimal/tuned.conf
Expand Down Expand Up @@ -502,8 +458,6 @@ Take the following steps to check the current operating system configuration and
>
> If your device uses the `noop` or `none` I/O Scheduler, skip this step. No Scheduler configuration is needed in the tuned profile.

{{< copyable "shell-regular" >}}

```bash
tuned-adm profile balanced-tidb-optimal
```
Expand All @@ -516,8 +470,6 @@ Take the following steps to check the current operating system configuration and
>
> Install the `grubby` package first before you execute `grubby`.

{{< copyable "shell-regular" >}}

```bash
grubby --default-kernel
```
Expand All @@ -528,20 +480,16 @@ Take the following steps to check the current operating system configuration and

2. Execute `grubby --update-kernel` to modify the kernel configuration:

{{< copyable "shell-regular" >}}

```bash
grubby --args="transparent_hugepage=never" --update-kernel `grubby --default-kernel`
```

> **Note:**
>
> You can also specify the actual version number after `--update-kernel`, for example, `--update-kernel /boot/vmlinuz-3.10.0-957.el7.x86_64`.
> You can also specify the actual version number after `--update-kernel`, for example, `--update-kernel /boot/vmlinuz-3.10.0-957.el7.x86_64` or `ALL`.

3. Execute `grubby --info` to see the modified default kernel configuration:

{{< copyable "shell-regular" >}}

```bash
grubby --info /boot/vmlinuz-3.10.0-957.el7.x86_64
```
Expand All @@ -561,17 +509,13 @@ Take the following steps to check the current operating system configuration and

4. Modify the current kernel configuration to immediately disable THP:

{{< copyable "shell-regular" >}}

```bash
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
```

5. Configure the I/O Scheduler in the udev script:

{{< copyable "shell-regular" >}}

```bash
vi /etc/udev/rules.d/60-tidb-schedulers.rules
```
Expand All @@ -588,17 +532,13 @@ Take the following steps to check the current operating system configuration and
>
> If your device uses the `noop` or `none` I/O Scheduler, skip this step. No udev rules configuration is needed.

{{< copyable "shell-regular" >}}

```bash
udevadm control --reload-rules
udevadm trigger --type=devices --action=change
```

7. Create a service to configure the CPU power policy:

{{< copyable "shell-regular" >}}

```bash
cat >> /etc/systemd/system/cpupower.service << EOF
[Unit]
Expand All @@ -613,8 +553,6 @@ Take the following steps to check the current operating system configuration and

8. Apply the CPU power policy configuration service:

{{< copyable "shell-regular" >}}

```bash
systemctl daemon-reload
systemctl enable cpupower.service
Expand All @@ -623,8 +561,6 @@ Take the following steps to check the current operating system configuration and

6. Execute the following command to verify the THP status:

{{< copyable "shell-regular" >}}

```bash
cat /sys/kernel/mm/transparent_hugepage/enabled
```
Expand All @@ -635,8 +571,6 @@ Take the following steps to check the current operating system configuration and

7. Execute the following command to verify the I/O Scheduler of the disk where the data directory is located:

{{< copyable "shell-regular" >}}

```bash
cat /sys/block/sd[bc]/queue/scheduler
```
Expand All @@ -648,8 +582,6 @@ Take the following steps to check the current operating system configuration and

8. Execute the following command to see the power policy of the cpufreq module:

{{< copyable "shell-regular" >}}

```bash
cpupower frequency-info --policy
```
Expand All @@ -662,8 +594,6 @@ Take the following steps to check the current operating system configuration and

9. Execute the following commands to modify the `sysctl` parameters:

{{< copyable "shell-regular" >}}

```bash
echo "fs.file-max = 1000000">> /etc/sysctl.conf
echo "net.core.somaxconn = 32768">> /etc/sysctl.conf
Expand All @@ -684,8 +614,6 @@ Take the following steps to check the current operating system configuration and

10. Execute the following command to configure the user's `limits.conf` file:

{{< copyable "shell-regular" >}}

```bash
cat << EOF >>/etc/security/limits.conf
tidb soft nofile 1000000
Expand All @@ -701,17 +629,13 @@ This section describes how to manually configure the SSH mutual trust and sudo w

1. Log in to the target machine respectively using the `root` user account, create the `tidb` user and set the login password.

{{< copyable "shell-root" >}}

```bash
useradd tidb && \
passwd tidb
```

2. To configure sudo without password, run the following command, and add `tidb ALL=(ALL) NOPASSWD: ALL` to the end of the file:

{{< copyable "shell-root" >}}

```bash
visudo
```
Expand All @@ -722,17 +646,13 @@ This section describes how to manually configure the SSH mutual trust and sudo w

3. Use the `tidb` user to log in to the control machine, and run the following command. Replace `10.0.1.1` with the IP of your target machine, and enter the `tidb` 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 created `tidb` 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.

{{< copyable "shell-regular" >}}

```bash
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub 10.0.1.1
```

4. Log in to the control machine using the `tidb` user account, and log in to the IP of the target machine using `ssh`. If you do not need to enter the password and can successfully log in, then the SSH mutual trust is successfully configured.

{{< copyable "shell-regular" >}}

```bash
ssh 10.0.1.1
```
Expand All @@ -743,8 +663,6 @@ This section describes how to manually configure the SSH mutual trust and sudo w

5. 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 the `root` user, then sudo without password of the `tidb` user is successfully configured.

{{< copyable "shell-regular" >}}

```bash
sudo -su root
```
Expand Down
10 changes: 10 additions & 0 deletions tiup/tiup-component-cluster-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ Check the values of the following kernel parameters:

Check whether THP is enabled on the target machine. It is recommended to disable THP.

To check if THP is enabled you can run this:

```
cat /sys/kernel/mm/transparent_hugepage/enabled
```

If it is not set to `never`, you can change it with `grubby --update-kernel=ALL --args="transparent_hugepage=never"`.

To change the running configuration, either reboot or run `echo never > /sys/kernel/mm/transparent_hugepage/enabled`.

### System limits

Check the limit values in the `/etc/security/limits.conf` file:
Expand Down
1 change: 1 addition & 0 deletions tune-operating-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ It is **NOT** recommended to use THP for database applications, because database
```shell
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
grubby --update-kernel="$KERNEL" --args='transparent_hugepage=never'
```

### Memory—virtual memory parameters
Expand Down
Loading