linux 集群
Last updated on August 14, 2025 am
🧙 Questions
☄️ Ideas
hostname
修改hostname
执行成功后,建议重新登录用户
sudo hostnamectl set-hostname isxcode
设置hostname配置
sudo vim /etc/sysconfig/network
HOSTNAME=isxcode
修改hosts域名映射
sudo vim /etc/hosts
# 建议注释掉内网ip那一行
# 建议使用内网映射
#172.26.34.192 iZ8vba7fpabuah6hxfi5m1Z iZ8vba7fpabuah6hxfi5m1Z
172.26.34.192 isxcode
集群时区同步
前提
- 关闭防火墙
- 关闭selinux
- 安装ntpd
修改ntpd配置
sudo systemctl start ntpd
sudo systemctl stop ntpd
sudo systemctl enable ntpd
sudo systemctl restart ntpd
sudo ntpq -p
sudo systemctl stop ntpd
sudo vim /etc/ntp.conf
# === sudo vim /etc/ntp.conf ===
restrict 127.0.0.1
restrict ::1
# 注释所有其他的sever,设置内网时区
server 127.127.1.0 iburst
fudge 127.127.1.0 stratum 3
# 启用本地时钟(硬件时钟)作为备用时间源,并设置其层级(stratum)
# === sudo vim /etc/ntp.conf ===
sudo systemctl start ntpd
sudo systemctl enable ntpd
sudo systemctl restart ntpd
# 检查ntpd是否启动 ntpd默认端口号为123
sudo netstat -tunlp | grep 123
ntpq -np
timedatectl status
date -s "2025-07-06 18:34:45"
# 查看时区服务器是否是通的
sudo ntpdate -d 192.168.9.146
sudo ntpdate -u 192.168.9.146
tail -f /var/log/messages
sudo systemctl status ntpd
ntpstat # 查看是否同步
# 强制单次同步并退出
sudo ntpd -gq
remote: NTP 服务器的主机名或 IP 地址。
refid: .LOCL. 表示服务器未同步到外部源(可能是本地硬件时钟)。
st: 1 是最高级(通常为原子钟或 GPS),但 .LOCL. 表示实际不可靠。2 表示从 stratum 1 同步的次级服务器。
t: 类型(u = 单播,b = 广播等)。
when: 上次同步至今的秒数(752 和 671 秒,约 12 分钟未同步)。
poll: 下次同步的间隔(秒,1024 秒 ≈ 17 分钟)。
reach: 最近 8 次同步的成功率(377 二进制 11111101,表示最近 7/8 次成功)。
delay: 网络延迟(毫秒,你的值 1.491 和 1.969 正常)。
offset: 本地与服务器的时间偏差(毫秒,你的值 -572469 和 -572505 异常大,约 572 秒偏差)。
jitter: 时间偏移的波动(毫秒,你的值 1022.17 和 1058.11 极高)。
手动同步时区
yum install ntp -y
# ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# echo "Asia/Shanghai" > /etc/timezone
# ntpdate -u ntp2.aliyun.com
vim /etc/ntp.conf
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
# 远程服务器放在最上面
server 192.168.11.150 iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
systemctl start ntpd
systemctl enable ntpd
systemctl status ntpd
免密认证
ssh
ssh-copy-id root@isxcode.com
ulimit 配置
ulimit -a
sudo vim /etc/security/limits.conf
# 追加 ------------------
* soft nproc 65535
* hard nproc 65535
dcloud soft nproc 65535
dcloud hard nproc 65535
# ----------------------
sudo vim /etc/pam.d/login
# 追加 -----------------
session required pam_limits.so
# ----------------------
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
修改sshd
sudo vim /etc/ssh/sshd_config
MaxSessions 3000
LoginGraceTime 5m
sudo systemctl reload sshd
sudo systemctl restart sshd
sudo systemctl status sshd
使用chrony做时区同步
sudo vim /etc/chrony.conf
server 192.168.9.146 iburst
server 192.168.9.147 iburst
# 最大同步50s,超过10秒不同步
maxdistance 50.0
sudo systemctl restart chronyd
sudo systemctl status chronyd
sudo systemctl start chronyd
sudo systemctl stop chronyd
chronyc tracking
chronyc sources -v
chronyc sourcestats -v
timedatectl status
timedatectl set-ntp true
sudo ntpdate -u cdh-master
// * 是对的
^* jac-dc01.jac.net 2 6 37 15 +2604us[+1705us] +/- 10.9s
🔗 Links
linux 集群
https://ispong.isxcode.com/os/linux/linux 集群/