Installation method one: Local Yum warehouse yum installation (automatically resolve software dependencies; use rpm packages for installation) (local yum warehouse, using CDs) 1. Create a mounting directory for the CD
mkdir /media/cdrom
2. Mount the CD (temporarily mount)
mount /dev/cdrom /media/cdrom
3. Enter the directory where the yum warehouse is located: cd /etc/yum.repos.d/ (warehouse files exist in this directory by default)
4. Delete these warehouse files: rm -rf *
5. Create the yum warehouse file yourself: vim centOS7. repo
添加:
[aaa] (仓库名字)
name=这是一个C7 的yum (仓库的描述信息)
baseurl=file:///media/cdrom (仓库依赖的文件位置,所挂载的光盘)
enabled=1 (启用该yum 仓库)
gpgcheck=0 (不检查秘钥)
保存退出
Configure automatic mounting
Automatically mounted configuration file: /etc/fstab, which stores the statically mounted data of the file system. When the Linux system is booted, it will automatically read the contents of the file to automatically mount the specified file system.
Detailed explanation of /etc/fstab file: (divided into 6 fields)
First field: device name or partition name
Second field: The mount point directory location of the file system
Third field: File system type
Fourth field: Mount parameters (default (default parameter); rw (writable); ro (read-only); noexec (disable execution program))
Fifth field: Indicates whether the file system requires dump backup (set to 1 to indicate required, set to 0 to ignore)
Sixth field: The order of disk checking when the system starts; 0 means no checking, 1 means checking first, 2 means checking second (in the production environment, the root partition needs to be set to 1; other partitions need to be set to 2; the experimental environment can be set directly is 0)
Note: After the configuration file is modified successfully, it needs to be restarted to take effect; after restarting, enter the mount command to check the mounting status.
vim /etc/fstab
add last line
If you don’t know, you can first check the information to be mounted.
lsblk -f
After the mounting is complete, restart and the automatic mounting will be completed.
Installation method two: Local Yum repository
Directly copy and paste the following command. No operation is required. The firewall selinux has been set up.
echo '
#!/bin/bash
mkdir /media/cdrom &> /dev/null
mount /dev/cdrom /media/cdrom &> /dev/null
q=$(echo $?)
if [ 0 -eq $q ]
then
echo "挂载成功"
else
echo "重复挂载 或 错误请检查光盘是否以挂载到虚拟机..."
fi
cd /etc/yum.repos.d/
mkdir aaa &> /dev/null
mv C* aaa &> /dev/null
echo "[aaa]
name=这是一个C7 的yum
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0"> /etc/yum.repos.d/centOS7.repo
#-------------------------以下为自动挂载自动判断是否挂载
grep -rn "iso9660" /etc/fstab | wc -l > /dev/null
ck=$(grep -w "iso9660" /etc/fstab | wc -l)
a=1
if [ $a -eq $ck ]
then
echo "手动挂载以,加入无需操心"
y=$(echo $?)
else
echo "/dev/sr0 /media/cdrom iso9660 defaults 0 0" >> /etc/fstab
b=$(echo $?)
fi
if [[ 0 -eq $b || 0 -eq $y ]]
then
echo "自动挂载已完成... 或 已经存在"
fi
#-----
systemctl stop firewalld
systemctl disable firewalld
sed -i '7s/enforcing/disabled/g' /etc/sysconfig/selinux #修改selinux
'> yum.sh
bash yum.sh
yum -y install vim
init 6 After restarting, check whether the firewall is turned off with yum and whether vim can be installed. For example: if it can be installed, then the script is executed successfully.