CentOS6 system optimization guide

Source: Internet
Author: User
The company's development environment uses centos + virtualbox, but has made some basic optimizations to facilitate development. since it is an internal development environment, the first thing we can ensure is that development is convenient to avoid unexpected events, other security and performance are basically not required. 1. disable iptables and selinuxiptables: serviceiptablesstopchkconfigiptablesoffservi

The company's development environment usesCentos+ Virtualbox is only optimized to facilitate development. since it is an internal development environment, the first thing to ensure is that development is convenient and less time-consuming. other security and performance are basically not required.

1. disableIptablesAnd selinux

Iptables:
Service iptables stop
Chkconfig iptables off
Service ip6tables stop
Chkconfig ip6tables offselinux:
Temporarily disable setenforce 0

Permanently disable vi/etc/selinux/config "more-11"> add or change to SELINUX = disabled
Note that the restart takes effect.

2. adjust the maximum number of opened files to 65535.

The default value is 1024.
Vi/etc/security/limits. conf
Join


*
Soft nofile
65535



*
Hard nofile
65535


3. disable ipv6

Vi/etc/modprobe. d/dist. conf
Add at last

Alias net-pf-10 off
After alias ipv6 is off, restart your computer.

4. perform time correction at four o'clock every day with the National Time Service Center

Vi/etc/crontab
Join
* 4 ***/usr/sbin/ntpdate 210.72.145.44

5. by default, vi enables syntax highlighting, line numbers, and mouse positioning. 

Vi/etc/vimrc
Add syntax on and set nu
If you want to use the mouse in vi to determine the position, you can add set mouse = a (I did not add it, depending on my hobbies)

6. added the sudo permission for the admin group by default. 

Mongodo
Join
% Admin ALL = (ALL) NOPASSWD:
ALL
Save and exit. Then:
Groupadd admin

In this way, you only need to use useradd-Gadmin XXX to add an account with the administrator privilege.

7. install Vbox Guset Additions 

Click the device on the virtual machine window --> install the enhancement function
Then log on to the terminal
A. mount the optical drive
Mkdir/cdrom
Mount/dev/sr0/cdrom (whether sr0 depends on your situation)
B. install the dependent environment
Yum install gcc
Yum instal kernel-devel
Yum install dkms
C. Installation
Cd/cdrom
./VBoxLinuxAdditions. run
D. restart the test (auto mouse removal, etc)

8. disable GSSAPI and DNS reverse resolution to speed up ssh connection

Disable empty password user login and allow root login
Vi/etc/ssh/sshd_config
Set the following items
GSSAPIAuthentication no
UseDNS no
PermitEmptyPasswords no
PermitRootLogin yes
Save service sshd restart

9. set the user to log out of the terminal after six hours.

Vi/etc/profile
Export TMOUT = 21600

10. cancel generating the whatis database and locate database to prevent high cpu memory usage during Database reconstruction.

Rm-rf/etc/cron. daily/makewhatis. cron

Rm-rf/etc/cron. daily/mlocate. cron

11. tcp performance optimization

Vi/etc/sysctl. conf
Join

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

12. disable and cancel startup of useless programsView all services

Chkconfig? List
View the started service chkconfig? List | grep "http://www.52os.net/wp-includes/images/smilies/icon_surprised.gif"
Alt = ": o" class = "wp-smiley"> n

Close with service name stop
Cancel startup with chkconfig service name off
Keep only the following programs

NetworkManager

Cpuspeed

Crond

Haldaemon

Irqbalance

Kdump

Lvm2-monitor

Messagebus

Portreserve

Rsyslog

Spice-vdagentd

Sshd

Sysstat

Udev-post

Vboxadd

Vboxadd-service

Vboxadd-x11

13. regularly clear logs 

# Backup sys log every day :01

28 04 *** root
/Opt/scripts/cron/backuplog. sh

# Clear backup sys log every month 1 :30

30 1 1 ** root/opt/scripts/cron/clearlog. sh
/Opt/scripts/cron/backuplog. sh

#! /Bin/sh

Day = $ (date + % Y % m % d)

Tar-cf/var/log/wtmp_1_day).tar.gz/var/log/wtmp
Echo "">/var/log/wtmp

Tar-cf/var/log/utmp_1_day).tar.gz/var/run/utmp
Echo "">/var/run/utmp
/Opt/scripts/cron/clearlog. sh

#! /Bin/sh
Day = $ (date-d "-2 month" + % Y % m)

Rm-f/var/log/wtmp _ "$ Day" * .tar.gz
Rm-f/var/log/utmp _ "$ Day" * .tar.gz

14. install jdk telnetMysqlAnd other common software 

Mysql is not started. please use chkconfig mysql on service mysql
Start.

15 disable ctrl + alt + del automatic restart 

Comment out
Exec/sbin/shutdown-r now "Control-Alt-Delete
Pressed"

16. delete logs and export command line records from virtual machines 

Rm-rf/var/log/wtmp
Rm-rf/var/run/utmp
Rm-rf/root/. bash_history

After testing that vbox is configured with dual-core 1 GB, the above image boot speed can be about 10 seconds. of course, the linux boot speed has not increased.

Practical

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.