1.基础优化操作项:更新yum源信息
第一个:就近使用yum源地址,安装软件更快。
curl -s -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
第二个:安装RHEL/CentOS官方源不提供的软件包
curl -s -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2.安全优化:关闭SELinux及iptables(在工作场景中,如果有外部IP一般要打开iptables,高并发流量的服务器可能无法开启)

# 关闭selinux
sed -i 's#SELINUX=.*#SELINUX=disabled#g' /etc/selinux/config
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce
getenforce

3.关闭firewalld防火墙服务

systemctl stop firewalld
systemctl disable firewalld
systemctl disable firewalld

4.基础优化操作项:设置普通用户提权操作(可选优化)
# 提权smile可以利用sudo

useradd smile
echo |passwd --stdin smile
\cp /etc/sudoers /etc/sudoers.ori
echo "smile ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers
tail - /etc/sudoers
visudo -c

5.设置系统中文UTF8字符集

[root@smile ~]# cat /etc/locale.conf
LANG="en_US.UTF-8"
修改命令如下:
cp /etc/locale.conf /etc/locale.conf.ori
echo 'LANG="zh_CN.UTF-8"' >/etc/locale.conf
source /etc/locale.conf
echo $LANG

6.基础优化操作项:时间同步设置
# 定时更新服务器时间,使其和互联网时间同步。

yum install ntpdate -y
/usr/sbin/ntpdate ntp3.aliyun.com echo '#crond-id-001:time sync' >>/var/spool/cron/root
echo "*/5 * * * * /usr/sbin/ntpdate ntp3.aliyun.com >/dev/null 2>&1">>/var/spool/cron/root
crontab -l

7.基础优化操作项:提升命令行操作安全性(可选优化)
# 超时时间、操作记录数更改(可选配置)

echo 'export TMOUT=300' >>/etc/profile
echo 'export HISTSIZE=500' >>/etc/profile
echo 'export HISTFILESIZE=5' >>/etc/profile
tail - /etc/profile
. /etc/profile

8.基础优化操作项:加大文件描述符

# 实例演示:加大文件描述
echo '* - nofile 65535 ' >>/etc/security/limits.conf
tail - /etc/security/limits.conf
ulimit -SHn
ulimit -n #<==命令方式查看配置结果

9.基础优化操作项:优化系统内核

cat >>/etc/sysctl.conf<<EOF
net.ipv4.tcp_fin_timeout =
net.ipv4.tcp_tw_reuse =
net.ipv4.tcp_tw_recycle =
net.ipv4.tcp_syncookies =
net.ipv4.tcp_keepalive_time =
net.ipv4.ip_local_port_range =
net.ipv4.tcp_max_syn_backlog =
net.ipv4.tcp_max_tw_buckets =
net.ipv4.route.gc_timeout =
net.ipv4.tcp_syn_retries =
net.ipv4.tcp_synack_retries =
net.core.somaxconn =
net.core.netdev_max_backlog =
net.ipv4.tcp_max_orphans =
#以下参数是对iptables防火墙的优化,防火墙不开会提示,可以忽略不理。
net.nf_conntrack_max =
net.netfilter.nf_conntrack_max =
net.netfilter.nf_conntrack_tcp_timeout_established =
net.netfilter.nf_conntrack_tcp_timeout_time_wait =
net.netfilter.nf_conntrack_tcp_timeout_close_wait =
net.netfilter.nf_conntrack_tcp_timeout_fin_wait =
net.core.wmem_default =
net.core.rmem_default =
net.core.wmem_max =
net.core.rmem_max =
EOF
sysctl -p

11.ssh服务配置优化:
####Start by smile#2019-04-26###
Port 52113 #使用大于10000的端口
PermitRootLogin no #禁止root远程登录,可以su - root,C7需要改yes为no
PermitEmptyPasswords no #禁止空密码登录,C7默认就是

UseDNS no #不使用dns解析,yes改为no
GSSAPIAuthentication no #禁止连接慢的解决配置
ListenAddress 172.16.1.61:52113 #只允许内网IP连接SSH(172.16.1.0)
####End by smile#2019-04-26###

最终配置为:
####Start by smile#2019-04-26###
PermitEmptyPasswords no
UseDNS no
GSSAPIAuthentication no
#ListenAddress 172.16.1.7:22
####End by smile#2019-04-26###

12.基础优化操作项:安装系统常用软件
CentOS6和CentOS7都要安装的企业运维常用基础工具包

yum install tree nmap dos2unix lrzsz nc lsof wget tcpdump htop iftop iotop sysstat nethogs -y

CentOS7要安装的企业运维常用基础工具包

yum install psmisc net-tools bash-completion vim-enhanced -y

11.打补丁并升级有已知漏洞的软件。

yum update

12.锁定关键系统文件,如/etc/passwd,/etc/shadow,/etc/group,/etc/gshadow,/etc/inittab,处理以上内容后吧chattr、lsattr改名为oldboy,转移走,这样就安全多了。

13.清空/etc/isuue、/etc/issue.net,去除系统及内核版本登录前的屏幕显示。

 >/etc/issue
>/etc/issue.net
cat /etc/issue
cat /etc/issue.net

最新文章

  1. 利用私有的库MobileCoreServices检测正在安装的应用
  2. MySQL如何利用索引优化ORDER BY排序语句
  3. 【EF学习笔记10】----------主从表级联操作
  4. 线程入门之实现Runnable接口和继承Thread类
  5. 第一个Apple Watch小例子
  6. Network 20Q--Q2 How does Google sell ad spaces?
  7. SQLite基础回顾
  8. 2017 Multi-University Training Contest - Team 1 1002&amp;&amp;HDU 6034 Balala Power!【字符串,贪心+排序】
  9. popstate事件在低版本webkit中的调用
  10. SQL Server数据类型int、bigint、smallint、tinyint对比表
  11. display设置弹性盒布局
  12. IDEA VM设置
  13. Ex 5_28 Alice想要举办一个舞会..._第十次作业
  14. MySQL Community Server 8.0.11下载与安装配置
  15. 推荐算法 pd
  16. java 内部类的继承
  17. 新建网站与新建Asp.Net Web 应用程序的区别
  18. python中执行命令的3种方法小结-乾颐堂
  19. ActiveMQ相关:
  20. Jenkins集成SonarQube

热门文章

  1. Vue组件传值,父传子,子传父,非父子组件
  2. 刷新页面后,让控制台的js代码继续执行
  3. cisco路由器配置(三) 最终网关
  4. C学习笔记-typedef
  5. Emgu 学习之HelloWorld
  6. 2019牛客暑期多校训练营(第一场)-B.Integration()
  7. 【转帖】2018全球公有云IaaS榜单出炉:阿里、腾讯、中国电信、金山云列前十
  8. tourist&#39;s modular arithmetic class
  9. Luogu P4902 乘积
  10. Stream 分布式数据流的轻量级异步快照