centos 已經發布了6.2版了,現在已經可以用在生產環境了,新版本的核心也能更好的利用硬體。
centos6開機指令碼,優化多種功能。centos 已經發布了6.2版了,現在已經可以用在生產環境了,新版本的核心也能更好的利用硬體。
寫了乙個指令碼,用來初始化系統環境,現在分享出來,你可以根據自己的需要,對指令碼進行相應的修改。
指令碼的內容如下:#!/bin/bash
#author suzezhi
#this script is only for centos 6
#check the os
platform=`uname -i`
if [ $platform != "x86_64" ];then
echo "this script is only for 64bit operating system !"
exit 1
fiecho "the platform is ok"
version=`lsb_release -r |awk ''`
if [ $version != 6 ];then
echo "this script is only for centos 6 !"
exit 1
ficat << eof
| your system is centos 6 x86_64 |
| start optimizing....... |
eof#make the 163.com as the default yum repo
mv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.backup
wget [url] -o /etc/yum.repos.d/centos-base.repo
#add the third-party repo
#add the epel
rpm -uvh [url]
rpm --import /etc/pki/rpm-gpg/rpm-gpg-key-epel-6
#add the rpmforge
rpm -uvh [url]
rpm --import /etc/pki/rpm-gpg/rpm-gpg-key-rpmforge-dag
#update the system and set the ntp
yum clean all
yum install kernel-devel kernel-headers && echo exclude=kernel* >> /etc/yum.conf
yum -y update glibc\*
yum -y update yum\* rpm\* python\*
yum -y update
yum -y install ntp
echo "* 4 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/root
service crond restart
#set the file limit
echo "ulimit -shn 102400" >> /etc/rc.local
cat >> /etc/security/limits.conf << eof
* soft nofile 65535
* hard nofile 65535
eof#set the control-alt-delete to guard against the misuse
sed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf
#disable selinux
sed -i 's/selinux=enforcing/selinux=disabled/' /etc/selinux/config
#set 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
#tune kernel parametres
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
#define the backspace button can erase the last character typed
echo 'stty erase ^h' >> /etc/profile
echo "syntax on" >> /root/.vimrc
#stop some crontab
mkdir /etc/cron.daily.bak
mv /etc/cron.daily/makewhatis.cron /etc/cron.daily.bak
mv /etc/cron.daily/mlocate.cron /etc/cron.daily.bak
chkconfig bluetooth off
chkconfig cups off
chkconfig ip6tables off
#disable the ipv6
cat > /etc/modprobe.d/ipv6.conf << eofi
alias net-pf-10 off
options ipv6 disable=1
eofi
echo "networking_ipv6=off" >> /etc/sysconfig/network
cat << eof
| optimizer is done |
| it's recommond to restart this server ! |
eof複製**對指令碼的內容做一下說明(給不太熟悉的哥們掃掃盲,高手直接繞開就行):
1.先對系統進行判斷,如果是cent os 64位,就繼續執行。
2.先將系統的安裝源設定為網易的(網易的安裝源算是國內比較穩定的)
3.安裝epel的源和rpmforge的源,利用第三方的源來讓yum安裝起來更方便
4.更新軟體
5.設定為每天凌晨四點進行時間同步(跟國家授時中心的伺服器進行時間同步)
6.將系統同時開啟的檔案個數增大
7.將ctrl alt delete鍵進行遮蔽,防止誤操作的時候伺服器重啟
8.關閉selinux
9,禁用gssapi來認證,也禁用dns反向解析,加快ssh登陸速度
10.優化一些核心引數
11.調整刪除字元的按鍵為backspace(某些系統預設是delete)
12.開啟vim的語法高亮
13.取消生成whatis資料庫和locate資料庫
14.關閉沒用的服務
15.關閉ipv6
centOS 6設定開機自啟
1 利用 chkconfig 來配置啟動級別 在centos或者redhat其他系統下,如果是後面安裝的服務,如httpd mysqld postfix等,安裝後系統預設不會自動啟動的。就算手動執行 etc init.d mysqld start 啟動了服務,只要伺服器重啟後,系統仍然不會自動啟動服...
centos6開機fsck失敗,導致開機異常
今天開啟centos系統出現畫面,an error occurred during the file system check.give root password for maintenance or type control d to continue 輸入root帳號的密碼,或者重啟都沒用。後...
編寫MYSQL主從指令碼 centos6
主從centos7鏈結 執行之前配好ssh免密 和關閉防火牆 vim aa.sh bin bash yum y install mysql mysql server 主安裝mysql sed i 0 a server id 1 etc my.cnf sed修改主配置 sed i 1 a log bi...