1.系统可用实验环境
1.关闭防火墙
$ systemctl status firewalld.service #查看firewall状态
$ systemctl stop firewalld.service #关闭
$ systemctl disable firewalld.service #设置开机不启动
$ iptables -F #清空防火墙规则
2.关闭SElinux
SELinux 模式介绍:
enforcing 强制模式,只要 selinux 不允许,就无法执行;
permissive 警告模式,你可以执行,但你所做事件全部记录;
disabled 关闭 selinux
$ setenforce 0 #临时关闭
$ vim /etc/selinux/config #永久关闭
修改内容
SELINUX=disabled
$ getenforce #获取状态
Disabled
3.设置本地yum源
$ cd /etc/yum.repos.d/
$ vim centos7.repo
添加内容:
[centos7]
name=centos-server
baseuel=file:///mnt
enabled=1
gpgcheck=0
$ cat centos7.repo
3.1.yum源详解
[centos7] yum源的ID,必须唯一
#括号中的名称为仓库源名称,通常为字母和数字,必须填写
name=centos7-server
name=设置的名字 #对yum的描述信息
baseurl=file:///mnt
#baseurl表示声明yum可以管理并使用的rpm包路径,必须填写,/mnt表示的是光盘的挂载点,file:后面有3
个///,前面两个是斜杠,后面的/代表根
enabled=1
#enabled表示当前仓库是否开启,1为开启,0为关闭,此项不写默认为开启
gpgcheck=0
#gpgcheck表示安装rpm包时,是否基于公私钥对匹配包的安全信息,1表示开启,0表示关闭,此项不写默认为验证
gpgkey #指定密钥的位置,比如阿里源密钥的位置如下
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
3.2.然后清空缓存信息,建立新的缓存
$ yum clean all #清空缓存信息
$ yum makecache #建立新的缓存
4.挂载创建的本地yum源
$ umount /dev/sr0 #卸载
$ mount /dev/cdrom /mnt #临时挂载
$ ll /dev/cdrom
lrwxrwxrwx 1 root root 3 1月 7 12:11 /dev/cdrom -> sr0 #同一个文件
$ df -h #查看挂载信息
$ yum repolist #查看当前yum仓库是否可用
4.1.测试yum源使用
$ yum -y install ntp
5.设置hostname
$ hostname set-hostname xxhf #设置主机名
$ bash #刷新
6.设置IP的对应域名(属于映射关系)
$ ifconfig | grep inet | awk '{print $2}'
192.168.66.61
fe80::9d57:84cb:3342:a387
192.168.138.61
fe80::ac61:2cfd:e94e:212c
127.0.0.1
::1
$ ifconfig | grep inet | awk 'NR==1{print $2}'
192.168.66.61
$ vim /etc/hosts
添加内容:
192.168.66.61 xxhf
$ cat !$
# !$把上一条命令的参数作为标准输入
# !!运行最近一次执行的命令
$ ping -c4 xxhf
7.设置网络源,比如阿里云网络源
7.1.问题:如果本地yum源一直不好?下载网络源
网址 https://developer.aliyun.com/mirror/
$ cd /etc/yum.repos.d/
$ ls
back
$ wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo #下载镜像
$ ls
back CentOS-Base.repo
$ yum update #安装所有更新软件
7.2.epel扩展源,额外的扩展包
$ yum -y install epel-release
$ cd /etc/yum.repos.d/
$ ls
back CentOS-Base.repo epel.repo epel-testing.repo