{"id":345,"date":"2015-12-01T11:09:50","date_gmt":"2015-12-01T03:09:50","guid":{"rendered":"http:\/\/www.codeeel.com\/?p=345"},"modified":"2015-12-01T11:09:50","modified_gmt":"2015-12-01T03:09:50","slug":"centos6%e5%92%8ccentos7%e5%88%9d%e5%a7%8b%e5%8c%96%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.codeeel.com\/?p=345","title":{"rendered":"centos6\u548ccentos7\u521d\u59cb\u5316\u811a\u672c"},"content":{"rendered":"<p>\u521a\u62ff\u5230\u4e00\u53f0\u673a\u5668\u7684\u786e\u5f88\u5174\u594b\uff0c\u4f46\u662f\u548c\u5b83\u4ea4\u6d41\u540e\u4f60\u4f1a\u53d1\u73b0\u4ed6\u8fd8\u6ca1\u51c6\u5907\u597d\uff0c\u4f60\u62ff\u4ed6\u6ca1\u529e\u6cd5\uff0c\u53ea\u80fd\u4e00\u6837\u8981\u7684\u6559\uff0c\u8fd9\u91cc\u6211\u7ed9\u51fa\u62c9\u7f51\u4e0a\u501f\u9274\u7684\u521d\u59cb\u5316\u811a\u672ccentos6\u548ccentos7\u7684shell\uff0c\u9644\u4ef6\u76ee\u5f55\u6211\u8fd8\u662f\u4e3a\u5927\u5bb6\u4e0a\u4f20\u5230\u767e\u5ea6\u4e91\u5427\uff0c\u4e0b\u9762\u5c31\u662f\u5c55\u793a\u4e00\u4e0b\u601d\u8def\u3002<\/p>\n<pre>#!\/bin\/bash\r\n#author jim.zhong\r\n#this script is only for CentOS 6\r\n#check the OS\r\n\r\n#\u2014\u2014\u5148\u5bf9\u7cfb\u7edf\u8fdb\u884c\u5224\u65ad\uff0c\u5982\u679c\u662fCent OS 64\u4f4d\uff0c\u5c31\u7ee7\u7eed\u8fd0\u884c\u3002\r\n#\u2014\u2014\u5148\u5c06\u7cfb\u7edf\u7684\u5b89\u88c5\u6e90\u8bbe\u7f6e\u4e3a\u7f51\u6613\u7684\uff08\u7f51\u6613\u7684\u5b89\u88c5\u6e90\u7b97\u662f\u56fd\u5185\u6bd4\u8f83\u7a33\u5b9a\u7684\uff09\r\n#\u2014\u2014\u5b89\u88c5epel\u7684\u6e90\u548crpmforge\u7684\u6e90\uff0c\u5229\u7528\u7b2c\u4e09\u65b9\u7684\u6e90\u6765\u8ba9yum\u5b89\u88c5\u8d77\u6765\u66f4\u65b9\u4fbf\r\n#\u2014\u2014\u66f4\u65b0\u8f6f\u4ef6\r\n#\u2014\u2014\u8bbe\u7f6e\u4e3a\u5468\u671f\u8fdb\u884c\u65f6\u95f4\u540c\u6b65\uff08\u8ddf\u56fd\u5bb6\u6388\u65f6\u4e2d\u5fc3\u7684\u670d\u52a1\u5668\u8fdb\u884c\u65f6\u95f4\u540c\u6b65\uff09\r\n#\u2014\u2014\u5c06\u7cfb\u7edf\u540c\u65f6\u6253\u5f00\u7684\u6587\u4ef6\u4e2a\u6570\u589e\u5927\r\n#\u2014\u2014disable = \u5c06ctrl\u5c06ctrl alt delete\u952e\u8fdb\u884c\u5c4f\u853d\uff0c\u9632\u6b62\u8bef\u64cd\u4f5c\u7684\u65f6\u5019\u670d\u52a1\u5668\u91cd\u542f\r\n#\u2014\u2014\u5173\u95edselinux\r\n#\u2014\u2014\u7981\u7528GSSAPI\u6765\u8ba4\u8bc1\uff0c\u4e5f\u7981\u7528DNS\u53cd\u5411\u89e3\u6790\uff0c\u52a0\u5febSSH\u767b\u9646\u901f\u5ea6\r\n#\u2014\u2014\u4f18\u5316\u4e00\u4e9b\u5185\u6838\u53c2\u6570\r\n#\u2014\u2014\u8c03\u6574\u5220\u9664\u5b57\u7b26\u7684\u6309\u952e\u4e3abackspace\uff08\u67d0\u4e9b\u7cfb\u7edf\u9ed8\u8ba4\u662fdelete\uff09\r\n#\u2014\u2014\u6253\u5f00vim\u7684\u8bed\u6cd5\u9ad8\u4eae\r\n#\u2014\u2014\u53d6\u6d88\u751f\u6210whatis\u6570\u636e\u5e93\u548clocate\u6570\u636e\u5e93\r\n#\u2014\u2014\u5173\u95ed\u6ca1\u7528\u7684\u670d\u52a1\r\n#\u2014\u2014 disable = \u5173\u95edIPv6\r\n\r\n\r\nplatform=`uname -i`\r\nif [ $platform != \"x86_64\" ];then \r\necho \"this script is only for 64bit Operating System !\"\r\nexit 1\r\nfi\r\n\r\ncat &lt;&lt; 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 http:\/\/mirrors.163.com\/.help\/CentOS6-Base-163.repo -O \/etc\/yum.repos.d\/CentOS-Base.repo #add the third-party repo #add the epel rpm -Uvh http:\/\/dl.fedoraproject.org\/pub\/epel\/6Server\/x86_64\/epel-release-6-8.noarch.rpm rpm --import \/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-EPEL-6 #add the rpmforge rpm -Uvh http:\/\/pkgs.repoforge.org\/rpmforge-release\/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm rpm --import \/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-rpmforge-dag #update the system and set the ntp yum clean all yum -y update glibc\\* yum -y update yum\\* rpm\\* python\\*  yum -y update yum -y install ntpdate cp \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime echo \"*\/10 * * * * \/usr\/sbin\/ntpdate cn.pool.ntp.org &amp;&amp; \/sbin\/clock -w\" &gt;&gt; \/var\/spool\/cron\/root\r\nservice crond restart\r\n\r\n#set the file limit\r\necho \"ulimit -SHn 102400\" &gt;&gt; \/etc\/rc.local\r\ncat &gt;&gt; \/etc\/security\/limits.conf &lt;&lt; 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 &gt;&gt; \/etc\/sysctl.conf &lt;&lt; EOF net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_syncookies = 1 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 net.ipv4.ip_local_port_range = 5000 65000 EOF \/sbin\/sysctl -p #define the backspace button can erase the last character typed echo 'stty erase ^H' &gt;&gt; \/etc\/profile\r\necho \"syntax on\" &gt;&gt; \/root\/.vimrc\r\n\r\n#stop some crontab\r\nmkdir \/etc\/cron.daily.bak\r\nmv \/etc\/cron.daily\/makewhatis.cron \/etc\/cron.daily.bak\r\nmv \/etc\/cron.daily\/mlocate.cron \/etc\/cron.daily.bak\r\n\r\nchkconfig bluetooth off\r\nchkconfig cups off\r\nchkconfig ip6tables off\r\n\r\n#install make\r\nyum install 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 openssl-devel libxml2-devel gettext-devel pcre-devel\r\n\r\n#install snmpd\r\nyum install net-snmp net-snmp-devel net-snmp-libs net-snmp-perl net-snmp-utils mrtg\r\n\r\n#\u914d\u7f6e\u6587\u4ef6snmpd \u4f5c\u4e3a\u76d1\u63a7\u4f7f\u7528\r\ncp snmpd.conf \/etc\/snmp\/smnpd.conf\r\n\r\nchkconfig snmpd on\r\n\r\n# install PHP \u5b89\u88c5\u9ed8\u8ba4php5.3,\u5982\u8be5\u9700\u8981\u66ff\u6362\u62105.4,\u8bf7\u641c\u7d22\u4e3a\u7684\u535a\u5ba25.4\u65b9\u5f0f\r\nyum install php.x86_64 php-cli.x86_64 php-common.x86_64 php-devel.x86_64 php-fpm.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-pdo.x86_64 php-pear.noarch php-pecl-apc.x86_64 php-process.x86_64 php-snmp.x86_64 php-xml.x86_64 php-xmlrpc.x86_64 php-pecl-memcache.x86_64\r\n\r\n#install java sun\r\nrpm -ivh jdk-7u71-linux-x64.rpm\r\n\r\ncat &gt;&gt; \/etc\/profile &lt;&lt; EOF export JAVA_HOME=\/usr\/java\/jdk1.7.0_71 export CLASSPATH=.:$JAVA_HOME\/jre\/lib\/rt.jar:$JAVA_HOME\/lib\/dt.jar:$JAVA_HOME\/lib\/tools.jar export PATH=$PATH:$JAVA_HOME\/bin EOF #disable the ipv6 #cat &gt; \/etc\/modprobe.d\/ipv6.conf &lt;&lt; EOFI #alias net-pf-10 off #options ipv6 disable=1 #EOFI #echo \"NETWORKING_IPV6=off\" &gt;&gt; \/etc\/sysconfig\/network\r\n\r\n\r\n\r\n\r\ncat &lt;&lt; EOF\r\n+-------------------------------------------------+\r\n|               optimizer is done                 |\r\n|   it's recommond to restart this server !       |\r\n+-------------------------------------------------+\r\nEOF\r\n<\/pre>\n<p>\u767e\u5ea6\u4e91\u5730\u5740<\/p>\n<p>centos6 \uff1ahttp:\/\/pan.baidu.com\/s\/1mg6eTiK<\/p>\n<p>centos7 \uff1ahttp:\/\/pan.baidu.com\/s\/1i3ttMNr<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521a\u62ff\u5230\u4e00\u53f0\u673a\u5668\u7684\u786e\u5f88\u5174\u594b\uff0c\u4f46\u662f\u548c\u5b83\u4ea4\u6d41\u540e\u4f60\u4f1a\u53d1\u73b0\u4ed6\u8fd8\u6ca1\u51c6\u5907\u597d\uff0c\u4f60\u62ff\u4ed6\u6ca1\u529e\u6cd5\uff0c\u53ea\u80fd\u4e00\u6837\u8981\u7684\u6559\uff0c\u8fd9\u91cc\u6211\u7ed9\u51fa\u62c9\u7f51\u4e0a\u501f\u9274\u7684\u521d\u59cb\u5316\u811a\u672ccentos6\u548ccentos7\u7684shell\uff0c\u9644\u4ef6\u76ee\u5f55\u6211\u8fd8\u662f\u4e3a\u5927\u5bb6\u4e0a\u4f20\u5230\u767e\u5ea6\u4e91\u5427\uff0c\u4e0b\u9762\u5c31\u662f\u5c55\u793a\u4e00\u4e0b\u601d\u8def\u3002 #!\/bin\/bash #author jim.zhong #this script is <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,11,48,14],"tags":[174,171,170,145,50,173,172],"_links":{"self":[{"href":"https:\/\/www.codeeel.com\/index.php?rest_route=\/wp\/v2\/posts\/345"}],"collection":[{"href":"https:\/\/www.codeeel.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codeeel.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codeeel.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codeeel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":1,"href":"https:\/\/www.codeeel.com\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions"}],"predecessor-version":[{"id":346,"href":"https:\/\/www.codeeel.com\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions\/346"}],"wp:attachment":[{"href":"https:\/\/www.codeeel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codeeel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codeeel.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}