centos7_初始化脚本.sh

centos7_初始化脚本.sh

#!/bin/bash

function selinux_close(){
setenforce 0
sed -i 's#^SELINUX=.*#SELINUX=disabled#' /etc/sysconfig/selinux
sed -i 's#^SELINUX=.*#SELINUX=disabled#' /etc/selinux/config
getenforce && echo "selinux run ..." || `echo "selinux is stop";exit 1`
}

function install_tools(){
rm -rf /run/yum.pid
yum clean all
yum install -y yum-axelget net-snmp.x86_64 epel-release lrzsz gcc gcc-c++ make man vim unzip wget curl lua-devel lua-static patch libxml2-devel libxslt libxslt-devel gd gd-devel ntp ntpdate screen sysstat tree rsync lsof openssh-clients iftop net-snmp libuuid-devel.x86_64 uuidd.x86_64 device-mapper-devel.x86_64 popt-devel.x86_64 popt.x86_64 popt-static.x86_64 iptables-services rdate ntp smartmontools iptraf psmisc traceroute net-tools.x86_64 tmux bash-completion
if [ $? -eq 0 ]; then
	echo "yum install is ok!!!"
else
	echo "yum install is fall !!!"
fi
}

function service_close(){
systemctl disable firewalld postfix acpid ip6tables mcelogd mdmonitor rpcbind rpcgssd &> /dev/null
systemctl disable rpcidmapd auditd haldaemon lldpad atd kdump netfs nfslock openct &> /dev/null
systemctl stop firewalld
systemctl restart iptables
systemctl enable iptables.service sshd crond &> /dev/null
echo "systemctl stop and disable some software is ok!!!"
}


function time_zone(){
echo "y"|cp -rf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &> /dev/null
echo "1 1 */1 * * ntpdate asia.pool.ntp.org" >>/var/spool/cron/root&&chmod 600 /var/spool/cron/root
echo "system time is Shanghai and ntpdate is ok!!!"
}

function innter_sys_optimization(){
cat > /etc/sysctl.conf <<EOF
net.nf_conntrack_max  = 65536
net.netfilter.nf_conntrack_max = 65536
net.ipv4.ip_forward = 0  
net.ipv4.conf.default.rp_filter = 1  
net.ipv4.conf.default.accept_source_route = 0  
kernel.sysrq = 0  
kernel.core_uses_pid = 1  
net.ipv4.tcp_syncookies = 1  
kernel.msgmnb = 65536  
kernel.msgmax = 65536  
kernel.shmmax = 68719476736  
kernel.shmall = 4294967296  
net.ipv4.tcp_max_tw_buckets = 15000
net.ipv4.tcp_sack = 1  
net.ipv4.tcp_window_scaling = 1  
net.ipv4.tcp_rmem = 4096 87380 4194304   
net.ipv4.tcp_wmem = 4096 16384 4194304   
net.core.wmem_default = 8388608  
net.core.rmem_default = 8388608  
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.ipv4.tcp_timestamps = 0  
net.ipv4.tcp_synack_retries = 1  
net.ipv4.tcp_syn_retries = 1  
net.ipv4.tcp_tw_recycle = 1  
net.ipv4.tcp_tw_reuse = 1  
net.ipv4.tcp_mem = 94500000 915000000 927000000   
net.ipv4.tcp_fin_timeout = 30 
net.ipv4.tcp_keepalive_time = 30  
net.ipv4.ip_local_port_range = 1024 65000
fs.file-max = 13000000 
net.ipv4.tcp_keepalive_probes=5
net.ipv4.tcp_orphan_retries=3
net.ipv4.tcp_synack_retries=2
kernel.printk_ratelimit = 30
kernel.printk_ratelimit_burst = 200
net.ipv6.conf.all.disable_ipv6=0
net.ipv6.conf.default.disable_ipv6=0
net.ipv6.conf.lo.disable_ipv6=0
EOF
sysctl -p &> /dev/null && echo "innter_sys_optimization is ok!!!" || `echo "innter_sys_optimization is fail ... ";exit 1`
}

function limit_file_num(){
cat >> /etc/security/limits.conf <<EOF
* soft nofile 1024000
* hard nofile 1024000
hive   - nofile 1024000
hive   - nproc  1024000
# End of file
EOF

ulimit -n 1024000
ulimit -HSn 102400
echo "limit_file_num is ok!!!" 
}

function history_set(){
cat >> /etc/profile <<EOF
USER_IP=\`who -u am i 2>/dev/null| awk '{print \$NF}'|sed -e 's/[()]//g'\`   
HISTFILESIZE=4000  
HISTSIZE=4000  
HISTTIMEFORMAT="%F %T \${USER_IP} \`whoami\` "  
export HISTTIMEFORMAT 
EOF
echo "history_set is ok!!!" 
}

selinux_close
install_tools
service_close
time_zone
innter_sys_optimization
limit_file_num
history_set
Teo

46条评论

erotik 发布于05:14 - 2021年2月18日

Super-Duper website! I am loving it!! Will be back later to read some more. I am bookmarking your feeds also. Tybie Isa Heigl

erotik 发布于02:01 - 2021年2月18日

When some one searches for his necessary thing, therefore he/she desires to be available that in detail, therefore that thing is maintained over here. Natka Patten Bunow

erotik 发布于00:38 - 2021年2月18日

Hi there, just wanted to say, I loved this article. Debby Justin Carline

샌즈카지노 发布于22:16 - 2021年2月17日

Hello, this weekend is nice designed for me, as this time i am reading this great educational paragraph here at my house.| Francesca Otto Correy

erotik 发布于21:19 - 2021年2月17日

Hello, I think your blog might be having browser compatibility issues. Barbra Yorgo Dalury

샌즈카지노 发布于19:54 - 2021年2月17日

Really Appreciate this update, can you make it so I receive an alert email whenever you write a new update? Mureil Eugen Sheelah

샌즈카지노 发布于17:00 - 2021年2月17日

Hiya, I am really glad I have found this information. Today bloggers publish only about gossip and net stuff and this is really irritating. A good web site with exciting content, that is what I need. Thanks for making this site, and I will be visiting again. Do you do newsletters by email? Reyna Ivor Berkman

turkce 发布于03:08 - 2021年2月17日

What a stuff of un-ambiguity and preserveness of valuable familiarity on the topic of unexpected emotions. Caro Gawen Forras

erotik 发布于02:10 - 2021年2月17日

This is my first time visit at here and i am genuinely pleassant to read all at alone place. Layne Klaus Barabas

turkce 发布于03:31 - 2021年2月16日

Thanks for this amzing blog, I sincerer agreed with everything you said, I will be viisting again . Once again thanks for an amazin blog Meridel Cirilo Krilov

turkce 发布于01:34 - 2021年2月16日

Merci beaucoup Stephanie pour ton gentil commentaire! Konstance Mohandis Ellord

turkce 发布于00:08 - 2021年2月16日

Thanks , I have recently been looking for info about this topic for a long time and yours is the best I have discovered so far. But, what about the conclusion? Are you certain in regards to the supply? Audrie Izzy Jago

turkce 发布于22:14 - 2021年2月15日

Useful information. Fortunate me I discovered your website accidentally, and I am surprised why this coincidence did not came about in advance! I bookmarked it. Jenna Zachery Cesare

turkce 发布于20:42 - 2021年2月15日

I blog often and I seriously appreciate your information. The article has truly peaked my interest. I will take a note of your website and keep checking for new details about once a week. I subscribed to your RSS feed too. Ava Jamey Dalston

turkce 发布于19:02 - 2021年2月15日

Virality iPhone monetization burn rate seed money buzz social media. Handshake bandwidth venture responsive web design hackathon. Graphical user interface influencer branding mass market business-to-consumer buzz vesting period seed round. Partner network ecosystem stock freemium. Hestia Greggory Eveleen

turkce 发布于17:36 - 2021年2月15日

Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. It extremely helps make reading your blog significantly easier. Celine Jock Michaeline

turkce 发布于16:21 - 2021年2月15日

Thank you, I have recently been looking for information about this subject for a while and yours is the greatest I have discovered so far. But, what concerning the conclusion? Are you positive in regards to the supply? Aretha Cobbie Amie

turkce 发布于14:02 - 2021年2月15日

As I website possessor I believe the content material here is rattling wonderful , appreciate it for your efforts. You should keep it up forever! Good Luck. Marijo Guillermo Victor

turkce 发布于03:00 - 2021年2月15日

This software makes you in a position to let you construct your dream kitchen very quickly as it generates you loads of gems fully free and very quickly. Mia Ellswerth Ontina

turkce 发布于01:27 - 2021年2月15日

Essentially, at the end of the shopping day, the choice will be almost certainly narrowed down to just two of these factors Adella Jeff Frodi

turkce 发布于23:50 - 2021年2月14日

I love reading through a post that can make people think. Also, thanks for allowing for me to comment. Jeanine Terrill Bozovich

turkce 发布于22:27 - 2021年2月14日

Greate article. Keep writing such kind of info on your blog. Florance Ernesto Desdee

turkce 发布于20:45 - 2021年2月14日

Indeed Grimey, certainly, I have never in the last 50 years seen a single positive broadcast, article or comment about Israel from the BBC and equally I have never seen a negative one from the BBC about the new kids on the block, invented in July 1964 the Palestinians. Prior to that date the only Palestinians were Jews i.e. the Palestine Symphony Orchestra, founded in 1936, all were Jews, the Palestine Football Team, founded in 1928 all again were Jews. Helsa Pieter Rawdan

turkce 发布于17:00 - 2021年2月14日

certainly like your web-site but you need to test the spelling on several of your posts. A number of them are rife with spelling issues and I find it very bothersome to inform the truth on the other hand I will certainly come again again. Madelena Broddie Balliol

turkce 发布于10:37 - 2021年2月14日

Gerardo ruiz dosal musician enlistment option program Cesya Hermann Mide

turkce 发布于09:35 - 2021年2月14日

Can I simply say what a relief to discover someone who truly understands what they are discussing on the internet. You actually realize how to bring a problem to light and make it important. A lot more people must read this and understand this side of the story. I was surprised that you are not more popular because you definitely possess the gift. Mariellen Cross Caundra

turkce 发布于07:27 - 2021年2月14日

nsightful thoughts here. Are you certain this is the best way to look at it though? My experience is that we should pretty much live and let live because what one person thinks just another person simply doesnt. People are going to do what they want to do. In the end, they always do. The most we can yearn for is to highlight a few things here and there that hopefully, allows them to make just a little better informed decision. Otherwise, great post. Youre definitely making me think! Barry Elianora Garik Cristin

turkce 发布于06:14 - 2021年2月14日

What a great list. I would love to visit one day and explore all this beautiful nature. Carlin Gar Hannon

turkce 发布于04:35 - 2021年2月14日

I loved as much as you will receive carried out right here. The sketch is tasteful, your authored subject matter stylish. nonetheless, you command get got an impatience over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this hike.| Lea Raimondo Maryly

turkce 发布于01:33 - 2021年2月14日

There is definately a great deal to learn about this subject. I love all the points you made. Jammie Temp MacKay

turkce 发布于00:47 - 2021年2月14日

Hello there! This is my first visit to your blog! We are a group of volunteers and starting a new project in a community in the same niche. Your blog provided us beneficial information to work on. You have done a marvellous job! Phillie Webb Wallas

turkce 发布于22:52 - 2021年2月13日

Greetings! Very useful advice in this particular article! It is the little changes that will make the largest changes. Many thanks for sharing! Melony Herman Clarance

turkce 发布于21:28 - 2021年2月13日

very few web-sites that take place to become in depth below, from our point of view are undoubtedly well worth checking out Henrietta Tynan Dang

Juan 发布于20:45 - 2021年2月13日

Hello! Someone in my Facebook group shared this site with us so
I came to check it out. I’m definitely enjoying the information. I’m book-marking and will be tweeting this
to my followers! Wonderful blog and fantastic
style and design.

Look at my web-site James

diziler 发布于21:38 - 2021年2月9日

Thanks for expressing your ideas. I might also like to express that video games have been ever before evolving. Better technology and inventions have aided create sensible and active games. All these entertainment games were not actually sensible when the actual concept was first of all being tried out. Just like other areas of technologies, video games too have had to evolve as a result of many years. This itself is testimony to the fast growth and development of video games. Brandice Wilton Sophi

netflix 发布于16:47 - 2021年2月1日

Hi there, after reading this awesome piece of writing i am also cheerful to share my familiarity here with colleagues. Glynda Shae Motteo

online 发布于04:09 - 2021年2月1日

What could possibly happen if I took out the sugar entirely. Family has dumped sugar and the fruits involved seem like reasonably tasty sweetness. Please advise. I hate messing up my baked goods!! Shirleen Granthem Bilow

online 发布于02:26 - 2021年2月1日

Way cool! Some extremely valid points! I appreciate you penning this post and the rest of the website is extremely good. Stacia Correy Dominik

watch 发布于17:30 - 2021年1月31日

You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog. Tiffani Diego Newbold

dizi 发布于03:24 - 2021年1月22日

Say, you got a nice blog. Really thank you! Want more. Ellynn Wylie Lianne

filmi izle 发布于02:27 - 2021年1月19日

Great article. I will be facing a few of these issues as well.. Bonny Erwin Hirst

film izle 发布于08:33 - 2021年1月18日

Hi there to all, the contents present at this web page are actually amazing for people experience, well, keep up the nice work fellows. Tove Heall Essam

hd film izle 发布于04:35 - 2021年1月18日

Fantastic article. Really looking forward to read more. Fantastic. Wilone Parnell Warton

Margot 发布于21:44 - 2020年12月29日

Hurrah! Finally I got a blog from where I be able to genuinely get valuable facts regarding my study and knowledge.

Also visit my page – Steven

Sabine 发布于01:11 - 2020年12月14日

I’m not that much of a internet reader to be honest but
your sites really nice, keep it up! I’ll go ahead
and bookmark your site to come back later. All the best

Here is my blog post :: fcaband.org

720p 发布于15:10 - 2020年12月10日

You made some nice points there. I did a search on the topic and found most persons will approve with your site. Antonietta Boyce Alvin

You must be logged in to post a comment