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 (#19672) #19682

Merged
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 @@ -21,8 +21,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

1. 查看数据盘。

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

```bash
fdisk -l
```
Expand All @@ -33,8 +31,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

2. 创建分区。

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

```bash
parted -s -a optimal /dev/nvme0n1 mklabel gpt -- mkpart primary ext4 1 -1
```
Expand All @@ -52,8 +48,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

3. 格式化文件系统。

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

```bash
mkfs.ext4 /dev/nvme0n1p1
```
Expand All @@ -62,8 +56,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

本例中 `nvme0n1p1` 的 UUID 为 `c51eb23b-195c-4061-92a9-3fad812cc12f`。

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

```bash
lsblk -f
```
Expand All @@ -81,8 +73,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

5. 编辑 `/etc/fstab` 文件,添加 `nodelalloc` 挂载参数。

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

```bash
vi /etc/fstab
```
Expand All @@ -93,8 +83,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

6. 挂载数据盘。

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

```bash
mkdir /data1 && \
systemctl daemon-reload && \
Expand All @@ -103,8 +91,6 @@ summary: 了解部署 TiDB 前的环境检查操作。

7. 执行以下命令,如果文件系统为 ext4,并且挂载参数中包含 `nodelalloc`,则表示已生效。

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

```bash
mount -t ext4
```
Expand Down Expand Up @@ -171,33 +157,25 @@ TiDB 的部分操作需要向服务器写入临时文件,因此需要确保运

1. 检查防火墙状态(以 CentOS Linux release 7.7.1908 (Core) 为例)

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

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

2. 关闭防火墙服务

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

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

3. 关闭防火墙自动启动服务

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

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

4. 检查防火墙状态

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

```bash
sudo systemctl status firewalld.service
```
Expand All @@ -210,8 +188,6 @@ TiDB 是一套分布式数据库系统,需要节点间保证时间的同步,

1. 执行以下命令,如果输出 `running` 表示 NTP 服务正在运行:

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

```bash
sudo systemctl status ntpd.service
```
Expand All @@ -224,8 +200,6 @@ TiDB 是一套分布式数据库系统,需要节点间保证时间的同步,

- 若返回报错信息 `Unit ntpd.service could not be found.`,请尝试执行以下命令,以查看与 NTP 进行时钟同步所使用的系统配置是 `chronyd` 还是 `ntpd`:

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

```bash
sudo systemctl status chronyd.service
```
Expand All @@ -246,8 +220,6 @@ TiDB 是一套分布式数据库系统,需要节点间保证时间的同步,
>
> Ubuntu 系统需安装 `ntpstat` 软件包。

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

```bash
ntpstat
```
Expand Down Expand Up @@ -278,8 +250,6 @@ TiDB 是一套分布式数据库系统,需要节点间保证时间的同步,
>
> 该操作仅适用于使用 Chrony 的系统,不适用于使用 NTPd 的系统。

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

```bash
chronyc tracking
```
Expand Down Expand Up @@ -316,8 +286,6 @@ TiDB 是一套分布式数据库系统,需要节点间保证时间的同步,

如果要使 NTP 服务尽快开始同步,执行以下命令。可以将 `pool.ntp.org` 替换为你的 NTP 服务器:

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

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

如果要在 CentOS 7 系统上手动安装 NTP 服务,可执行以下命令:

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

```bash
sudo yum install ntp ntpdate && \
sudo systemctl start ntpd.service && \
Expand All @@ -350,8 +316,6 @@ sudo systemctl enable ntpd.service

1. 执行以下命令查看透明大页的开启状态。

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

```bash
cat /sys/kernel/mm/transparent_hugepage/enabled
```
Expand Down Expand Up @@ -398,8 +362,6 @@ sudo systemctl enable ntpd.service

3. 执行以下命令查看磁盘的唯一标识 `ID_SERIAL`。

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

```bash
udevadm info --name=/dev/sdb | grep ID_SERIAL
```
Expand All @@ -416,8 +378,6 @@ sudo systemctl enable ntpd.service

4. 执行以下命令查看 cpufreq 模块选用的节能策略。

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

```bash
cpupower frequency-info --policy
```
Expand All @@ -438,8 +398,6 @@ sudo systemctl enable ntpd.service

1. 执行 `tuned-adm list` 命令查看当前操作系统的 tuned 策略。

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

```bash
tuned-adm list
```
Expand All @@ -463,8 +421,6 @@ sudo systemctl enable ntpd.service

2. 创建新的 tuned 策略。

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

```bash
mkdir /etc/tuned/balanced-tidb-optimal/
vi /etc/tuned/balanced-tidb-optimal/tuned.conf
Expand Down Expand Up @@ -493,8 +449,6 @@ sudo systemctl enable ntpd.service
>
> 如果已经使用 `noop` 或 `none` I/O 调度器,则无需在 tuned 策略中配置调度器相关的内容,可以跳过此步骤。

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

```bash
tuned-adm profile balanced-tidb-optimal
```
Expand All @@ -507,8 +461,6 @@ sudo systemctl enable ntpd.service
>
> 需安装 `grubby` 软件包。

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

```bash
grubby --default-kernel
```
Expand All @@ -519,20 +471,16 @@ sudo systemctl enable ntpd.service

2. 执行 `grubby --update-kernel` 命令修改内核配置。

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

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

> **注意:**
>
> 你也可以在 `--update-kernel` 后指定实际的版本号,例如:`--update-kernel /boot/vmlinuz-3.10.0-957.el7.x86_64`。
> 你也可以在 `--update-kernel` 后指定实际的版本号,例如:`--update-kernel /boot/vmlinuz-3.10.0-957.el7.x86_64` 或 `ALL`

3. 执行 `grubby --info` 命令查看修改后的默认内核配置。

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

```bash
grubby --info /boot/vmlinuz-3.10.0-957.el7.x86_64
```
Expand All @@ -552,17 +500,13 @@ sudo systemctl enable ntpd.service

4. 修改当前的内核配置立即关闭透明大页。

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

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

5. 配置 udev 脚本应用 IO 调度器策略。

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

```bash
vi /etc/udev/rules.d/60-tidb-schedulers.rules
```
Expand All @@ -579,17 +523,13 @@ sudo systemctl enable ntpd.service
>
> 对于已经使用 `noop` 或 `none` I/O 调度器的设备,无需配置 udev 规则,可以跳过此步骤。

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

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

7. 创建 CPU 节能策略配置服务。

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

```bash
cat >> /etc/systemd/system/cpupower.service << EOF
[Unit]
Expand All @@ -604,8 +544,6 @@ sudo systemctl enable ntpd.service

8. 应用 CPU 节能策略配置服务。

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

```bash
systemctl daemon-reload
systemctl enable cpupower.service
Expand All @@ -614,8 +552,6 @@ sudo systemctl enable ntpd.service

6. 执行以下命令验证透明大页的状态。

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

```bash
cat /sys/kernel/mm/transparent_hugepage/enabled
```
Expand All @@ -626,8 +562,6 @@ sudo systemctl enable ntpd.service

7. 执行以下命令验证数据目录所在磁盘的 I/O 调度器。

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

```bash
cat /sys/block/sd[bc]/queue/scheduler
```
Expand All @@ -639,8 +573,6 @@ sudo systemctl enable ntpd.service

8. 执行以下命令查看 cpufreq 模块选用的节能策略。

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

```bash
cpupower frequency-info --policy
```
Expand All @@ -653,8 +585,6 @@ sudo systemctl enable ntpd.service

9. 执行以下命令修改 sysctl 参数。

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

```bash
echo "fs.file-max = 1000000">> /etc/sysctl.conf
echo "net.core.somaxconn = 32768">> /etc/sysctl.conf
Expand All @@ -675,8 +605,6 @@ sudo systemctl enable ntpd.service

10. 执行以下命令配置用户的 limits.conf 文件。

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

```bash
cat << EOF >>/etc/security/limits.conf
tidb soft nofile 1000000
Expand All @@ -692,17 +620,13 @@ sudo systemctl enable ntpd.service

1. 以 `root` 用户依次登录到部署目标机器创建 `tidb` 用户并设置登录密码。

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

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

2. 执行以下命令,将 `tidb ALL=(ALL) NOPASSWD: ALL` 添加到文件末尾,即配置好 sudo 免密码。

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

```bash
visudo
```
Expand All @@ -713,17 +637,13 @@ sudo systemctl enable ntpd.service

3. 以 `tidb` 用户登录到中控机,执行以下命令。将 `10.0.1.1` 替换成你的部署目标机器 IP,按提示输入部署目标机器 `tidb` 用户密码,执行成功后即创建好 SSH 互信,其他机器同理。新建的 `tidb` 用户下没有 `.ssh` 目录,需要执行生成 rsa 密钥的命令来生成 `.ssh` 目录。如果要在中控机上部署 TiDB 组件,需要为中控机和中控机自身配置互信。

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

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

4. 以 `tidb` 用户登录中控机,通过 `ssh` 的方式登录目标机器 IP。如果不需要输入密码并登录成功,即表示 SSH 互信配置成功。

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

```bash
ssh 10.0.1.1
```
Expand All @@ -734,8 +654,6 @@ sudo systemctl enable ntpd.service

5. 以 `tidb` 用户登录到部署目标机器后,执行以下命令,不需要输入密码并切换到 `root` 用户,表示 `tidb` 用户 sudo 免密码配置成功。

{{< 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 @@ summary: TiUP Cluster 提供了 `check` 子命令,用于检查集群的硬件

检查部署机是否启用透明大页:建议禁用透明大页。

要检查 THP 是否启用,可以运行以下命令:

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

如果结果不是 `never`,你可以使用 `grubby --update-kernel=ALL --args="transparent_hugepage=never"` 修改。

要更改当前运行的配置,你可以选择重启系统,或者运行 `echo never > /sys/kernel/mm/transparent_hugepage/enabled`。

### 系统限制

检查 /etc/security/limits.conf 中各项 limit 值:
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 @@ cpufreq 是一个动态调整 CPU 频率的模块,可支持五种模式。为
```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'
```

### 内存——虚拟内存参数
Expand Down
Loading