博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
初始化一个新的服务器
阅读量:4480 次
发布时间:2019-06-08

本文共 2873 字,大约阅读时间需要 9 分钟。

一、查看硬件环境:

查看硬件产品名称:[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 -r2.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 weiweiChanging 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/sudoersweiwei ALL=(ALL) ALL

  

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

  

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

  

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

  

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

 

转载于:https://www.cnblogs.com/bill2014/p/7510711.html

你可能感兴趣的文章
自定义宏
查看>>
适配器模式
查看>>
Android中购物车的全选、反选、问题和计算价格
查看>>
GeoServer Rest服务启动匿名认证的配置方法
查看>>
网络流(最大独立点集):POJ 1466 Girls and Boys
查看>>
cpio命令详解
查看>>
python学习笔记 python实现k-means聚类
查看>>
DNS & CDN & HTTPDNS 原理简析
查看>>
RS485连接CAN——应急用法【worldsing笔记】【待完善】
查看>>
新公司新项目新团队新领导
查看>>
在PADS中如何导出PCB封装库
查看>>
《设计模式之禅》学习笔记(十)
查看>>
160. Intersection of Two Linked Lists
查看>>
深入浅出 Java Concurrency (36): 线程池 part 9 并发操作异常体系[转]
查看>>
面试内容
查看>>
最小公倍数
查看>>
大数乘大数
查看>>
C++继承与派生(原理归纳)
查看>>
PO与PR之间的关系SQL
查看>>
String、StringBuffer和StringBuilder的区别
查看>>