系统yum源优化
yum源仓库:汇总保存多个软件包的服务器
yum源:/etc/yum.repos.d配置好yum源文件,便于找到指定yum仓库
yum安装软件特点:便于解决软件依赖
优化基础yum(base)
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
优化扩展yum(epel---Extra Packages for Enterprise Linux)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
无法正常用yum安装软件排错
1、网络配置不正确
2、yum源是否更新
3、清理yum缓存(yum clean all)
查看软件是否安装
rpm -qa cowsay
查看安装哪些信息
rpm -ql cosway
系统安全有关优化
防火墙优化:关闭
确认一个主机里面有哪些服务
netstat -lntup 查看网络服务端口号码信息
[root@oldboy0708 /oldboy]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6795/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7169/master
tcp6 0 0 :::22 :::* LISTEN 6795/sshd
tcp6 0 0 ::1:25 :::* LISTEN 7169/master
udp 0 0 127.0.0.1:323 0.0.0.0:* 5869/chronyd
udp6 0 0 ::1:323 :::* 5869/chronyd
CentOS6:
etc/init.d/iptables stop 临时关闭
etc/init.d/iptables status 查看临时
etc/init.d/iptables start 临时开启
chkconfig iptables off 永久关闭
chkconfig iptables on 永久开启
chkconfig --list iptables 查看永久
CentOS7
systemctl stop firewalld.service 临时关
systemctl stop firewalld.service 临时开
systemctl disable firewalld.service 永久关
systemctl enable firewalld.service 永久开
systemctl status firewalld.service 查看实时状态
systemctl is-active firewalld.service 查看临时状态
systemctl is-enabled firewalld.service 查看永久状态
selinux:企业中都会关闭
临时关闭:
setenforce 0 临时关
getenforce 查看状态
Enforcing/1 处于开启
Permissive/0 处于关闭
永久关闭:/etc/selinux/config
[root@oldboy0708 /oldboy]# 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 - No SELinux policy is loaded. ===============关闭
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
修改方法:
1、vi直接修改
2、vi 替换(s###g)
3、sed
sed -i '7s#enforcing#disabled#g' /etc/selinux/config
系统编码优化
作用:1避免出现中文乱码,2部分信息显示中文
查看系统字符编码:
[root@oldboy0708 /oldboy]# echo $LANG
en_US.UTF-8
修改字符编码:
临时修改:export LANG="en_US.UTF-8"
永久修改:
CentOS6:
vim /etc/systemconfig/i18n
export LANG="en_US.UTF-8"
CentOS7:
[root@oldboy0708 /oldboy]# vim /etc/locale.conf
LANG=en_US.UTF-8
source /etc/locale.conf
localectl set-locale LANG="en_US.UTF-8" 临时也永久
时间和时区优化
查看时间和时区信息
[root@oldboy0708 /oldboy]# timedatectl
Local time: Sun 2019-07-21 22:51:19 CST
Universal time: Sun 2019-07-21 14:51:19 UTC
RTC time: Sun 2019-07-21 22:51:19
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: yes
DST active: n/a
Warning: The system is configured to read the RTC time in the local time zone.
This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
=======================================================================================
timedatectl set-time 09:00 手动设置时间信息
timedatectl set-timezone Asia/Shanghai 设置时区
timedatectl list-timezone 查看有哪些时区
timedatectl set-local-trc 主板时间同步
timedatectl set-ntp 网络自动同步时间