修复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

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 脚本

python-dev无法安装

安装有些package之前需要先安装python—dev, 这个不能用pip install来安装,只能用sudo apt-get install来安装。安装后会发现还要先装另外两个东西,但是装这两个东西也还要继续装其他东西,相当麻烦且并没有成功。

会出现:

~$ sudo apt-get install python-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
python-dev : Depends: libpython-dev (= 2.7.11-1) but it is not going to be installed
Depends: python2.7-dev (>= 2.7.11-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

用aptitude 工具可以搞定
先:sudo apt-get install aptitude
然后:
sudo aptitude install python-dev,之后会出现:

sudo aptitude install python-dev
The following NEW packages will be installed:
libexpat1-dev{ab} libpython-dev{a} libpython2.7-dev{ab} python-dev
python2.7-dev{ab}
0 packages upgraded, 5 newly installed, 0 to remove and 1 not upgraded.
Need to get 28.1 MB of archives. After unpacking 42.1 MB will be used.
The following packages have unmet dependencies:
python2.7-dev : Depends: python2.7 (= 2.7.11-2) but 2.7.12-1ubuntu0~16.04.1 is installed.
Depends: libpython2.7 (= 2.7.11-2) but 2.7.12-1ubuntu0~16.04.1 is installed.
libexpat1-dev : Depends: libexpat1 (= 2.1.0-7) but 2.1.0-7ubuntu0.16.04.2 is installed.
libpython2.7-dev : Depends: libpython2.7-stdlib (= 2.7.11-2) but 2.7.12-1ubuntu0~16.04.1 is installed.
Depends: libpython2.7 (= 2.7.11-2) but 2.7.12-1ubuntu0~16.04.1 is installed.
open: 24; closed: 106; defer: 16; conflict: 21 .The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) libexpat1-dev [Not Installed]
2) libpython-dev [Not Installed]
3) libpython2.7-dev [Not Installed]
4) python-dev [Not Installed]
5) python2.7-dev [Not Installed]

Accept this solution? [Y/n/q/?] n 这里一定要n,因为给的solution是保持现在的状态,即不安装
The following actions will resolve these dependencies:

Downgrade the following packages:
1) libexpat1 [2.1.0-7ubuntu0.16.04.2 (now) -> 2.1.0-7 (xenial)]
2) libpython2.7 [2.7.12-1ubuntu0~16.04.1 (now) -> 2.7.11-2 (xenial)]
3) libpython2.7-minimal [2.7.12-1ubuntu0~16.04.1 (now) -> 2.7.11-2 (xenial)]
4) libpython2.7-stdlib [2.7.12-1ubuntu0~16.04.1 (now) -> 2.7.11-2 (xenial)]
5) python2.7 [2.7.12-1ubuntu0~16.04.1 (now) -> 2.7.11-2 (xenial)]
6) python2.7-minimal [2.7.12-1ubuntu0~16.04.1 (now) -> 2.7.11-2 (xenial)]

Accept this solution? [Y/n/q/?] y 接受新状态就可以安装了

Debian vps上安装net-speeder

tennfy之前在Linode debian系统下安装锐速教程一文中介绍过锐速,锐速使用效果确实非常好,可以有效的提升本地到VPS的连接速度。但是,锐速在KVM或XEN VPS中方可使用,对于众多OPENVZ vps用户来说未免有些遗憾。本文就来介绍一下锐速在OPENVZ vps环境下的替代品–net-speeder。
net-speeder介绍

net-speeder是一款与锐速类似的TCP加速程序,且具有锐速不具备的优势:可以用于OPENVZ虚拟化的vps中。但是,相对于锐速可以通过丢包判断及预测、准确估算路径带宽等方式智能发包,net-speeder采用了更为简单粗暴的方式,强制双倍发包。这样的做法有利有弊,优点在高延迟不稳定链路上(如电信到美国VPS)可以有效的降低丢包率,但是双倍发包就意味着耗费双倍流量,对于VPS流量有限的朋友来说需要慎重。

net-speeder github项目地址:https://github.com/snooda/net-speeder
net-speeder的安装及使用
net-speeder的安装

登入VPS后,下载net-speeder安装脚本

1

wget –no-check-certificate https://raw.githubusercontent.com/tennfy/net-speeder/master/debian_netspeeder_tennfy.sh

执行该脚本

1

bash debian_netspeeder_tennfy.sh

net-speeder的使用

脚本安装完成后,会自动运行net-speeder。可以通过如下命令查看net-speeder运行状态及停止net-speeder。

查看net-speeder是否运行

1

ps aux|grep net_speeder|grep -v grep

停止net-speeder

1

killall net_speeder

启动net-speeder(OPENVZ环境)

1

nohup /root/net_speeder venet0 “ip” >/dev/null 2>&1 &

设置net-speeder定时开关

net-speeder实际上是颇有争议的,双倍发包会导致网络拥堵,有点损人利己的感觉。因此,tennfy给出一个折中的方案,就是在晚上高峰期的时候开启net-speeder,空闲时间关闭。
1、设置时区

由于美国的VPS时区跟中国是不一致的,因此需要给VPS设置一下时区。
执行以下命令

1

echo “Asia/Shanghai” >/etc/timezone

输入date命令查看VPS上显示的时间是否与本地相同。
2、设置net-speeder定时开关

我们设定19点开启,24点关闭。执行以下命令:

1
2
3

echo ‘0 19 * * * root nohup /root/net_speeder venet0 “ip” >/dev/null 2>&1 &’ >>/etc/crontab
echo “0 0 * * * root killall net_speeder” >>/etc/crontab
/etc/init.d/cron restart

net-speeder注意事项

以下几种情况不适合使用net-speeder:
1、服务器流量较小,因为使用net-speeder会消耗双倍流量。
2、主要提供网页、图片等小文件访问。net-speeder对于下载大文件、代理访问视频网站等效果比较好,而对小文件加速效果不明显。
3、需要使用pptpd等不支持双倍发包的网络软件。net-speeder会造成这些软件无法正常使用。
4、如果线路本身很好,不存在延迟较大情况,使用net-speeder效果会适得其反。

本文出自 TENNFY WU,转载时请注明出处及相应链接。

本文永久链接: http://www.tennfy.com/3495.html