β

Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-7-网络管理之修改IP

Lunar的oracle实验室 74 阅读

联系: QQ(5163721)

标题: Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-7-网络管理之修改IP地址

作者: Lunar ©版权所有[文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.]

首先,还是确认NetworkManager服务已经启动(不启动NetworkManager也可以配置IP和connect等等):


[root@lunar1 ~]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
   Active: active (running) since 六 2016-01-16 06:38:43 CST; 36min ago
 Main PID: 758 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─758 /usr/sbin/NetworkManager --no-daemon
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: failed -> disconnected (reason 'none') [120 30 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  Auto-activating connection 'enp0s9'.
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): Activation: starting connection 'enp0s9' (5e43be5e-5a8c-4f33-bdd1-dfdce55cec0d)
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: disconnected -> prepare (reason 'none') [30 40 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: prepare -> config (reason 'none') [40 50 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: config -> ip-config (reason 'none') [50 70 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: ip-config -> ip-check (reason 'none') [70 80 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): device state change: secondaries -> activated (reason 'none') [90 100 0]
月 16 07:13:45 lunar1 NetworkManager[758]: <info>  (enp0s9): Activation: successful, device activated.
[root@lunar1 ~]#

nmtui的配置和修改会自动更新/etc/sysconfig/network-scripts/下面相关的配置文件:
比如,我们使用nmtui将enp0s9的IP地址修改为192.168.209.15
这时,我们看到,nmtui已经修改了/etc/sysconfig/network-scripts/ifcfg-enp0s9的内容:


[root@lunar1 ~]# ll /etc/sysconfig/network-scripts/ifcfg*
-rw-r--r--. 1 root root 319 1月  16 03:08 /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. 1 root root 319 1月  16 03:08 /etc/sysconfig/network-scripts/ifcfg-enp0s8
-rw-r--r--. 1 root root 315 1月  16 07:18 /etc/sysconfig/network-scripts/ifcfg-enp0s9
-rw-r--r--. 1 root root 254 9月  16 19:51 /etc/sysconfig/network-scripts/ifcfg-lo
[root@lunar1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s9
HWADDR=08:00:27:A8:83:CF
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
NAME=enp0s9
UUID=5e43be5e-5a8c-4f33-bdd1-dfdce55cec0d
ONBOOT=yes
IPADDR=192.168.209.15
PREFIX=24
GATEWAY=192.168.209.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
[root@lunar1 ~]#

但是,此时IP地址还没有修改:
[root@lunar1 ~]# ifconfig


enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.11  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:feee:cd8d  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:ee:cd:8d  txqueuelen 1000  (Ethernet)
        RX packets 928  bytes 75822 (74.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 573  bytes 183191 (178.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.60.11  netmask 255.255.255.0  broadcast 192.168.60.255
        inet6 fe80::a00:27ff:fe42:fb8  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:42:0f:b8  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 27  bytes 3989 (3.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.209.11  netmask 255.255.255.0  broadcast 192.168.209.255
        inet6 fe80::a00:27ff:fea8:83cf  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a8:83:cf  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 416 (416.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 295  bytes 51719 (50.5 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 0  (Local Loopback)
        RX packets 660  bytes 53540 (52.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 660  bytes 53540 (52.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@lunar1 ~]#

我们查看一下名称为enp0s9的网络设备:


[root@lunar1 ~]# nmcli dev show enp0s9
GENERAL.设备:                           enp0s9
GENERAL.类型:                           ethernet
GENERAL.硬盘:                           08:00:27:A8:83:CF
GENERAL.MTU:                            1500
GENERAL.状态:                           100 (连接的)
GENERAL.CONNECTION:                     enp0s9
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/24
WIRED-PROPERTIES.容器:                  开
IP4.地址[1]:                            192.168.209.11/24
IP4.网关:                               192.168.209.1
IP6.地址[1]:                            fe80::a00:27ff:fea8:83cf/64
IP6.网关:                               
[root@lunar1 ~]# 

看一下当前所有的网络连接:


[root@lunar1 ~]# nmcli conn show
名称    UUID                                  类型            设备   
enp0s9  5e43be5e-5a8c-4f33-bdd1-dfdce55cec0d  802-3-ethernet  enp0s9 
enp0s8  ba5021c5-727b-4b19-b6eb-c77892fb40b6  802-3-ethernet  enp0s8 
enp0s3  3e33deb2-5f53-4850-a424-76042c27b419  802-3-ethernet  enp0s3 
[root@lunar1 ~]# 

修改IP后,要使修改后的连接生效,需要重新加载配置文件:


[root@lunar1 ~]# nmcli con load /etc/sysconfig/network-scripts/ifcfg-enp0s9
[root@lunar1 ~]#

然后重新连接设备enp0s9:


[root@lunar1 ~]# nmcli dev connect enp0s9
Device 'enp0s9' successfully activated with '5e43be5e-5a8c-4f33-bdd1-dfdce55cec0d'.
[root@lunar1 ~]# 

现在IP就修改好了,太方便了:


[root@lunar1 ~]# ifconfig enp0s9
enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.209.15  netmask 255.255.255.0  broadcast 192.168.209.255
        inet6 fe80::a00:27ff:fea8:83cf  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a8:83:cf  txqueuelen 1000  (Ethernet)
        RX packets 6  bytes 416 (416.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 323  bytes 55802 (54.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@lunar1 ~]# 
[root@lunar1 ~]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    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
: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:ee:cd:8d brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.11/24 brd 192.168.56.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:feee:cd8d/64 scope link 
       valid_lft forever preferred_lft forever
: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:42:0f:b8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.11/24 brd 192.168.60.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe42:fb8/64 scope link 
       valid_lft forever preferred_lft forever
: enp0s9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:a8:83:cf brd ff:ff:ff:ff:ff:ff
    inet 192.168.209.15/24 brd 192.168.209.255 scope global enp0s9
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fea8:83cf/64 scope link 
       valid_lft forever preferred_lft forever
[root@lunar1 ~]# 

Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列–1-简介
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-2-修改主机名和hostnamectl工具的使用
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列–3-systemd(d.bin和ohasd守护进程)
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列–4-target(图形界面和字符界面)
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列–5-防火墙
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列–6-开机自动启动或者禁用服务
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-7-网络管理之添加网
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-7-网络管理之修改IP地址
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-7-网络管理之修改网络接口名
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-8-在Linux7上安装11.2 RAC和12.1 RAC需要禁用哪些服务
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-9-Linux 7.2上的virbr0设备
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-10-ABRT-系统启动后自动检查和报告错误
Linux7(CentOS,RHEL,OEL)和Oracle RAC环境系列-11-配置VNC和常见问题处理
作者:Lunar的oracle实验室
世间所有相遇都是久别重逢

发表评论