一、查看硬件环境:

查看硬件产品名称:
[root@aliyun ~]# dmidecode | grep "Product Name"
	Product Name: Alibaba Cloud ECS

查看CPU型号:	一核CPU
[root@aliyun ~]# grep name /proc/cpuinfo 
model name	: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz

查看CPU个数:
[root@aliyun ~]# grep "physical id" /proc/cpuinfo 
physical id	: 0

查看内存的信息:
[root@aliyun ~]# grep MemTotal /proc/meminfo 
MemTotal:        1019984 kB


查看系统环境:
系统版本:
[root@aliyun ~]# cat /etc/redhat-release 
CentOS release 6.8 (Final)

[root@aliyun ~]# uname -r
2.6.32-696.1.1.el6.x86_64

二、操作系统的优化

关闭防火墙,在生产环境中如果没有外网ip,一般也可以关闭防火墙
[root@aliyun ~]# chkconfig iptables off
[root@aliyun ~]# /etc/init.d/iptables stop

关闭selinux
[root@aliyun ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#	enforcing - SELinux security policy is enforced.
#	permissive - SELinux prints warnings instead of enforcing.
#	disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#	targeted - Only targeted network daemons are protected.
#	strict - Full SELinux protection.
SELINUXTYPE=targeted

[root@aliyun ~]# sed -i \'s#SELINUX=disabled#SELINUX=disabled#g\' /etc/selinux/config
[root@aliyun ~]# setenforce 
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]

 

添加一个普通用户账号
[root@aliyun ~]# useradd weiwei
[root@aliyun ~]# echo \'123456\'| passwd --stdin weiwei
Changing password for user weiwei.
passwd: all authentication tokens updated successfully.

为了安全可以将历史记录清空echo \'123456\'| passwd --stdin weiwei && history -c

 

配置yum源,可以考虑阿里云的源
http://mirrors.aliyun.com/help/centos
配置好源之后可以将系统更新
http://www.linuxidc.com/Linux/2013-08/88808.htm

 

清理开机自启动的服务
for var in `chkconfig | grep \'3:on\'| awk -F \' \' \'{print $1}\'`;do chkconfig --level 3 $var off;done
执行如下命令开启需要开机自启动的服务
for var in crond network syslog sshd;do chkconfig --level 3 $var on;done

 

更改ssh登录配置
[root@aliyun ~]# sed -i \'s/#Port 22/Port 123123/g\' /etc/ssh/sshd_config			改默认端口
[root@aliyun ~]# sed -i \'s/#PermitRootLogin yes/PermitRootLogin no/g\' /etc/ssh/sshd_config		root用户黑客都知道,禁止登录
[root@aliyun ~]# sed -i \'s/#PermitEmptyPasswords no/PermitEmptyPasswords no/g\' /etc/ssh/sshd_config			禁止空密码登录
[root@aliyun ~]# sed -i \'s/#UseDNS yes/UseDNS no/g\' /etc/ssh/sshd_config		不使用DNS
重启服务

 

将weiwei普通账号加入到sudo管理
[root@aliyun ~]# cp /etc/sudoers /etc/sudoers.bak
[root@aliyun ~]# echo \'weiwei ALL=(ALL) ALL\' >>/etc/sudoers
[root@aliyun ~]# tail -1 /etc/sudoers
weiwei ALL=(ALL) ALL

  

修改中文显示
locale
echo \'LANG=字符集\' >/etc/sysconfig/i18n
[root@aliyun ~]# cat /etc/sysconfig/i18n 
LANG=en_US.UTF-8
SYSFONT=latarcyrheb-sun16

  

服务器时间同步
echo \'*/5 * * * * /usr/sbin/ntpdate time.windows.com>/dev/null 2>&1\'>>/var/spool/cron/root 
如果此时的服务器很多的时候可以搞一个时间同步服务器
crontab -l

  

加大服务器文件描述符
[root@aliyun ~]# ulimit -n
65535
echo \'*		-		nofile		65535\'>>/etc/security/limits.conf
这个要设置的时候去配置文件里面看看

  

调整内核参数文件/etc/sysctl.conf

 

版权声明:本文为bill2014原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/bill2014/p/7510711.html