配置光驱自动挂载
#!/bin/bash
echo ' /dev/cdrom /mnt iso9660 defaults 0 0 ' >> /etc/fstab
mount -a
配置本地yum源
#!/bin/bash
cd /etc/yum.repos.d/
mkdir bak
mv *.repo bak
touch Local.repo
cat > Local.repo << EOF
[LOCAL_REPO]
name=LOCAL
baseurl=file:///mnt
enabled=1
gpgcheck=0
EOF
yum clean && yum makecache
yum repolist
共享本地文件
#!/bin/bash
yum -y install vsftpd
systemctl start vsftpd && systemctl enable vsftpd
mount /dev/cdrom /var/ftp/pub
setenforce 0
配置本地共享yum仓库
#!/bin/bash
cd /etc/yum.repos.d/
touch ftp.repo
cat > ftp.repo <<EOF
[FTP_REPO]
name=FTP_REPO
baseurl=ftp://192.168.8.102
enable=1
gpgcheck=0
EOF
#
yum clean all && yum makecache
yum repolist
配置华为网络yum仓库
#!/bin/bash
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
yum clean all && yum makecache
yum repolist
使用本地rpm包建立yum仓库
#安装yum仓库构建工具
yum -y install createrepo
#将/mnt中的rpm软件包进行构建
create /mnt
ls /mnt
repodata #为仓库文件
vi /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enable=1
gpgcheck=0
yum makecache
源码构建rpm包
yum -y install rpm-build gcc pcre-devel zlib-devel
rpmbuild -ba nginx.spec #会报错,用来创建目录
cp nginx-1.22.1.tar.gz ./rpmbuild/SOURCES/
编辑安装文件
vim .rpmbuild/SPECS/nginx.spec
Name: nginx
Version: 1.22.1
Release: 1%{?dist}
Summary: This is a web server
#Group:
License: GPL
URL: www.test.com
Source0: nginx-1.22.1.tar.gz
BuildRequires: gcc
Requires: pcre-devel zlib-devel
%description
This is a web server
%post
useradd -s /sbin/nologin nginx
%prep
%setup -q
%build
./configure
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%files
%doc
/usr/local/nginx/*
%changelog
安装
rpmbuild -ba ./rpmbuild/SPECS/nginx.spec
cd ./rpmbuild/RPMS/x86_64/
yum -y install nginx-1.22.1.1.el7.x86_64.rpm
yum 相关操作
yum -y install httpd #安装httpd
yum repolist #查看现有yum源
yum grouplist #查看软件包组
yum -y groupinstall " groupname" #安装包组
yum history list #查看安装历史
yum history undo ID # 取消历史安装
yum -y localinstall openvswith #当前文件夹的软件包安装