1. 前言
RHEL(Red Hat Enterprise Linux)10 是 Red Hat 最新的企业级 Linux 版本,适用于服务器、虚拟化及容器化场景。本文详细介绍 RHEL 10 的安装步骤,以及 安装完成后的优化配置,协助你打造一个稳定、安全、高性能的企业级操作系统环境。
2. 准备工作
项目 |
说明 |
安装介质 |
RHEL 10 ISO 镜像(从 Red Hat 官网获取) |
硬件需求 |
CPU ≥ 2 核;内存 ≥ 2GB;硬盘 ≥ 20GB |
网络 |
提议可访问外网以激活订阅和更新 |
权限 |
root 用户或有 sudo 权限的普通用户 |
3. 安装步骤
3.1 获取 ISO
登录 Red Hat 官网,下载 RHEL 10 的官方镜像:
https://access.redhat.com/downloads
3.2 制作启动盘
在 Windows 中使用 Rufus / BalenaEtcher 制作 U 盘启动盘。
在 Linux 中:
sudo dd if=rhel-10.iso of=/dev/sdX bs=4M status=progress
3.3 BIOS/UEFI 设置
- 将启动顺序设置为 U 盘优先
- 若使用虚拟机,加载 ISO 文件并启动
3.4 安装界面
- 选择 Install Red Hat Enterprise Linux 10
- 语言选择 简体中文 或 English
- 键盘布局、时间区域根据需求设置
3.5 磁盘分区
- 提议使用 LVM(逻辑卷管理)
- 挂载点推荐:
- /boot → 1G
- / → 20G+
- swap → 2G 或内存大小的 1~2 倍
- 生产环境可单独分出 /var、/home、/opt
3.6 网络与主机名
- 勾选 自动连接
- 设置主机名:server01.example.com
3.7 软件选择
- 选择 Server with GUI(服务器+图形界面)
- 或 Minimal Install(最小化安装)更精简
3.8 创建用户
- 设置 root 密码
- 创建普通用户并勾选 管理员权限
3.9 开始安装
点击 Begin Installation,等待完成后重启系统。
4. 激活订阅
安装完成后需激活 Red Hat 订阅:
sudo subscription-manager register –username <你的RH账号> –password <密码>
sudo subscription-manager attach –auto
更新系统:
sudo dnf update -y
5. 安装后优化配置
5.1 配置防火墙(firewalld)
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd –zone=public –add-service=ssh –permanent
sudo firewall-cmd –reload
5.2 配置 SELinux
检查状态:
getenforce
推荐保持 Enforcing 模式,若需临时关闭:
sudo setenforce 0
5.3 SSH 加固
- 禁用 root 远程登录:编辑 /etc/ssh/sshd_config
PermitRootLogin no
PasswordAuthentication no
- 使用密钥登录:
ssh-keygen -t rsa
ssh-copy-id user@server_ip
重启 SSH:
sudo systemctl restart sshd
5.4 时区与时间同步
sudo timedatectl set-timezone Asia/Shanghai
sudo dnf install -y chrony
sudo systemctl enable chronyd –now
5.5 常用工具安装
sudo dnf install -y vim net-tools wget curl htop lsof unzip tar git
5.6 开启自动安全更新
sudo dnf install -y dnf-automatic
sudo systemctl enable –now dnf-automatic.timer
5.7 优化内核参数(提高并发和安全性)
编辑 /etc/sysctl.conf:
net.ipv4.ip_forward = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 600
fs.file-max = 65535
使其生效:
sudo sysctl -p
5.8 设置开机自检与日志
sudo systemctl enable auditd
sudo systemctl start auditd
sudo journalctl -xe
6. 性能优化小技巧
优化方向 |
提议 |
服务精简 |
禁用不需要的服务 systemctl disable 服务名 |
内存管理 |
使用 htop 查看内存占用,及时优化 |
SSD 优化 |
如果硬盘是 SSD,启用 TRIM:sudo systemctl enable fstrim.timer |
自动备份 |
配合 rsync 或 tar 进行定期备份 |
7. 常见问题排查
问题 |
解决方案 |
无法激活订阅 |
检查网络 / Red Hat 账户,或使用离线订阅 |
网络不通 |
检查 nmcli 配置或防火墙 |
GUI 无法启动 |
确认已安装 gnome-desktop 并设置 systemctl set-default graphical.target |
8. 总结
通过本文,你可以:
- 快速安装 RHEL 10
- 完成必要的安全加固和性能优化
- 配置关键服务和常用工具
- 提升系统稳定性和安全性
这套流程基本覆盖了企业环境下 RHEL 服务器的标准部署与优化,适合新手和运维人员作为参考。
暂无评论内容