yum命令详解
===========================start
学习原理不错的博客 点这里
根据本地rpm包yum安装软件
[root@localhost firefox]# ls a.txt b.txt firefox-78.14.0-1.el7.centos.x86_64.rpm firefoxbak #本地rpm包 [root@localhost firefox]# yum localinstall firefox-78.14.0-1.el7.centos.x86_64.rpm #yum安装解决依赖包 Loaded plugins: fastestmirror Examining firefox-78.14.0-1.el7.centos.x86_64.rpm: firefox-78.14.0-1.el7.centos.x86_64 Marking firefox-78.14.0-1.el7.centos.x86_64.rpm to be installed [root@localhost firefox]# rpm -qa|grep firefox firefox-78.14.0-1.el7.centos.x86_64 [root@localhost firefox]# which firefox #查看包启动命令 /usr/bin/firefox [root@localhost firefox]# rpm -ql firefox-78.14.0-1.el7.centos.x86_64 #查看包的所有安装文件路径 /etc/firefox /etc/firefox/pref /usr/bin/firefox /usr/lib64/firefox
使用YUM查看所有版本的包以及指定版本安装
https://blog.51cto.com/foolishfish/1437662
原文来自RHCA北京同学袁麟
默认情况下,我们用yum list 或者 yum install 的时候,yum会默认选择最新的版本。
如果我们需要安装指定版本的某个软件包,以使之能够和我们现有环境的软件包版本匹配,那么就需要用到下面提到的方法了。
#以下示例,以RH442需要安装的kernel-debuginfo包为例 yum list kernel-debuginfo --showduplicates #Loaded plugins: product-id, refresh-packagekit, security, subscription-manager #Updating certificate-based repositories. #Available Packages #kernel-debuginfo.x86_64 2.6.32-220.el6 kernel-extras #kernel-debuginfo.x86_64 2.6.32-220.2.1.el6 kernel-extras #kernel-debuginfo.x86_64 2.6.32-220.4.1.el6 kernel-extras #查看yum能提供的软件包的全部版本,这里能看到,kernel-debuginfo有3个版本 yum list kernel #Loaded plugins: product-id, refresh-packagekit, security, subscription-manager #Updating certificate-based repositories. #Installed Packages #kernel.x86_64 2.6.32-220.el6 @anaconda-RedHatEnterpriseLinux-201111171049.x86_64/6.2 #Available Packages #kernel.x86_64 2.6.32-220.4.1.el6 Updates #查看到当前使用的kernel版本是2.6.32-220,指定软件版本进行安装 yum install kernel-debuginfo-2.6.32-220.el6
yum指定安装路径(可实现安装后的软件移植)
[root@mcw1 ~]# ls #查看目录下有哪些文件 1.sh 2.sh 3.sh 4.sh 5.sh anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 hi.txt host_ip.txt idc-check.tgz log mcw rpms ssh_auto.sh tmp [root@mcw1 ~]# mkdir mcw1 #创建指定安装目录 [root@mcw1 ~]# pwd /root [root@mcw1 ~]# yum -c /etc/yum.conf --installroot=/root/mcw1/ --releasever=/ install htop #执行yum命令,指定安装路径mcw1,安装htop,指定配置文件 Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 [root@mcw1 ~]# ls mcw1/ #安装好后查看安装目录,发现有很多子目录,和根下目录差不多 bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@mcw1 ~]# rpm -ql htop #用rpm命令查看安装包htop,显示是未安装的 package htop is not installed [root@mcw1 ~]# find mcw1/ -name "htop" #在安装目录下,找到htop命令 mcw1/usr/bin/htop [root@mcw1 ~]# mcw1/usr/bin/htop #相对路径或绝对路径执行命令,发现命令是可以执行的,执行效果是一样的。 [root@mcw1 ~]# rpm -ql mcw1/usr/bin/htop #rpm这样是差不到这个包文件安装在哪里 package mcw1/usr/bin/htop is not installed [root@mcw1 ~]# htop #直接执行命令,也是找不到这个命令的 -bash: htop: command not found [root@mcw1 ~]# yum install -y htop #直接yum安装,还是可以安装的。不过之前安装了很多依赖包,而这次却没有安装依赖包,只有htop Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com [root@mcw1 ~]# htop #直接执行命令,可以看到正常的效果 [root@mcw1 ~]# which htop #查看yum安装的路径 /usr/bin/htop [root@mcw1 ~]# rpm -ql htop #查看htop包的文件安装路径 /usr/bin/htop /usr/share/applications/htop.desktop /usr/share/doc/htop-2.2.0 /usr/share/doc/htop-2.2.0/AUTHORS /usr/share/doc/htop-2.2.0/ChangeLog /usr/share/doc/htop-2.2.0/README /usr/share/licenses/htop-2.2.0 /usr/share/licenses/htop-2.2.0/COPYING /usr/share/man/man1/htop.1.gz /usr/share/pixmaps/htop.png [root@mcw1 ~]# ls /usr/share/ #查看直接安装这个目录下的文件 abrt automake-1.13 defaults firstboot gettext-0.19.8 gtk-2.0 kdump magic open-vm-tools redhat-release tcl8.5 xsessions aclocal awk desktop-directories fontconfig ghostscript gtk-3.0 kernelshark man os-prober selinux terminfo yum-cli aclocal-1.13 backgrounds dict fonts git-core hwdata libdrm mime p11-kit sos themes yum-plugins alsa bash-completion doc games glib-2.0 i18n libreport mime-info perl5 sounds thumbnailers zoneinfo anaconda bison egl gcc-4.8.2 glvnd icons libthai misc pixmaps sql-bench tuned zsh appdata centos-logos emacs gcc-4.8.5 gnome idl libtool mozilla pkgconfig swig vim applications centos-release empty GConf gnome-background-properties info licenses mysql pki systemd wallpapers augeas cracklib et gdb gnupg intltool locale mysql-test plymouth systemtap X11 authconfig cscope file GeoIP groff ipmitool ltrace nmap polkit-1 tabset xemacs autoconf dbus-1 firewalld gettext grub kde4 lua omf python-dmidecode tcl8 xml [root@mcw1 ~]# ls mcw1/usr/share/ #查看指定目录mcw1对应目录下的文件,少不少 aclocal augeas centos-release dict empty gcc-4.8.2 gdb gnome icons info locale mime-info omf redhat-release tabset themes xsessions applications backgrounds desktop-directories doc games gcc-4.8.5 ghostscript i18n idl licenses man misc pixmaps sounds terminfo X11 zoneinfo [root@mcw1 ~]# ls mcw1/usr/share/|wc -l 34 #688 tar zcvf mcw1 mcw1.tar.gz#将安装目录打成tar包 [root@mcw1 ~]# ls 1.sh 2.sh 3.sh 4.sh 5.sh anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 hi.txt host_ip.txt idc-check.tgz log mcw mcw1 mcw1.tar.gz rpms ssh_auto.sh tmp [root@mcw1 ~]# scp -rp mcw1.tar.gz 10.0.0.130:/root #将tar包传输到其它主机130 The authenticity of host '10.0.0.130 (10.0.0.130)' can't be established. ECDSA key fingerprint is SHA256:4evLFLaqcnEUgEe0CUjeiur8vzS1Zyij8MVD7Q3QcMA. ECDSA key fingerprint is MD5:18:e8:66:50:a5:d5:b7:b2:25:e1:17:77:b1:d7:ad:1e. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.0.130' (ECDSA) to the list of known hosts. root@10.0.0.130's password: mcw1.tar.gz 100% 96MB 32.0MB/s 00:03 [root@mcw1 ~]# hostname -I #本机131 10.0.0.131 172.168.1.4 [root@localhost ~]# hostname -I #到130主机上去查看 10.0.0.130 172.168.1.3 [root@localhost ~]# ls #查看到tar包已经传输过来了 anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 idc-check.tgz log mcw mcw1.tar.gz rpms tmp [root@localhost ~]# htop #130主机没有安装htop包 -bash: htop: command not found [root@localhost ~]# tar xf mcw1.tar.gz #解压传输过来的tar包 [root@localhost ~]# ls anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 idc-check.tgz log mcw mcw1 mcw1.tar.gz rpms tmp [root@localhost ~]# ls mcw1/usr/bin/htop #查看解压包下的htop命令 mcw1/usr/bin/htop [root@localhost ~]# mcw1/usr/bin/htop #执行命令,能正常使用和显示命令执行结果。如上那般,似乎可以算是一个可迁移安装软件的方式。这样一来,貌似可以在某个通外网的环境yum安装好软件,然后打包上传到不通外网的环境下。从而实现没有外网,能方便的安装软件。 [root@localhost ~]#
疑问:指定目录安装后打包,但是多了很多目录,我不想要那么多。是否可以用rpm -ql 查看到这个包安装路径,然后只要保留这个安装路径的,其它的都删除掉呢。似乎是不可以的,我觉得指定安装某个软件,它的依赖包也是被安装到这个指定目录下了。相当于docker里的root环境,单独出来了。执行程序时,应该在这个指定目录也就是相对来说是软件的根目录下,调用其它的依赖包,而不影响整个操作系统的其它目录环境。
自行制作yum源仓库
自行制作yum源仓库 https://www.cnblogs.com/FengGeBlog/p/10230311.html
[root@mcw1 ~]# mkdir mcw2 #在131上创建软件包和依赖的下载目录 [root@mcw1 ~]# ls 1.sh 2.sh 3.sh 4.sh 5.sh anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 hi.txt host_ip.txt idc-check.tgz log mcw mcw1 mcw2 rpms ssh_auto.sh tmp [root@mcw1 ~]# cd mcw2/ [root@mcw1 mcw2]# ls [root@mcw1 mcw2]# pwd /root/mcw2 [root@mcw1 ~]# yum install nginx --downloadonly --downloaddir=/root/mcw2/ Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:01 (2/2): epel/x86_64/primary_db | 7.0 MB 00:00:05 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.20.1-2.el7 will be installed --> Processing Dependency: nginx-filesystem = 1:1.20.1-2.el7 for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_1)(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Running transaction check ---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed ---> Package nginx-filesystem.noarch 1:1.20.1-2.el7 will be installed ---> Package openssl11-libs.x86_64 1:1.1.1g-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================== Package Arch Version Repository Size ========================================== Installing: nginx x86_64 1:1.20.1-2.el7 epel 586 k Installing for dependencies: centos-indexhtml noarch 7-9.el7.centos base 92 k gperftools-libs x86_64 2.6.1-1.el7 base 272 k nginx-filesystem noarch 1:1.20.1-2.el7 epel 23 k openssl11-libs x86_64 1:1.1.1g-3.el7 epel 1.5 M Transaction Summary =============================================================================================================================================================================================== Install 1 Package (+4 Dependent packages) Total download size: 2.4 M Installed size: 6.7 M Background downloading packages, then exiting: (1/5): centos-indexhtml-7-9.el7.centos.noarch.rpm | 92 kB 00:00:00 (2/5): nginx-filesystem-1.20.1-2.el7.noarch.rpm | 23 kB 00:00:00 (3/5): gperftools-libs-2.6.1-1.el7.x86_64.rpm | 272 kB 00:00:00 (4/5): nginx-1.20.1-2.el7.x86_64.rpm | 586 kB 00:00:01 (5/5): openssl11-libs-1.1.1g-3.el7.x86_64.rpm | 1.5 MB 00:00:01 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 1.2 MB/s | 2.4 MB 00:00:02 exiting because "Download Only" specified [root@mcw1 ~]# ls /root/mcw2/ #查看下载的5个软件包 centos-indexhtml-7-9.el7.centos.noarch.rpm nginx-1.20.1-2.el7.x86_64.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm gperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-filesystem-1.20.1-2.el7.noarch.rpm [root@mcw1 ~]# rsync -avz /root/mcw2/ 10.0.0.130:/root/mcw3/ #将软件包传输到内网主机130上 root@10.0.0.130's password: sending incremental file list ./ centos-indexhtml-7-9.el7.centos.noarch.rpm gperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-1.20.1-2.el7.x86_64.rpm nginx-filesystem-1.20.1-2.el7.noarch.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm sent 2518526 bytes received 110 bytes 559696.89 bytes/sec total size is 2517211 speedup is 1.00 =========================130内网主机 [root@localhost ~]# ls anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 idc-check.tgz log mcw mcw1 mcw1.tar.gz mcw2 rpms tmp [root@localhost ~]# mkdir mcw3/ #创建目录存放上传的软件包 [root@localhost ~]# pwd /root [root@localhost ~]# cd mcw2 [root@localhost mcw2]# cd ../mcw3/ #进入创建的目录 [root@localhost mcw3]# ls #发现nginx及其依赖包总共5个,都已经从外网传输上来了。 centos-indexhtml-7-9.el7.centos.noarch.rpm nginx-1.20.1-2.el7.x86_64.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm gperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-filesystem-1.20.1-2.el7.noarch.rpm [root@localhost mcw3]# createrepo . #在内网130主机上在这个放包的目录下创建仓库,结果没有这个命令 -bash: createrepo: command not found [root@localhost mcw3]# yum install createrepo #这里先将它安装,假设它是安装好的(后面再添加假设没有安装好,那怎么在内网上装上它) Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/3): epel/x86_64/group_gz | 96 kB 00:00:00 (2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:01 (3/3): epel/x86_64/primary_db | 7.0 MB 00:00:03 Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package createrepo.noarch 0:0.9.9-28.el7 will be installed --> Processing Dependency: python-deltarpm for package: createrepo-0.9.9-28.el7.noarch --> Processing Dependency: deltarpm for package: createrepo-0.9.9-28.el7.noarch --> Running transaction check ---> Package deltarpm.x86_64 0:3.6-3.el7 will be installed ---> Package python-deltarpm.x86_64 0:3.6-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved =================================================================================================================== Package Arch Version Repository Size ================================================================================================================ Installing: createrepo noarch 0.9.9-28.el7 base 94 k Installing for dependencies: deltarpm x86_64 3.6-3.el7 base 82 k python-deltarpm x86_64 3.6-3.el7 base 31 k Transaction Summary ====================================================================================================================== Install 1 Package (+2 Dependent packages) Total download size: 207 k Installed size: 558 k Is this ok [y/d/N]: y Downloading packages: (1/3): createrepo-0.9.9-28.el7.noarch.rpm | 94 kB 00:00:00 (2/3): python-deltarpm-3.6-3.el7.x86_64.rpm | 31 kB 00:00:00 (3/3): deltarpm-3.6-3.el7.x86_64.rpm | 82 kB 00:00:00 -------------------------------------------------------------------------------------------------------------------- Total 275 kB/s | 207 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : deltarpm-3.6-3.el7.x86_64 1/3 Installing : python-deltarpm-3.6-3.el7.x86_64 2/3 Installing : createrepo-0.9.9-28.el7.noarch 3/3 Verifying : createrepo-0.9.9-28.el7.noarch 1/3 Verifying : deltarpm-3.6-3.el7.x86_64 2/3 Verifying : python-deltarpm-3.6-3.el7.x86_64 3/3 Installed: createrepo.noarch 0:0.9.9-28.el7 Dependency Installed: deltarpm.x86_64 0:3.6-3.el7 python-deltarpm.x86_64 0:3.6-3.el7 Complete! [root@localhost ~]# ls anaconda-ks.cfg bin conf default etc firefox firefox-92.0.tar.bz2 idc-check.tgz log mcw mcw1 mcw1.tar.gz mcw2 mcw3 rpms tmp [root@localhost ~]# cd mcw3/ #进入包目录 [root@localhost mcw3]# ls centos-indexhtml-7-9.el7.centos.noarch.rpm nginx-1.20.1-2.el7.x86_64.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm gperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-filesystem-1.20.1-2.el7.noarch.rpm [root@localhost mcw3]# createrepo . #在包的目录下执行创建yum仓库的命令 Spawning worker 0 with 5 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@localhost mcw3]# ls #查看包目录下多了个repodata的目录 centos-indexhtml-7-9.el7.centos.noarch.rpm nginx-1.20.1-2.el7.x86_64.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm gperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-filesystem-1.20.1-2.el7.noarch.rpm repodata [root@localhost mcw3]# ls /etc/yum.repos.d/ #查看yum源有哪些 CentOS-Base.repo CentOS-Base.repo.backup CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo epel.repo [root@localhost mcw3]# cd /etc/yum.repos.d/ #进入yum源目录, [root@localhost yum.repos.d]# vim localself.repo #编辑本地yum源 [root@localhost yum.repos.d]# yum clean all #清除以前的yum缓存 Loaded plugins: fastestmirror Cleaning repos: base epel extras self updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# yum repolist #查看yum仓库 Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 self | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/8): base/7/x86_64/group_gz | 153 kB 00:00:00 (2/8): epel/x86_64/group_gz | 96 kB 00:00:00 (3/8): self/primary_db | 5.9 kB 00:00:00 (4/8): epel/x86_64/updateinfo | 1.0 MB 00:00:00 (5/8): extras/7/x86_64/primary_db | 243 kB 00:00:06 (6/8): base/7/x86_64/primary_db | 6.1 MB 00:00:07 (7/8): epel/x86_64/primary_db | 7.0 MB 00:00:08 (8/8): updates/7/x86_64/primary_db | 11 MB 00:00:11 Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com repo id repo name status base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,674 extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 500 self local 5 updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 2,751 repolist: 27,002 [root@localhost yum.repos.d]# ping 223.5.5.5 #查看网络现在是同外网的,这不符合内网不通外网的环境 PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data. 64 bytes from 223.5.5.5: icmp_seq=1 ttl=128 time=10.5 ms 64 bytes from 223.5.5.5: icmp_seq=2 ttl=128 time=7.99 ms ^C --- 223.5.5.5 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1003ms rtt min/avg/max/mdev = 7.991/9.250/10.509/1.259 ms [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost ~]# grep -i gateway /etc/sysconfig/network-scripts/ifcfg-eth0 #编辑虚拟机能通外网的ip网关,将网关关掉,这样就不通外网了。 #GATEWAY=10.0.0.253 #网关 [root@localhost ~]# systemctl restart network #重启网络 [root@localhost ~]# ping 223.5.5.5 #外网不通 PING 223.5.5.5 (223.5.5.5) 56(84) bytes of data. From 172.168.1.3 icmp_seq=1 Destination Host Unreachable From 172.168.1.3 icmp_seq=2 Destination Host Unreachable From 172.168.1.3 icmp_seq=3 Destination Host Unreachable From 172.168.1.3 icmp_seq=4 Destination Host Unreachable ^C --- 223.5.5.5 ping statistics --- 4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3000ms pipe 4 [root@localhost ~]# yum install nginx #现在安装Nginx。发现它会走阿里云镜像源站,但是我们没有外网了,是不通的。 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.20.1-2.el7 will be installed ......省略 Downloading packages: gperftools-libs-2.6.1-1.el7.x8 FAILED http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm: [Errno 12] Timeout on http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm: (28, 'Resolving timed out after 30589 milliseconds') Trying other mirror. ^C Exiting on user cancel [root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls #切换到yum源配置目录,查看有哪些源 CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repo localself.repo CentOS-Base.repo.backup CentOS-fasttrack.repo CentOS-Vault.repo CentOS-CR.repo CentOS-Media.repo epel.repo [root@localhost yum.repos.d]# cat localself.repo #查看我们自己编辑的repo文件, [self] name=local baseurl=file:///root/mcw3/ gpgcheck=0 [root@localhost yum.repos.d]# yum clean all #清除yum缓存 Loaded plugins: fastestmirror Cleaning repos: base epel extras self updates Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# yum repolist #查看repo,这里还是会查阿里云镜像网站 Loaded plugins: fastestmirror http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Resolving timed out after 30571 milliseconds') Trying other mirror. ....... [root@localhost ~]# ls /etc/yum.repos.d/ #这是因为我们有很多repo文件, CentOS-Base.repo CentOS-Base.repo.backup CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo epel.repo localself.repo [root@localhost ~]# ls /etc/yum.repos.d/localself.repo #这个是我们现在做的repo文件 /etc/yum.repos.d/localself.repo [root@localhost ~]# yum install nginx --enablerepo=/etc/yum.repos.d/localself.repo #指定用这个镜像源repo配置,参考未找到 Loaded plugins: fastestmirror Error getting repository data for /etc/yum.repos.d/localself.repo, repository not found [root@localhost ~]# ls /root/mcw3 #查看到包目录,也就是刚刚做的yum仓库,有那5个产品 centos-indexhtml-7-9.el7.centos.noarch.rpm nginx-1.20.1-2.el7.x86_64.rpm openssl11-libs-1.1.1g-3.el7.x86_64.rpm gperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-filesystem-1.20.1-2.el7.noarch.rpm repodata [root@localhost ~]# ls /root/mcw3/repodata/ #查看创建仓库时创建的文件 0daf738aefd911c487e164c03527aa075d662168a7266a1db5e2a5e4ef7faef6-primary.xml.gz 7262073604838a951794e1e5435f1caa0ec85a74daf563697783825279f327a8-other.xml.gz repomd.xml 1381fc87e43bf6b37dd6e57817719f7e003ea8bd0ebfc710fd42bdcd4239a170-filelists.sqlite.bz2 bc176743f4b2d0b2b7ffc1127f390ba35bb034ddb6f452f80a460f0d228b194c-primary.sqlite.bz2 1448e7ea06cf95f9da96abcd62fc0a59c02366fe5757a94d99a74c16f54b85ab-other.sqlite.bz2 e2cdba10f69887b4aecd98ed073ecf61b69f3e27b5a10b37b798dd141692accf-filelists.xml.gz [root@localhost ~]# cat /etc/yum.repos.d/localself.repo #查看自建的repo [self] name=local baseurl=file:///root/mcw3/ gpgcheck=0 [root@localhost etc]# cp -a yum.repos.d yum.repos.dbak #将repo上级目录及它下的文件保存做备份 [root@localhost etc]# ls yum.repos.dbak/ CentOS-Base.repo CentOS-Base.repo.backup CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo epel.repo localself.repo [root@localhost yum.repos.d]# rm -fr Cen* #删除其它的,只留自己的仓库 [root@localhost yum.repos.d]# rm -rf epel.repo [root@localhost yum.repos.d]# ls localself.repo [root@localhost yum.repos.d]# yum clean all #清除yum缓存 Loaded plugins: fastestmirror Cleaning repos: self Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos [root@localhost yum.repos.d]# yum repolist #查看自己建的repo文件 Loaded plugins: fastestmirror self | 2.9 kB 00:00:00 self/primary_db | 5.9 kB 00:00:00 Determining fastest mirrors repo id repo name status self local 5 repolist: 5 [root@localhost yum.repos.d]# yum install -y nginx #yum安装Nginx。 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 1:1.20.1-2.el7 will be installed --> Processing Dependency: nginx-filesystem = 1:1.20.1-2.el7 for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: redhat-indexhtml for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: nginx-filesystem for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_1)(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libssl.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libcrypto.so.1.1(OPENSSL_1_1_0)(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libssl.so.1.1()(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libprofiler.so.0()(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Processing Dependency: libcrypto.so.1.1()(64bit) for package: 1:nginx-1.20.1-2.el7.x86_64 --> Running transaction check ---> Package centos-indexhtml.noarch 0:7-9.el7.centos will be installed ---> Package gperftools-libs.x86_64 0:2.6.1-1.el7 will be installed ---> Package nginx-filesystem.noarch 1:1.20.1-2.el7 will be installed ---> Package openssl11-libs.x86_64 1:1.1.1g-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================== Package Arch Version Repository Size ==================================================================== Installing: nginx x86_64 1:1.20.1-2.el7 self 586 k Installing for dependencies: centos-indexhtml noarch 7-9.el7.centos self 92 k gperftools-libs x86_64 2.6.1-1.el7 self 272 k nginx-filesystem noarch 1:1.20.1-2.el7 self 23 k openssl11-libs x86_64 1:1.1.1g-3.el7 self 1.5 M Transaction Summary =========================================================================== Install 1 Package (+4 Dependent packages) Total download size: 2.4 M Installed size: 6.7 M Downloading packages: ----------------------------------------------------------------------------------------------- Total 70 MB/s | 2.4 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:openssl11-libs-1.1.1g-3.el7.x86_64 1/5 Installing : gperftools-libs-2.6.1-1.el7.x86_64 2/5 Installing : centos-indexhtml-7-9.el7.centos.noarch 3/5 Installing : 1:nginx-filesystem-1.20.1-2.el7.noarch 4/5 Installing : 1:nginx-1.20.1-2.el7.x86_64 5/5 Verifying : 1:nginx-1.20.1-2.el7.x86_64 1/5 Verifying : 1:nginx-filesystem-1.20.1-2.el7.noarch 2/5 Verifying : centos-indexhtml-7-9.el7.centos.noarch 3/5 Verifying : gperftools-libs-2.6.1-1.el7.x86_64 4/5 Verifying : 1:openssl11-libs-1.1.1g-3.el7.x86_64 5/5 Installed: nginx.x86_64 1:1.20.1-2.el7 Dependency Installed: centos-indexhtml.noarch 0:7-9.el7.centos gperftools-libs.x86_64 0:2.6.1-1.el7 nginx-filesystem.noarch 1:1.20.1-2.el7 openssl11-libs.x86_64 1:1.1.1g-3.el7 Complete!包 [root@localhost yum.repos.d]# rpm -qa|grep nginx #查看新yum部署的软件信息 nginx-1.20.1-2.el7.x86_64 nginx-filesystem-1.20.1-2.el7.noarch [root@localhost yum.repos.d]# rpm -ql nginx #查看到.. /etc/logrotate.d/nginx ...... /etc/nginx/fastcgi.conf /usr/sbin/nginx /var/lib/nginx /var/log/nginx/access.log /var/log/nginx/error.log .........
[root@localhost yum.repos.d]# /usr/sbin/nginx #启动Nginx [root@localhost yum.repos.d]# ps -ef|grep nginx root 10179 1 0 01:29 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 10180 10179 0 01:29 ? 00:00:00 nginx: worker process root 10182 10051 0 01:29 pts/0 00:00:00 grep --color=auto nginx [root@localhost yum.repos.d]# ip a|sed -n "9p" inet 10.0.0.130/24 brd 10.0.0.255 scope global eth0 [root@localhost yum.repos.d]#
然后通过ip加端口访问网页,通过内网(不通外网)使用本地自制的yum源(自制yum仓库)
需要研究跨主机的自制内网yum仓库,仓库配置文件修改
设置仓库id和仓库名字
非root用户默认没有创建repo文件的权限
使用centos7镜像制作yum仓库
虚拟机将镜像挂载到系统中,cdrom文件就是这个镜像挂载的地方
[root@localhost ~]# ls /mnt/ [root@localhost ~]# mount /dev/cdrom /mnt/ mount: /dev/sr0 is write-protected, mounting read-only [root@localhost ~]# mount -o wr /dev/cdrom /mnt/ #挂载centos7镜像文件到系统目录下。其实可以挂载之后将文件复制一份到本地 mount: /dev/sr0 is write-protected, mounting read-only mount: /dev/sr0 is already mounted or /mnt busy /dev/sr0 is already mounted on /mnt [root@localhost ~]# ls /mnt/ CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL [root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# ls fonts2.repo mcw [root@localhost yum.repos.d]# mv fonts2.repo mcw/ [root@localhost yum.repos.d]# ls mcw [root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repolist: 0 [root@localhost yum.repos.d]# rpm -ql yum-3.4.3-154.el7.centos.noarch|grep cache /var/cache/yum [root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/ base epel extras google-chrome lang language self timedhosts timedhosts.txt updates [root@localhost yum.repos.d]# ls /var/cache/yum/x86_64/7/base/ 6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2 cachecookie packages a4e2b46586aa556c3b6f814dad5b16db5a669984d66b68e873586cd7c7253301-c7-x86_64-comps.xml.gz gen repomd.xml [root@localhost yum.repos.d]# ls mcw [root@localhost yum.repos.d]# cp mcw/fonts.repo . [root@localhost yum.repos.d]# [root@localhost yum.repos.d]# yum clean all Loaded plugins: fastestmirror Cleaning repos: language Cleaning up everything Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# ls fonts.repo mcw [root@localhost yum.repos.d]# rm -rf fonts.repo [root@localhost yum.repos.d]# ls mcw [root@localhost yum.repos.d]# vim mcw.repo [root@localhost yum.repos.d]# ls mcw mcw.repo [root@localhost yum.repos.d]# cat mcw.repo #查看编辑好的以contos7镜像为yum源的repo文件 [media] name=CentOS-$releasever - Media baseurl=file:///mnt/ gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 [root@localhost yum.repos.d]# ls /mnt/ #查看centos7镜像文件,文件下有repodata文件。一般我们创建都是跟包在同一目录,这里不是,回头研究一下 CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL [root@localhost yum.repos.d]# cat /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 #查看文件信息 -----BEGIN PGP PUBLIC KEY BLOCK----- Version: GnuPG v1.4.5 (GNU/Linux) mQINBFOn/0sBEADLDyZ+DQHkcTHDQSE0a0B2iYAEXwpPvs67cJ4tmhe/iMOyVMh9 Yw/vBIF8scm6T/vPN5fopsKiW9UsAhGKg0epC6y5ed+NAUHTEa6pSOdo7CyFDwtn 4HF61Esyb4gzPT6QiSr0zvdTtgYBRZjAEPFVu3Dio0oZ5UQZ7fzdZfeixMQ8VMTQ 4y4x5vik9B+cqmGiq9AW71ixlDYVWasgR093fXiD9NLT4DTtK+KLGYNjJ8eMRqfZ Ws7g7C+9aEGHfsGZ/SxLOumx/GfiTloal0dnq8TC7XQ/JuNdB9qjoXzRF+faDUsj WuvNSQEqUXW1dzJjBvroEvgTdfCJfRpIgOrc256qvDMp1SxchMFltPlo5mbSMKu1 x1p4UkAzx543meMlRXOgx2/hnBm6H6L0FsSyDS6P224yF+30eeODD4Ju4BCyQ0jO IpUxmUnApo/m0eRelI6TRl7jK6aGqSYUNhFBuFxSPKgKYBpFhVzRM63Jsvib82rY 438q3sIOUdxZY6pvMOWRkdUVoz7WBExTdx5NtGX4kdW5QtcQHM+2kht6sBnJsvcB JYcYIwAUeA5vdRfwLKuZn6SgAUKdgeOtuf+cPR3/E68LZr784SlokiHLtQkfk98j NXm6fJjXwJvwiM2IiFyg8aUwEEDX5U+QOCA0wYrgUQ/h8iathvBJKSc9jQARAQAB tEJDZW50T1MtNyBLZXkgKENlbnRPUyA3IE9mZmljaWFsIFNpZ25pbmcgS2V5KSA8 c2VjdXJpdHlAY2VudG9zLm9yZz6JAjUEEwECAB8FAlOn/0sCGwMGCwkIBwMCBBUC CAMDFgIBAh4BAheAAAoJECTGqKf0qA61TN0P/2730Th8cM+d1pEON7n0F1YiyxqG QzwpC2Fhr2UIsXpi/lWTXIG6AlRvrajjFhw9HktYjlF4oMG032SnI0XPdmrN29lL F+ee1ANdyvtkw4mMu2yQweVxU7Ku4oATPBvWRv+6pCQPTOMe5xPG0ZPjPGNiJ0xw 4Ns+f5Q6Gqm927oHXpylUQEmuHKsCp3dK/kZaxJOXsmq6syY1gbrLj2Anq0iWWP4 Tq8WMktUrTcc+zQ2pFR7ovEihK0Rvhmk6/N4+4JwAGijfhejxwNX8T6PCuYs5Jiv hQvsI9FdIIlTP4XhFZ4N9ndnEwA4AH7tNBsmB3HEbLqUSmu2Rr8hGiT2Plc4Y9AO aliW1kOMsZFYrX39krfRk2n2NXvieQJ/lw318gSGR67uckkz2ZekbCEpj/0mnHWD 3R6V7m95R6UYqjcw++Q5CtZ2tzmxomZTf42IGIKBbSVmIS75WY+cBULUx3PcZYHD ZqAbB0Dl4MbdEH61kOI8EbN/TLl1i077r+9LXR1mOnlC3GLD03+XfY8eEBQf7137 YSMiW5r/5xwQk7xEcKlbZdmUJp3ZDTQBXT06vavvp3jlkqqH9QOE8ViZZ6aKQLqv pL+4bs52jzuGwTMT7gOR5MzD+vT0fVS7Xm8MjOxvZgbHsAgzyFGlI1ggUQmU7lu3 uPNL0eRx4S1G4Jn5 =OGYX -----END PGP PUBLIC KEY BLOCK----- [root@localhost yum.repos.d]# yum repolist #查看现有的yum仓库,只有以镜像iso文件刚刚新建立的仓库 Loaded plugins: fastestmirror media | 3.6 kB 00:00:00 (1/2): media/group_gz | 156 kB 00:00:00 (2/2): media/primary_db | 3.1 MB 00:00:00 Loading mirror speeds from cached hostfile repo id repo name status media CentOS-7 - Media 3,894 repolist: 3,894 [root@localhost yum.repos.d]# [root@localhost yum.repos.d]# rpm -qa|grep gtk #gtk2系统查看未安装 gtk3-3.22.30-6.el7.x86_64 gtk-update-icon-cache-3.22.30-6.el7.x86_64 [root@localhost yum.repos.d]# yum install gtk2 #yum安装gtk2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package gtk2.x86_64 0:2.24.31-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================== Installing: gtk2 x86_64 2.24.31-1.el7 media 3.4 M Transaction Summary ================================================================================================================================================================================== Install 1 Package Total download size: 3.4 M Installed size: 13 M Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : gtk2-2.24.31-1.el7.x86_64 1/1 Verifying : gtk2-2.24.31-1.el7.x86_64 1/1 Installed: gtk2.x86_64 0:2.24.31-1.el7 Complete! [root@localhost yum.repos.d]# rpm -qa|grep gtk #gtk2已安装 gtk3-3.22.30-6.el7.x86_64 gtk2-2.24.31-1.el7.x86_64 gtk-update-icon-cache-3.22.30-6.el7.x86_64 [root@localhost yum.repos.d]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 19G 2.7G 17G 15% / devtmpfs 479M 0 479M 0% /dev tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 6.7M 482M 2% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 473M 111M 362M 24% /boot tmpfs 98M 0 98M 0% /run/user/0 /dev/sr0 4.3G 4.3G 0 100% /mnt [root@localhost yum.repos.d]# umount /mnt [root@localhost yum.repos.d]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 19G 2.7G 17G 15% / devtmpfs 479M 0 479M 0% /dev tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 6.7M 482M 2% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 473M 111M 362M 24% /boot tmpfs 98M 0 98M 0% /run/user/0 [root@localhost yum.repos.d]# ls /mnt/ [root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status media CentOS-7 - Media 3,894 repolist: 3,894 [root@localhost yum.repos.d]# yum install -y gtk2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Package gtk2-2.24.31-1.el7.x86_64 already installed and latest version Nothing to do [root@localhost yum.repos.d]# yum remove gtk2 Loaded plugins: fastestmirror Resolving Dependencies --> Running transaction check ---> Package gtk2.x86_64 0:2.24.31-1.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================== Removing: gtk2 x86_64 2.24.31-1.el7 @media 13 M Transaction Summary ================================================================================================================================================================================== Remove 1 Package Installed size: 13 M Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : gtk2-2.24.31-1.el7.x86_64 1/1 Verifying : gtk2-2.24.31-1.el7.x86_64 1/1 Removed: gtk2.x86_64 0:2.24.31-1.el7 Complete! [root@localhost yum.repos.d]# yum install -y gtk2 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package gtk2.x86_64 0:2.24.31-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================================== Installing: gtk2 x86_64 2.24.31-1.el7 media 3.4 M Transaction Summary ================================================================================================================================================================================== Install 1 Package Total download size: 3.4 M Installed size: 13 M Downloading packages: Error downloading packages: gtk2-2.24.31-1.el7.x86_64: [Errno 256] No more mirrors to try. [root@localhost yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status media CentOS-7 - Media 3,894 repolist: 3,894 [root@localhost yum.repos.d]# 错误做法,貌似以Packege目录自己做仓库,安装不了软件,下次这样实验并安装gtk2试试,
将iso文件挂载到挂载目录。
mount -o loop -t iso9660 /opt/tools/CentOS-6.7-x86_64-bin-DVD1.iso /mnt/vcdrom
关于yum remove把我们需要的依赖一同卸载掉的问题
- 问题一复现及解决: 前面链接包含了一次误卸载依赖的事例。比如拨测服务器需要拥有谷歌和火狐浏览器,我把gtk3卸载掉,但是谷歌浏览器作为依赖被卸载掉了,这就不是我们想要的,把使用的软件直接误卸载了,很危险,后来重装了gtk3,但是谷歌浏览器并没有被重装。那么是否可以用卸载软件,但不卸载依赖的方式呢。
yum history 历史记录功能
使用详情请点击链接: yum history使用详解(某次为解决误卸载软件的回退实验)
上个标题的问题如何yum删除软件不删除依赖
貌似没办法。
你可以用yum history 查看历史记录来找到它所依赖的包,然后删除,
如:yum history list 列出最近的历史
yum history info id 列出某次的详细信息,
yum history undo id 撤销某次更改
yum history help 查看帮助
yum组安装
https://www.cnblogs.com/wenwei-blog/p/11660900.html
Nginx提供yum仓库的存储和展示,提供yum仓库的http访问
1、在主机1上配置yum仓库,并放到Nginx站点目录下
检查没有htop包,下载下来 [root@mcw01 ~]$ rpm -qa|grep htop [root@mcw01 /opt]$ mkdir cangku [root@mcw01 /opt]$ cd cangku [root@mcw01 /opt/cangku]$ yum install htop --downloadonly --downloaddir=/opt/cngku 创建yum仓库 [root@mcw01 /opt/cangku]$ createrepo . Spawning worker 0 with 1 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete [root@mcw01 /opt/cangku]$ ls htop-2.2.0-3.el7.x86_64.rpm repodata 安装Nginx [root@mcw01 /opt/cangku]$ yum install -y nginx 配置Nginx [root@mcw01 /opt/cangku]$ mkdir /usr/share/nginx/bak [root@mcw01 /opt/cangku]$ mv /usr/share/nginx/html/* /usr/share/nginx/bak/ [root@mcw01 /opt/cangku]$ ls htop-2.2.0-3.el7.x86_64.rpm repodata [root@mcw01 /opt/cangku]$ mv ./* /usr/share/nginx/html/ #将仓库文件传到站点目录 [root@mcw01 /opt/cangku]$ cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak [root@mcw01 /etc/yum.repos.d]$ vim /etc/nginx/nginx.conf #修改root,打开autoindex root /usr/share/nginx/html/; location / { autoindex on; } [root@mcw01 /opt/cangku]$ hostname -I 10.0.0.11
在主机2上配置yum源,yum安装验证,可正常使用, 可以看到访问的是mcw仓库,mcw仓库访问的是10.0.0.11即主机1的yum包访问地址
[root@mcw02 ~]$ rpm -qa|grep htop [root@mcw02 ~]$ [root@mcw02 /etc/yum.repos.d]$ ls CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo [root@mcw02 /etc/yum.repos.d]$ mkdir bak [root@mcw02 /etc/yum.repos.d]$ mv C* ep* bak [root@mcw02 /etc/yum.repos.d]$ vim mcw.repo [mcw] name=mcw baseurl=http://10.0.0.11/ enabled=1 gpgcheck=0 [root@mcw02 /etc/yum.repos.d]$ yum repolist Loaded plugins: fastestmirror mcw | 2.9 kB 00:00:00 mcw/primary_db | 2.0 kB 00:00:00 Determining fastest mirrors repo id repo name status mcw mcw 1 repolist: 1 [root@mcw02 /etc/yum.repos.d]$ yum install -y htop Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package htop.x86_64 0:2.2.0-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================== Package Arch Version Repository Size ==================================================================================================================== htop x86_64 2.2.0-3.el7 mcw 103 k Transaction Summary ================================================= Install 1 Package Total download size: 103 k Installed size: 218 k Downloading packages: htop-2.2.0-3.el7.x86_64.rpm | 103 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : htop-2.2.0-3.el7.x86_64 1/1 Verifying : htop-2.2.0-3.el7.x86_64 1/1 Installed: htop.x86_64 0:2.2.0-3.el7 Complete! [root@mcw02 /etc/yum.repos.d]$
[root@mcw02 /etc/yum.repos.d]$ ls
bak mcw.repo
[root@mcw02 /etc/yum.repos.d]$ cat mcw.repo
[mcw]
name=mcw
baseurl=http://10.0.0.11/
enabled=1
gpgcheck=0
码云(gitlab)上做yum源
也可以把yum仓库文件访问码云或者gitlab等上面,找到访问路径,配置yum源时就指定访问路径就可以了。
右击下载属性
找到目录地址
[root@mcw02 /etc/yum.repos.d]$ ls bak mcw.repo [root@mcw02 /etc/yum.repos.d]$ vim mcw.repo # [root@mcw02 /etc/yum.repos.d]$ cat mcw.repo #修改yum源配置,指向码云的下载目录 [mcw] name=mcw #baseurl=http://10.0.0.11/ baseurl=https://gitee.com/machangwei-8/picture/raw/master/yuan/ enabled=1 gpgcheck=0 [root@mcw02 /etc/yum.repos.d]$ yum remove htop #移除已经有的 [root@mcw02 /etc/yum.repos.d]$ [root@mcw02 /etc/yum.repos.d]$ [root@mcw02 /etc/yum.repos.d]$ yum repolist #检查仓库正常 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status mcw mcw 1 repolist: 1 [root@mcw02 /etc/yum.repos.d]$ yum install htop #下载正常,并且是从mcw仓库下载的,也就是去请求码云上的文件了。 Loaded plugins: fastestmirror mcw | 2.9 kB 00:00:00 Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package htop.x86_64 0:2.2.0-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================================== Installing: htop x86_64 2.2.0-3.el7 mcw 103 k Transaction Summary ============================================================================================================== Install 1 Package Total download size: 103 k Installed size: 218 k Is this ok [y/d/N]: y Downloading packages: htop-2.2.0-3.el7.x86_64.rpm | 103 kB 00:00:06 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : htop-2.2.0-3.el7.x86_64 1/1 Verifying : htop-2.2.0-3.el7.x86_64 1/1 Installed: htop.x86_64 0:2.2.0-3.el7 Complete! [root@mcw02 /etc/yum.repos.d]$ [root@mcw02 /etc/yum.repos.d]$ cat mcw.repo [mcw] name=mcw #baseurl=http://10.0.0.11/ baseurl=https://gitee.com/machangwei-8/picture/raw/master/yuan/ enabled=1 gpgcheck=0 [root@mcw02 /etc/yum.repos.d]$
===============================end
有用的其它命令
Yum 查看某个软件的依赖关系
[root@localhost ~]# yum deplist gtk3
Loaded plugins: fastestmirror
[root@localhost ~]# yum deplist gtk3 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com package: gtk3.i686 3.22.30-6.el7 dependency: /bin/sh provider: bash.x86_64 4.2.46-34.el7 dependency: adwaita-icon-theme provider: adwaita-icon-theme.noarch 3.28.0-1.el7 dependency: atk(x86-32) >= 2.15.1 provider: atk.i686 2.28.1-2.el7 dependency: cairo(x86-32) >= 1.14.0 provider: cairo.i686 1.15.12-4.el7 dependency: cairo-gobject(x86-32) >= 1.14.0 provider: cairo-gobject.i686 1.15.12-4.el7 dependency: dconf(x86-32) provider: dconf.i686 0.28.0-4.el7 dependency: glib2(x86-32) >= 2.49.4 provider: glib2.i686 2.56.1-9.el7_9 dependency: gtk-update-icon-cache provider: gtk-update-icon-cache.x86_64 3.22.30-6.el7 dependency: hicolor-icon-theme provider: hicolor-icon-theme.noarch 0.12-7.el7 dependency: libX11.so.6 provider: libX11.i686 1.6.7-4.el7_9 dependency: libXcomposite.so.1 provider: libXcomposite.i686 0.4.4-4.1.el7 dependency: libXcursor.so.1 provider: libXcursor.i686 1.1.15-1.el7 dependency: libXdamage.so.1 provider: libXdamage.i686 1.1.4-4.1.el7 dependency: libXext.so.6 provider: libXext.i686 1.3.3-3.el7 dependency: libXfixes.so.3 provider: libXfixes.i686 5.0.3-1.el7 dependency: libXi.so.6 provider: libXi.i686 1.7.9-1.el7 dependency: libXinerama.so.1 provider: libXinerama.i686 1.1.3-2.1.el7 dependency: libXrandr(x86-32) >= 1.5.0 provider: libXrandr.i686 1.5.1-2.el7 dependency: libXrandr.so.2 provider: libXrandr.i686 1.5.1-2.el7 dependency: libatk-1.0.so.0 provider: atk.i686 2.28.1-2.el7 dependency: libatk-bridge-2.0.so.0 provider: at-spi2-atk.i686 2.26.2-1.el7 dependency: libc.so.6(GLIBC_2.4) provider: glibc.i686 2.17-325.el7_9 dependency: libcairo-gobject.so.2 provider: cairo-gobject.i686 1.15.12-4.el7 dependency: libcairo.so.2 provider: cairo.i686 1.15.12-4.el7 dependency: libcolord.so.2 provider: colord-libs.i686 1.3.4-2.el7 dependency: libcups.so.2 provider: cups-libs.i686 1:1.6.3-51.el7 dependency: libepoxy(x86-32) >= 1.0 provider: libepoxy.i686 1.5.2-1.el7 dependency: libepoxy.so.0 provider: libepoxy.i686 1.5.2-1.el7 dependency: libfontconfig.so.1 provider: fontconfig.i686 2.13.0-4.3.el7 dependency: libfreetype.so.6 provider: freetype.i686 2.8-14.el7_9.1 dependency: libgdk_pixbuf-2.0.so.0 provider: gdk-pixbuf2.i686 2.36.12-3.el7 dependency: libgio-2.0.so.0 provider: glib2.i686 2.56.1-9.el7_9 dependency: libglib-2.0.so.0 provider: glib2.i686 2.56.1-9.el7_9 dependency: libgmodule-2.0.so.0 provider: glib2.i686 2.56.1-9.el7_9 dependency: libgobject-2.0.so.0 provider: glib2.i686 2.56.1-9.el7_9 dependency: libjson-glib-1.0.so.0 provider: json-glib.i686 1.4.2-2.el7 dependency: libm.so.6 provider: glibc.i686 2.17-325.el7_9 dependency: libm.so.6(GLIBC_2.0) provider: glibc.i686 2.17-325.el7_9 dependency: libm.so.6(GLIBC_2.1) provider: glibc.i686 2.17-325.el7_9 dependency: libpango-1.0.so.0 provider: pango.i686 1.42.4-4.el7_7 dependency: libpangocairo-1.0.so.0 provider: pango.i686 1.42.4-4.el7_7 dependency: libpangoft2-1.0.so.0 provider: pango.i686 1.42.4-4.el7_7 dependency: libpthread.so.0 provider: glibc.i686 2.17-325.el7_9 dependency: libpthread.so.0(GLIBC_2.0) provider: glibc.i686 2.17-325.el7_9 dependency: libpthread.so.0(GLIBC_2.2) provider: glibc.i686 2.17-325.el7_9 dependency: librest-0.7.so.0 provider: rest.i686 0.8.1-2.el7 dependency: librt.so.1 provider: glibc.i686 2.17-325.el7_9 dependency: librt.so.1(GLIBC_2.2) provider: glibc.i686 2.17-325.el7_9 dependency: libwayland-client(x86-32) >= 1.9.91 provider: libwayland-client.i686 1.15.0-1.el7 dependency: libwayland-client.so.0 provider: libwayland-client.i686 1.15.0-1.el7 dependency: libwayland-cursor(x86-32) >= 1.9.91 provider: libwayland-cursor.i686 1.15.0-1.el7 dependency: libwayland-cursor.so.0 provider: libwayland-cursor.i686 1.15.0-1.el7 dependency: libwayland-egl.so.1 provider: libwayland-egl.i686 1.15.0-1.el7 dependency: libxkbcommon.so.0 provider: libxkbcommon.i686 0.7.1-3.el7 dependency: libxkbcommon.so.0(V_0.5.0) provider: libxkbcommon.i686 0.7.1-3.el7 dependency: pango(x86-32) >= 1.37.3 provider: pango.i686 1.42.4-4.el7_7 dependency: rtld(GNU_HASH) provider: glibc.x86_64 2.17-325.el7_9 provider: glibc.i686 2.17-325.el7_9 package: gtk3.x86_64 3.22.30-6.el7 dependency: /bin/sh provider: bash.x86_64 4.2.46-34.el7 dependency: adwaita-icon-theme provider: adwaita-icon-theme.noarch 3.28.0-1.el7 dependency: atk(x86-64) >= 2.15.1 provider: atk.x86_64 2.28.1-2.el7 dependency: cairo(x86-64) >= 1.14.0 provider: cairo.x86_64 1.15.12-4.el7 dependency: cairo-gobject(x86-64) >= 1.14.0 provider: cairo-gobject.x86_64 1.15.12-4.el7 dependency: dconf(x86-64) provider: dconf.x86_64 0.28.0-4.el7 dependency: glib2(x86-64) >= 2.49.4 provider: glib2.x86_64 2.56.1-9.el7_9 dependency: gtk-update-icon-cache provider: gtk-update-icon-cache.x86_64 3.22.30-6.el7 dependency: hicolor-icon-theme provider: hicolor-icon-theme.noarch 0.12-7.el7 dependency: libX11.so.6()(64bit) provider: libX11.x86_64 1.6.7-4.el7_9 dependency: libXcomposite.so.1()(64bit) provider: libXcomposite.x86_64 0.4.4-4.1.el7 dependency: libXcursor.so.1()(64bit) provider: libXcursor.x86_64 1.1.15-1.el7 dependency: libXdamage.so.1()(64bit) provider: libXdamage.x86_64 1.1.4-4.1.el7 dependency: libXext.so.6()(64bit) provider: libXext.x86_64 1.3.3-3.el7 dependency: libXfixes.so.3()(64bit) provider: libXfixes.x86_64 5.0.3-1.el7 dependency: libXi.so.6()(64bit) provider: libXi.x86_64 1.7.9-1.el7 dependency: libXinerama.so.1()(64bit) provider: libXinerama.x86_64 1.1.3-2.1.el7 dependency: libXrandr(x86-64) >= 1.5.0 provider: libXrandr.x86_64 1.5.1-2.el7 dependency: libXrandr.so.2()(64bit) provider: libXrandr.x86_64 1.5.1-2.el7 dependency: libatk-1.0.so.0()(64bit) provider: atk.x86_64 2.28.1-2.el7 dependency: libatk-bridge-2.0.so.0()(64bit) provider: at-spi2-atk.x86_64 2.26.2-1.el7 dependency: libc.so.6(GLIBC_2.14)(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: libcairo-gobject.so.2()(64bit) provider: cairo-gobject.x86_64 1.15.12-4.el7 dependency: libcairo.so.2()(64bit) provider: cairo.x86_64 1.15.12-4.el7 dependency: libcolord.so.2()(64bit) provider: colord-libs.x86_64 1.3.4-2.el7 dependency: libcups.so.2()(64bit) provider: cups-libs.x86_64 1:1.6.3-51.el7 dependency: libepoxy(x86-64) >= 1.0 provider: libepoxy.x86_64 1.5.2-1.el7 dependency: libepoxy.so.0()(64bit) provider: libepoxy.x86_64 1.5.2-1.el7 dependency: libfontconfig.so.1()(64bit) provider: fontconfig.x86_64 2.13.0-4.3.el7 dependency: libfreetype.so.6()(64bit) provider: freetype.x86_64 2.8-14.el7_9.1 dependency: libgdk_pixbuf-2.0.so.0()(64bit) provider: gdk-pixbuf2.x86_64 2.36.12-3.el7 dependency: libgio-2.0.so.0()(64bit) provider: glib2.x86_64 2.56.1-9.el7_9 dependency: libglib-2.0.so.0()(64bit) provider: glib2.x86_64 2.56.1-9.el7_9 dependency: libgmodule-2.0.so.0()(64bit) provider: glib2.x86_64 2.56.1-9.el7_9 dependency: libgobject-2.0.so.0()(64bit) provider: glib2.x86_64 2.56.1-9.el7_9 dependency: libjson-glib-1.0.so.0()(64bit) provider: json-glib.x86_64 1.4.2-2.el7 dependency: libm.so.6()(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: libm.so.6(GLIBC_2.2.5)(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: libpango-1.0.so.0()(64bit) provider: pango.x86_64 1.42.4-4.el7_7 dependency: libpangocairo-1.0.so.0()(64bit) provider: pango.x86_64 1.42.4-4.el7_7 dependency: libpangoft2-1.0.so.0()(64bit) provider: pango.x86_64 1.42.4-4.el7_7 dependency: libpthread.so.0()(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: libpthread.so.0(GLIBC_2.2.5)(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: librest-0.7.so.0()(64bit) provider: rest.x86_64 0.8.1-2.el7 dependency: librt.so.1()(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: librt.so.1(GLIBC_2.2.5)(64bit) provider: glibc.x86_64 2.17-325.el7_9 dependency: libwayland-client(x86-64) >= 1.9.91 provider: libwayland-client.x86_64 1.15.0-1.el7 dependency: libwayland-client.so.0()(64bit) provider: libwayland-client.x86_64 1.15.0-1.el7 dependency: libwayland-cursor(x86-64) >= 1.9.91 provider: libwayland-cursor.x86_64 1.15.0-1.el7 dependency: libwayland-cursor.so.0()(64bit) provider: libwayland-cursor.x86_64 1.15.0-1.el7 dependency: libwayland-egl.so.1()(64bit) provider: libwayland-egl.x86_64 1.15.0-1.el7 dependency: libxkbcommon.so.0()(64bit) provider: libxkbcommon.x86_64 0.7.1-3.el7 dependency: libxkbcommon.so.0(V_0.5.0)(64bit) provider: libxkbcommon.x86_64 0.7.1-3.el7 dependency: pango(x86-64) >= 1.37.3 provider: pango.x86_64 1.42.4-4.el7_7 dependency: rtld(GNU_HASH) provider: glibc.x86_64 2.17-325.el7_9 provider: glibc.i686 2.17-325.el7_9 [root@localhost ~]#
yum查看依赖的时候没说谷歌是依赖呀,那为什么卸载gtk3会把谷歌浏览器卸载掉呢,不懂
1.使用YUM查找软件包 yum search
命令:yum search
效果貌似差不多呀
2.列出所有可安装的软件包 yum list
命令:yum list
3.列出所有可更新的软件包
命令:yum list updates
b版本的确是已有的比较旧
4.列出所有已安装的软件包
命令:yum list installed
还是用 rpm -qa过滤查询用的多
5.列出所有已安装但不在 Yum Repository 内的软件包(需要待研究准确性)
命令:yum list extras
明明是已安装的,且版本在仓库里也能看到,这个标题貌似不太准,有时间再研究怎么回事
6.使用YUM获取软件包信息yum info
命令:yum info
root@localhost ~]# rpm -qa|grep zlib zlib-1.2.7-17.el7.x86_64 [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# yum info zlib Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Packages Name : zlib Arch : x86_64 Version : 1.2.7 Release : 17.el7 Size : 181 k Repo : installed From repo : anaconda Summary : The compression and decompression library URL : http://www.zlib.net/ License : zlib and Boost Description : Zlib is a general-purpose, patent-free, lossless data compression : library which is used by many different programs. Available Packages Name : zlib Arch : i686 Version : 1.2.7 Release : 19.el7_9 Size : 91 k Repo : updates/7/x86_64 Summary : The compression and decompression library URL : http://www.zlib.net/ License : zlib and Boost Description : Zlib is a general-purpose, patent-free, lossless data compression : library which is used by many different programs. Name : zlib Arch : x86_64 Version : 1.2.7 Release : 19.el7_9 Size : 90 k Repo : updates/7/x86_64 Summary : The compression and decompression library URL : http://www.zlib.net/ License : zlib and Boost Description : Zlib is a general-purpose, patent-free, lossless data compression : library which is used by many different programs. [root@localhost ~]#
7.列出所有可更新的软件包信息yum info updates
命令:yum info updates
8.列出所有已安装的软件包信息 yum info installed
命令:yum info installed
9.列出所有已安装但不在 Yum Repository 内的软件包信息
命令:yum info extras
还需检验
10.列出软件包提供哪些文件yum provides 意思好像是哪个repo文件提供包
命令:yum provides
----------------------------------
Linux升级命令yum update
清华源:https://mirrors.tuna.tsinghua.edu.cn/
原文链接:https://www.cnblogs.com/liaocheng/p/4243589.html
yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令,而且命令简洁而又好记。
yum的命令形式一般是如下:yum [options] [command] [package ...]
其中的[options]是可选的,选项包括-h(帮助),-y(当安装过程提示选择全部为"yes"),-q(不显示安装的过程)等等。[command]为所要进行的操作,[package ...]是操作的对象。
概括了部分常用的命令包括:
自动搜索最快镜像插件: yum install yum-fastestmirror
安装yum图形窗口插件: yum install yumex
查看可能批量安装的列表: yum grouplist
1 安装
yum install 全部安装
yum install package1 安装指定的安装包package1
yum groupinsall group1 安装程序组group1
2 更新和升级
yum update 全部更新
yum update package1 更新指定程序包package1
yum check-update 检查可更新的程序
yum upgrade package1 升级指定程序包package1
yum groupupdate group1 升级程序组group1
3 查找和显示
yum info package1 显示安装包信息package1
yum list 显示所有已经安装和可以安装的程序包
yum list package1 显示指定程序包安装情况package1
yum groupinfo group1 显示程序组group1信息yum search string 根据关键字string查找安装包
4 删除程序
yum remove | erase package1 删除程序包package1
yum groupremove group1 删除程序组group1
yum deplist package1 查看程序package1依赖情况
5 清除缓存
yum clean packages 清除缓存目录下的软件包
yum clean headers 清除缓存目录下的 headers
yum clean oldheaders 清除缓存目录下旧的 headers
yum clean, yum clean all (= yum clean packages; yum clean oldheaders) 清除缓存目录下的软件包及旧的headers
比如,要安装游戏程序组,首先进行查找:
#:yum grouplist
可以发现,可安装的游戏程序包名字是”Games and Entertainment“,这样就可以进行安装:
#:yum groupinstall "Games and Entertainment"
所 有的游戏程序包就自动安装了。在这里Games and Entertainment的名字必须用双引号选定,因为linux下面遇到空格会认为文件名结束了,因此必须告诉系统安装的程序包的名字是“Games and Entertainment”而不是“Games"。
此外,还可以修改配置文件/etc/yum.conf选择安装源。可见yum进行配置程序有多方便了吧。更多详细的选项和命令,当然只要在命令提示行下面:man yum
yum groupinstall "KDE (K Desktop Environment)"
yum install pirut k3b mikmod
yum groupinstall "Server Configuration Tools"
yum groupinstall "Sound and Video"
#yum groupinstall "GNOME Desktop Environment"
yum groupinstall "Legacy Software Support"
yum groupinstall "Development Libraries"
yum groupinstall "Development Tools"
#yum groupinstall "Windows File Server"
yum groupinstall "System Tools"
yum groupinstall "X Window System"
yum install php-gd
yum install gd-devel
yum groupinstall "Chinese Support"
#yum install samba-common //该执行会一起安装 samba-client
#yum install samba
yum install gcc
yum install cpp
yum install gcc-c++
yum install ncurses
yum install ncurses-devel
yum install gd-devel php-gd
yum install gd-devel
yum install gcc
yum install cpp
yum install gcc-c++
yum install ncurses
yum install ncurses-devel
yum install gd-devel php-gd
yum install gd-devel
yum install zlib-devel
yum install freetype-devel freetype-demos freetype-utils
yum install libpng-devel libpng10 libpng10-devel
yum install libjpeg-devel
yum install ImageMagick
yum install php-gd
yum install flex
yum install ImageMagick-devel
#yum install system-config-bind
#yum groupinstall "DNS Name Server" //安裝 bind 及 bind-chroot 套件
yum groupinstall "MySQL Database"'
yum clean all
-----------------------------------------------------------------------------------------------------------
装了个fedora linux不能用中文输入是一件很棘手的事,连搜解决方案都没法搜。只能勉强用几个拼音碰碰运气,看Google能不能识别了。而我就遇见了这样的事。
解决方案:
yum install scim* -y
yum 命令详解:
Redhat和Fedora的软件安装命令是rpm,但是用rpm安装软件最大的麻烦就是需要手动寻找安装该软件所需要的一系列依赖关系,超级 麻烦不说,要是软件不用了需要卸载的话由于卸载掉了某个依赖关系而导致其他的软件不能用是非常恼人的。令人高兴的是,Fedora终于推出了类似于 ubuntu中的apt的命令yum,令Fedora的软件安装变得简单容易。Yum 有以下特点:
*可以同时配置多个资源库(Repository)
*简洁的配置文件(/etc/yum.conf)
*自动解决增加或删除rpm包时遇到的倚赖性问题
*使用方便
*保持与RPM数据库的一致性
yum,是Yellow dog Updater Modified的简称,起初是由yellow dog这一发行版的开发者Terra Soft研发,用python写成,那时还叫做yup(yellow dog updater),后经杜克大学的Linux@Duke开发团队进行改进,遂有此名。yum的宗旨是自动化地升级,安装/移除rpm包,收集rpm包的相关信息,检查依赖性并自动提示用户解决。yum的关键之处是要有可靠的repository,顾名思义,这是软件的仓库,它可以是http或ftp站点, 也可以是本地软件池,但必须包含rpm的header, header包括了rpm包的各种信息,包括描述,功能,提供的文件,依赖性等.正是收集了这些 header并加以分析,才能自动化地完成余下的任务。
1.yum的一切配置信息都储存在一个叫yum.conf的配置文件中,通常位于/etc目 录下,这是整个yum系统的重中之重,我在的F9中查看了这一文件,大家一起来看下:
[hanlong@localhost F9常用文档]$ sudo more /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d
下面简单的对这一文件作简要的说明:
cachedir:yum缓存的目录,yum在此存储下载的rpm包和数据库,一般是/var/cache/yum。
debuglevel:除错级别,0──10,默认是2
logfile:yum的日志文件,默认是/var/log/yum.log。
exactarch,有两个选项1和0,代表是否只升级和你安装软件包cpu体系一致的包,如果设为1,则如你安装了一个i386的rpm,则yum不会用686的包来升级。
gpgchkeck= 有1和0两个选择,分别代表是否是否进行gpg校验,如果没有这一项,默认好像也是检查的。
2.好了,接下来就是yum的使用了,首先用yum来升级软件,yum的操作大都须有超级用户的权限,当然可以用sudo。
yum update,这一步是必须的,yum会从服务器的header目录下载rpm的header,放在本地的缓存中,这可能会花费一定的时间,但比起yum 给我们带来方便,这些时间的花费又算的了什么呢?header下载完毕,yum会判断是否有可更新的软件包,如果有,它会询问你的意见,是否更新,还是说 y吧,把系统始终up to date总是不错的,这时yum开始下载软件包并使用调用rpm安装,这可能要一定时间,取决于要更新软件的数目和网络状况,万一网络断了,也没关系,再 进行一次就可以了。升级完毕,以后每天只要使用yum check-update检查一下有无跟新,如果有,就用yum update进行跟新,时刻保持系统为最新,堵住一切发现的漏洞。用yum update packagename 对某个单独包进行升级。
现在简单的把yum软件升级的一些命令罗列一下:
(更新:我在安装wine的时候是用rpm一个一个安装的,先安装以来关系,然后在安装wine的主包,但是刚刚在论坛上发现来一个好的帖子,就yum的本地安装。参数是-localinstall
$yum localinstall wine-*
这样的话,yum会自动安装所有的依赖关系,而不用rpm一个一个的安装了,省了好多工作。
还有一个与他类似的参数:
$yum localupdate wine-*
如果有wine的新版本,而且你也下载到来本地,就可以这样本地更新wine了。)
1.列出所有可更新的软件清单
命令:yum check-update
2.安装所有更新软件
命令:yum update
3.仅安装指定的软件
命令:yum install
4.仅更新指定的软件
命令:yum update
5.列出所有可安裝的软件清单
命令:yum list
3.使用yum安装和卸载软件,有个前提是yum安装的软件包都是rpm格式的。
安装的命令是,yum install xxx,yum会查询数据库,有无这一软件包,如果有,则检查其依赖冲突关系,如果没有依赖冲突,那么最好,下载安装;如果有,则会给出提示,询问是否要同时安装依赖,或删除冲突的包,你可以自己作出判断
删除的命令是,yum remove xxx,同安装一样,yum也会查询数据库,给出解决依赖关系的提示。
1.用YUM安装软件包
命令:yum install
2.用YUM删除软件包
命令:yum remove
4.用yum查询想安装的软件
我们常会碰到这样的情况,想要安装一个软件,只知道它和某方面有关,但又不能确切知道它的名字。这时yum的查询功能就起作用了。你可以用 yum search keyword这样的命令来进行搜索,比如我们要则安装一个Instant Messenger,但又不知到底有哪些,这时不妨用 yum search messenger这样的指令进行搜索,yum会搜索所有可用rpm的描述,列出所有描述中和messeger有关的rpm包,于是我们可能得到 gaim,kopete等等,并从中选择。
有时我们还会碰到安装了一个包,但又不知道其用途,我们可以用yum info packagename这个指令来获取信息。
1.使用YUM查找软件包
命令:yum search
2.列出所有可安装的软件包
命令:yum list
3.列出所有可更新的软件包
命令:yum list updates
4.列出所有已安装的软件包
命令:yum list installed
5.列出所有已安装但不在 Yum Repository 內的软件包
命令:yum list extras
6.列出所指定的软件包
命令:yum list 7.使用YUM获取软件包信息
命令:yum info 8.列出所有软件包的信息
命令:yum info
9.列出所有可更新的软件包信息
命令:yum info updates
10.列出所有已安裝的软件包信息
命令:yum info installed
11.列出所有已安裝但不在 Yum Repository 內的软件包信息
命令:yum info extras
12.列出软件包提供哪些文件
命令:yum provides
5.清除YUM缓存
yum 会把下载的软件包和header存储在cache中,而不会自动删除。如果我们觉得它们占用了磁盘空间,可以使用yum clean指令进行清除,更精确的用法是yum clean headers清除header,yum clean packages清除下载的rpm包,yum clean all 清除所有
1.清除缓存目录(/var/cache/yum)下的软件包
命令:yum clean packages
2.清除缓存目录(/var/cache/yum)下的 headers
命令:yum clean headers
3.清除缓存目录(/var/cache/yum)下旧的 headers
命令:yum clean oldheaders
4.清除缓存目录(/var/cache/yum)下的软件包及旧的headers
命令:yum clean, yum clean all (= yum clean packages; yum clean oldheaders)
以上所有命令参数的使用都可以用man来查看:
1、安装图形版yumex:yum install yumex。
2、安装额外的软件仓库:
rpm.livna.org 的软件包仓库:
rpm -ivh http://livna-dl.reloumirrors.net … ease-7-2.noarch.rpm
freshrpms.net 的软件包仓库:
rpm –ivh http://ftp.freshrpms.net/pub/fre … 1.1-1.fc.noarch.rpm
3、安装最快源 yum install yum-fastestmirror
资源真的是非常丰富,从Centos到Ubuntu,ISO镜像、升级包,应有尽有,上交的兄弟们真是幸福,羡慕啊。不过还好,我们好歹也算是在教育网内,凑合着也可以沾点光,下载一些。
网址为:ftp://ftp.sjtu.edu.cn/
相应的yum的repo为
[updates]
name=Fedora updates
baseurl=ftp://ftp.sjtu.edu.cn/fedora/linux/updates/$releasever/$basearch/
enabled=1
gpgcheck=0
[fedora]
name=Fedora $releasever - $basearch
baseurl=ftp://ftp.sjtu.edu.cn/fedora/linux/releases/$releasever/Everything/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY
如果在机器上安装了apt管理器,则相应的源为
repomd ftp://ftp.sjtu.edu.cn/ fedora/linux/updates/$(VERSION)/$(ARCH)/
repomd ftp://ftp.sjtu.edu.cn/ fedora/linux/releases/$(VERSION)/Everything/$(ARCH)/os/
这与前面yum的源的格式上有一些差别,需要加以注意。
下面介绍一下fedora 下安装 scim
1. 什么输入法适合我?
fcitx和scim是目前比较好的输入法, 但是他们的特点不同,fcitx只能输入中文,而scim可以根据需要,利用不同的码表达到中英日…等等各种语言的输入问题。如果你只懂中文,或者只会输 入英文&中文,那么fcitx是一个不错的选择,因为它漂亮,小巧,实用。如果你还需要输入日文或者其他语言,那么你因该安装scim。通 过合理的配置,他能够让你像在windows里面一样,想输入什么语言就能输入什么语言,同一种语言想用什么输入法就用什么输入法。Scim的扩充性很 强,而且比较稳定,我就是选择的是scim.
2. 安装一个新输入法前需要哪些准备?
如果你选择fcitx或者scim,那么我建议你删除系统自带的中文输入法。方法如下:
rpm –qa | grep iiimf | xargs rpm –e
rpm –qa | grep Chinput| xargs rpm –e
如果有哪一行提示rpm: no packages given for erase那表示本身你的系统里面没有该输入法,不用担心,继续往下看就行了。
说 明:rpm –qa是列出所有安装的rpm包,grep iiimf是选择出其中名字含有iiimf的那些包,xargs rpm –e的意思是把前面列出的这些包删除掉。Xargs的作用就是把前面通过 | 传过来的数据作为下面命令的参数。这就好比一个过滤器,首先是放着所有的安装包,然后grep以后,只留下了含有某些特定关键字的rpm包,然后通过 xargs和rpm –e的组合运用,把剩下的这些含有某特定关键字的包删掉。这样就达到了删除该输入法及相关包的目的。下面的Chinput也是如此,在此不再重复。如果你还安装了其他输入法,比如你原来装的是fcitx,现在想装scim,那么你最好模仿上面的样子把fcitx删除,方法就是把iiimf的位置改成 fcitx就可以了。
在安装新输入法之前,最好这样做一下,因为多种输入法同时存在一个系统中没有什么好处,你只可能去用一个,而且他们同时存在可能有的时候会出现问题,想想也知道,会互相竞争嘛。所以在此以后,你应该保证系统里面已经没有中文输入法了。通过类似以下方式验证:
whereis fcitx
whereis scim
whereis miniChinput
…
3. 输入法是何时被系统调用的?
很多人不知道输入法到底什么时候被load进来,不知道这个当然就不知道为什么有的时候呼不出输入法(因为可能根本没有调入)当然也不会知道如何配置能够符合自己的要求。
大 家都知道,linux下面比较常用的有两个桌面系统,gnome和kde,这都无所谓,他们其实都是架在X系统之上的。简单的说X系统就是一个最核心,也 是最底层的桌面系统,gnome也好,kde也罢,或者其他的什么fvwm之类的,都只不过是X系统和用户之间的另一层软件而已。所以要想达到不管使用什 么桌面系统,都能调入输入法,就是要在X系统启动的时候,让输入法也启动起来,那么这样之后,无论你使用的是gnome还是kde或者其他什么桌面,都能 够调入输入法。因为当轮到他们启动的时候,X系统已经启动好了,输入法已经被系统调入了。那么X系统又是如何启动的呢?让我们从startx开始说起。
无论你用什么桌面系统,都是通过startx启动的,那么startx究竟是什么呢?一个应用程序还是一个脚本文件?为什么它能够启动各种桌面系统,并且能够按照相应的配置文件来设置呢?带着疑问,我在console里面输入whereis startx.
在 找到了存放startx的路径以后,用编辑器打开它发现原来是一个脚本文件。这个脚本文件的内容可能根据发行版不同,会有差异,如果你懂一些shell的 语言,那么你可以尝试看看,不一定要全部看懂,但是你大致看过以后会发现最后有一个xinit的命令,然后跟着一些参数。我尝试在console下面输入 xinit(注意,不要在图形界面下做此操作)
发现图形界面启动拉,但是很丑陋,什么功能都没有,鼠标可以动,还有一个可以输入命令的小窗口。怎 么退出来?ctrl+alt+backspace. 原来如此,startx只是一个脚本,里面通过对一系列配置文件的分析设置,最终利用xinit命令启动图形界面。不管是kde还是gnome,都是在这 个脚本中完成的。那么让我们再打开startx脚本看看里面还做了些什么。你仔细看看,会发现有一个东西很显眼,就是/etc/X11/xinit /xinitrc,这个xinitrc好像很眼熟,在配置输入法的其他贴中总是看到,这里出现了肯定是里面运行了这个脚本。再看其他的一些东西,其实都是利用shell配置出一个xinit启动的参数,用来配置桌面系统用的,不用管它。目前已知的就是startx的时候它会去执行一个/etc/X11 /xinit/xinitrc的脚本,让我们打开来看看里面有什么。
打开一看,其中一段我觉得最有价值,是一个for循环,他依次执行了/etc /X11/xinit/xinitrc.d/下面的所有脚本。你可以耐心的找一下,一定可以发现。那么这个目录里面有些什么内容呢?有一个文件看名字就知道和输入相关,他叫xinput。等等,让我们理一下,是怎么从startx到xinput的。
首先是执行startx这个脚本文件,里面他会执行xinitrc这个脚本,然后xinitrc脚本里面的,叫xinput。OK, 我们继续,打开xinput看看。
4.安装软件包
rpm -Uvh scim-0.8.2-1.i586.rpm
rpm -Uvh scim-chinese-0.2.6-1.i586.rpm
5.修改配置文件
接下来重要的一步就是,修改一下
/etc /X11/xinit/xinitrc.d/xinput文件,让SCIM在X启动的时候也启动。我看到网上很多文章也说过,但总是不得要领,经过自己试 验,最简单的就是把xinput文件里的Chinput全部替换为SCIM,chinput替换为scim,保存重启X就可以了。
zh_CN*)
if [ -e /usr/bin/scim ]; then
XIM="SCIM"
elif [ -e /usr/X11R6/bin/xcin ] ; then
export LC_CTYPE=zh_CN.GB2312
XIM="xcin-zh_CN.GB2312"
fi
;;
..............................
SCIM)
XIM_PROGRAM=scim
XIM_ARGS="-d"
;;
然后修改/etc/gtk-2.0/gtk.immodules,找到这一行:
"xim" "X Input Method" "gtk20" "/usr/share/locale" "ko:ja:zh"
改为:
"xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:zh"
可能表示输入英文时也使用该输入法
安装完毕后运行scim-setup,将输入法的切换键改为ctrl+space
1.安装yum包:
$ yum install PACKAGE_NAME
2.取出yum包装:
$ yum remove PACKAGE_NAME
3.重新安装一个yum包:
$ yum reinstall PACKAGE_NAME
4.搜索yum包:
$ yum search PACKAGE_NAME
5.显示yum包的信息:
$ yum info PACKAGE_NAME
6.更新安装的yum包:
$ yum update
7.更新具体的yum包:
$ yum update PACKAGE_NAME
8.显示yum历史:
$ yum history
9.显示已启用的yum存储库的列表:
$ yum repolist
10.找出哪个yum包提供了一个特定的文件(例如:/usr/bin/nc)):
$ yum whatprovides "*bin/nc"
11.清除yum缓存:
$ yum clean all
完结。
原文来自:https://renwole.com/archives/780
本文地址:https://www.linuxprobe.com/centos7-yum.html编辑:何云艳,审核员:逄增宝
本文原创地址:https://www.linuxprobe.com/centos7-yum.html
[root@mcw02 ~]$ rpm -qa|grep htop[root@mcw02 ~]$ [root@mcw02 /etc/yum.repos.d]$ lsCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo epel.repo[root@mcw02 /etc/yum.repos.d]$ mkdir bak [root@mcw02 /etc/yum.repos.d]$ mv C* ep* bak
[root@mcw02 /etc/yum.repos.d]$ vim mcw.repo[mcw]name=mcwbaseurl=http://10.0.0.11/enabled=1gpgcheck=0[root@mcw02 /etc/yum.repos.d]$ yum repolistLoaded plugins: fastestmirrormcw | 2.9 kB 00:00:00 mcw/primary_db | 2.0 kB 00:00:00 Determining fastest mirrorsrepo id repo name statusmcw mcw 1repolist: 1[root@mcw02 /etc/yum.repos.d]$ yum install -y htopLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfileResolving Dependencies--> Running transaction check---> Package htop.x86_64 0:2.2.0-3.el7 will be installed--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================== Package Arch Version Repository Size==================================================================================================================== htop x86_64 2.2.0-3.el7 mcw 103 k
Transaction Summary=================================================Install 1 Package
Total download size: 103 kInstalled size: 218 kDownloading packages:htop-2.2.0-3.el7.x86_64.rpm | 103 kB 00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : htop-2.2.0-3.el7.x86_64 1/1 Verifying : htop-2.2.0-3.el7.x86_64 1/1
Installed: htop.x86_64 0:2.2.0-3.el7
Complete![root@mcw02 /etc/yum.repos.d]$
一个问题,执行命令语法错误,是因为Python链接版本变了,找到不是python2
[root@mcw01 ~]# yum clean all File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax [root@mcw01 ~]# [root@mcw01 ~]# yum list all File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax [root@mcw01 ~]# [root@mcw01 ~]# yum repolist File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax [root@mcw01 ~]# ls -lh /usr/bin/python lrwxrwxrwx 1 root root 16 Jan 5 01:39 /usr/bin/python -> /usr/bin/python3 [root@mcw01 ~]# rm -rf /usr/bin/python [root@mcw01 ~]# ln -s /usr/bin/python2 /usr/bin/python [root@mcw01 ~]# ls -lh /usr/bin/python lrwxrwxrwx 1 root root 16 Jan 21 15:33 /usr/bin/python -> /usr/bin/python2 [root@mcw01 ~]# yum repolist Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 docker-ce-stable | 3.5 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 glusterfs | 2.9 kB 00:00:00 mysql-connectors-community