服务器时间异常造成ORA-00600 [2252]的故障处理

数据库服务器重启之后,检查Oracle集群资源发现四个实例启动了两个,还有两个没有启动(wu,rl)

[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.CWDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DADATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.OCR.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.KDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.asm
               ONLINE  ONLINE       db1                      Started             
               ONLINE  ONLINE       db2                      Started             
ora.gsd
               OFFLINE OFFLINE      db1                                          
               OFFLINE OFFLINE      db2                                          
ora.net1.network
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.ons
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1                                          
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.wu.db
      1        ONLINE  OFFLINE                               Instance Shutdown   
      2        ONLINE  ONLINE       db2                      Open                
ora.dyl.db
      1        ONLINE  OFFLINE                                                   
      2        ONLINE  ONLINE       db2                      Open                
ora.cvu
      1        ONLINE  ONLINE       db2                                          
ora.da.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.db1.vip
      1        ONLINE  ONLINE       db1                                          
ora.db2.vip
      1        ONLINE  ONLINE       db2                                          
ora.oc4j
      1        ONLINE  ONLINE       db2                                          
ora.rl.db
      1        ONLINE  OFFLINE                               Instance Shutdown   
      2        ONLINE  ONLINE       db2                      Open                
ora.scan1.vip
      1        ONLINE  ONLINE       db1                                          
ora.scan2.vip
      1        ONLINE  ONLINE       db2                                          
ora.scan3.vip
      1        ONLINE  ONLINE       db2                               

查看rlzy实例的alert.log文件,可以看到以下错误信息“ORA-00600: internal error code, arguments: [2252], [3418], [573259345], [1594], [50675712]”,关于这个ORA-00600 2252在MOS上有相关bug描述,但我这并不是bug引起的,查看信息时我们也是需要关注时间的,这里时间显示为2001年1月1号了,与当前时间相差了16年2个多月。

Picked broadcast on commit scheme to generate SCNs
Mon Jan 01 08:23:50 2001
Errors in file /u01/app/oracle/diag/rdbms/rl/RL1/trace/RL1_dbw0_19789.trc  (incident=544328):
ORA-00600: internal error code, arguments: [2252], [3418], [573259345], [1594], [50675712], [], [], [], [], [], [], []
Incident details in: /u01/app/oracle/diag/rdbms/rl/RL1/incident/incdir_544216/RL1_diag_19753_i544216.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Errors in file /u01/app/oracle/diag/rdbms/rl/RL1/trace/RL1_dbw0_19789.trc:
ORA-01186: file 2 failed verification tests
ORA-00600: internal error code, arguments: [2252], [3418], [573259345], [1594], [50675712], [], [], [], [], [], [], []
DBW0 (ospid: 19789): terminating the instance due to error 1186
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
Mon Jan 01 08:23:56 2001
ORA-1092 : opitsk aborting process
Mon Jan 01 08:23:56 2001

查看系统当前时间,居然变成了2001年1月1号,而且奇怪的是并不是重启时时间就被修改了,因为有两个实例在重启之后正常启动了

[root@db1 ~]# date
Mon Jan  1 08:25:34 CST 2001

手工更新为当前时间后并手动启动实例(caiwu,rlzy),就能正常启动

[root@db1 ~]# date
Fri Mar 24 11:26:44 CST 2017

[grid@db1 ~]$ srvctl start database -d caiwu

[grid@db1 ~]$ srvctl start database -d rlzy

[grid@db1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.CWDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DADATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.DATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.LISTENER.lsnr
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.OCR.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.KDATA.dg
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.asm
               ONLINE  ONLINE       db1                      Started             
               ONLINE  ONLINE       db2                      Started             
ora.gsd
               OFFLINE OFFLINE      db1                                          
               OFFLINE OFFLINE      db2                                          
ora.net1.network
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
ora.ons
               ONLINE  ONLINE       db1                                          
               ONLINE  ONLINE       db2                                          
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       db1                                          
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       db2                                          
ora.wu.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.dyl.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.cvu
      1        ONLINE  ONLINE       db2                                          
ora.da.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.db1.vip
      1        ONLINE  ONLINE       db1                                          
ora.db2.vip
      1        ONLINE  ONLINE       db2                                          
ora.oc4j
      1        ONLINE  ONLINE       db2                                          
ora.rl.db
      1        ONLINE  ONLINE       db1                      Open                
      2        ONLINE  ONLINE       db2                      Open                
ora.scan1.vip
      1        ONLINE  ONLINE       db1                                          
ora.scan2.vip
      1        ONLINE  ONLINE       db2                                          
ora.scan3.vip
      1        ONLINE  ONLINE       db2       

问题虽然解决了,但是为什么服务器会在启动两个实例后,系统时间发生改变还是不得而知,需要找浪潮服务器的工程师来检查。

Oracle Linux 7 Configure DNS

Oracle Linux 7.1配置DNS服务
一.安装DNS需要的软件包

# yum install bind-libs bind bind-utils

二.编辑named.conf文件
在编辑前先复制一份named.conf文件

[root@jytest1 ~]# cp /etc/named.conf /etc/named.conf.backup


[root@jytest1 ~]# vi /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
        listen-on port 53 { any; };--将127.0.0.1修改成any
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };--将127.0.0.1修改成any

        /* 
         - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
         - If you are building a RECURSIVE (caching) DNS server, you need to enable 
           recursion. 
         - If your recursive DNS server has a public IP address, you MUST enable access 
           control to limit queries to your legitimate users. Failing to do so will
           cause your server to become part of large scale DNS amplification 
           attacks. Implementing BCP38 within your network would greatly
           reduce such attack surface 
        */
        recursion yes;

        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";

        managed-keys-directory "/var/named/dynamic";

        pid-file "/run/named/named.pid";
        session-keyfile "/run/named/session.key";
};

logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};

zone "." IN {
        type hint;
        file "named.ca";
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";

三.配置host.conf

[root@jytest1 ~]# cat /etc/host.conf
multi on

该文件指定如何解析主机名。Linux通过解析器库来获得主机名对应的IP地址。下面是一个“/etc/host.conf”的示例:
order bind,hosts
multi on
nospoof on
“order bind,hosts”指定主机名查询顺序,这里规定先使用DNS来解析域名,然后再查询“/etc/hosts”文件(也可以相反)。
“multi on”指定是否“/etc/hosts”文件中指定的主机可以有多个地址,拥有多个IP地址的主机一般称为多穴主机。
“nospoof on”指不允许对该服务器进行IP地址欺骗。IP欺骗是一种攻击系统安全的手段,通过把IP地址伪装成别的计算机,来取得其它计算机的信任。

四.修改/etc/named.rfc1912.zones

[root@jytest1 ~]# cp /etc/named.rfc1912.zones /etc/named.rfc1912.zones.backup
[root@jytest1 ~]# vi /etc/named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

zone "localhost.localdomain" IN {
        type master;
        file "named.localhost";
        allow-update { none; };
};

zone "localhost" IN {
        type master;
        file "named.localhost";
        allow-update { none; };
};

zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
        type master;
        file "named.loopback";
        allow-update { none; };
};

zone "1.0.0.127.in-addr.arpa" IN {
        type master;
        file "named.loopback";
        allow-update { none; };
};

zone "0.in-addr.arpa" IN {
        type master;
        file "named.empty";
        allow-update { none; };
};

--下面为增加的内容,jybd.net.forward为正向解析,jydba.net.reverse为反向解析
zone "jydba.net" IN {
        type master;
        file "jydba.net.forward";
        allow-update { none; };
};

zone "130.138.10.in-addr.arpa" IN {
        type master;
        file "jydba.net.reverse";
        allow-update { none; };
};
"/etc/named.rfc1912.zones" 54L, 1171C written

五.修改具体的zone配置文件

[root@jytest1 named]# cd /var/named
[root@jytest1 named]# cp named.localhost jydba.net.forward
[root@jytest1 named]# cp named.loopback jydba.net.reverse

[root@jytest1 named]# vi jydba.net.forward
$TTL 1D
@       IN SOA  @ root.jydba.net. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       10.138.130.171
        AAAA    ::1

jytest1              A            10.138.130.171
jytest2              A            10.138.130.172
jytest1-vip          A            10.138.130.175
jytest2-vip          A            10.138.130.176
jytest-scan          A            10.138.130.177
jytest-scan          A            10.138.130.178
jytest-scan          A            10.138.130.179


[root@jytest1 named]# vi jydba.net.reverse
$TTL 1D
@       IN SOA  @ root.jydba.net. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        A       10.138.130.171
        AAAA    ::1
        PTR     localhost.

171           PTR     jytest1
172           PTR     jytest2
175           PTR     jytest1-vip
176           PTR     jytest2-vip
177           PTR     jytest-scan
178           PTR     jytest-scan
179           PTR     jytest-scan

六.配置resolv.conf

[root@jytest1 named]# cat /etc/resolv.conf
# Generated by NetworkManager
search jydba.net


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
search jydba.net
nameserver       10.138.130.171

七.测试

[root@jytest1 named]# dig -x 10.138.130.172

; < <>> DiG 9.9.4-RedHat-9.9.4-18.el7 < <>> -x 10.138.130.172
;; global options: +cmd
;; Got answer:
;; ->>HEADER< <- opcode: QUERY, status: REFUSED, id: 20870
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;172.130.138.10.in-addr.arpa.   IN      PTR

;; Query time: 6 msec
;; SERVER: 10.138.130.171#53(10.138.130.171)
;; WHEN: Fri Mar 17 19:15:47 CST 2017
;; MSG SIZE  rcvd: 56




[root@jytest1 named]# service named restart
Redirecting to /bin/systemctl restart  named.service
[root@jytest1 named]# nslookup jytest1
Server:         10.138.130.171
Address:        10.138.130.171#53

** server can't find jytest1: SERVFAIL

上面出现错误,server can't find jytest1: SERVFAIL,错误信息是因为之前创建文件时使用的是root用户,将这些创建的文件修改为named用户与组。

[root@jytest1 named]# ls -lrt
total 32
-rw-r-----. 1 root  named  152 Jun 21  2007 named.localhost
-rw-r-----. 1 root  named  168 Dec 15  2009 named.loopback
-rw-r-----. 1 root  named  152 Dec 15  2009 named.empty
-rw-r-----. 1 root  named 2076 Jan 28  2013 named.ca
drwxrwx---. 2 root  named    6 Mar  6  2015 dyndb-ldap
drwxrwx---. 2 named named    6 Mar  6  2015 slaves
drwxr-x---. 7 root  named   56 Nov  5 11:03 chroot
-rw-r-----  1 root  named  728 Mar 17 18:45 named.jydba
-rw-r--r--  1 root  root   829 Mar 17 18:45 jydba.zone
drwxrwx---. 2 named named   22 Mar 17 18:45 data
-rw-r-----  1 root  root   503 Mar 17 19:13 jydba.net.forward
-rw-r-----  1 root  root   406 Mar 17 19:15 jydba.net.reverse
drwxrwx---. 2 named named   58 Mar 17 19:16 dynamic
[root@jytest1 named]# chown -R named:named jydba*
[root@jytest1 named]# ls -lrt
total 32
-rw-r-----. 1 root  named  152 Jun 21  2007 named.localhost
-rw-r-----. 1 root  named  168 Dec 15  2009 named.loopback
-rw-r-----. 1 root  named  152 Dec 15  2009 named.empty
-rw-r-----. 1 root  named 2076 Jan 28  2013 named.ca
drwxrwx---. 2 root  named    6 Mar  6  2015 dyndb-ldap
drwxrwx---. 2 named named    6 Mar  6  2015 slaves
drwxr-x---. 7 root  named   56 Nov  5 11:03 chroot
-rw-r-----  1 root  named  728 Mar 17 18:45 named.jydba
-rw-r--r--  1 named named  829 Mar 17 18:45 jydba.zone
drwxrwx---. 2 named named   22 Mar 17 18:45 data
-rw-r-----  1 named named  503 Mar 17 19:13 jydba.net.forward
-rw-r-----  1 named named  406 Mar 17 19:15 jydba.net.reverse
drwxrwx---. 2 named named   58 Mar 17 19:16 dynamic
[root@jytest1 named]# systemctl restart  named.service
[root@jytest1 named]# nslookup jytest1
Server:         10.138.130.171
Address:        10.138.130.171#53

Name:   jytest1.jydba.net
Address: 10.138.130.171

[root@jytest1 named]# nslookup jytest1.jydba.net
Server:         10.138.130.171
Address:        10.138.130.171#53

Name:   jytest1.jydba.net
Address: 10.138.130.171

[root@jytest1 named]# nslookup jytest2-priv.jydba.net
Server:         10.138.130.171
Address:        10.138.130.171#53

** server can't find jytest2-priv.jydba.net: NXDOMAIN

[root@jytest1 named]# nslookup jytest2-vip.jydba.net
Server:         10.138.130.171
Address:        10.138.130.171#53

Name:   jytest2-vip.jydba.net
Address: 10.138.130.176

[root@jytest1 named]# nslookup jytest-scan.jydba.net
Server:         10.138.130.171
Address:        10.138.130.171#53

Name:   jytest-scan.jydba.net
Address: 10.138.130.178
Name:   jytest-scan.jydba.net
Address: 10.138.130.179
Name:   jytest-scan.jydba.net
Address: 10.138.130.177

[root@jytest1 named]# nslookup 10.138.130.179
Server:         10.138.130.171
Address:        10.138.130.171#53

179.130.138.10.in-addr.arpa     name = jytest-scan.130.138.10.in-addr.arpa.

通过测试可以看到DNS通过正向与反向解析都是正常的,说明配置成功。

注意:
对于Linux 使用NetworkManager来控制网络的操作系统,当主机重启之前/etc/resolv.conf文件可能会被重写。如果发生这种情况,需要对相应的网卡配置文件增加以下记录
对于Oracle Linux 6修改类似文件 /etc/sysconfig/network-scripts/ifcfg-eth0 (ifcfg-eth1 etc.)
对于Oracle Linux 7修改类似文/etc/sysconfig/network-scripts/ifcfg-ens160 (ifcfg-ens34 etc.)
DNS1=10.138.130.171
DOMAIN=jydba.net

Oracle Linux 7.1 增加网卡及IP配置

由于需要给虚拟机(oracle linux 7.1)增加网卡并设置IP操作,在增加网卡后执行ifconfig命令可以看到增加的网卡信息,但没有生成网卡配置文件

[root@jytest1 ~]# ifconfig
ens34: flags=4163  mtu 1500
        ether 00:50:56:a0:7e:4c  txqueuelen 1000  (Ethernet)
        RX packets 14332  bytes 1177864 (1.1 MiB)
        RX errors 0  dropped 25  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens160: flags=4163  mtu 1500
        inet 10.138.130.171  netmask 255.255.255.0  broadcast 10.138.130.255
        inet6 fe80::250:56ff:feb1:260  prefixlen 64  scopeid 0x20
        ether 00:50:56:b1:02:60  txqueuelen 1000  (Ethernet)
        RX packets 14524  bytes 1203727 (1.1 MiB)
        RX errors 0  dropped 11  overruns 0  frame 0
        TX packets 349  bytes 31569 (30.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 1152  bytes 89096 (87.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1152  bytes 89096 (87.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:88:ce:47  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 1172 (1.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@jytest1 ~]# cd /etc/sysconfig/network-scripts
[root@jytest1 network-scripts]# ls -lrt
total 232
-rwxr-xr-x. 1 root root  1876 Nov  6  2014 ifup-TeamPort
-rwxr-xr-x. 1 root root  1755 Nov  6  2014 ifup-Team
-rwxr-xr-x. 1 root root  1556 Nov  6  2014 ifdown-TeamPort
-rwxr-xr-x. 1 root root  1599 Nov  6  2014 ifdown-Team
-rw-r--r--. 1 root root 26134 Jan 15  2015 network-functions-ipv6
-rw-r--r--. 1 root root 15316 Jan 15  2015 network-functions
-rwxr-xr-x. 1 root root  4623 Jan 15  2015 init.ipv6-global
-rwxr-xr-x. 1 root root  1740 Jan 15  2015 ifup-wireless
-rwxr-xr-x. 1 root root  2682 Jan 15  2015 ifup-tunnel
-rwxr-xr-x. 1 root root  3263 Jan 15  2015 ifup-sit
-rwxr-xr-x. 1 root root  1925 Jan 15  2015 ifup-routes
-rwxr-xr-x. 1 root root  4154 Jan 15  2015 ifup-ppp
-rwxr-xr-x. 1 root root  2609 Jan 15  2015 ifup-post
-rwxr-xr-x. 1 root root  1043 Jan 15  2015 ifup-plusb
-rwxr-xr-x. 1 root root   642 Jan 15  2015 ifup-plip
-rwxr-xr-x. 1 root root 10430 Jan 15  2015 ifup-ipv6
-rwxr-xr-x. 1 root root 12039 Jan 15  2015 ifup-ippp
-rwxr-xr-x. 1 root root 11502 Jan 15  2015 ifup-eth
-rwxr-xr-x. 1 root root   859 Jan 15  2015 ifup-bnep
-rwxr-xr-x. 1 root root 12616 Jan 15  2015 ifup-aliases
-rwxr-xr-x. 1 root root  1462 Jan 15  2015 ifdown-tunnel
-rwxr-xr-x. 1 root root  1444 Jan 15  2015 ifdown-sit
-rwxr-xr-x. 1 root root   837 Jan 15  2015 ifdown-routes
-rwxr-xr-x. 1 root root  1068 Jan 15  2015 ifdown-ppp
-rwxr-xr-x. 1 root root  1642 Jan 15  2015 ifdown-post
-rwxr-xr-x. 1 root root  4201 Jan 15  2015 ifdown-ipv6
-rwxr-xr-x. 1 root root   781 Jan 15  2015 ifdown-ippp
-rwxr-xr-x. 1 root root  5817 Jan 15  2015 ifdown-eth
-rwxr-xr-x. 1 root root   627 Jan 15  2015 ifdown-bnep
-rw-r--r--. 1 root root   254 Jan 15  2015 ifcfg-lo
-rwxr-xr-x. 1 root root 10145 Mar  6  2015 ifup-ib
-rwxr-xr-x. 1 root root  6196 Mar  6  2015 ifdown-ib
lrwxrwxrwx. 1 root root    24 Nov  5 10:11 ifdown -> ../../../usr/sbin/ifdown
lrwxrwxrwx. 1 root root    11 Nov  5 10:11 ifdown-isdn -> ifdown-ippp
lrwxrwxrwx. 1 root root    22 Nov  5 10:11 ifup -> ../../../usr/sbin/ifup
lrwxrwxrwx. 1 root root     9 Nov  5 10:11 ifup-isdn -> ifup-ippp
-rw-r--r--. 1 root root   358 Nov  5 12:01 ifcfg-ens160

可以看到并没有生成网卡配置文件ifcfg-ens34,而之前在创建虚拟机时增加的网卡ens160是有相应的配置文件ifcfg-ens160。在oracle linux 7.1中使用nmtui来设置网络,nmtui 属于curses-based text user interface(文本用户界面), 类似Linux7以前的setup工具

[root@jytest1 ~]# nmtui

使用nmtui设置完后可以看到生成了网卡ens34的配置文件ifcfg-ens34

 [root@jytest1 network-scripts]# ls -lrt
total 236
-rwxr-xr-x. 1 root root  1876 Nov  6  2014 ifup-TeamPort
-rwxr-xr-x. 1 root root  1755 Nov  6  2014 ifup-Team
-rwxr-xr-x. 1 root root  1556 Nov  6  2014 ifdown-TeamPort
-rwxr-xr-x. 1 root root  1599 Nov  6  2014 ifdown-Team
-rw-r--r--. 1 root root 26134 Jan 15  2015 network-functions-ipv6
-rw-r--r--. 1 root root 15316 Jan 15  2015 network-functions
-rwxr-xr-x. 1 root root  4623 Jan 15  2015 init.ipv6-global
-rwxr-xr-x. 1 root root  1740 Jan 15  2015 ifup-wireless
-rwxr-xr-x. 1 root root  2682 Jan 15  2015 ifup-tunnel
-rwxr-xr-x. 1 root root  3263 Jan 15  2015 ifup-sit
-rwxr-xr-x. 1 root root  1925 Jan 15  2015 ifup-routes
-rwxr-xr-x. 1 root root  4154 Jan 15  2015 ifup-ppp
-rwxr-xr-x. 1 root root  2609 Jan 15  2015 ifup-post
-rwxr-xr-x. 1 root root  1043 Jan 15  2015 ifup-plusb
-rwxr-xr-x. 1 root root   642 Jan 15  2015 ifup-plip
-rwxr-xr-x. 1 root root 10430 Jan 15  2015 ifup-ipv6
-rwxr-xr-x. 1 root root 12039 Jan 15  2015 ifup-ippp
-rwxr-xr-x. 1 root root 11502 Jan 15  2015 ifup-eth
-rwxr-xr-x. 1 root root   859 Jan 15  2015 ifup-bnep
-rwxr-xr-x. 1 root root 12616 Jan 15  2015 ifup-aliases
-rwxr-xr-x. 1 root root  1462 Jan 15  2015 ifdown-tunnel
-rwxr-xr-x. 1 root root  1444 Jan 15  2015 ifdown-sit
-rwxr-xr-x. 1 root root   837 Jan 15  2015 ifdown-routes
-rwxr-xr-x. 1 root root  1068 Jan 15  2015 ifdown-ppp
-rwxr-xr-x. 1 root root  1642 Jan 15  2015 ifdown-post
-rwxr-xr-x. 1 root root  4201 Jan 15  2015 ifdown-ipv6
-rwxr-xr-x. 1 root root   781 Jan 15  2015 ifdown-ippp
-rwxr-xr-x. 1 root root  5817 Jan 15  2015 ifdown-eth
-rwxr-xr-x. 1 root root   627 Jan 15  2015 ifdown-bnep
-rw-r--r--. 1 root root   254 Jan 15  2015 ifcfg-lo
-rwxr-xr-x. 1 root root 10145 Mar  6  2015 ifup-ib
-rwxr-xr-x. 1 root root  6196 Mar  6  2015 ifdown-ib
lrwxrwxrwx. 1 root root    24 Nov  5 10:11 ifdown -> ../../../usr/sbin/ifdown
lrwxrwxrwx. 1 root root    11 Nov  5 10:11 ifdown-isdn -> ifdown-ippp
lrwxrwxrwx. 1 root root    22 Nov  5 10:11 ifup -> ../../../usr/sbin/ifup
lrwxrwxrwx. 1 root root     9 Nov  5 10:11 ifup-isdn -> ifup-ippp
-rw-r--r--. 1 root root   346 Mar 16 12:36 ifcfg-ens160
-rw-r--r--. 1 root root   181 Mar 16 12:42 ifcfg-ens34

编辑配置文件

[root@jytest1 network-scripts]# vi ifcfg-ens34
TYPE=Ethernet
BOOTPROTO=none
IPADDR=88.88.88.1
NETMASK=255.255.255.0
PREFIX=32
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=ens34
UUID=f0e4fffc-668c-4b3d-b1cf-ab2b0122dd7d
DEVICE=ens34
ONBOOT=yes

重启网络

[root@jytest1 network-scripts]# systemctl restart network
[root@jytest1 network-scripts]# ifconfig
ens34: flags=4163  mtu 1500
        inet 88.88.88.1  netmask 255.255.255.255  broadcast 88.88.88.1
        inet6 fe80::250:56ff:fea0:7e4c  prefixlen 64  scopeid 0x20
        ether 00:50:56:a0:7e:4c  txqueuelen 1000  (Ethernet)
        RX packets 24804  bytes 2064784 (1.9 MiB)
        RX errors 0  dropped 25  overruns 0  frame 0
        TX packets 57  bytes 8254 (8.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens160: flags=4163  mtu 1500
        inet 10.138.130.171  netmask 255.255.255.0  broadcast 10.138.130.255
        inet6 fe80::250:56ff:feb1:260  prefixlen 64  scopeid 0x20
        ether 00:50:56:b1:02:60  txqueuelen 1000  (Ethernet)
        RX packets 25331  bytes 2120003 (2.0 MiB)
        RX errors 0  dropped 11  overruns 0  frame 0
        TX packets 767  bytes 84120 (82.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 1480  bytes 113808 (111.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1480  bytes 113808 (111.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:88:ce:47  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 1172 (1.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 [root@jytest1 network-scripts]# ping jytest1-priv
PING jytest1-priv (88.88.88.1) 56(84) bytes of data.
64 bytes from jytest1-priv (88.88.88.1): icmp_seq=1 ttl=64 time=0.419 ms
64 bytes from jytest1-priv (88.88.88.1): icmp_seq=2 ttl=64 time=0.227 ms
^C
--- jytest1-priv ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.227/0.323/0.419/0.096 ms

配置完成

How to Change hostname in Oracle Linux 7

在Oracle Linux7中通过修改/etc/sysconfig/network这种方式并不能修改Oracle Linux 7的主机名。为了对Oracle Linux 7修改主机名,可以通过执行以下任何一种方法来实现:
1.使用主机名控制工具(hostnamectl)
2.使用网络管理命令行工具(nmcli)
3.编辑/etc/hostname文件

1.使用主机名控制工具(hostnamectl),它是systemd-hostnamed服务的命令行工具
获取当前主机名:

[root@jytest ~]# hostnamectl status
   Static hostname: jytest
         Icon name: computer
           Chassis: n/a
        Machine ID: 66203d1dd6f54e5da356f986ac82f473
           Boot ID: e8ca08f1d73347358f085a6d0f5ed201
    Virtualization: vmware
  Operating System: Oracle Linux Server 7.1
       CPE OS Name: cpe:/o:oracle:linux:7:1
            Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64
      Architecture: x86_64

修改主机名:

[root@jytest ~]# hostnamectl set-hostname jytest3

重新登录获取当前主机名可以看到主机名已经变成了jytest3

[root@jytest3 ~]# hostnamectl status
   Static hostname: jytest3
         Icon name: computer
           Chassis: n/a
        Machine ID: 66203d1dd6f54e5da356f986ac82f473
           Boot ID: e8ca08f1d73347358f085a6d0f5ed201
    Virtualization: vmware
  Operating System: Oracle Linux Server 7.1
       CPE OS Name: cpe:/o:oracle:linux:7:1
            Kernel: Linux 3.8.13-55.1.6.el7uek.x86_64
      Architecture: x86_64

2.使用网络管理命令行工具(nmcli)
获取当前主机名

[root@jytest3 ~]# nmcli general hostname
jytest3

修改主机名并重新启动systemd-hostnamed服务

[root@jytest3 ~]# nmcli general hostname jytest2
[root@jytest3 ~]# systemctl restart systemd-hostnamed

重新登录并检查当前主机名

[root@jytest2 ~]# hostname
jytest2

3.编辑/etc/hostname文件
获取当前主机名

[root@jytest2 ~]# cat /etc/hostname
jytest2

修改主机名

[root@jytest2 ~]# echo "jytest1" > /etc/hostname
[root@jytest2 ~]# cat /etc/hostname
jytest1

重启系统并检查主机名

[root@jytest2 ~]# reboot
[root@jytest1 ~]# hostname
jytest1
[root@jytest1 ~]# cat /etc/hostname
jytest1

引用:How to Configure hostname in Oracle Linux 7 (Doc ID 2049221.1)

Proudly powered by WordPress | Indrajeet by Sus Hill.