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主机并不是用来做网站的,而是用来作为下载资源工具使用的.确实用这样的工具搭建之后是比本地下载速度快,因为有些资源.软件等是海外资源,而且挂载在服务器上不占用本地的资源.在这 ...
随机推荐
- python 教程 第十六章、 正则表达式
第十六章. 正则表达式 1) 匹配多个表达式 记号 re1|re2 说明 匹配正则表达式re1或re2 举例 foo|bar 匹配 foo, bar 记号 {N} 说明 匹配前面出 ...
- 如何构造请求处理对象链(Pipeline)
在开发中,我们经常会遇到这样一个场景:传入一个对象,经过不同的节点对这个对象做不同的操作,比如ASP.NET Core 中的pipeline,IIS中的HTTPpipeline等.在这类问题中,往往我 ...
- XDEBUG+PHPSTORM 开发 调试
原文:XDEBUG+PHPSTORM 开发 调试 XDEBUG+PHPSTORM 开发 调试 在我们开发过程中.我们如果经常性的echo.dump效率很低.所以我们就可以使用xdebug进行断点调试. ...
- 一台虚拟机配置nginx反向代理+3个apache虚拟主机
三个虚拟主机通过一张网卡添加三个IP来实现 一.安装nginx 1.解决依赖 [root@xuegod1 ~]# yum groupinstall "Development Tools&qu ...
- WPF CommandParameter的使用
<Window x:Class="Wpf180706.Window5" xmlns="http://schemas.microsoft.com/win ...
- datacontract helper
public static class DataContractHelper { public static void ToDCFile<T>(this T obj, string pat ...
- java模拟post请求发送json数据
import com.alibaba.fastjson.JSONObject; import org.apache.http.client.methods.CloseableHttpResponse; ...
- BackgroundWorker 简单使用教程 多个线程的创建
原文:BackgroundWorker 简单使用教程 多个线程的创建 BackgroundWorker是一个非常不错的线程控件,能避免界面假死,让线程操作你想要做的事,它学习起来很简单,但是能实现很强 ...
- MIPS开发板的“不二”选择——Creator Ci20单板计算机评测(芯片是君正JZ4780 ,也就是MIPS R3000,系统推荐Debian或深度,官网就有,其它语言有FreePascal和Go和Java和Python)
在MIPS架构的CPU上开发软件,当然需要使用MIPS专用的工具链来编译代码.不过一般的LINUX发行版内都有相应的配套工具链供用户使用.Ci20出厂时的LINUX发行版为DEBIAN 7.5,相应的 ...
- UBUNTU 16.04 + CUDA8.0 + CUDNN6.0 + OPENCV3.2 + MKL +CAFFE + tensorflow
首先说一下自己机子的配置 CPU:Intel(R) Core(TM) i5-5600 CUP @3.20GHz *4 GPU : GTX 1060 OS : 64bit Ubuntu16.04LTS ...