Linux系统初始的一些优化(模板机)

linux系统的简单优化:

1.网卡的配置优化:
添加一块网卡,实现一个虚拟机有两块网卡(内网网卡 外网网卡)
vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.255.10
NETMASK=255.255.255.0
GATEWAY=192.168.255.2
DNS1=192.168.255.2


2.hosts优化,/etc/hosts下设置网络框架中的主机
[root@041840612cjd ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.28.5 lb01
172.16.28.6 lb02
172.16.28.7 web01
172.16.28.8 web02
172.16.28.9 web03
172.16.28.51 db01 db01.etianetian.org
172.16.28.31 nfs01
172.16.28.41 backup
172.16.28.61 m01


3.配置yum源和epel源
cd /etc/yum.repos.d
1)Base.repo 源 配置为国内的aliyun或者清华源
[Base]
name=Base
baseurl=https://mirror.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/
gpgcheck=0
enable=1
清空缓存重新建立缓存
[root@test ~]# yum clean all && yum makecache fast

2)epel源的配置
直接进行安装
[root@test ~]#yum -y install epel-release-7-13.noarch.rpm


4.关闭firewalld 和 selinux
firewalld:
[root@test ~]# systemctl stop firewalld
[root@test ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

selinux:
/etc/selinux/config
SELINUX=disable
[root@test ~]# setenforce 0 设置selinux临时关闭(shutdown 0 shutup 1)
[root@test ~]# getenforce
Permissive
永久关闭要修改配置文件


5.创建一个普通用户
[root@test ~]# useradd huajia
[root@test ~]# echo 123456 | passwd --stdin huajia
Changing password for user huajia.
passwd: all authentication tokens updated successfully.

配置普通用户的权限:vim /etc/sudoers
echo "oldboy ALL=(ALL) NOPASSWD:ALL " >> /etc/sudoers
tail -1 /etc/sudoers
visudo -c
oldboy ALL=(ALL) NOPASSWD:ALL
第一个ALL 表示所有计算机
第二个ALL 表示所有的用户
第三个ALL 表示所有的命令
NOPASSWD:ALL 表示输入命令无需密码


6.英文字符集优化
[root@test ~]# echo $LANG
en_US.UTF-8
[root@test ~]# localectl set-locale LANG=“en_US.UTF-8”


7.配置主机的时间同步服务 ntpdata + crond
[root@test ~]# yum -y install ntpdata
vim /var/spool/cron/root

#time sync by huajia 2021-6-5
*/5 * * * * /usr/sbin/ntpdate ntp1.aliyum.com > /dev/null 2>&1


8.加大系统的文件打开数量
说明:一个服务程序运行起来,会打开相应的文件
crond 定时任务服务启动后会打开相应文件,加载其中的配置
/var/spool/cron/root — 加载配置文件
/var/log/cron -----加载打开日志文件
lsof -i:22 查看22号端口打开文件的数量
lsof(list system open file)
设置系统打开文件最大65535 /etc/security/limits.conf
echo "* - nofile 65535 ">>/etc/security/limits.conf


9.ssh的优化
sed -i ‘s@#UseDNS yes@UseDNS no@g;s@GSSAPIAuthentication yes@GSSAPIAuthentication no@g’ /etc/ssh/sshd_config
systemctl reload sshd

UseDNS : 使用DNS反向解析 开启连接较慢(建议关闭)
GSSAPIAuthentication


10.安装基础的命令
yum -y lrzsz nmap tree dos2unix nc telnet wget lsof ntpdate bash-completion bash-completion-extra

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值