今天重装了本地的Centos,升级为最新的Centos7.4,在yum update的时候报了一个https://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/x86_64/Packages/kernel-headers-3.10.0-693.5.2.el7.x86_64.rpm: [Errno 14] curl#7 - "FAIled to connect to 2402:f000:1:416:101:6:6:177: Network is unreachable"
,除了教育网,普通家庭都是IPV4,从而导致无法解析IPV6地址,LNMP环境搭建请参考:#环境:CentOS 7安装 LNMP(Linux+Nginx+MariaDB+PHP)
更换为国内源
首先备份 CentOS-Base.repo sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
vi /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
:wq 保存后更新软件包缓存:yum makecache
报错解决办法:
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6 禁用IPv6(包括回环接口)
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6 禁用IPv6(默认)
#编辑sysctl更改proc全局
vim /etc/sysctl.conf
禁用整个系统所有接口的IPv6
net.ipv6.conf.all.disable_ipv6 = 1
#禁用某一个指定接口的IPv6(例如:eth0, lo)
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
#设置更改生效
sysctl -p /etc/sysctl.conf
设置:因为是在本地建议关闭防火墙firewalld和selinux,服务器端务必不要关闭firewalld和色Linux。
#关闭防火墙,并禁止自启动
systemctl disable firewalld
systemctl stop firewalld
#查看selinux状态
[root@localhost ~]# getenforce
Enforcing
#临时关闭selinux
##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
setenforce 0
#永久关闭selinux,重启后生效
[root@localhost ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing 修改enforcing为disabled
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted