wang618

操作系统介绍和安装centos7

 

 

 

 

掌握GNU、GPL

 

 

 


 

 

 

 

 

 

 

一操作系统发展历史


1969       Unix       贝尔实验室
1986       Minix      教授谭宁邦
1986       类似uinx   斯托曼
   目标:  GNU项目--创建一个类似unix系统
   公司:  FSF自由软件基金会
   规则:  GPL通用许可协议
  1) 所有代码信息必须是开源
  2) 代码可以进行修改,必须进行说明
            成绩:  软件(编辑软件 查询日志)     解释器(bash == shell)     内核 The Hurd(没开发好)
1991       内核   托瓦茨(芬兰大学学生)
           GNU+内核==linux

 

 

 

 

 

 

 

 

 

 

 

 

 

 

二操作系统版本选择

 


乌班图ubuntu:桌面领域,图形界面,适合开发人员使用
红帽 redhat:服务器领域,收费,国企、外企使用的更多

centos:服务器领域(免费)互联网领域
debian:服务器领域(安全性)金融领域,上海使用的比较多

SUSE:服务器领域(网络服务器)实现网络功能

Fredora:测试操作系统
centos6部署cobbler openstack很难,但是在centos7上可以很好部署

注意新的红帽软件开发是对Fredora进行测试调整,发布新版redhat或者centos

 

 

 

 

 

 

 

 

 

 

三操作系统安装过程

 

 

虚拟环境的概念


1虚拟出来多个真实系统环境,可以充分利用硬件资源
2可以节省物理空间占用

 

 

 

 

(一)虚拟环境部署


安装虚拟软件
windows:vmware workstation 15(收费版,但是学习时一般使用破解版,具有快照功能,相当于月光宝盒)

注意windows10检查vmware版本,如果不符合要求,会提示下载vmware player(免费版),不要下载

Mac OS:vmware fusion

 

 

 

 

 

开启虚拟打印功能
编辑 --> 首选项 --> 设备 --> 开启虚拟打印功能        

 

 

 

 

 

 

 

 

 

 

(二)操作系统安装

 
 

创建虚拟主机

 

 

 

 

 

 

 

 

 

 

 

 

 

 

系统位数的选择  

32位系统(i386架构):   识别内存最多只能4G,64位系统(x86_64架构): 识别内存可以超过4G

我的电脑内存是8G,所以选择64位

 

 

 

 

 

 

 

 

 

下载系统镜像文件

 
安装版本是centos 7.6-1810
新版系统下载: https://developer.aliyun.com/mirror 
旧版系统下载: http://vault.centos.org/

 

 

 

加载系统镜像文件

 

 

 

 

 

 

 

 

 

 

 

安装操作系统

 


       Install centos7                     --- 安装centos7系统
       Test this media & install Centos7   --- 测试光盘介质并且安装系统
       Troubleshooting                     --- 系统修复

 

 

 

 

 

 

 

 

 

 

修改网卡名

 

修改网卡名称为eth0,保持和工作环境一致,在centos7上默认是ens33

修改方法:
选择第1个选项install centos7

按tab 键,输入 net.ifnames=0    biosdevname=0

注意第1个有s,第2个没有

 

注意技巧:在虚拟机的编辑处可以进行粘贴,比如把上面的两条设置进行粘贴,net.ifnames=0    biosdevname=0

 

 

 

 

 

 

 

 

 

 

 

 

 



 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

系统磁盘分区

 

灵活分区方案
            /boot分区   类似系统分区, 启动分区                     200M
           swap分区    交换分区(硬盘空间 - 交换 -> 内存使用)      
                      内存 <8G   swap分区大小 = 1.5内存
                      内存>=8G   swap分区大小 = 8G    
          /分区       20G~500G   40G
                      剩余空间不分

注意在生产中根分区40G就可以了

我的虚拟机内存为1G,设置交换分区为1.5G

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

系统网络和主机名称配置

 

地址: 10.0.0.200  
掩码 255.255.255.0 
网关 10.0.0.254    
  
 
 
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

系统预装软件

注意最小化安装,左侧选择

centos6: 235
centos7: 1236         
       
       

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[c:\~]$ ssh  10.0.0.200


Connecting to 10.0.0.200:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].

WARNING! The remote SSH server rejected X11 forwarding request.
Last failed login: Tue Nov 26 17:41:56 CST 2019 from 10.0.0.1 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Tue Nov 26 17:40:18 2019
[root@centos7 ~]# ip   address  show
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:ea:b8:14 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.200/24 brd 10.0.0.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::951a:d6ce:9fbd:c7b7/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

 

 

 

 

 

 

[root@centos7 ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda3       41922560 1513544  40409016   4% /
devtmpfs          487048       0    487048   0% /dev
tmpfs             497948       0    497948   0% /dev/shm
tmpfs             497948    7788    490160   2% /run
tmpfs             497948       0    497948   0% /sys/fs/cgroup
/dev/sda1         201380  107080     94300  54% /boot
tmpfs              99592       0     99592   0% /run/user/0
[root@centos7 ~]# mount  /dev/cdrom  /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@centos7 ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda3       41922560 1513544  40409016   4% /
devtmpfs          487048       0    487048   0% /dev
tmpfs             497948       0    497948   0% /dev/shm
tmpfs             497948    7788    490160   2% /run
tmpfs             497948       0    497948   0% /sys/fs/cgroup
/dev/sda1         201380  107080     94300  54% /boot
tmpfs              99592       0     99592   0% /run/user/0
/dev/sr0         4480476 4480476         0 100% /mnt

 

 

 

 

 

 

 

最小化安装默认是没有yum命令的

[root@centos7 ~]# rpm  -ivh  /mnt/Packages/net-tools-2.0-0.24.20131004git.el7.x86_64.rpm 
warning: /mnt/Packages/net-tools-2.0-0.24.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:net-tools-2.0-0.24.20131004git.el################################# [100%]
[root@centos7 ~]# ifc
ifcfg     ifconfig  

 

 

 

 

 

 

[root@centos7 ~]# rpm  -ivh  /mnt/Packages/yum-3.4.3-161.el7.centos.noarch.rpm 
warning: /mnt/Packages/yum-3.4.3-161.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
    package yum-3.4.3-161.el7.centos.noarch is already installed

 

 

 

 

 

 

 

[root@centos7 ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda3       41922560 1515920  40406640   4% /
devtmpfs          487048       0    487048   0% /dev
tmpfs             497948       0    497948   0% /dev/shm
tmpfs             497948    7788    490160   2% /run
tmpfs             497948       0    497948   0% /sys/fs/cgroup
/dev/sda1         201380  107080     94300  54% /boot
tmpfs              99592       0     99592   0% /run/user/0
/dev/sr0         4480476 4480476         0 100% /mnt
[root@centos7 ~]# df  -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        40G  1.5G   39G   4% /
devtmpfs        476M     0  476M   0% /dev
tmpfs           487M     0  487M   0% /dev/shm
tmpfs           487M  7.7M  479M   2% /run
tmpfs           487M     0  487M   0% /sys/fs/cgroup
/dev/sda1       197M  105M   93M  54% /boot
tmpfs            98M     0   98M   0% /run/user/0
/dev/sr0        4.3G  4.3G     0 100% /mnt

[root@centos7 ~]# yum  repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
Loading mirror speeds from cached hostfile
repo id                                         repo name                                         status
base/7/x86_64                                   CentOS-7 - Base                                   0
extras/7/x86_64                                 CentOS-7 - Extras                                 0
updates/7/x86_64                                CentOS-7 - Updates                                0
repolist: 0

 

 

 

 

 

 

[root@centos7 ~]# mkdir  /etc/yum.repos.d/bak
[root@centos7 ~]# ls   /etc/yum.repos.d/bak
[root@centos7 ~]# mv  /etc/yum.repos.d/*  /etc/yum.repos.d/bak/
mv: cannot move ‘/etc/yum.repos.d/bak’ to a subdirectory of itself, ‘/etc/yum.repos.d/bak/bak’
[root@centos7 ~]# cd  /etc/yum.repos.d/
[root@centos7 yum.repos.d]# ls
bak
[root@centos7 yum.repos.d]# cd  bak/
[root@centos7 bak]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@centos7 bak]# ll
total 32
-rw-r--r--. 1 root root 1664 Nov 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Nov 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Nov 23  2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Nov 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23  2018 CentOS-Vault.repo
[root@centos7 bak]# cd  ..
[root@centos7 yum.repos.d]# vim  base.repo
-bash: vim: command not found
[root@centos7 yum.repos.d]# vi   base.repo
[root@centos7 yum.repos.d]# yum  repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                             | 3.6 kB  00:00:00     
(1/2): base/group_gz                                                             | 166 kB  00:00:00     
(2/2): base/primary_db                                                           | 3.1 MB  00:00:00     
repo id                                           repo name                                       status
base                                              base                                            4,021
repolist: 4,021

 

 

 

 

[root@centos7 yum.repos.d]# cat  base.repo 
[base]
name=base
enable=1
baseurl=file:///mnt
gpgcheck=0

 

 

 

 

 

 

 

 

[root@centos7 ~]# yum  search  bash
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
========================================== N/S matched: bash ===========================================
bash-completion.noarch : Programmable completion for Bash
libvirt-bash-completion.x86_64 : Bash completion script
pcp-pmda-bash.x86_64 : Performance Co-Pilot (PCP) metrics for the Bash shell
bash.x86_64 : The GNU Bourne Again shell

  Name and summary matches only, use "search all" for everything.

 

 

 

 

 

 

 

问题yum配置有误,跳过检查

[root@centos7 ~]# yum  install  bash-completion.noarch -y
Loaded plugins: fastestmirror

You have enabled checking of packages via GPG keys. This is a good thing. 
However, you do not have any GPG public keys installed. You need to download
the keys for packages you wish to install and install them.
You can do that by running the command:
    rpm --import public.gpg.key


Alternatively you can specify the url to the key you would like to use
for a repository in the \'gpgkey\' option in a repository section and yum 
will install it for you.

For more information contact your distribution or package provider.

Problem repository: base

 

 

 

 

 

 

[root@centos7 yum.repos.d]# yum  install  bash-completion.noarch -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                             | 3.6 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package bash-completion.noarch 1:2.1-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
 Package                       Arch                 Version                    Repository          Size
========================================================================================================
Installing:
 bash-completion               noarch               1:2.1-6.el7                base                85 k

Transaction Summary
========================================================================================================
Install  1 Package

Total download size: 85 k
Installed size: 259 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 1:bash-completion-2.1-6.el7.noarch                                                   1/1 
  Verifying  : 1:bash-completion-2.1-6.el7.noarch                                                   1/1 

Installed:
  bash-completion.noarch 1:2.1-6.el7                                                                    

Complete!

 

 

 

 

 

注意debian和乌班图的命令相似,掌握一个就会另外一个了

 

分类:

技术点:

相关文章:

  • 2021-04-29
猜你喜欢
  • 2022-02-06
  • 2022-02-21
  • 2022-01-02
  • 2022-02-08
  • 2021-10-05
相关资源
相似解决方案