centos模板机制作前修改配置

简介:

1.关闭selinux
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0 临时生效,想要长期生效,重启系统
getenforce 查看selinux状态
2.关闭防火墙
/etc/init.d/iptables stop
/etc/init.d/iptables stop 要关闭至少2次
chkconfig iptables off
3.精简开机自启动服务
chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk '{print "chkconfig",$1,"off"}'|bash
export LANG=en
chkconfig --list|grep 3:on

4.提权oldboy可以sudo
useradd oldboy
\cp /etc/sudoers /etc/sudoers.ori
echo "oldboy ALL=(ALL) NOPASSWD:ALL">>/etc/sudoers
tail -l /etc/sudoers
visudo -c

5.中文字符集
先查看
[root@oldboy ~]# cat /etc/sysconfig/i18n 
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
再备份
[root@oldboy ~]# cp /etc/sysconfig/i18n /etc/sysconfig/i18n.ori
再修改
[root@oldboy ~]# echo 'LANG="zh_CN.UTF-8"'>/etc/sysconfig/i18n
[root@oldboy ~]# source /etc/sysconfig/i18n 
#使上文修改生效
[root@oldboy ~]# echo $LANG
查看当前字符集状态

6.时间同步
[root@oldboy ~]# echo '#time sync by oldboy at 2010-2-1'>>/var/spool/cron/root
[root@oldboy ~]# echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1' >>/var/spool/cron/root
[root@oldboy ~]# crontab -l
#time sync by oldboy at 2010-2-1
*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1


7.命令行安全

[root@oldboy ~]# #time sync by oldboy at 2010-2-1
[root@oldboy ~]# echo 'export TMOUT=300' >>/etc/profile
[root@oldboy ~]# echo 'export HISTSIZE=5' >>/etc/profile          
[root@oldboy ~]# echo 'export HISTFILESIZE=5' >>/etc/profile
[root@oldboy ~]# tail -3 /etc/profile

[root@oldboy ~]# . /etc/profile


8.加大文件描述

[root@oldboy ~]# echo '*        -       nofile       65535' >>/etc/security/limits.conf

[root@oldboy ~]# tail -1 /etc/security/limits.conf  
*        -       nofile       65535


9.内核优化

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 = 400065000

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
#以下参数是对iptables防火墙的优化,防火墙不开会提示,可以忽略不理。
#以下参数是对iptables防火墙的优化。
#CentOS 6.X:

net.netfilter.nf_conntrack_max = 25000000

net.netfilter.nf_conntrack_tcp_timeout_established = 180

net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120

net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60

net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120

#注意:在此优化过程中可能会有报错

#举例:

#5.8版本上

error: "net.ipv4.ip_conntrack_max"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_max"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait"is an unknown key

error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait"is an unknown key

#6.4版本上

error: "net.nf_conntrack_max"isan unknown key

error: "net.netfilter.nf_conntrack_max"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_established"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_time_wait"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_close_wait"isan unknown key

error: "net.netfilter.nf_conntrack_tcp_timeout_fin_wait"isan unknown key

#6.4版本上

error: "net.bridge.bridge-nf-call-ip6tables"isan unknown key

error: "net.bridge.bridge-nf-call-iptables"isan unknown key

error: "net.bridge.bridge-nf-call-arptables"isan unknown key
EOF

本文转自sandshell博客51CTO博客,原文链接http://blog.51cto.com/sandshell/1950291如需转载请自行联系原作者


sandshell

相关文章
|
3月前
|
应用服务中间件 Linux 网络安全
centos7 下离线安装gcc g++ nginx,并配置nginx进行网络流转发
centos7 下离线安装gcc g++ nginx,并配置nginx进行网络流转发
111 0
|
4月前
|
Kubernetes Ubuntu 安全
Linux|科普扫盲帖|配置网络软件源---阿里云镜像仓库服务使用(centos,Ubuntu)
Linux|科普扫盲帖|配置网络软件源---阿里云镜像仓库服务使用(centos,Ubuntu)
558 0
|
16天前
|
Linux 虚拟化
VMware workstation 中centos7虚拟机在nat模式下怎么配置网卡,指定我想要的IP并且可以联网
https://blog.csdn.net/2302_78534730/article/details/132825156?spm=1001.2014.3001.5502
131 0
|
1天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置PXE服务
PXE是Intel开发的预启动执行环境,允许工作站通过网络从远程服务器启动操作系统。它依赖DHCP分配IP,DNS服务分配主机名,TFTP提供引导程序,HTTP/FTP/NFS提供安装源。要部署PXE服务器,需关闭selinux和防火墙,安装dhcpd、httpd、tftp、xinetd及相关服务,配置引导文件和Centos7安装源。最后,通过syslinux安装引导文件,并创建pxelinux.cfg/default配置文件来定义启动参数。
5 0
|
1天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置postfix服务
安装CentOS7的Postfix和Dovecot,配置Postfix的`main.cf`文件,包括修改完全域名、允许所有IP、启用邮箱等。然后,配置Dovecot的多个配置文件以启用auth服务和调整相关设置。重启Postfix和Dovecot,设置开机自启,并关闭防火墙进行测试。最后,创建邮箱账户并在Windows邮箱客户端中添加账户设置。
9 0
|
2天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
8 0
|
15天前
|
网络协议
centos8 网卡 Nmcli(是network的简写 Nmcli)配置网络
centos8 网卡 Nmcli(是network的简写 Nmcli)配置网络
15 0
|
1月前
|
运维 Linux 应用服务中间件
Centos7如何配置firewalld防火墙规则
Centos7如何配置firewalld防火墙规则
49 0
|
1月前
|
存储 监控 Linux
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
【2月更文挑战第17天】Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
28 1
Flume【部署 02】Flume监控工具Ganglia的安装与配置(CentOS 7.5 在线安装系统监控工具Ganglia + 权限问题处理 + Flume接入监控配置 + 图例说明)
|
2月前
|
Ubuntu Linux 网络安全