Centos7 系统初试化脚本
系统初始化设置
# 设置主机名,永久修改,再次登陆生效
hostnamectl set-hostname xxxxx # 安装eprl源,常用命令
yum install -y wget && \
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo && \
yum -y install bash-completion telnet nmap tree net-tools ntpdate && \ # 查看时区,同步时间
timedatectl set-timezone Asia/Shanghai 修改时区命令
ntpdate hk.ntp.org.cn 同步时间 # 优化文件描述符
cat >>/etc/security/limits.conf<<EOF
root soft nofile
root hard nofile
* soft nofile
* hard nofile
EOF
ulimit -n # 查看 # 防火墙设置
添加允许访问的端口
firewall-cmd --zone=public --add-port=/tcp --permanent 添加允许访问的服务
firewall-cmd --permanent --add-service https 对指定IP或某个网段开放端口,允许192.168.142.166和192.168.224./24访问5432端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.224.0/" port protocol="tcp" port="" accept" 重新加载防火墙,防火墙规则生效
firewall-cmd --reload # 关闭防火墙,如果需要
systemctl stop firewalld.service && systemctl disable firewalld.service # 关闭selinux
setenforce && sed '7s#enforcing#disabled#g' /etc/selinux/config -i # 关闭ssh解析
sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config
systemctl restart sshd # 目录规划
/server/scripts/ 脚本存放目录
/server/tools/ 安装包存放目录
/usr/local/ 服务安装目录
/backup/ 备份目录 # ssh 白名单规则
在 /etc/hosts.allow 设置,允许连接的IP
sshd:167.179.49.12
sshd:192.168.224.0/ 在/etc/hosts.deny 设置,拒绝所有的连接
echo "sshd:all" >> /etc/hosts.deny
Centos7 系统初试化脚本
#!/bin/bash
yum install -y wget && \
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo && \
yum -y install vim wget bash-completion lrzsz nmap tree nc net-tools htop iotop iftop psmisc ntpdate && \
systemctl stop firewalld.service && systemctl disable firewalld.service
#setenforce 0 && sed '7s#enforcing#disabled#g' /etc/selinux/config -i
#优化文件描述符
echo -e "* soft nofile 65535\n* hard nofile 65535" >> /etc/security/limits.conf
ulimit -n 65535
#内核优化
cat >>/etc/sysctl.conf<<EOF
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.ip_local_port_range = 4000 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.tcp_max_orphans = 16384
EOF
sysctl -p
sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config
systemctl restart sshd
echo '* * * * * root /usr/sbin/ntpdate ntp1.aliyun.com' >>/etc/crontab
Centos7 系统初试化脚本的更多相关文章
- CentOS7.5 系统最小化安装与初始化配置
CentOS7.5 系统最小化安装与初始化配置 1.安装标准化的系统 1.1.系统安装期间的语言 选择:中文-简体中文,安装完成也会默认支持中文输出,便于管理 1.2.时区选择 亚洲上海,CST时区( ...
- 基于CentOS7系统添加自定义脚本服务及参数说明【转】
概述 centos6如果要添加自定义脚本服务只需要把脚本放到/etc/init.d然后授权后用chkconfig添加后就可以管理了,那么centos7又是怎么添加自定义脚本服务呢? CentOS7添加 ...
- CentOS7 系统服务器初始化配置、安全加固、内核升级优化常用软件安装的Shell脚本分享
转载自:https://www.bilibili.com/read/cv13875630?spm_id_from=333.999.0.0 描述: 适用于企业内部 CentOS7 系列操作服务器初始化. ...
- centos7系统下nginx安装并配置开机自启动操作
准备工作 我的centos7系统是最小化安装的, 缺很多库, 首先安装必须的运行库 ? 1 2 3 4 5 6 7 8 9 10 11 yum install wget gcc gcc-c++ pcr ...
- 使用Xshell5连接虚拟机VMware中安装的CentOS7系统
使用Xshell5连接VMware中安装的CentOS7系统 准备材料 Xshell 下载地址 VMware Workstation 12 Pro 下载地址 CentOS 7 64位系统 下载地址 安 ...
- CentOS7系统 ansible自动化部署多台服务器部署
CentOS7系统 ansible自动化部署多台服务器部署 Ansible工作机制 从图中可以看出ansible分为以下几个部份: 1> Control Node:控制机器2> In ...
- Centos7系统特性之systemd
1.centos系列的系统启动流程(内核级别的启动流程): POST(加电自检)---> Boot Sequence(BIOS)---> Boot loader (MBR)---> ...
- centos7最小安装初始化脚本
#!/bin/bash #zhangsen #lovexlzs@qq.com if [[ "$(whoami)" != "root" ]]; then exit ...
- 基于CentOS7系统一键配置Aria2 实现服务器离线下载工具
我们有些网友购买的海外VPS主机并不是用来做网站的,而是用来作为下载资源工具使用的.确实用这样的工具搭建之后是比本地下载速度快,因为有些资源.软件等是海外资源,而且挂载在服务器上不占用本地的资源.在这 ...
随机推荐
- Get and Post(Unity3D六个发展)
猴子原创,欢迎转载. 转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=565 unity3d中的www ...
- cross-compile-openssl-windows.sh,cross-compile-curl-windows.sh,cross-compile-zlib-windows.sh,build-zlib-visual-studio-2015-cli.bat
https://gist.github.com/artynet build zlib with Visual Studio CLI toolhttps://gist.github.com/artyne ...
- 【v2.x OGE课程 15】 布局相关
1.父亲和儿子的关系 我们可以Entity类看到非常多parent(父)与child(子)这种字眼,这是游戏引擎中常有的概念,简单而言是一种has-a的关系 watermark/2/text/aHR0 ...
- Ubuntu 15.04 clang++ 3.6 编译boost 1.59/1.55
Ubuntu 15.04已经可以直接通过apt-get insall 安装clang 3.6, 并且预装的gcc版本是4.9.2.这些安装过程在这里介绍. 首先下载boost源码 wget -O bo ...
- WPF 元素tag属性绑定一个属性或一个对象
<Window x:Class="CollectionBinding.CategoryDataTemp" xmlns="http://schemas. ...
- 关于Socket的建立及连接
最近在做一个东西,目前考虑的是采用Socket连接,从网上找了一个SuperSocket的socket通信框架.... 关于Socket连接,个人并不是搞得太懂,写的东西也全是个人理解,那么这里先整理 ...
- Have You Tried Delphi on Amazon Linux? (就是AWS用的Linux)
The new Delphi Linux compiler enables customers to take new or existing Windows server applications ...
- 零元学Expression Blend 4 - Chapter 6 如何置入Photoshop档案以及入门动画设计
原文:零元学Expression Blend 4 - Chapter 6 如何置入Photoshop档案以及入门动画设计 本章将教大家如何把Photoshop档案置入Expression Blend ...
- CRS-2800: Cannot start resource 'ora.asm' as it is already in the INTERMEDIATE state on server ‘RAC02’
在安装ORACLE RAC的Grid Infrastructure时,在节点1运行/u01/app/11.2.0/grid/root.sh正常,当在节点2运行/u01/app/11.2.0/grid/ ...
- VS2008 环境中完美搭建 Qt 4.7.4 静态编译的调试与发布(很不错,有六张插图说明,修改qmake.conf里的MD参数等)good
为什么要在VS2008中使用QT静态编译呢?很简单,因为VS2008编译器编译出来的文件比mingw编译的要几乎小一半. 好了现在我们来做些准备工作,VS2008自然要安装的,然后打上SP1的补丁.然 ...