Xshell連接Centos7.5和yum


1 Centos7 IP地址的配置    1

1.1 第一種配置ip方法(nmtui    1

1.2 第二種 修改網卡配置文件    5

1.2.1 使用cat查看配置文件    5

1.2.2 使用sed命令更改IP地址    6

2 xshell的優化    6

2.1 xshell連接失敗、排錯思路    6

3 CentosOS7.5 修改語言支持    7

3.1 查看當前系統語言支持    7

3.2 清屏    7

3.3 虛擬機通過net網絡模式上網,排錯思路    7

4 yum    7

4.1 yum    7

4.2 Sentos7.5構建國內yum    8

5 虛擬機的快照以及克隆    9

5.1 虛擬機的快照    9

5.2 虛擬機的克隆    9

 

  1. Centos7 IP地址的配置

  2. 第一種配置ip方法(nmtui)

nmtui

使用方向鍵、tab、空格、回車操作

  1. 第二種 修改網卡配置文件

    1. 使用cat查看配置文件

cat /etc/sysconfig/network-scripts/ifcfg-ens33

[root@majinhai ~]# cat /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=c32bc0de-5592-4f17-89b9-51ead27064c9

DEVICE=ens33

ONBOOT=yes

IPADDR=10.0.0.200

PREFIX=24

GATEWAY=10.0.0.254

DNS1=114.114.114.114

IPV6_PRIVACY=no

[root@majinhai ~]#

BOOTPROTO=none/start/dhcp #網卡獲取ip地址的方式

        none/start 手動配置ip

        dhcp        自動獲取ip

    ONBOOT=yes/no

                    yes 是開機啟動狀態    

                    no    開啟禁用狀態

    IPADDR=10.0.0.100 #配置IP地址

    PREFIX=24 或者    NETMASK=255.255.255.0    #子網掩碼

    GATEWAY=10.0.0.254        #網關

    DNS1=114.114.114.114        #配置DNS 可以寫三個

  1. 使用sed命令更改IP地址

sed -i 's/IPADDR=10.0.0.200/IPADDR=10.0.0.100/g' /etc/sysconfig/network-scripts/ifcfg-ens33

[root@majinhai ~]# sed -i 's/IPADDR=10.0.0.200/IPADDR=10.0.0.100/g' /etc/sysconfig/network-scripts/ifcfg-ens33

[root@majinhai ~]# cat /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=c32bc0de-5592-4f17-89b9-51ead27064c9

DEVICE=ens33

ONBOOT=yes

IPADDR=10.0.0.100

PREFIX=24

GATEWAY=10.0.0.254

DNS1=114.114.114.114

IPV6_PRIVACY=no

修改開機啟動sed –i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/netowek-script/ifcfg-ens33

[root@majinhai ~]# sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-ens33

[root@majinhai ~]# cat /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=c32bc0de-5592-4f17-89b9-51ead27064c9

DEVICE=ens33

ONBOOT=yes

IPADDR=10.0.0.100

PREFIX=24

GATEWAY=10.0.0.254

DNS1=114.114.114.114

IPV6_PRIVACY=no

 

sed –i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' /etc/sysconfig/network-scripts/ifcfg-ens33

[root@majinhai ~]# sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/g' /etc/sysconfig/network-scripts/ifcfg-ens33

[root@majinhai ~]# cat /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=c32bc0de-5592-4f17-89b9-51ead27064c9

DEVICE=ens33

ONBOOT=yes

IPADDR=10.0.0.100

PREFIX=24

GATEWAY=10.0.0.254

DNS1=114.114.114.114

IPV6_PRIVACY=no

 

修改完之后,使用systemctl restart network重啟網絡服務,讓配置生效

 

  1. Xshell連接Cenos7.5

  2. xshell連接失敗、排錯思路

    1. ping虛擬機,如果ping不通,檢查VMware8網卡的ip地址

    B、關閉selinux

    1. 查看selinux配置文件 cat /etc/selinux/config

[root@majinhai ~]# cat /etc/selinux/config

 

# 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

# 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

  1. 修改配置文件關閉selinux

    sed –i 's/SELINUX=enforcing/SELINUX=disable/g' /etc/selinux/config

[root@majinhai ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

[root@majinhai ~]# cat /etc/selinux/config

 

# 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

# 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

  1. 修改完以后重啟服務器配置才能生效
  2. setenforce 0 #臨時關閉selinux

[root@majinhai ~]# setenforce 0

  1. 關閉firewalld(防火牆)

    systemctl stop firewalld    #臨時關閉防火牆

    systemctl disable firewalld        永久關閉防火牆

[root@majinhai ~]# systemctl stop firewalld

[root@majinhai ~]# systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@majinhai ~]#

  1. CentosOS7.5 修改語言支持

  2. 查看當前系統語言支持

    echo $LANG

        英文:LANG=en_US.UTF-8

        中文:LANG=zh_CN.UTF-8

  1. 清屏

    clear

    ctrl+l

  2. 虛擬機通過net網絡模式上網,排錯思路

    1. ping www.baidu.com
    2. 檢查網關
    3. 檢查VMware的虛擬網絡編輯器—>服務
    4. 檢查windows系統服務
      1. 右鍵此電腦——》管理——》服務和應用程序——》服務
      2. win+r 鍵入services.msc
      3. 任務管理器——》服務
  3. yum

  4. yum

    yum是linux系統下的軟件包管理器(倉庫、庫管、菜單)

        路徑:/etc/yum.repos.d/*.repo

        /etc/yum.repos.d/*.repo

[base] #倉庫名稱

name= #倉庫描述

mirrorlist= #倉庫鏡像路徑

baseurl= #倉庫url路徑 http://www.baidu.com

enabled= #倉庫是否啟用 1表示啟用,0表示關閉

gpgcheck= #密鑰檢測 1表示開啟,0表示關閉

  1. Sentos7.5構建國內yum源

  2. 下載國內的yum源(aliyun

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

    # 如果是最小安裝,系統里沒有wget命令,就使用下面的命令來實現

    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

[root@majinhai ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 2523 100 2523 0 0 31511 0 --:--:-- --:--:-- --:--:-- 31537

  1. 下載成功后,使用yum makecache,生成緩存

[root@majinhai ~]# yum makecache

已加載插件:fastestmirror

Determining fastest mirrors

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

base | 3.6 kB 00:00:00

extras | 3.4 kB 00:00:00

updates | 3.4 kB 00:00:00

(1/12): base/7/x86_64/group_gz | 166 kB 00:00:00

base/7/x86_64/primary_db FAILED

http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/03d0a660eb33174331aee3e077e11d4c017412d761b7f2eaa8555e7898e701e0-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"

正在嘗試其它鏡像。

(2/12): extras/7/x86_64/primary_db | 172 kB 00:00:00

(3/12): extras/7/x86_64/other_db | 110 kB 00:00:00

(4/12): extras/7/x86_64/filelists_db | 588 kB 00:00:00

(5/12): base/7/x86_64/other_db | 2.5 MB 00:00:00

(6/12): updates/7/x86_64/filelists_db | 2.4 MB 00:00:00

(7/12): updates/7/x86_64/other_db | 373 kB 00:00:00

(8/12): updates/7/x86_64/primary_db | 4.3 MB 00:00:00

(9/12): base/7/x86_64/primary_db | 5.9 MB 00:00:00

base/7/x86_64/filelists_db FAILED

http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/f35d0029ad59e9fca0823be708150f5ee28ee1707cdc9bdaf420da676daafe28-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"

正在嘗試其它鏡像。

extras/7/x86_64/prestodelta FAILED

http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/6c971648c41e83b5a7036ff70e79fee7f28c3b480d2f76001e6df8cfde507ab2-prestodelta.xml.gz: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"

正在嘗試其它鏡像。

(10/12): base/7/x86_64/filelists_db | 6.9 MB 00:00:00

(11/12): extras/7/x86_64/prestodelta | 68 kB 00:00:00

updates/7/x86_64/prestodelta FAILED

http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/78b732b6beb1c39406c440264f8bc168484b4600e3a418d0b6919dad291f7037-prestodelta.xml.gz: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"

正在嘗試其它鏡像。

(12/12): updates/7/x86_64/prestodelta | 400 kB 00:00:00

元數據緩存已建立

  1. 注意:

    如果有報錯需要關閉yum源驗證

    sed –i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-Base.repo

[root@majinhai ~]# sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-Base.repo

[root@majinhai ~]# cat /etc/yum.repos.d/CentOS-Base.repo

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client. You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

 

[base]

name=CentOS-$releasever - Base - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/

http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/

http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/

gpgcheck=0

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

 

  1. yum的常用命令:安裝常用的工具ifconfig

    查找哪個包包含了ifconfig

[root@majinhai ~]# yum search ifconfig

已加載插件:fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

===================================== 匹配:ifconfig ======================================

net-tools.x86_64 : Basic networking tools

[root@majinhai ~]#

 

安裝net-tools

[root@majinhai ~]# yum install -y net-tools

已加載插件:fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com

* extras: mirrors.aliyun.com

* updates: mirrors.aliyun.com

正在解決依賴關系

--> 正在檢查事務

---> 軟件包 net-tools.x86_64.0.2.0-0.22.20131004git.el7 將被 安裝

--> 解決依賴關系完成

 

依賴關系解決

 

===========================================================================================

Package 架構 版本 源 大小

===========================================================================================

正在安裝:

net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k

 

事務概要

===========================================================================================

安裝 1 軟件包

 

總下載量:305 k

安裝大小:917 k

Downloading packages:

net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

正在安裝 : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1

驗證中 : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1

 

已安裝:

net-tools.x86_64 0:2.0-0.22.20131004git.el7

 

完畢!

 

 

輸入ifconfig

[root@majinhai ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500

inet 10.0.0.100 netmask 255.255.255.0 broadcast 10.0.0.255

inet6 fe80::6d25:5198:5939:f0c1 prefixlen 64 scopeid 0x20<link>

ether 00:0c:29:89:21:4f txqueuelen 1000 (Ethernet)

RX packets 19634 bytes 26554679 (25.3 MiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 2521 bytes 253823 (247.8 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

 

yum list     列表

yum search     搜索

install            安裝

        yum install –y net-tools

remove            卸載

        yum remove –y 軟件名

  1. yum grouplist

    yum groupstall

    yum groupmove

     

    yum updata(更新linux內核)

  2. 虛擬機的快照以及克隆

  3. 虛擬機的快照             

    1. 建議在關機狀態下進行
    2. 虛擬機——》快照——》拍攝快照(備注當前要做快照的虛擬機當前配置狀態
  4. 虛擬機的克隆

    1. 必須在關機狀態下進行
    2. 建議使用快照克隆
    3. 建議使用鏈接克隆
    4. 克隆完后,需要進入虛擬機修改相應的參數
    5. 修改/etc/sysconfig/network-scripts/ifcfg-ens33,修改IP地址,並刪除UUID


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM