安装 Ollama
curl -fsSL https://ollama.com/install.sh | sh报错
[root@ah-ipv6 ~]# curl -fsSL https://ollama.com/install.sh | sh
>>> Installing ollama to /usr/local
ERROR: This version requires zstd for extraction. Please install zstd and try again:
- Debian/Ubuntu: sudo apt-get install zstd
- RHEL/CentOS/Fedora: sudo dnf install zstd
- Arch: sudo pacman -S zstd
[root@ah-ipv6 ~]#安装报错是因为 Ollama 的安装脚本需要 zstd 这个压缩工具来解压文件。这个错误信息已经直接给出了解决方案:先安装 zstd 再重试即可。
安装 zstd
sudo dnf install -y zstd还是报错
[root@ah-ipv6 ~]# sudo dnf install -y zstd
sudo: dnf:找不到命令
[root@ah-ipv6 ~]#报错 sudo: dnf:找不到命令 说明系统中没有 dnf 这个包管理器。
这是因为 CentOS 7 及更早的 RHEL 系统默认使用 yum 作为包管理器,并未预装 dnf。此系统应该也属于这种情况。
CentOS 7 的 yum 官方源已停用,以及某些第三方源(如 EPEL)因压缩格式不兼容也会报错。
使用正确的包管理器安装 zstd
[root@ah-ipv6 ~]# # 清理yum缓存并生成新缓存
[root@ah-ipv6 ~]# sudo yum clean all
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
正在清理软件源: base cloudflared-stable docker-ce-stable epel extras updates
Cleaning up list of fastest mirrors
[root@ah-ipv6 ~]# sudo yum makecache
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
epel/x86_64/metalink | 4.2 kB 00:00:00
* base: mirrors.aliyun.com
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
cloudflared-stable | 1.5 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.3 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/22): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/22): base/7/x86_64/primary_db | 6.1 MB 00:00:03
(3/22): base/7/x86_64/filelists_db | 7.2 MB 00:00:03
(4/22): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:00
(5/22): docker-ce-stable/x86_64/filelists_db | 66 kB 00:00:00
(6/22): docker-ce-stable/x86_64/primary_db | 152 kB 00:00:00
(7/22): docker-ce-stable/x86_64/other_db | 145 kB 00:00:00
(8/22): base/7/x86_64/other_db | 2.6 MB 00:00:01
(9/22): epel/x86_64/group | 399 kB 00:00:00
(10/22): cloudflared-stable/filelists | 377 B 00:00:02
(11/22): cloudflared-stable/other | 423 B 00:00:02
(12/22): epel/x86_64/filelists_db | 15 MB 00:00:01
(13/22): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(14/22): epel/x86_64/prestodelta | 592 B 00:00:00
(15/22): epel/x86_64/primary_db | 8.7 MB 00:00:00
(16/22): extras/7/x86_64/filelists_db | 305 kB 00:00:00
(17/22): extras/7/x86_64/other_db | 154 kB 00:00:00
(18/22): extras/7/x86_64/primary_db | 253 kB 00:00:00
(19/22): epel/x86_64/other_db | 4.1 MB 00:00:00
(20/22): updates/7/x86_64/filelists_db | 15 MB 00:00:08
(21/22): updates/7/x86_64/other_db | 1.6 MB 00:00:00
(22/22): updates/7/x86_64/primary_db | 27 MB 00:00:15
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Parsing primary.xml error: Start tag expected, '<' not found
[root@ah-ipv6 ~]#看起来问题出在 cloudflared-stable 或 docker-ce-stable 这两个第三方仓库的元数据损坏了,导致 yum makecache 整体失败。我们可以暂时禁用它们,只从 CentOS 官方源和 EPEL 源安装 zstd。
# 1. 禁用有问题的仓库,然后安装 zstd
sudo yum --disablerepo=cloudflared-stable --disablerepo=docker-ce-stable install -y zstd运行结果
[root@ah-ipv6 ~]# sudo yum --disablerepo=cloudflared-stable --disablerepo=docker-ce-stable install -y zstd
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 4.2 kB 00:00:00
* base: mirrors.aliyun.com
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 zstd.x86_64.0.1.5.5-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=================================================================================================================================================================================================
Package 架构 版本 源 大小
=================================================================================================================================================================================================
正在安装:
zstd x86_64 1.5.5-1.el7 epel 449 k
事务概要
=================================================================================================================================================================================================
安装 1 件包
总下载量:449 k
安装大小:1.7 M
Downloading packages:
zstd-1.5.5-1.el7.x86_64.rpm | 449 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : zstd-1.5.5-1.el7.x86_64 1/1
验证中 : zstd-1.5.5-1.el7.x86_64 1/1
已安装:
zstd.x86_64 0:1.5.5-1.el7
完毕!
[root@ah-ipv6 ~]#zstd 已经成功安装。现在继续安装 Ollama:
curl -fsSL https://ollama.com/install.sh | sh安装完成后,验证一下:
ollama --version正常输出版本号(例如 ollama version is 0.5.1),就可以拉取并运行模型了。
ollama run deepseek-r1:7bOllama 会自动下载模型并启动对话。出现 >>> Send a message (/? for help) 提示时,就说明成功了。
评论 (0)