“OTHER_DIRS = ”是指定额外的软件包目录。注意:一旦指定,在该目录下的所有文件都会被上传
“UPLOAD_LIMIT = ”指定是否进行软件包下载数据列表统计并公布。默认为“yes”即进行公布,若你的电脑对保密等级要求特别高,那请设置为“no”
“DHT-ONLY = ”是否仅只使用分布式散列表提供的资源,建议使用默认值“no”
5、若是装有防火墙,须将“9967”、“9977”端口开放;若是使用路由器,还需要进行映射设置
6、重新启动 apt-p2p,以应用新配置
复制代码
sudo rm -rf /var/cache/apt-p2p/cache/*
sudo /etc/init.d/apt-p2p restart
7、开始更新、升级系统或安装软件包
复制代码
sudo apt-get update
sudo apt-get upgrade
说明:有的教程说要禁用第三方源,但就鄙人实际使用下来的情况,就算不禁用第三方源也没有什么影响
检视 apt-p2p 运行情况的方法:
在浏览器地址栏中输入 http://localhost:9977/,即可察看相关信息
本地软件包缓存搭建方法:
apt-p2p由Python写成,安装好后默认监听于TCP和UDP的9977端口,可通过/etc/apt-p2p/apt-p2p.conf改变其行为。TCP端口同时用于本机apt下载软件包,而UDP端口用于组建在p2p文件共享工具中常见的DHT网络。只需要在/etc/apt/sources.list文件中软件源的url,例如http://mirror.server/debian/的服务器域名前面插入localhost:9977,即成为http://localhost:9977/mirror.server/debian/,具体从互联网上获取软件包的工作便交给apt-p2p负责了:
当收到来自本机apt的文件下载请求时,apt-p2p会先检测文件是否已经存在于缓存的目录树中
如果已存在,则还要检查是否为最新(通过向软件源服务器发出HEAD请求来实现)
如果是,则直接返回缓存的文件
否则从互联网上下载文件供给apt,同时存入缓存并记录其散列值
下载文件会首先尝试从peer处下载,不成再到软件源服务器处下载
缓存下来的文件和散列值可供其他peer使用。可以通过apt-p2p的日志文件/var/log/apt-p2p.log深入观测这一过程。
以下是我安装了apt-p2p的主机mycastle的sources.list:
复制代码
deb http://localhost:9977/mirrors.ustc.edu.cn/debian/ testing main
deb-src http://localhost:9977/mirrors.ustc.edu.cn/debian/ testing main
deb http://localhost:9977/mirrors.ustc.edu.cn/debian-security/ testing/updates main
deb-src http://localhost:9977/mirrors.ustc.edu.cn/debian-security testing/updates main
deb http://localhost:9977/mirrors.ustc.edu.cn/debian/ testing-proposed-updates main
deb-src http://localhost:9977/mirrors.ustc.edu.cn/debian/ testing-proposed-updates main
deb http://localhost:9977/mirrors.ustc.edu.cn/debian/ unstable main










