centOS6详细安装步骤以及基础配置
1. centOS6安装
安装前准备:提前下载好CentOS-6.8-x86_64-bin-DVD1.iso镜像文件,推荐下载地址:Download - The CentOS Project
1.1 启动安装程序
- 开启虚拟机,选择「Install or upgrade an existing system」,按回车进入安装界面。
- 跳过介质检测(选择Skip)。
1.2 基础配置
- 语言:建议选择「English」以减少兼容性问题。
- 键盘:默认「U.S. English」。
- 存储设备:选「Basic Storage Devices」,确认「Yes, discard any data」清空虚拟磁盘。
1.3 网络与主机名
- 主机名:自定义(如centos6.8),网络配置可后续通过网卡文件调整。
- 时区:选择「Asia/Shanghai」,取消勾选「System clock uses UTC」。
1.4 分区方案(关键步骤)
- 选择「Create Custom Layout」手动分区。
分区 | 大小 | 文件系统类型 | 挂载点 |
---|---|---|---|
/boot | 200MB | ext4 | /boot |
swap | 内存的2倍(如4GB) | swap | swap |
/ | 剩余全部空间 | ext4 | / |
- 点击「Format」→「Write changes to disk」确认格式化 。
1.5 系统安装
- 设置root密码(需满足长度要求,若提示简单密码选择「Use Anyway」)。
- 选择安装类型:
- Basic Server:最小化服务器环境(无图形界面)。
- Desktop:带图形界面(适合新手)。
1.6 完成安装
- 点击「Reboot」重启,进入系统登录界面。
1.7 初始配置
1.7.1 首次启动
- 接受许可证协议,设置系统时间。
- 可选创建普通用户(建议使用
root
登录后通过useradd
命令创建)。
1.7.2 网络配置
1.7.3 禁用Kdump(可选)
- 编辑
/etc/grub.conf
,删除crashkernel=auto
参数。
2 基础配置
2.1 网络配置
提示:centOS6和centOS7网络配置在会有小的差别,但是总体的步骤还是不变的。
2.1.1 centos6网络配置
- 查看当前IP地址。
ip addr
- 编辑网卡配置文件(需确保网关和DNS正确,否则无法访问外网)。
vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=114.114.114.114
- 重启网络服务。
service network restart
- 测试连通性。
ping www.baidu.com
2.1.2 centos7网络配置
- 查看当前的IP地址。
ip addr
- 编辑网卡配置文件(需确保网关和DNS正确,否则无法访问外网)。
vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DNS2=8.8.8.8
- 重启网络服务。
systemctl restart network
- 测试连通性。
ping www.baidu.com
2.1.3 区别
功能 | CentOS 6 | CentOS 7 |
---|---|---|
网络工具 | ifconfig 和network 服务 | ip 命令和NetworkManager |
防火墙 | iptables | firewalld |
网卡命名规则 | eth0 、eth1 | ens33 、enp0s3 (基于硬件拓扑) |
默认文件系统 | Ext4 | XFS(支持更大文件) |
2.2 修改yum源
注:CentOS 6已经停止维护,官方源不可用,需要更换为归档源或第三方镜像。
2.2.1 备份原始配置
- 备份原始配置,防止误操作。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.2.2 下载并配置阿里云归档源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
2.2.3 手动修正配置文件
sed -i 's/$releasever/6.8/g' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's#centos/#centos-vault/#g' /etc/yum.repos.d/CentOS-Base.repo
2.2.4 解决网络或缓存问题
- 禁用fastestmirror插件(可选)。
sed -i "s/enabled=1/enabled=0/g" /etc/yum/pluginconf.d/fastestmirror.conf #若出现PYCURL ERROR 6或连接超时,需禁用该插件
- 清理并重建缓存。
yum clean all
yum makecache
2.2.5 测试与验证
- 安装测试软件包。
yum install -y tree
- 检查仓库列表,应显示
base
、updates
、extras
仓库状态为可用。
yum repolist
现PYCURL ERROR 6或连接超时,需禁用该插件
- 清理并重建缓存。
~~~bash
yum clean all
yum makecache
2.2.5 测试与验证
- 安装测试软件包。
yum install -y tree
- 检查仓库列表,应显示
base
、updates
、extras
仓库状态为可用。
yum repolist