CentOS 7 mini 运行环境搭建与测试——CentOS Mini 安装ifconfig工具【云原生开发部署实践笔记】

2023-12-14 10:33:29

云原生开发部署实践笔记

一、开发测试环境搭建与测试

1.1 Linux运行环境的搭建与测试

虽然CentOS已经更新到Stream 9 版本,但基于大多数企业和单位多数使用CentOS 7版本作为运行底座,7版本也一直在更行维护,此实践基于CentOS 7 Mini版本搭建。(8和9版本的CentOS系统命令少有差别,但主要用到的其实都差不多,最大的差别在于系统内核与自带的软件组件和库比较新。如果企业开发部署对兼容性有要求,应选择其要求或匹配版本。)

1.1.1 CentOS 7 运行环境搭建与测试

下载安装CentOS 7 mini ,安装教程网上很多,不再赘述

安装镜像下载地址:

http://isoredirect.centos.org/centos/7/isos/x86_64/

按提示安装完系统后,进入系统逐步骤配置。

有的Mini版本默认不带ifconfig命令,安装完成后可使用"dhclient"和 "ip add"命令查询IP地址信息,先让CentOS 连入互联网,

[root@localhost ~]# dhclient
[root@localhost ~]# ip add
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:40:cf:dc brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.150/24 brd 192.168.2.255 scope global noprefixroute dynamic ens33
       valid_lft 602786sec preferred_lft 602786sec
    inet 192.168.2.231/24 brd 192.168.2.255 scope global secondary dynamic ens33
       valid_lft 604788sec preferred_lft 604788sec
    inet6 fe80::5720:3274:4656:f9a8/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

查出本地ip地址为 192.168.2.150 和192.168.2.231,本地客户端ping测试一下,IP能通即可使用远程管理工具使用SSH命令登入,方便命令复制粘贴和整理。

ssh root@192.168.2.231

出现“Are you sure you want to continue connecting (yes/no/[fingerprint])? ” 时输入“yes”连接CentOS主机

输出信息如下:

(base) tony@Mac ~ % ssh root@192.168.2.231
The authenticity of host '192.168.2.231 (192.168.2.231)' can't be established.
ED25519 key fingerprint is SHA256:gEwRjBgU36s9mLvP9R9oJOLEUPvy/KnSlFYIrtbIJ6Y.
This host key is known by the following other names/addresses:
    ~/.ssh/known_hosts:5: 192.168.2.150
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.2.231' (ED25519) to the list of known hosts.
root@192.168.2.231's password: 
Last login: Thu Dec  7 10:18:29 2023 from 192.168.2.221
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
[root@localhost ~]# 

安装ifconfig命令
  1. 首先,让我们找出哪个包提供了ifconfig命令。要完成这项任务,输入以下命令:
yum provides ifconfig

输出:

[root@localhost ~]# yum provides ifconfig
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
net-tools-2.0-0.25.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/sbin/ifconfig

[root@localhost ~]# 

2.就像你在上面的输出中所看到的,net-tools包提供了ifconfig命令。因此,让我们安装net-tools包来使用ifconfig命令。

yum install net-tools

3.现在,你就可以像以往一样使用ifconfig命令了。

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.150  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::5720:3274:4656:f9a8  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:40:cf:dc  txqueuelen 1000  (Ethernet)
        RX packets 111766  bytes 160337382 (152.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15956  bytes 1308349 (1.2 MiB)
        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 68  bytes 5912 (5.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 68  bytes 5912 (5.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]# 

文章来源:https://blog.csdn.net/lqzixi/article/details/134868064
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。