01linux基础服务-安装各项服务前的实验环境配置

 

1.1在安装服务之前,我们首先对我们的实验环境进行一些配置

1.1.1清空关闭防火墙

[root@localhost ~]# iptables -F     #请购iptables的规则
[root@localhost ~]# systemctl stop firewalld      #关闭防火墙
[root@localhost ~]# systemctl disable firewalld     #关闭防火墙开机自启动
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

1.1.2关闭selinux

[root@localhost ~]# getenforce     #查看selinux的状态
Enforcing

[root@localhost ~]# vim /etc/selinux/config   #打开selinux的配置文件

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled                                          #此项设置为disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

1.1.3 配置好静态IP

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-enp0s3     #编辑网络配置文件

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=79d2c568-f2ba-4cbc-a9c7-28263b697660
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.135.8
GATEWAY=192.168.135.2
NETMASK=255.255.255.0
DNS1=61.128.128.68

1.1.4 配置主机和IP映射关系

[root@localhost ~]# vim /etc/host

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.135.8 test.cn test

1.1.5 修改主机名

[root@localhost ~]# vim /etc/hostname   #打开主机名配置文件

test

[root@localhost ~]# hostname test    #立即生效

1.1.6 配置好yum源

  1)配置本地yum源

[root@test ~]# mount /dev/sr0 /mnt/      #将镜像文件挂载到mnt下
mount: /dev/sr0 写保护,将以只读方式挂载
[root@test ~]# echo "/dev/sro /mnt iso9660 defaults 0 0 " >>/etc/fstab    #写入挂载配置文件中,让镜像开机自动挂载
[root@test ~]# rm -rf /etc/yum.repos.d/*        #删除系统原自带的所有yum源
[root@test ~]# cat>/etc/yum.repos.d/Centos7.repo<<EOF       #新建一个Centos7名字的yum源配置文件
> [Centos7]
> name=Centos7
> baseurl=file:///mnt
> enabled=1
> gpgcheck=0
> EOF

2)配置网络yum源

阿里云镜像源站点(http://mirrors.aliyun.com/)。

centos镜像参考:http://mirrors.aliyun.com/help/centos

CentOS

1、备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo

3)清楚原来yum缓存,并生成新的缓存

[root@test ~]# yum clean all
已加载插件:fastestmirror
正在清理软件源: Centos7
Cleaning up list of fastest mirrors
Other repos take up 79 M of disk space (use --verbose for details)
[root@test ~]# yum makecache

4)安装epel源  

[root@test ~]# yum -y install epel-release

 

 

 

猜你喜欢

转载自www.cnblogs.com/hackerlin/p/11276589.html