#############如何安装软件####################
yum #全称Yellow dog Updater Moddified,能够从指定的服务器自动下载RPM包并安装
yum list all ##列出所有安装包
yum list installed ##列出已经安装的
yum list available ##列出没有安装的
yum remove package ##卸载软件(package是软件包)
yum install package ##安装软件
yum reinstall package ##重新安装软件
yum localinstall 本地软件 ##安装本地软件并解决依赖关系
yum search 关键字 ##搜索与关键字相关的软件
yum whatprovides 文件 ##搜索包含此文件的包
yum info ##显示软件信息
yum groups list ##列出软件组
yum groups install ##安装组
yum groups remove ##卸载组
yum groups info ##查看组信息
yum update ##全部更新
yum update package ##更新指定软件包
yum clean packages ##清除缓存目录下的软件包
yum repolist ##查看yum资源库信息
eg:
yum install package -y ##安装软件,-y表示安装过程提示全部为yes
yum whatprovides */lftp ##搜索包含此文件的包
##############软件仓库的建立##############
1.先建立一个软件仓库
1)需要一个与本机匹配的安装镜像,rhel-server-7.0-x86_64-dvd.iso,这个文件从官方网站下载得到
2)mount rhel-server-7.0-x86_64-dvd.iso /yum ##挂在到/yum,/yum目录是新建出来的
3)mv /etc/yum.repos.d/* /mnt ##把原来的文件移到/mnt下
4)vim /etc/yum.repos.d/yum.repo ##文件格式要以.repo结尾
[redhatpackage] ##仓库名称
name=localpackage ##仓库描述
baseurl=file:///yum ##仓库地址
gpgcheck=0 ##是否检测软件的gpgkey,0为不检测,1为检测
5)yum clean all ##刷新仓库配置
6)yum repolist ##查看yum资源库信息
注:df命令 ##查看第2步挂载情况
2./etc/fstab ##fstab文件包含了系统在启动时,挂载文件系统和存储设备的详细信息
格式:
/绝对路径/rhel-server-7.0-x86_64-dvd.iso /xxx iso9660 ro,relatime 0 0
镜像文件位置 挂在点 类型 挂载参数 不备份 不检测
eg:
vim /etc/fstab
写入/etc/fstab,使系统能够开机读取rhel-server-7.0-x86_64-dvd.iso中的内容
mount -a ##检查/etc/fstab内容,并把所写内容进行挂载
3.编写软件仓库的指定文件
/etc/yum.repos.d ##仓库指向文件存储目录
vim /etc/yum.repos.d/test.repo ##仓库指向文件
[redhatpackage] ##仓库名称
name=localpackage ##仓库描述
baseurl=file:///yumsource ##仓库地址
gpgcheck=1 ##是否检测软件的gpgkey
enabled=1 ##此仓库在系统中生效(0为在系统中不生效)
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ##本机gpgkey文件
eg:
vim /etc/yum.repos.d/test.repo(/etc/yum.repos.d/中只留下test.repo)
[test]
name=test
baseurl=file:///source(那台机子的仓库位置)
gpgcheck=0
enabled=0
4.网络软件仓库的配置
(物理机搭建网络yum源,虚拟机可以访问使用物理机yum源)
1)yum install httpd -y ##物理机要有httpd服务
2)systemctl start httpd ##启动httpd
3)systemctl enable httpd ##开机启动httpd
4)systemctl stop firewalld ##关闭物理机的防火墙
5)mkdir -p /var/www/html/yum ##在/var/www/html/下建立yum目录
6)mount /iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/yum ##挂载镜像
7)vim /etc/fstab ##写在/etc/fstab可以记录下来,下次开机即可启动
/iso/rhel-server-7.0-x86_64-dvd.iso /var/www/html/yum iso9660 ro,relatime 0 0
(小技巧:vim编辑时ctrl+z打入后台,复制rhel-server-7.0-x86_64-dvd.iso,fg调出来,粘贴,继续编辑)
8)mount -a ##检查/etc/fstab内容,并把所写内容进行挂载
浏览器访问:http://物理机ip/yum ##可以查看到仓库内容
5.第三方软件仓库的搭建
1)mkdir /software ##新建/software
2)mv .rpm包 /software ##把所有rpm包放到指定目录中
3)createrepo -v /software ##创建repodata
4)vim /etc/yum.repos.d/test.repo ##仓库指向文件
[software]
name=software
baseurl=file:///software
gpgcheck=0
5)yum clean all ##刷新配置
6)yum repolist ##查看software库信息
6.以ftp服务的方式搭建
1)yum install vsftp -y ##安装vsftp服务
2)systemctl start vsftpd ##开启服务
3)firewall-cmd --permanent --add-service=ftp
4)保证/var/ftp/下的内容有可读权限
(访问:ftp://ip地址/pub/可以看到内容)
5)可以使用lftp ip 访问了
############rpm命令##########
rpm ###Red Hat Package Manager,软件包管理工具,类似windows里面的“添加/删除”程序
-a ###所有的安装包
-i ###install
-v ###显示信息
-h ###指定包的解密方式为hash
-q ###查询
-p ###指定软件包本身
-l ###列出软件中文件的名字
-f ###查询某个文件属于那个安装包
-a ###所有
-e ###卸载
--force ###强制
--nodeps ###忽略依赖性
--scripts ##查看软件安装和卸载过程中所执行的动作常用组合:
1)对已安装的软件的查询
rpm -qa |grep 关键字 ##在已经安装的软件包中查找关键字软件
rpm -qf 文件名 ##查询已安装的文件属于哪个包,文件名的绝对路径要写出来
rpm -qR 软件名 ##查看软件的依赖性
rpm -qd 软件名 ##查询软件的文档安装位置
2)对为安装的软件包的查看
rpm -qpi file.rpm ##查询此file.rpm件包的用途、版本信息
rpm -qpl file.rpm ##查询此软件包所包含的软件
rpm -qpd file.rpm ##查询此软件包文档位置
rpm -qpR file.rpm ##查询此软件包的依赖关系
3)软件包的安装、升级、删除
rpm -ivh file.rpm ##安装file.rpm
rpm -Uvh file.rpm ##升级file.rpm
rpm -e 软件包名 ##卸载此软件包
cat CentOS-Base-aliyun.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/
http://mirrors.aliyuncs.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/
http://mirrors.aliyuncs.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/
http://mirrors.aliyuncs.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
163的yum
cat CentOS-Base-163.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#released updates
[updates]
name=CentOS-6 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6