引言

CentOS Stream 是一个由 CentOS 社区维护的免费企业级 Linux 发行版,它提供了与 Red Hat Enterprise Linux (RHEL) 相似的技术预览。CentOS Stream 10 作为最新的版本,提供了许多改进和新的功能。本文将为您详细讲解如何掌握 CentOS Stream 10,并轻松配置一个高效系统。

系统安装

1. 准备安装介质

首先,您需要下载 CentOS Stream 10 的安装镜像。您可以从 CentOS 官方网站下载。

2. 创建启动盘

使用工具如 Rufus 或 balenaEtcher 将下载的镜像烧录到 USB 启动盘。

3. 启动计算机并安装

重启计算机,进入 BIOS 设置,将 USB 启动盘设置为首选启动设备。启动计算机后,按照安装向导进行操作。

系统配置

1. 更新系统

安装完成后,首先更新系统:

sudo dnf update -y 

2. 设置网络

确保您的网络配置正确,可以使用以下命令检查网络连接:

ping google.com 

如果需要配置静态 IP 地址,编辑 /etc/sysconfig/network-scripts/ifcfg-eth0(根据您的网络接口名修改):

sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 

设置以下参数:

BOOTPROTO=static ONBOOT=yes IPADDR=192.168.1.100 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 DNS1=8.8.8.8 DNS2=8.8.4.4 

重启网络服务:

sudo systemctl restart network 

3. 安装常用软件

使用以下命令安装常用软件:

sudo dnf install -y net-tools curl git nano htop tree 

4. 配置用户权限

为提高安全性,删除默认的 root 用户:

sudo userdel -r root 

创建新用户并设置密码:

sudo useradd -m -s /bin/bash username sudo passwd username 

将新用户添加到 sudo 组:

sudo usermod -aG sudo username 

高效系统配置

1. 系统优化

a. 关闭不必要的系统服务

sudo systemctl disable cups.service sudo systemctl disable firewalld.service 

b. 优化内核参数

编辑 /etc/sysctl.conf

sudo vi /etc/sysctl.conf 

添加以下参数:

vm.swappiness = 10 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 

应用配置:

sudo sysctl -p 

2. 使用 Docker

安装 Docker:

sudo dnf install -y dnf-plugins-core sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo sudo dnf install -y containerd.io docker-ce docker-ce-cli sudo systemctl start docker sudo systemctl enable docker 

配置 Docker:

sudo groupadd docker sudo usermod -aG docker $USER newgrp docker 

3. 安装 Nginx

安装 Nginx:

sudo dnf install -y nginx sudo systemctl start nginx sudo systemctl enable nginx 

配置 Nginx:

sudo vi /etc/nginx/nginx.conf 

根据您的需求进行配置。

总结

通过以上步骤,您已经掌握了 CentOS Stream 10 的基本安装和配置。接下来,您可以继续优化和扩展您的系统,以满足您的特定需求。希望本文能帮助您轻松配置一个高效系统。