centos7 日常使用汇总 主机 | 网络 | 安装

1.主机相关

1.1 yum换源

yum换源-aliyun

1.2 安装ifconfig

yum install -y net-tools

1.3 更改主机名

//永久性的修改主机名称,重启后能保持修改后的。
hostnamectl set-hostname xxx	
 
//删除hostname
hostnamectl set-hostname ""

// 临时修改,重启失效
hostname master

1.4 设置静态IP

centos 配置静态ip

1.5 shellcheck

#安装扩展源

yum -y install epel-release

#安装shellcheck

yum install ShellCheck

1.6 时间同步

单台srv对时间要求不高,如果集群则要求时间同步,按如下步骤设置时间同步。

date

yum install -y ntpdate

ntpdate -u cn.pool.ntp.org  # -u:从man ntpdate中可以看出-u参数可以越过防火墙与主机同步

crontab -e 
# */20 * * * * /usr/sbin/ntpdate -u ntp1.aliyun.com >/dev/null
---
ntp常用服务器
国内:
cn.pool.ntp.org  中国开源免费NTP服务器
ntp1.aliyun.com 阿里云NTP服务器
ntp2.aliyun.com 阿里云NTP服务器
time1.aliyun.com 阿里云NTP服务器
time2.aliyun.com 阿里云NTP服务器
国外:
time1.apple.com 苹果NTP服务器
time2.apple.com 苹果NTP服务器
time3.apple.com 苹果NTP服务器
time4.apple.com 苹果NTP服务器
time5.apple.com 苹果NTP服务器
time1.google.com 谷歌NTP服务器
time2.google.com 谷歌NTP服务器
time3.google.com 谷歌NTP服务器
time4.google.com 谷歌NTP服务器
pool.ntp.org 开源免费NTP服务器
原文地址:https://www.cnblogs.com/davis12/p/15075466.html