Linux - 基础环境检查

 

检查操作系统:建议根据实际产品需要进行安装

检查主机名:集群中统一前缀并区分服务器功能,小写命名

检查内存:建议至少128G

检查CPU:建议至少2个支持超线程技术的10核芯片

检查磁盘:同一功能的服务器,建议统一磁盘规格

关闭防火墙:关闭且禁掉开机自启

字符集:设为zh_CN.UTF-8

时间时区:设置为北京时间,东八区

SSH端口号:设置为22

网络和网卡:千兆网卡,万兆更佳,节点之间 scp 传输网速在百兆左右

SELinux:设置为disable,需重启

 

 

 

 

操作系统

 

$ lsb_release -a
# ---------------------------------
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.9 (Final)
Release:        6.9
Codename:       Final

$ cat /etc/issue
# ---------------------------------
CentOS release 6.9 (Final)
Kernel \r on an \m


$ cat /etc/redhat-release
# ---------------------------------
CentOS release 6.9 (Final)

 

 

“主机名”

 

# >>>> centos 6.x <<<<

# 查看主机名
hostname
cat /etc/sysconfig/network

# 修改主机名
vim /etc/sysconfig/network
HOSTNAME=[主机名]


# >>>> centos 7.x <<<<

# 修改主机名
hostnamectl set-hostname [主机名]
# 主机名配置文件
vim /etc/hostname
# 查看主机名更改是否生效
hostnamectl status

 

“内存”

# 查看内存大小
cat /proc/meminfo | grep -i 'MemTotal'

# 查看内存使用情况
free -g

 

“CPU”

# 查看CPU型号
cat /proc/cpuinfo | grep -i 'name' | uniq
# 查看CPU核数
cat /proc/cpuinfo | grep -i 'cpu cores' | uniq
# 查看CPU个数
cat /proc/cpuinfo | grep -i 'physical id' | sort | uniq | wc -l
# 查看CPU信息
lscpu

 

 

“磁盘”

# 查看磁盘使用情况
df -h
df -lTh
# 查看服务器所有磁盘
fdisk -l
# 查看磁盘挂载情况
lsblk
# 查看磁盘属性(UUID、TYPE)
blkid
# 查看自动挂载配置文件
cat /etc/fstab
# 重新加载fstab文件,检查挂载是否有误,无回显则无误
mount -a

 

“防火墙”

# >>>> centos 6.x <<<<

# 查看防火墙状态
service iptables status
# 关闭防火墙服务
service iptables stop
# 查看防火墙自启服务配置
chkconfig iptables --list
# 关闭防火墙开机自启服务
chkconfig iptables off

# >>>> centos 7.x <<<<

# 查看防火墙状态
firewall-cmd --state
# 关闭防火墙服务
systemctl stop firewalld
# 关闭防火墙开机自启服务
systemctl disable firewalld
# 查看是否开机自启
systemctl is-enabled firewalld

 

 

“字符集”

# >>>> centos 6.x <<<<

# 查看字符集
locale
# 修改字符集
vim /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
# 修改后,执行source
source /etc/sysconfig/i18n

# >>>> centos 7.x <<<<

# 查看字符集
locale
# 修改字符集
vim /etc/locale.conf
LANF="zh_CN.UTF-8"
# 修改后,执行source
source /etc/locale.conf

 

 

“时间(区)”

# >>>> centos 6.x <<<<

# 查看时间
date
# 修改时间
date -s "2022-01-24 13:14:00"
# 查看时区
date -R
# 修改时区
rm -f /etc/localtime
ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


# >>>> centos 7.x <<<<

# 查看时间&时区
[root@localhost ~]# timedatectl
      Local time: Thu 2020-05-20 13:20:00 CST
  Universal time: Thu 2020-05-20 05:20:00 UTC
        RTC time: Thu 2020-05-20 05:20:00
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

# 修改时区
timedatectl set-timezone Asia/Shanghai

 

 

“NTP校时”

# >>>> centos 6.x <<<<

# 查看校时服务状态
service ntpd status
# 停止校时服务
service ntpd stop
# 校时
ntpdate [hostname|ip]
# 校时完毕,启动校时服务
service ntpd start

# >>>> centos 7.x <<<<

# 查看校时服务状态
systemctl status ntpd
# 停止校时服务
systemctl stop ntpd
# 校时
ntpdate [hostname|ip]
# 校时完毕,启动校时服务
systemctl start ntpd

 

 

“SSH端口号”

# >>>> centos 6.x <<<<

# 查看SSH端口号

USAGE: cat /etc/ssh/sshd_config | grep -i 'port'
-----------------------------------------------------
# If you want to change the port on a SELinux system, you have to tell
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#Port 22
# WARNING: 'UsePAM no' is not supported in openEuler and may cause several
#GatewayPorts no
GatewayPorts no

USAGE: netstat -tunlp | grep "ssh"
-----------------------------------------------------
tcp     0      0 0.0.0.0:22       0.0.0.0:*        LISTEN      4910/sshd
tcp6    0      0 :::22            :::*             LISTEN      4910/sshd


# 修改SSH端口号(可以存在多个Port)
vim /etc/ssh/sshd_config
Port [ssh端口号]


# 重启sshd服务
service sshd restart

# 使用新的SSH端口访问

 

 

“网络(卡)”

# 查看网卡设备
ifconfig
ip addr
# 配置静态IP(以网卡设备名称ifcfg-eth0为例)
cd /etc/sysconfig/network-scripts
vim ifcfg-eth0
# -------------------------
# 开机启动网络
ONBOOT=yes

# 网络配置参数
BOOTPROTO=static
# none:引导时不使用协议
# static:静态分配
# bootp:BOOTP协议
# dhcp:DHCP协议

# 设置为静态IP
IPADDR=[IP地址]
# 网关
GATEWAY=[网关]
# 子网掩码
NETMASK=225.225.225.0


# 修改网卡配置文件之后,重启网络
service network restart


# 查看网卡设备网速,假如网卡设备名:eth0
ethtool eth0 | grep -i 'speed'
# ----------------------------------
        Speed: 10000Mb/s



# 删除虚拟网卡操作流程

# 1、删除虚拟网卡

# 方法一(推荐): 不需要指定虚拟网卡名
virsh net-destroy default

# 方法二(参考): 禁用网卡
ifconfig 网卡名 down

# 2、重启网络服务
service network restart

 

 

“SELinux”

# 查看SELinux的状态
getenforce

# 《SELinux三种状态》
# Enforcing:强制启用
# Permissive:宽容,即大部分规则都放行
# disabled:禁用,即不设置任何规则
# 前两种可以通过setenforce命令来临时设置,重启系统后会失效
# 设置Enforcing
setenforce 1
# 设置permissive
setenforce 0
# disabled需要修改配置文件,并需要重启系统。

# 通过修改配置文件,让SELinux的配置永久生效
vim /etc/selinux/config
# -------start-------/etc/selinux/config-------start-------
# This file controls the state of SELinux on the system.
SELINUX=disabled
#     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 these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
# -------end-------/etc/selinux/config-------end-------

# 修改之后,重启系统
reboot

 

 

 

— 养成终生学习的习惯 —

 

posted @   HOUHUILIN  阅读(116)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示