centos7最小安装初始化脚本
#!/bin/bash
#zhangsen
#lovexlzs@qq.com if [[ "$(whoami)" != "root" ]]; then echo "please run this script as root ." >&
exit
fi echo -e "\033[31m 这个是centos7系统初始化脚本,请慎重运行!Please continue to enter or ctrl+C to cancel \033[0m"
sleep #configure yum source
yum_config(){
yum install wget epel-release -y
cd /etc/yum.repos.d/ && mkdir bak && mv -f *.repo bak/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all && yum makecache
yum -y install iotop iftop net-tools lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel python-devel bash-completion
}
#firewalld
iptables_config(){
systemctl stop firewalld.service
systemctl disable firewalld.service
yum install iptables-services -y
systemctl enable iptables
systemctl start iptables
iptables -F
service iptables save
}
#system config
system_config(){
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
timedatectl set-local-rtc && timedatectl set-timezone Asia/Shanghai
yum -y install chrony && systemctl start chronyd.service && systemctl enable chronyd.service
}
ulimit_config(){
echo "ulimit -SHn 102400" >> /etc/rc.local
cat >> /etc/security/limits.conf << EOF
* soft nofile
* hard nofile
* soft nproc
* hard nproc 102400
EOF
} #set sysctl
sysctl_config(){
cp /etc/sysctl.conf /etc/sysctl.conf.bak
cat > /etc/sysctl.conf << EOF
net.ipv4.ip_forward =
net.ipv4.conf.default.rp_filter =
net.ipv4.conf.default.accept_source_route =
kernel.sysrq =
kernel.core_uses_pid =
net.ipv4.tcp_syncookies =
kernel.msgmnb =
kernel.msgmax =
kernel.shmmax =
kernel.shmall =
net.ipv4.tcp_max_tw_buckets =
net.ipv4.tcp_sack =
net.ipv4.tcp_window_scaling =
net.ipv4.tcp_rmem =
net.ipv4.tcp_wmem =
net.core.wmem_default =
net.core.rmem_default =
net.core.rmem_max =
net.core.wmem_max =
net.core.netdev_max_backlog =
net.core.somaxconn =
net.ipv4.tcp_max_orphans =
net.ipv4.tcp_max_syn_backlog =
net.ipv4.tcp_timestamps =
net.ipv4.tcp_synack_retries =
net.ipv4.tcp_syn_retries =
net.ipv4.tcp_tw_recycle =
net.ipv4.tcp_tw_reuse =
net.ipv4.tcp_mem =
net.ipv4.tcp_fin_timeout =
net.ipv4.tcp_keepalive_time =
net.ipv4.ip_local_port_range =
EOF
/sbin/sysctl -p
echo "sysctl set OK!!"
} main(){
yum_config
iptables_config
system_config
ulimit_config
sysctl_config
}
main
centos7最小安装初始化脚本的更多相关文章
- centos7 最小安装初始化
配置阿里yum源 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \&&cu ...
- Linux工作环境:CentOS7最小安装+Xfce桌面环境
ref: https://blog.csdn.net/smstong/article/details/44802989 3.1 执行CentOS7 最小安装去官网下载CentOS-7.0-1406-x ...
- CentOS7 最小安装 vmware 创建虚拟机 nmcli ip systemctl
镜像网站 一些开源软件的国内镜像源 站点版 (一).企业站 1.搜狐:http://mirrors.sohu.com/ 2.网易:http://mirrors.163.com/ 3.阿里云:http: ...
- centos7最小安装后——网络配置、常见命令安装,远程连接、yum源安装软件包
安装环境 #软件:vmware 14 #centos版本:CentOS-7-x86_64-DVD-1810 下载地址: #网络配置:NAT模式 配置 网络配置 #动态获取ip: centos7最小安装 ...
- Centos7最小安装化后安装图形界面
首先需要对系统进行更新 yum -y upgrade 然后安装桌面组件包 ,在命令行下输入下面的命令来安装 Gnome 包 yum groupinstall "GNOME Desktop&q ...
- Centos7最小安装后快速初始化脚本
功能说明 服务器通常使用最小化安装操作系统,使用该脚本可快速初始化一些基本配置,包括以下: 1.ssh修改默认端口 2.ssh禁止root登陆 3.selinux及firewalld禁用 4.hist ...
- centos7最小安装后常常需要添加的命令
本人下载的最小镜像文件下载地址:http://pan.baidu.com/s/1kUD2jbT 原文地址:http://blog.csdn.net/nmgrd/article/details/5176 ...
- centos7 最小安装无ifconfig
可能不会有人看到这篇文章,加入有幸被看到,建议读者从后往前看!最小化安装问题:1 没有ifconfig 命令,解决:yum install net-tools2 使用yum install n ...
- CentOs7 最小安装版安装后配置和java环境的搭建
下面是contos7 最小化安装成功以后进行一些基础的配置和java环境的安装教程: 1 防火墙 : 关闭防火墙: systemctl stop firewalld.service . 关闭开机启 ...
随机推荐
- 【图算法】Dijkstra算法及变形
图示: 模版: /* Dijkstra计算单源最短路径,并记录路径 m个点,n条边,每条边上的权值非负,求起点st到终点et的最短路径 input: n m st et 6 10 1 6 1 2 6 ...
- C# EF中调用 存储过程并调回参数
TourEntities db = new TourEntities(); List<v_product> v = new List<v_product>(); SqlPara ...
- C#TreeView节点选中后失去焦点时改变节点背景色
C#TreeView节点选中后失去焦点时改变节点背景色 在使用TreeView控件时候,单击一个节点,当鼠标聚焦到别的地方的时候,之前点击的这个节点就看不清楚了 举例截图 单击后 ...
- [转]redhat7(centos7) not registered to Red Hat Subscription Management
[root@controller0 ~]# yum install ntp Loaded plugins: fastestmirror, product-id, search-disabled-rep ...
- 2527: [Poi2011]Meteors[整体二分]
2527: [Poi2011]Meteors Time Limit: 60 Sec Memory Limit: 128 MB Submit: 1528 Solved: 556 [Submit][S ...
- Spring web.xml中的配置
转载博客:http://blog.163.com/zhangke_616/blog/static/191980492007994948206/ 在实际项目中spring的配置文件application ...
- ansible的优化
Ansible企业实战环境中,如果管理的服务器越来越多,Ansibe执行效率会变得比较慢,可以通过优化Ansible提供工作效率,由于Ansible基于SSH协议通信,SSH连接慢会导致整个基于Ans ...
- [转]理解Linux的处理器负载均值
[转自]http://www.mike.org.cn/articles/understanding-of-linux-processor-load-average/ 你可能对于Linux的负载均值(l ...
- 9.14.16 Django ORM进阶用法
2018-9-14 14:26:45 ORM 练习题 : http://www.cnblogs.com/liwenzhou/articles/8337352.html 2018-9-14 21:1 ...
- [分布式系统学习]阅读笔记 Distributed systems for fun and profit 之四 Replication 拷贝
阅读http://book.mixu.net/distsys/replication.html的笔记,是本系列的第四章 拷贝其实是一组通信问题,为一些子问题,例如选举,失灵检测,一致性和原子广播提供了 ...