Loading

OS-CentOS-01-CentOS7

下载

官网CentOS Mirrors List

下载CentOS-7-x86_64-Minimal-2009.iso 文件

安装

配置

主机名

# 设置新的主机名 默认localhost
hostnamectl set-hostname <HostName>

网络[可选 一般已经配置好了]

DHCP

# 修改网络适配器配置
# 修改BOOTPROTO为dhcp 设置启动行为为DPCH自动分配IP地址 BOOTPROTO=dhcp
# 修改ONBOOT为yes 以便开机启动时进行DPCH ONBOOT=yes
vi /etc/sysconfig/network-scripts/ifcfg-xxx
# 重启网络服务以便立即生效配置
systemctl restart network

静态地址

# 修改网络适配器配置
# 修改BOOTPROTO为none,以便使用静态IP BOOTPROTO=none
# 修改ONBOOT为yes,以便开机启动时能设置静态IP ONBOOT=yes
# 新增或修改子网掩码位数,24需替换为对应值 PREFIX=24
# 新增或修改IP地址,IP地址需要替换为对应值 IPADDR=192.168.62.203
# 新增或修改网关地址,网关IP地址需要替换为对应值 GATEWAY=192.168.62.2
vi /etc/sysconfig/network-scripts/ifcfg-xxx
# 重启网络服务以便立即生效配置
systemctl restart network
# 设置dns 增加nameserver 例如:
# nameserver 8.8.8.8
# nameserver 8.8.4.4
# nameserver 223.5.5.5
# nameserver 223.6.6.6
vi /etc/resov.conf

SSH[可选 默认已安装启用]

安装

# 安装openssh-server
yum install -y openssh-server

启动

# 启动sshd服务,安装后默认会启动
systemctl start sshd
# 检查sshd服务是否启动
systemctl is-active sshd

设置自动启动

# 设置自动启动,安装后默认为自动启动
systemctl enable sshd
# 查看是否为自动启动
systemctl is-enabled sshd

配置

vim /etc/ssh/sshd_config

换源

阿里云

# 备份原文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

禁用SeLinux

# 禁用selinux配置
sed -i 's/enforcing/disabled/' /etc/selinux/config
# 关闭selinux
setenforce 0
# 重启后,再获取selinux状态确认已关闭,应返回Disabled
# 重启服务器后,sestatus 也能获取selinux状态
getenforce

时区

# 查询可用时区
timedatectl list-timezones

# 调整时区为上海
timedatectl set-timezone Asia/Shanghai

# 验证时区设置成功
timedatectl

时间同步

# 安装chrony时间同步工具
yum -y install chrony

# 启用开机启动
systemctl enable chronyd.service
# 启动chronyd服务
systemctl start chronyd.service

# 查看chronyd服务状态,确认服务已正常启动
systemctl status chronyd.service
posted @ 2022-12-11 15:42  知科行技  阅读(73)  评论(0编辑  收藏  举报