免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1804 | 回复: 2
打印 上一主题 下一主题

linux 系统优化- Centos [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-27 18:40 |只看该作者 |倒序浏览



             CentOS 系统优化
        系统环境部署及调整
1. 检查系统是否正常
   # more /var/log/messages   (检查有无系统内核级错误信息)
   # dmesg (检查硬件设备是否有错误信息)
   # ifconfig(检查网卡设置是否正确)
   # ping
www.163.com
  (检查网络是否正常)
2. 关闭不需要的服务
   # ntsysv
   以下仅列出需要启动的服务,未列出的服务一律关闭:
   crond
   lighttpd //之前添加的web服务
   irqbalance (仅当服务器CPU为S.M.P架构或支持双核心、HT技术时,才需开启,否则关闭。)
   mysql //之前添加的mysql服务
   microcode_ctl
   network
   random
   sendmail
   sshd
   syslog
3. 对TCP/IP网络参数进行调整,加强抗SYN Flood能力
   # echo 'net.ipv4.tcp_syncookies = 1' >> /etc/sysctl.conf
   # sysctl -p
4. 配置yum
   # rpm --import /usr/share/doc/centos-release-5/RPM-GPG-KEY-CentOS-5 //导入RPM包的Key
   # yum list | tee /etc/yum.list
5. 修改命令history记录
   # vi /etc/profile
     找到 HISTSIZE=1000 改为 HISTSIZE=50
6. 定时校正服务器时间
   # yum install ntp
   # crontab -e
加入一行:
*/15 * * * * ntpdate 210.72.145.44
## 210.72.145.44 为中国国家授时中心服务器地址。
7. 重新启动系统
   # init 6
8. 使用 yum 程序安装所需开发包(以下为标准的 RPM 包名称)
   gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel

[8] 定义yum的非官方库
  在服务器构建的过程中,我们将要用到的一些工具不存在于
CentOS
中yum的官方库中,所以需要定义yum的非官方库文件,让一些必需的工具通过yum也能够安装。
[root@sample ~]#vi /etc/yum.repos.d/dag.repo ← 建立dag.repo,定义非官方库
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
[root@sample ~]#rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt ← 导入非官方库的GPG
[9] 停止打印服务
  如果不准备提供打印服务,停止默认被设置为自动启动的打印服务。
root@sample ~]#/etc/rc.d/init.d/cups stop ← 停止打印服务
Stopping cups:            [OK]    ← 停止服务成功,出现“OK”
[root@sample ~]#chkconfig cups off ← 禁止打印服务自动启动
[root@sample ~]#chkconfig --list cups ← 确认打印服务自启动设置状态
cups0:off 1:off 2:off 3:off 4:off 5:off 6:off ← 0-6都为off的状态就OK(当前打印服务自启动被禁止中)
[10] 停止ipv6
  在CentOS默认的状态下,ipv6是被启用的状态。因为我们不使用ipv6,所以,停止ipv6,以最大限度保证安全和快速。
  首先再次确认一下ipv6功能是不是被启动的状态。
root@sample ~]#ifconfig -a ← 列出全部网络接口信息
eth0 Link encap:Ethernet HWaddr 00:0C:29:B6:16:A3
inet addr:192.168.0.13 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb6:16a3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:84 errors:0 dropped:0 overruns:0 frame.:0
TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10288 (10.0 KiB) TX bytes:9337 (9.1 KiB)
Interrupt:185 Base address:0x1400
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame.:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:952 (952.0 b) TX bytes:952 (952.0 b)
sit0 Link encap:IPv6-in-IPv4 ← 确认ipv6是被启动的状态
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame.:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
  然后修改相应配置文件,停止ipv6。
[root@sample ~]#vi /etc/modprobe.conf ← 修改相应配置文件,添加如下行到文尾:
alias net-pf-10 off
alias ipv6 off
[root@sample ~]#shutdown -r now ← 重新启动系统,使设置生效
  最后确认ipv6的功能已经被关闭。
root@sample ~]#ifconfig -a ← 列出全部网络接口信息
eth0 Link encap:Ethernet HWaddr 00:0C:29:B6:16:A3
inet addr:192.168.0.13 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb6:16a3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:84 errors:0 dropped:0 overruns:0 frame.:0
TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10288 (10.0 KiB) TX bytes:9337 (9.1 KiB)
Interrupt:185 Base address:0x1400lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame.:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:952 (952.0 b) TX bytes:952 (952.0 b)
(确认ipv6的相关信息没有被列出,说明ipv6功能已被关闭。)




本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/69106/showart_709574.html

论坛徽章:
0
2 [报告]
发表于 2008-06-11 09:04 |只看该作者
很好很强大!

不过还不全.

系统优化调节,进程精简.还没有说.

论坛徽章:
0
3 [报告]
发表于 2008-06-16 17:19 |只看该作者
支持一下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP