有的时候安装centos6.2时,由于各种原因无法连接网络,自然在连网状态下的yum就无法使用了。

那么在断网情况下,有办法使用yum吗?确实有的,centos已经帮我们考虑好了喔。
 
1、修改CentOS-Media.repo文件
打开 /etc/yum.repos.d/ 目录,可以看到下面有3个文件
其中 CentOS-Base.repo 就是正常联网情况下使用的设置,打开文件可以看到一堆http的地址,不能联网自然就不能用了。
其中还有一个文件CentOS-Media.repo就是从本地设备安装软件的设置啦。打开文件:设置 baseurl=file://本地的文件目录
例如我光驱是/media/CentOS_6.2_Final/, 那么我的baseurl=file:///media/CentOS_6.2_Final/
 
2、使用 yum --disablerepo=* --enablerepo=c6-media [command]
保存后还是不能直接使用yum,查看CentOS-Media.repo这个文件,发现文件上面有说明,要使用
[plain] view plaincopy
yum --disablerepo=* --enablerepo=c6-media [command] 
这个命令才能正常执行。
测试一下,搜索gcc:
[plain] view plaincopy
yum --disablerepo=* --enablerepo=c6-media search gcc 
 
可以来正常使用了。
 

---------------

文章介绍CentOS6.x 系统安装好后的初始化配置,主要为系统 便捷设置,安全设置以及系统优化
本文安装系统为CentOS-6.2-x86_64-minimal,即CentOS6.2(64位)的最小安装包,和桌面环境安装有些小区别,不过本质是一样的.

一.常规设置

1.安装EPEL和RPMFORGE软件仓库

rpm -Uvh http://download.Fedora.RedHat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
#add the rpmforge
rpm -Uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag

2.关闭selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

3. SSH配置 关闭GSSAPIAuth和DNS反解析,提供ssh连接速度

sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
service sshd restart

4. 关闭ipv6(根据需求)

cat > /etc/modprobe.d/ipv6.conf << EOF
alias net-pf-10 off
options ipv6 disable=1
EOF

二.安全设置

1. 更新系统

 

三.系统优化

1.系统内核参数设置

cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
EOF
/sbin/sysctl -p

 

2.关闭不必要的服务

#蓝牙服务
chkconfig bluetooth off
#打印服务
chkconfig cups off
#ipv6的iptables
chkconfig ip6tables off
#yum更新服务
chkconfig yum-updatesd off
# sendmail服务
chkconfig sendmail off

参考:

http://www.talaland.com/centos6-x-system-init-configuration/

http://info.zgsj.com/html/xwpd/sh_678_2340.html

-----------