主机优化
hostname
hostnamectl set-hostname docker
hostnamectl set-hostname bj-wads-lb03
hostname命令的其他使用参数
hostname -i
fe80::e65d:444c:c009:cbf9%eth0 10.0 .0.100
hostname -I
10.0 .0.100
二、时间同步的优化
1,设置时区
timedatectl
[ root@localhost ~]
Local time: 四 2024 -06-27 17 :04:55 CST
Universal time: 四 2024 -06-27 09:04:55 UTC
RTC time: 四 2024 -06-27 09:04:56
Time zone: Asia/Shanghai ( CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
2,查看系统中所有的时区
timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
3,设置系统时区
timedatectl set-timezone Asia/Shanghai
2,设置时间(对表)
手动方式同步时间
yum -y install ntpdate
ntpdate ntp.aliyun.com
自动方式同步时间
timedatectl
查看自动时间同步工具chronyd的状态是否开启(是否有绿色的running)
systemctl status chronyd
如果没有
systemctl start chronyd
三、下载软件优化
1,配置下载源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 7851 0 --:--:-- --:--:-- --:--:-- 7859
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
2,安装重要常用的软件
yum -y install tree vim wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip nc nmap telnet bc psmisc httpd-tools bind-utils methogs expect dos2unix
bash-completion bash-completion-extras
lrzsz
nmap
net-tools
dos2unix
3,查看当前的yum源地址
yum repolist
四、安全软件的关闭优化
1,selinux关闭
getenforce
Enforcing
Permissive
vim /etc/selinux/config
.. .. .. .
SELINUX = disabled
.. .. .
2,关闭防火墙firewalld
systemctl stop firewalld.service
systemctl disable firewalld.service
3,拓展:systemctl命令
systemctl stop 服务名称
systemctl start 服务名称
systemctl status 服务名称
systemctl disable 服务名称
systemctl enable 服务名称
五、字符集优化
1 ,ascll码,; 1 字符1字节
2 ,各个国家都有计算机使用需求,GBK;
3 ,unicode:【每个字符占用4字节】;
4 ,【UTF-8万国码】;英文占用1字节,汉语占用2字节;
1 字节== 8bit== 256
4 字节== 32bit== 4294967296
localectl
System Locale: LANG = zh_CN.UTF-8
VC Keymap: cn
X11 Layout: cn
localectl list-locales
localectl set-locale LANG = 编码表名称
localectl set-locale LANG = zh_CN.utf8
六、系统远程连接优化
vim /etc/ssh/sshd_config
79 GSSAPIAuthentication no
115 UseDNS no