centos系统升级请看
Centos7 升级 RHEL8
网络配置
1
| vim /etc/sysconfig/network-scripts/ifcfg-ens**
|
固定ip配置
1 2 3 4 5 6 7 8 9 10
| TYPE=Ethernet BOOTPROTO=none DEVICE=ens33 ONBOOT=yes IPADDR=10.0.0.7 PREFIX=24 GATEWAY=10.0.0.2 DNS1=10.0.0.2 DNS2=223.5.5.5 DOMAIN=10.0.0.2
|
DHCP配置
1 2 3 4 5
| TYPE=Ethernet BOOTPROTO=dhcp PERSISTENT_DHCLIENT=yes DEVICE=ens33 ONBOOT=yes
|
临时修改IP(重启失效)
1 2 3
| ifconfig eth0 192.168.120.56 ifconfig eth0 192.168.120.56 netmask 255.255.255.0 ifconfig eth0 192.168.120.56 netmask 255.255.255.0 broadcast 192.168.120.255
|
临时增加vip
1
| ip addr add 192.168.20.20/24 brd + dev eth0
|
网卡配置VLAN
1 2 3 4 5 6 7 8 9 10 11 12
| TYPE=Vlan VLAN=yes VLAN_ID=180 BOOTPROTO=none DEFROUTE=yes NAME=enp3s0f0 DEVICE=enp3s0f0 ONBOOT=yes IPADDR=192.168.20.230 PREFIX=24 GATEWAY=192.168.20.1 DNS1=114.114.114.114
|
修改网卡名
centos7默认是以接口名称被自动基于固件,拓扑结构和位置信息来确定。如ens33,如果想要以eth0来命名
光标选择“Install CentOS 7”
点击Tab,打开kernel启动选项后,增加net.ifnames=0 biosdevname=0
系统配置
关闭 selinux
1
| sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux && setenforce 0
|
timedatectl命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| timedatectl list-timezones timedatectl set-local-rtc 1 timedatectl set-timezone Asia/Shanghai
timedatectl status
timedatectl set-ntp 0
timedatectl set-time 15:58:30
timedatectl set-time 20151120
timedatectl set-time '16:10:40 2015-11-20'
|
ntp时间同步
1 2 3 4 5
| yum install ntp ntpdate -y
systemctl start ntpdate
ntpdate time.windows.com
|
ntp只会同步系统时间而不会同步硬件时间,若服务器重启则系统时间会失效,依旧从硬件时间开始计时,所以使用ntp同步系统时间后需要将系统时间同步到硬件时间 hwclock -w
修改内核参数
1
| sysctl -w net.ipv4.ip_forward=1
|
忘记密码
重启, 在 grub2
界面 先按 ↑
停在这个界面,然后按 e
进入编辑模式
找到 linux16
那一行, 在最后面添加 init=/bin/sh
按 ctrl + x
继续启动
1 2 3 4 5
| mount -o remount,rw / passwd root
touch /.autorelabel exec /sbin/init
|
修改时区
1 2 3 4 5 6 7 8 9 10
|
sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
export TZ='Asia/Shanghai'
rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
安装相应字体
1
| yum install dejavu-lgc-sans-fonts
|
全局代理
1 2 3 4
| vim /etc/profile
export http_proxy="http://10.0.0.1:21882" source /etc/profile
|
服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| systemctl list-units systemctl list-unit-files systemctl status sshd systemctl stop sshd systemctl start sshd systemctl restart sshd systemctl enable sshd systemctl disable sshd systemctl reload sshd systemctl list-dependencies sshd systemctl mask sshd systemctl unmask sshd systemctl set-default multi-user.target systemctl set-default graphical.target setterm
|
查看所有的service
1
| ll /usr/lib/systemd/system/
|
查看开机自启的service
1 2
| systemctl list-unit-files | grep enabled ll /etc/systemd/system/multi-user.target.wants/
|
hostnamectl命令
1
| hostnamectl set-hostname centos1
|
防火墙
1 2 3
| systemctl start firewalld.service systemctl stop firewalld.service systemctl disable firewalld.service
|
基础环境
编译环境
1
| yum groupinstall "Development Tools"
|
yum 和 rpm
yum 是用python写的
查看一个包有哪些文件组成
查看所有包列表
本地安装包,会自动处理依赖
1
| yum localinstall ./xxx.rpm
|
本地安装包,不处理依赖
阿里云源
1 2 3 4 5 6 7 8 9
| mv /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
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
|
Remi源(各种版本的php)
1 2 3
| yum install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm
yum install php74-php-fpm
|
查询一个文件属于哪个包
只下载不安装
1
| yum install --downloadonly --downloaddir=/tmp/ vsftpd
|
安装指定版本的包
查询包有那些可用的版本
1
| yum list kubelet kubeadm kubectl --showduplicates | sort -r
|
安装指定版本的包
1
| yum install kubelet-1.16.9-0 kubeadm-1.16.9-0 kubectl-1.16.9-0
|