1.双击启动vmware,新建一个虚拟机
虚拟机名称命名规则如下:
CentOS7.5 x64 -60
操作系统 版本 IP地址
界面说明:
Install CentOS 7 安装CentOS 7
Test this media & install CentOS 7 测试安装文件并安装CentOS 7
Troubleshooting 修复故障
/boot分区500M
标准分区
一般swap分区为物理内存的1.5~2倍,
swap分区:内存扩展分区 交换分区 给多大? 一般最多:8G,16G,如果swap不够用,就直接添加物理内存吧。
LVM分区
创建/分区 根分区 20G
LVM分区
设置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
四、设置系统光盘开机自动挂载
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源
[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.
3.Htop在Centos7的安装
安装lrzsz包
[root@ShuaiJhou ~]# yum -y install lrzsz