39.CentOs7.5操作系统最小安装
2019-05-10 本文已影响311人
一枼落知天下
1.双击启动vmware,新建一个虚拟机
新建一个虚拟机 注意:选择自定义,然后下一步 下一步 注意:稍后安装操作系统,然后下一步 注意:选择客户机操作系统,然后下一步 注意:命名虚拟机,存放位置,然后下一步虚拟机名称命名规则如下:
CentOS7.5 x64 -60
操作系统 版本 IP地址
处理器配置,然后下一步
内存分配
温馨提示:桥接,然后下一步
下一步
下一步
下一步
下一步
下一步
选择自定义硬件
选择好下载的镜像(CentOS-7.5-x86_64-DVD-1804.iso)
点击完成
虚拟机创建完成
虚拟机硬件信息修改,单击“编辑虚拟机设置”或直接双击相应的设备
移除无用设备“打印机”
修改硬件信息具体如下
内存——>大于768MB(若小于768MB,则安装时不能打开图形界面,无法进行安装,建议1024MB以上),
添加光盘镜像
修改网卡配置(为了后期虚拟机联网方便,这里网卡选择桥接模式,并把“复制物理网络连接状态勾选”)
硬件配置修改完成后,单击“确定”
开始安装单击“开启此虚拟机”
成功引导系统后,会出现下面的界面
界面说明:
Install CentOS 7 安装CentOS 7
Test this media & install CentOS 7 测试安装文件并安装CentOS 7
Troubleshooting 修复故障
这里选择第一项,安装centos 7,回车,进入下面的界面
按回车开始安装
安装中
安装英文版本,单击继续按钮
进入一站式安装界面,在此界面,只需把所有带“黄色叹号”内容的感叹号全部消除,便可进行安装
时间和时区选择
系统语言支持:增加简体中文和英文
系统语言支持:增加简体中文和英文 本地存储介质,和最小安装 配置分区
/boot分区500M
标准分区
/boot分区500M
一般swap分区为物理内存的1.5~2倍,
swap分区:内存扩展分区 交换分区 给多大? 一般最多:8G,16G,如果swap不够用,就直接添加物理内存吧。
LVM分区
swap分区
接收更改 自定义分区完成 配置网络和主机名 配置网络 开始系统安装创建/分区 根分区 20G
LVM分区
根分区 20G
设置root用户密码,如果密码过于简单,需要连续点击左上角Done两次;
创建一个普通用户 等待系统安装完成 系统安装完成,重启
配置
一、配置网络
在最小化安装的CentOS7中,ifconfig是不能使用的,查看网卡信息的命令是
[root@ZhouShuai ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:24:bc:ef brd ff:ff:ff:ff:ff:ff
inet 192.168.31.63/24 brd 192.168.31.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::227f:32:d731:5753/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@ZhouShuai ~]#
[root@ZhouShuai ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
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="ens33"
UUID="b6a6ec0e-d014-4ef0-a0f0-afbf00a715e6"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.31.63"
PREFIX="24"
GATEWAY="192.168.31.1"
DNS1="192.168.31.1"
IPV6_PRIVACY="no"
[root@ZhouShuai ~]# systemctl restart network
[root@ZhouShuai ~]# ping www.baidu.com
PING www.a.shifen.com (180.97.33.108) 56(84) bytes of data.
64 bytes from 180.97.33.108 (180.97.33.108): icmp_seq=1 ttl=54 time=33.4 ms
64 bytes from 180.97.33.108 (180.97.33.108): icmp_seq=2 ttl=54 time=33.0 ms
64 bytes from 180.97.33.108 (180.97.33.108): icmp_seq=3 ttl=54 time=33.0 ms
64 bytes from 180.97.33.108 (180.97.33.108): icmp_seq=4 ttl=54 time=33.2 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 33.013/33.208/33.457/0.178 ms
[root@ZhouShuai ~]#
安装ifconfig命令
查看哪个组件包含了ifconfig命令
[root@ZhouShuai ~]# yum install -y net-tools
[root@ZhouShuai ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.31.63 netmask 255.255.255.0 broadcast 192.168.31.255
inet6 fe80::227f:32:d731:5753 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:24:bc:ef txqueuelen 1000 (Ethernet)
RX packets 19241 bytes 23775987 (22.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9276 bytes 601766 (587.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@ZhouShuai ~]#
安装vim编辑器
[root@ZhouShuai ~]# yum install -y vim-enhanced
安装wget
[root@ZhouShuai ~]# yum install -y wget
安装rz和sz命令 lrzsz
[root@ZhouShuai ~]# yum -y install lrzsz
CentOs7.5系统IP配置、关闭防火墙和selinux、光盘开机自动挂载、配置本地YUM源、实验快照
CentOs7.5系统基本操作和环境配置
二、关闭防火墙并设置开机自动关闭
[root@JhouShuai ~]# systemctl status firewalld.service #查看服务运行状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 六 2019-02-23 12:42:38 CST; 41min ago
Docs: man:firewalld(1)
Main PID: 795 (firewalld)
Tasks: 2
CGroup: /system.slice/firewalld.service
└─795 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopi...
2月 23 12:42:36 JhouShuai systemd[1]: Starting firewalld - dynamic fir....
2月 23 12:42:38 JhouShuai systemd[1]: Started firewalld - dynamic fire....
Hint: Some lines were ellipsized, use -l to show in full.
[root@JhouShuai ~]# systemctl stop firewalld.service #关闭当前
[root@JhouShuai ~]# systemctl status firewalld.service #查看服务运行状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since 六 2019-02-23 13:25:58 CST; 8s ago
Docs: man:firewalld(1)
Process: 795 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 795 (code=exited, status=0/SUCCESS)
2月 23 12:42:36 JhouShuai systemd[1]: Starting firewalld - dynamic fir....
2月 23 12:42:38 JhouShuai systemd[1]: Started firewalld - dynamic fire....
2月 23 13:25:57 JhouShuai systemd[1]: Stopping firewalld - dynamic fir....
2月 23 13:25:58 JhouShuai systemd[1]: Stopped firewalld - dynamic fire....
Hint: Some lines were ellipsized, use -l to show in full.
[root@JhouShuai ~]# systemctl disable firewalld.service #开机自动关闭
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@JhouShuai ~]#
[root@JhouShuai ~]# reboot #重启系统生效
三、关闭selinux并设置开机自动关闭
[root@JhouShuai ~]# getenforce
Enforcing
[root@JhouShuai ~]# setenforce 0 #临时关闭
[root@JhouShuai ~]# getenforce
Permissive
[root@JhouShuai ~]#
#开机自动关闭:
[root@JhouShuai ~]# vim /etc/sysconfig/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=enforcing #删除enforcing,改为disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
——————————————————————————————————————————————————————————————————————————————————————————————————
[root@JhouShuai ~]# reboot #重启系统生效
root@JhouShuai ~]# getenforce
Disabled
删除enforcing,改为disabled
四、设置系统光盘开机自动挂载
linux中一切皆文件
[root@JhouShuai ~]# echo "/dev/sr0 /mnt iso9660 defaults 0 0" >> /etc/fstab
[root@JhouShuai ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Feb 21 00:28:07 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=91733de7-9339-4f8c-bb3a-92a2aac9463d / xfs defaults 0 0
UUID=b7c20cc2-17ab-4d5a-9b4d-7c8b037e3ac4 /boot xfs defaults 0 0
UUID=46a5b91f-a2e0-4296-8bcd-c6db48943ab8 swap swap defaults 0 0
/dev/sr0 /mnt iso9660 defaults 0 0
~
~
[root@JhouShuai ~]# mount -a
mount: /dev/sr0 写保护,将以只读方式挂载
[root@JhouShuai ~]# df -h #查看挂载情况
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 10G 4.6G 5.5G 46% /
devtmpfs 976M 0 976M 0% /dev
tmpfs 992M 0 992M 0% /dev/shm
tmpfs 992M 11M 981M 2% /run
tmpfs 992M 0 992M 0% /sys/fs/cgroup
/dev/sda1 497M 148M 350M 30% /boot
tmpfs 199M 24K 199M 1% /run/user/0
/dev/sr0 4.2G 4.2G 0 100% /mnt
[root@JhouShuai ~]# ls /mnt/ #可以查看到此目录下有内容,说明挂载成功
CentOS_BuildTag GPL LiveOS RPM-GPG-KEY-CentOS-7
EFI images Packages RPM-GPG-KEY-CentOS-Testing-7
EULA isolinux repodata TRANS.TBL
五、配置本地YUM源
什么是yum
Yum****(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。
YUM的配置文件
yum****的一切配置信息都储存在一个叫yum.repos.d目录的配置文件中,通常位于/etc目 录下,这是整个yum系统的重中之重
创建文件 文件的格式 必须是.repo结尾
[root@JhouShuai ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@JhouShuai ~]#
Centos7已经自动配好了网络yum源
[root@JhouShuai ~]# vim /etc/yum.repos.d/CentOS-Base.repo
网络yum源
配置本地YUM源
[root@JhouShuai ~]# cd /etc/yum.repos.d/
[root@JhouShuai yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@JhouShuai yum.repos.d]# vim CentOS7.repo
[CentOS7-source] #yum的ID,必须唯一
name=CentOS7-server #描述信息
baseurl=file:///mnt # /mnt表示的是光盘的挂载点 . file:后面有3个///
enabled=1 #启用
gpgcheck=0 #取消验证
[root@JhouShuai yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
CentOS7-source | 3.6 kB 00:00
(1/2): CentOS7-source/group_gz | 166 kB 00:00
(2/2): CentOS7-source/primary_db | 3.1 MB 00:00
源标识 源名称 状态
CentOS7-source CentOS7-server 3,971
repolist: 3,971
[root@JhouShuai yum.repos.d]#
[root@JhouShuai yum.repos.d]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识 源名称 状态
CentOS7-source CentOS7-server 3,971
repolist: 3,971
[root@JhouShuai yum.repos.d]# yum clean all #清空yum缓存
已加载插件:fastestmirror, langpacks
正在清理软件源: CentOS7-source
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@JhouShuai yum.repos.d]# yum list #生成缓存列表
本地源
六、创建可用实验快照
虚拟机----》快照----》拍摄快照----》自定义快照名如“可用实验快照”
拍摄快照 拍摄快照 快照2.XSHELL连接:The remote SSH server rejected X11 forwarding request.
The remote SSH server rejected X11 forwarding request.