修复CentOS升级过程中出现的package is a duplicate with的错误

服务器CentOS 7升级过程中出现中断,再次运行yum update则出现大量的包重复问题。

错误内容大致如下:

glibc-2.12-1.107.el6_4.5.x86_64 is a duplicate with glibc-2.12-1.107.el6_4.4.x86_64
glibc-common-2.12-1.107.el6_4.5.x86_64 is a duplicate with glibc-common-2.12-1.107.el6_4.4.x86_64
glibc-devel-2.12-1.107.el6_4.5.x86_64 is a duplicate with glibc-devel-2.12-1.107.el6_4.4.x86_64
glibc-devel-2.12-1.107.el6_4.5.x86_64 has missing requires of glibc-headers = ('0', '2.12', '1.107.el6_4.5')
iputils-20071127-17.el6_4.2.x86_64 is a duplicate with iputils-20071127-17.el6_4.x86_64
nspr-4.9.5-2.el6_4.x86_64 is a duplicate with nspr-4.9.2-1.el6.x86_64
nss-3.14.3-4.el6_4.x86_64 is a duplicate with nss-3.14.0.0-12.el6.x86_64
nss-softokn-3.14.3-3.el6_4.x86_64 is a duplicate with nss-softokn-3.12.9-11.el6.x86_64
nss-util-3.14.3-3.el6_4.x86_64 is a duplicate with nss-util-3.14.0.0-2.el6.x86_64
tzdata-2013g-1.el6.noarch is a duplicate with tzdata-2013c-2.el6.noarch
2:xinetd-2.3.14-39.el6_4.x86_64 is a duplicate with 2:xinetd-2.3.14-38.el6.x86_64

解决:

1,需要安装yum-utils

yum install yum-utils -y

2,清除yum缓存

yum clean all

3,列出重复的包

package-cleanup --dupes

4,删除重复的包

package-cleanup --cleandupes --removenewestdupes

5,清除可能存在的损坏包

package-cleanup --problems

6,继续升级

yum update -y

处理完成。

转自:https://my.oschina.net/u/1261643/blog/1840518

centos 更新内核后切换内核并删除旧内核

切换内核:

更新最新内核后需要删除旧内核腾出空间,突然发现虽然更新了内核但是没有启动

首先
uname -r
确认当前启动内核版本

其次
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

查看当前安装好的内核列表

下来

grub2-set-default 0

设置你想要启动的内核序号

最后

grub2-mkconfig -o /boot/grub2/grub.cfg

生成最新的启动列表

重启


删除旧内核:

先查询一下系统已安装的内核
rpm -qa | grep kernel
sudo yum remove -y 旧内核的名字

就好了

Debian/Ubuntu 官方完整源列表

Debian 9.0 源列表 (sources.list)

 

deb http://ftp.us.debian.org/debian/ stretch main non-free contrib
deb http://ftp.us.debian.org/debian/ stretch-proposed-updates main non-free contrib
deb-src http://ftp.us.debian.org/debian/ stretch main non-free contrib
deb-src http://ftp.us.debian.org/debian/ stretch-proposed-updates main non-free contrib
deb http://ftp.us.debian.org/debian/ stretch-backports main contrib non-free
deb-src http://ftp.us.debian.org/debian/ stretch-backports main contrib non-free
deb http://security.debian.org/ stretch/updates main
deb-src http://security.debian.org/ stretch/updates main

Debian 8.0 源列表 (sources.list)

deb http://ftp.us.debian.org/debian/ jessie main non-free contrib
deb http://ftp.us.debian.org/debian/ jessie-proposed-updates main non-free contrib
deb-src http://ftp.us.debian.org/debian/ jessie main non-free contrib
deb-src http://ftp.us.debian.org/debian/ jessie-proposed-updates main non-free contrib
deb http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free
deb-src http://ftp.us.debian.org/debian/ jessie-backports main contrib non-free
deb http://security.debian.org/ jessie/updates main
deb-src http://security.debian.org/ jessie/updates main

Debian 7.0 源列表 (sources.list)

deb http://ftp.us.debian.org/debian/ wheezy main non-free contrib
deb http://ftp.us.debian.org/debian/ wheezy-proposed-updates main non-free contrib
deb-src http://ftp.us.debian.org/debian/ wheezy main non-free contrib
deb-src http://ftp.us.debian.org/debian/ wheezy-proposed-updates main non-free contrib
deb http://ftp.us.debian.org/debian/ wheezy-backports main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy-backports main contrib non-free
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main

Debian 6.0 源列表 (sources.list)

deb http://ftp.us.debian.org/debian/ squeeze main non-free contrib
deb http://ftp.us.debian.org/debian/ squeeze-proposed-updates main non-free contrib
deb-src http://ftp.us.debian.org/debian/ squeeze main non-free contrib
deb-src http://ftp.us.debian.org/debian/ squeeze-proposed-updates main non-free contrib
deb http://ftp.us.debian.org/debian/ squeeze-backports main contrib non-free
deb-src http://ftp.us.debian.org/debian/ squeeze-backports main contrib non-free
deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main

Ubuntu 17.04 源列表 (sources.list)

deb http://archive.ubuntu.com/ubuntu/ zesty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ zesty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ zesty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ zesty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ zesty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ zesty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ zesty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ zesty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ zesty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ zesty-backports main restricted universe multiverse

Ubuntu 16.10 源列表 (sources.list)

deb http://archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ yakkety-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ yakkety-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ yakkety main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ yakkety-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ yakkety-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ yakkety-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ yakkety-backports main restricted universe multiverse

Ubuntu 16.04 源列表 (sources.list)

deb http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

Ubuntu 14.04 源列表 (sources.list)

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

Ubuntu 12.04 源列表 (sources.list)

deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

一键安装最新内核并开启 BBR 脚本

最近,Google 开源了其 TCP BBR 拥塞控制算法,并提交到了 Linux 内核,从 4.9 开始,Linux 内核已经用上了该算法。根据以往的传统,Google 总是先在自家的生产环境上线运用后,才会将代码开源,此次也不例外。
根据实地测试,在部署了最新版内核并开启了 TCP BBR 的机器上,网速甚至可以提升好几个数量级。
于是我根据目前三大发行版的最新内核,开发了一键安装最新内核并开启 TCP BBR 脚本。

本脚本适用环境

系统支持:CentOS 6+,Debian 7+,Ubuntu 12+
虚拟技术:OpenVZ 以外的,比如 KVM、Xen、VMware 等
内存要求:≥128M
日期  :2018 年 12 月 14 日

关于本脚本

1、本脚本已在 Vultr 上的 VPS 全部测试通过。
2、当脚本检测到 VPS 的虚拟方式为 OpenVZ 时,会提示错误,并自动退出安装。
3、脚本运行完重启发现开不了机的,打开 VPS 后台控制面板的 VNC, 开机卡在 grub 引导, 手动选择内核即可。
4、由于是使用最新版系统内核,最好请勿在生产环境安装,以免产生不可预测之后果。

使用方法

使用root用户登录,运行以下命令:

wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh

安装完成后,脚本会提示需要重启 VPS,输入 y 并回车后重启。
重启完成后,进入 VPS,验证一下是否成功安装最新内核并开启 TCP BBR,输入以下命令:

uname -r

查看内核版本,显示为最新版就表示 OK 了

sysctl net.ipv4.tcp_available_congestion_control

返回值一般为:
net.ipv4.tcp_available_congestion_control = bbr cubic reno
或者为:
net.ipv4.tcp_available_congestion_control = reno cubic bbr

sysctl net.ipv4.tcp_congestion_control

返回值一般为:
net.ipv4.tcp_congestion_control = bbr

sysctl net.core.default_qdisc

返回值一般为:
net.core.default_qdisc = fq

lsmod | grep bbr

返回值有 tcp_bbr 模块即说明 bbr 已启动。注意:并不是所有的 VPS 都会有此返回值,若没有也属正常。

CentOS 下最新版内核 headers 安装方法

本来打算在脚本里直接安装 kernel-ml-headers,但会出现和原版内核 headers 冲突的问题。因此在这里添加一个脚本执行完后,手动安装最新版内核 headers 之教程。
执行以下命令

yum --enablerepo=elrepo-kernel -y install kernel-ml-headers

根据 CentOS 版本的不同,此时一般会出现类似于以下的错误提示:

Error: kernel-ml-headers conflicts with kernel-headers-2.6.32-696.20.1.el6.x86_64
Error: kernel-ml-headers conflicts with kernel-headers-3.10.0-693.17.1.el7.x86_64

因此需要先卸载原版内核 headers ,然后再安装最新版内核 headers。执行命令:

yum remove kernel-headers

确认无误后,输入 y,回车开始卸载。注意,有时候这么操作还会卸载一些对内核 headers 依赖的安装包,比如 gcc、gcc-c++ 之类的。不过不要紧,我们可以在安装完最新版内核 headers 后再重新安装回来即可。
卸载完成后,再次执行上面给出的安装命令。

yum --enablerepo=elrepo-kernel -y install kernel-ml-headers

成功安装后,再把那些之前对内核 headers 依赖的安装包,比如 gcc、gcc-c++ 之类的再安装一次即可。

为什么要安装最新版内核 headers 呢?
这是因为 shadowsocks-libev 版有个 tcp fast open 功能,如果不安装的话,这个功能是无法开启的。

内核升级方法

如果是 CentOS 系统,执行如下命令即可升级内核:

yum -y install kernel-ml kernel-ml-devel

如果你还手动安装了新版内核 headers ,那么还需要以下命令来升级 headers :

yum -y install kernel-ml-headers

CentOS 6 的话,执行命令:

sed -i 's/^default=.*/default=0/g' /boot/grub/grub.conf

CentOS 7 的话,执行命令:

grub2-set-default 0

如果是 Debian/Ubuntu 系统,则需要手动下载最新版内核来安装升级。
这里下载最新版的内核 deb 安装包。
如果系统是 64 位,则下载 amd64 的 linux-image 中含有 generic 这个 deb 包;
如果系统是 32 位,则下载 i386 的 linux-image 中含有 generic 这个 deb 包;
安装的命令如下(以最新版的 64 位 4.12.4 举例而已,请替换为下载好的 deb 包):

dpkg -i linux-image-4.12.4-041204-generic_4.12.4-041204.201707271932_amd64.deb

安装完成后,再执行命令:

/usr/sbin/update-grub

最后,重启 VPS 即可。

特别说明

如果你使用的是 Google Cloud Platform (GCP)更换内核,有时会遇到重启后,整个磁盘变为只读的情况。只需执行以下命令即可恢复:

mount -o remount rw /

更新日志:

2018 年 12 月 14 日:
1、修正:在 CentOS 6 系统下 kernel-ml 及 kernel-ml-devel 无法安装的问题。原因是 elrepo 官方最近取消了 kernel-ml 及 kernel-ml-devel 的 rpm 资源。脚本已改为下载 rpm 来安装的方式。版本 4.18.20 将会是 CentOS 6 下最新的内核,目测以后也不会再有升级了,请尽快迁移到 CentOS 7 系统。

2018 年 06 月 09 日:
1、修正:在 CentOS 系统下将 elrepo-kernel 默认启用,以解决在安装新内核后执行 yum update 再次安装旧内核的问题。

2018 年 05 月 12 日:
1、修正:在 Ubuntu 或 Debian 系统中某些情况下获取不到某个编译失败的安装包导致退出安装的问题。并且现在可以手动选择安装从 4.14 到最新版本的内核。

2018 年 02 月 24 日:
1、新增:手动安装最新版内核 headers 的教程。

2017 年 10 月 28 日:
1、更新:自动判断内核版本。如果内核版本已经大于或等于 4.9 且没有开启 BBR,脚本会直接设置好 BBR;
2、新增:脚本执行时会在当前目录下创建日志(install_bbr.log),方便查看及排错。

2017 年 02 月 22 日:
1、更新:自动获取最新版 4.10 内核。

2017 年 01 月 20 日:
1、新增:自动获取并下载安装最新版内核的功能。

2017 年 01 月 13 日:
1、更新:内核到 4.9.3。

2017 年 01 月 09 日:
1、更新:内核到 4.9.1。

参考链接:

https://github.com/google/bbr/blob/master/Documentation/bbr-quick-start.md
http://elrepo.org/tiki/tiki-index.php
http://kernel.ubuntu.com/~kernel-ppa/mainline/

转载请注明:秋水逸冰 » 一键安装最新内核并开启 BBR 脚本

一句话解决debian“Hash Sum mismatch”错误

买了个新vps,安装的debian7系统,apt-get后出来了Hash Sum mismatch错误,经过搜索发现问题出在apt软件版本低,不能正确的解析压缩过的metadata files,解决方法是,要么升级一下 apt,要么这么做:

apt-get update -o Acquire::CompressionTypes::Order::=gz

对于命令:也可以设置下载文件的压缩格式为bz2。
如果不想每次的对apt的配置进行第二条命令那样设置的话,可以这么做。

1, 创建一个新文件,
/etc/apt/apt.conf.d/99compression-workaround
2,添加文本
Acquire::CompressionTypes::Order:: “gz”;

———————

本文来自 忧愁莫扎特 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/chenming_hnu/article/details/54572708?utm_source=copy

解决!!!