centos离线安装软件

# yum的使用

# 查找相关库

# nslookup的安装方法

  • 直接使用yum安装,没有找到:yum install nslookup;
  • yum provides nslookup查询nslookup在哪个套件里面
  • 根据上面的提示,在"*/nslookup","*bin/nslookup"里找找看;
  • yum install bind-utils安装成功;
#查看安装目录相关信息
rpm -ql jenkins
1
2

# 源安装

# 下载程序包

# 方法一:使用 yum 下载

yum --downloadonly --downloaddir=/home/packages install polkit
1

通过 --downloaddir 参数指定程序包下载保存路径,修改 polkit 为自己需要下载的程序包名

# 方法二:在 pkgs.org 中下载

https://pkgs.org/ 打开该网站,根据操作系统及架构选择对应的软件源目录中
进入软件目录后,右上角输入软件包名进行搜索
如下图,找到所需要的软件包,点击进入详情页
找到 Download 标签,复制二进制文件 URL 到迅雷等下载工具中下载即可
1
2
3
4

# 本地http源方式

# 在能联网的服务器上

# 1、安装yumdownloader

yumdownloader是什么: yumdownloader is a program for downloading RPMs from Yum repositories

安装: yum install yum-utils -y

# 2、获取ansible安装包及依赖

mkdir /tmp/ansible
yumdownloader --resolve --destdir /tmp/ansible ansible
yumdownloader --resolve --destdir /tmp/ansible createrepo
tar zcf ansible.tar.gz /tmp/ansible
1
2
3
4

注意/tmp/ansible ansible之间是有空格的哦

# 3、上传

将ansible.tar.gz上传到离线服务器上/tmp目录下

# 在离线服务器上[推荐]

结合yumdownloader下载依赖库,再放到本地源中处理;

# 1、解压压缩包

tar zxf /tmp/ansible.tar.gz
1

# 2、制作离线源

cd /tmp/ansible
rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
rpm -ivh createrepo-0.9.9-28.el7.noarch.rpm
cd /tmp
createrepo ansible
1
2
3
4
5
6

# 3、编辑yum文件

vim /etc/yum.repos.d/ansible.repo
1
[ansible]
name=ansible
baseurl=file:///tmp/ansible
gpgcheck=0
enabled=1
1
2
3
4
5

# 4、安装ansible

yum install ansible -y
1

# rpm安装

首先将程序包放在指定路径下,例如 /home/packages/ 下

# 全新安装

(原系统中无该软件任何版本)

rpm -ivh /home/packages/polkit-0.112-26.el7_9.1.x86_64.rpm
1

如果有多个程序包,可以使用如下命令批量安装

rpm -ivh /home/packages/*.rpm
1

升级安装(新安装版本高于系统原有版本) 如果系统已有该软件较老版本,直接安装会提示版本冲突,安装失败,需要使用 -U 进行升级安装

rpm -Uvh /home/packages/polkit-0.112-26.el7_9.1.x86_64.rpm
1

降级安装(新安装版本低于系统原有版本) 需要使用 --oldpackage 参数

rpm -Uvh /home/packages/polkit-0.112-26.el7_9.1.x86_64.rpm --oldpackage
1

# 示范

  • 安装包 附件“离线安装包”目录中
  • 安装
rpm -vih docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm 
rpm -vih docker-ce-17.03.3.ce-1.el7.x86_64.rpm4.rpm 
1
2
  • 启动并设置开机启动

    systemctl daemon-reload 
    systemctl start redis-server.service 
    systemctl enable redis-server.servic
    
    ps -A|grep docker
    
    1
    2
    3
    4
    5

# yum 安装

准备好yum用的rpm包,拷贝到服务器,执行

yum localinstall *.rpm
1

# 二进制文件安装

tar xf docker-xxxxx.tgz
1
  • 拷贝二进制文件
cp docker/* /usr/bin/
1
  • docker注册为server

创建 /etc/systemd/system/docker.service文件内容如下:

[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

[Service]

Type=notify

# the default is not to use systemd for cgroups because the delegate issues still

# exists and systemd currently does not support the cgroup feature set required

# for containers run by docker

ExecStart=/usr/bin/dockerd

ExecReload=/bin/kill -s HUP $MAINPID

# Having non-zero Limit*s causes performance problems due to accounting overhead

# in the kernel. We recommend using cgroups to do container-local accounting.

LimitNOFILE=infinity

LimitNPROC=infinity

LimitCORE=infinity

# Uncomment TasksMax if your systemd version supports it.

# Only systemd 226 and above support this version.

#TasksMax=infinity

TimeoutStartSec=0

# set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

# kill only the docker process, not all processes in the cgroup

KillMode=process

# restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s

[Install]

WantedBy=multi-user.target
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  • 给执行权限
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
1
2
  • 启动并设置开机启动

    systemctl daemon-reload 
    systemctl start redis-server.service 
    systemctl enable redis-server.servic
    
    ps -A|grep docker
    
    1
    2
    3
    4
    5

# 参考链接

https://blog.csdn.net/qq12547345/article/details/122804730

上次更新: 2022/04/15, 05:41:32
×