Skip to content

Commit

Permalink
tiup: Update THP docs (#20070) (#20139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Jan 23, 2025
1 parent f4d7647 commit ccbb487
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 83 deletions.
84 changes: 1 addition & 83 deletions check-before-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Take the `/dev/nvme0n1` data disk as an example:

1. View the data disk.

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

```bash
fdisk -l
```
Expand All @@ -35,8 +33,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 @@ -54,8 +50,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 @@ -64,8 +58,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 @@ -83,8 +75,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 @@ -95,8 +85,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 @@ -105,8 +93,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 @@ -177,33 +163,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 @@ -218,8 +196,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 @@ -232,8 +208,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 @@ -254,8 +228,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 @@ -286,8 +258,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 @@ -324,8 +294,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 @@ -334,8 +302,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 @@ -358,8 +324,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 @@ -406,8 +370,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 @@ -424,8 +386,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 @@ -446,8 +406,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 @@ -471,8 +429,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 @@ -501,8 +457,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 @@ -515,8 +469,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 @@ -527,20 +479,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 @@ -560,17 +508,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 @@ -587,17 +531,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 @@ -612,8 +552,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 @@ -622,8 +560,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 @@ -634,8 +570,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 @@ -647,8 +581,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 @@ -661,8 +593,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 @@ -683,8 +613,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 @@ -700,17 +628,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 @@ -721,17 +645,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 @@ -742,8 +662,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 @@ -69,6 +69,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

0 comments on commit ccbb487

Please sign in to comment.