奋斗
努力

Linux CentOS 7.9 64 位操作系统的服务器?

云计算

在Linux CentOS 7.9 64位操作系统的服务器上,以下是关键点总结及常见操作指南:


1. 系统基础信息

  • 版本确认

    cat /etc/centos-release  # 输出示例:CentOS Linux release 7.9.2009 (Core)
    uname -m                # 确认架构(应为x86_64)
  • 内核版本

    uname -r  # 示例:3.10.0-1160.el7.x86_64

2. 系统管理命令

  • 服务管理

    systemctl start httpd      # 启动服务
    systemctl enable httpd     # 设置开机自启
    systemctl status httpd     # 查看状态
  • 防火墙(firewalld)

    firewall-cmd --zone=public --add-port=80/tcp --permanent  # 开放端口
    firewall-cmd --reload                                     # 重载配置
  • SELinux管理

    getenforce                         # 查看状态(Enforcing/Permissive/Disabled)
    setenforce 0                       # 临时关闭(Permissive模式)
    vi /etc/selinux/config             # 永久修改为SELINUX=disabled

3. 软件包管理(YUM)

  • 常用操作

    yum update -y                      # 更新所有软件包
    yum install httpd -y               # 安装软件
    yum remove httpd                   # 卸载软件
    yum list installed                 # 查看已安装包
  • EPEL仓库

    yum install epel-release -y        # 启用EPEL扩展仓库

4. 网络配置

  • IP地址/DNS

    vi /etc/sysconfig/network-scripts/ifcfg-ens192  # 编辑网卡配置(根据实际网卡名)
    systemctl restart network                       # 重启网络服务
  • 主机名

    hostnamectl set-hostname server1.example.com    # 修改主机名

5. 安全建议

  • 禁用root SSH登录

    vi /etc/ssh/sshd_config          # 修改为PermitRootLogin no
    systemctl restart sshd
  • 用户与sudo权限

    adduser username                 # 创建新用户
    passwd username                  # 设置密码
    usermod -aG wheel username       # 加入sudo组(需先配置sudoers)

6. 维护与监控

  • 磁盘空间

    df -h                            # 查看磁盘使用
    du -sh /var/log                 # 检查目录大小
  • 日志查看

    journalctl -xe                   # 查看系统日志
    tail -f /var/log/messages        # 实时监控日志

7. 注意事项

  • CentOS 7 EOL
    CentOS 7已于2024年6月30日结束官方支持,建议:

    • 迁移至 CentOS StreamRocky LinuxAlmaLinux
    • 若需继续使用,配置第三方仓库(如ELRepo)或付费扩展支持(如Red Hat ELS)。

常见问题解决

  • YUM报错

    yum clean all && yum makecache    # 清除缓存并重建
  • 时间同步

    yum install chrony -y
    systemctl enable --now chronyd
    chronyc sources                  # 检查同步状态

如需更具体的配置或问题排查,请提供详细需求或错误信息!

未经允许不得转载:云服务器 » Linux CentOS 7.9 64 位操作系统的服务器?