Linux 使用本地yum源及软件包管理

时间:2022-10-20 21:21:08

[root@node130 rh]# pwd
/opt/rh
[root@node130 rh]# ls
rhel-server-6.4-x86_64-dvd.iso

[root@node130 rh]#mkdir /mnt/cdrom

[root@node130 dev]# mount -v -t iso9660 -o loop  /opt/rh/rhel-server-6.4-x86_64-dvd.iso /mnt/cdrom/
mount: going to use the loop device /dev/loop0
/opt/rh/rhel-server-6.4-x86_64-dvd.iso on /mnt/cdrom type iso9660 (rw,loop=/dev/loop0)

[root@node130 yum.repos.d]# vim rhel-source.repo

[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

清除原有缓存

[root@node130 cdrom]# yum clean all

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Cleaning repos: rhel-source

Cleaning up Everything


获取yum列表

验证yum配置是否成功

[root@node130 cdrom]# yum makecache

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

rhel-source                                                                                                                           | 3.9 kB     00:00 ...

rhel-source/group_gz                                                                                                                  | 204 kB     00:00 ...

rhel-source/filelists_db                                                                                                              | 3.7 MB     00:00 ...

rhel-source/primary_db                                                                                                                | 3.1 MB     00:00 ...

rhel-source/other_db                                                                                                                  | 1.5 MB     00:00 ...

Metadata Cache Create

验证yum配置是否成功
[root@node130 cdrom]# yum grouplist | grep Server

Network Infrastructure Server

Print Server

Web Server

Backup Server

Directory Server

Identity Management Server

Network Storage Server

Server Platform

Server Platform Development

Systems Management Messaging Server support

查找软件包

yum list available  #列出可供安装的软件包

yum list installed #列出已安装的软件包

yum list extras #列出不是通过仓库安装的软件包

yum list *vorbis*#列出标题包含vorbis的软件包

yum list updates #列出可以更新的软件包

yum info wordpress #wordpress软件包说明

yum info word* #以word开头的软件包说明

yum search mp3 #查找包含字符串mp3的软件包

安装软包

yum install wordpress

yum groupinstall XFCE #安装整套XFCE桌面软件包

更新软件包

yum check-update #列出所有可更新的软件包

yum list updates openoffice* #查找openoffice*的更新

yum update #更新所有可更新的软件包

删除软件包

yum remove beagle #删除beagle 软件包

yum remove xscreen* 删除xscreen开头的软件包

yum groupremove XFCE 删除XFCE的组内的所有软件包

清除软件包

yum clean packages #清除遗留在缓存里的包文件

yum clean metadata #清除遗留在缓存里的元数据

yum clean headers #清除遗留在缓存里的头文件

yum clean all #清除元数据,头文件和包文件

rpm安装软妹包

rpm -ivh rpmforge-release-*.rpm

rpm -ivh http://ftp************.rpm

rpm升级软件包

rpm -Uhv  *.rpm

删除软件包

rpm -e rpmforge-release

rpm -e --nodeps  rpmforge-release

查询rpm包相关信息

rpm -q rsync  #版本信息

rpm -qp ***.rpm #获取当前目录下rpm包的相关信息

rpm -qa|less #列出系统中已安装的所有软件包

rpm -qf /etc/sysctl.conf #检查系统里某个文件以查看该文件属于哪个软件包

rpm -qi rpmforge-release #列出已安装软件包的标准信息信息

rpm -qlp *.rpm |less #列出rpm文件的内容

rpm -q --scripts kernel |less #列出已安装的rpm包自带的安装前和安装后脚本

[root@node130 ~]# find / -name 'functest.sh' -print | xargs ls -l;
-rw-r--r--. 1 root root 202 Nov 30 06:42 /root/functest.sh
-rw-r--r--  1 root root 202 Dec 18 05:09 /tmp/functest.sh
[root@node130 ~]# find / -name "postgresql-9.4.10-1-linux-x64.run" -exec ls -l {} \;
-rwxr-xr-x. 1 root root 37291135 Nov  8 08:27 /root/postgresql-9.4.10-1-linux-x64.run
-rwxr-xr-x. 1 postgres postgres 37291135 Nov  8 08:30 /home/postgres/postgresql-9.4.10-1-linux-x64.run
[root@node130 ~]# find / -name "functest.sh" -exec ls -l {} \;
-rw-r--r--. 1 root root 202 Nov 30 06:42 /root/functest.sh
-rw-r--r-- 1 root root 202 Dec 18 05:09 /tmp/functest.sh
[root@node130 ~]# find /home -name '*.conf' |xargs -I {} cp -r {} /tmp/
[root@node130 tmp]# find /home -name '*.conf' |xargs -I {} ls -l {}
-rw------- 1 root root 20642 Dec 18 05:23 /home/kingbase/data/kingbase.conf
-rw------- 1 root root 4106 Dec 18 05:23 /home/kingbase/data/sys_hba.conf
-rw------- 1 root root 88 Dec 18 05:23 /home/kingbase/data/kingbase.auto.conf
-rw------- 1 root root 1628 Dec 18 05:23 /home/kingbase/data/sys_ident.conf
-rw------- 1 root root 20642 Dec 18 05:24 /home/kaadmin/data/master/kaseg-1/kingbase.conf
-rw-r--r-- 1 root root 2361 Dec 18 05:25 /home/kaadmin/data/master/kaseg-1/kaperfmon/conf/kaperfmon.conf
-rw------- 1 root root 4106 Dec 18 05:25 /home/kaadmin/data/master/kaseg-1/sys_hba.conf
-rw------- 1 root root 1628 Dec 18 05:25 /home/kaadmin/data/master/kaseg-1/sys_ident.conf
-rw------- 1 root root 20642 Dec 18 05:26 /home/kaadmin/data/kaseg0/kingbase.conf
-rw------- 1 root root 4106 Dec 18 05:26 /home/kaadmin/data/kaseg0/sys_hba.conf
-rw------- 1 root root 1628 Dec 18 05:26 /home/kaadmin/data/kaseg0/sys_ident.conf
-rw------- 1 root root 7856 Dec 18 05:23 /home/postgres/.gnupg/gpg.conf
-rw------- 1 root root 4214 Dec 18 05:22 /home/postgres/data/pg_hba.conf
-rw------- 1 root root 1636 Dec 18 05:22 /home/postgres/data/pg_ident.conf
-rw------- 1 root root 88 Dec 18 05:22 /home/postgres/data/postgresql.auto.conf
-rw-r--r-- 1 root root 20825 Dec 18 05:22 /home/postgres/data/postgresql.conf
[root@node130 tmp]# find /home -name '*.conf' -exec ls -l {}\;
find: missing argument to `-exec'
[root@node130 tmp]# find /home -name '*.conf' -exec ls -l {} \;
-rw------- 1 root root 20642 Dec 18 05:23 /home/kingbase/data/kingbase.conf
-rw------- 1 root root 4106 Dec 18 05:23 /home/kingbase/data/sys_hba.conf
-rw------- 1 root root 88 Dec 18 05:23 /home/kingbase/data/kingbase.auto.conf
-rw------- 1 root root 1628 Dec 18 05:23 /home/kingbase/data/sys_ident.conf
-rw------- 1 root root 20642 Dec 18 05:24 /home/kaadmin/data/master/kaseg-1/kingbase.conf
-rw-r--r-- 1 root root 2361 Dec 18 05:25 /home/kaadmin/data/master/kaseg-1/kaperfmon/conf/kaperfmon.conf
-rw------- 1 root root 4106 Dec 18 05:25 /home/kaadmin/data/master/kaseg-1/sys_hba.conf
-rw------- 1 root root 1628 Dec 18 05:25 /home/kaadmin/data/master/kaseg-1/sys_ident.conf
-rw------- 1 root root 20642 Dec 18 05:26 /home/kaadmin/data/kaseg0/kingbase.conf
-rw------- 1 root root 4106 Dec 18 05:26 /home/kaadmin/data/kaseg0/sys_hba.conf
-rw------- 1 root root 1628 Dec 18 05:26 /home/kaadmin/data/kaseg0/sys_ident.conf
-rw------- 1 root root 7856 Dec 18 05:23 /home/postgres/.gnupg/gpg.conf
-rw------- 1 root root 4214 Dec 18 05:22 /home/postgres/data/pg_hba.conf
-rw------- 1 root root 1636 Dec 18 05:22 /home/postgres/data/pg_ident.conf
-rw------- 1 root root 88 Dec 18 05:22 /home/postgres/data/postgresql.auto.conf
-rw-r--r-- 1 root root 20825 Dec 18 05:22 /home/postgres/data/postgresql.conf