linux修改網(wǎng)卡名稱、主機(jī)名
環(huán)境:virtualbox 5.0.14 + rhel 6.5
需求:個(gè)人實(shí)驗(yàn)搭建一套standby rac時(shí),為了節(jié)約時(shí)間,直接復(fù)制之前安裝rac的主機(jī)模板。
但復(fù)制之后發(fā)現(xiàn)網(wǎng)卡名稱不一致:
我這里的環(huán)境,primary rac的public ip和private ip分別對(duì)應(yīng)的網(wǎng)卡名稱是eth2,eth3。
而復(fù)制standby rac的其中一臺(tái)網(wǎng)卡名稱是eth6,eth7;另一臺(tái)是eth4,eth5.為了保持一致方便后續(xù)管理維護(hù),需要將standby rac的兩臺(tái)機(jī)器的網(wǎng)卡都統(tǒng)一改為eth2,eth3.
同樣的,復(fù)制的主機(jī)主機(jī)名是和之前一樣的,所以把主機(jī)名也修改一下。
以其中一臺(tái)為例: 首先查看主機(jī)目前的網(wǎng)絡(luò)情況,如下圖:
確認(rèn)eth7的mac地址是:08:00:27:62:cc:7b
確認(rèn)eth6的mac地址是:08:00:27:bc:1b:9f
然后在virtualbox的設(shè)置中,
根據(jù)mac地址確認(rèn)eth6對(duì)應(yīng)的是內(nèi)部網(wǎng)絡(luò)(private ip);而eth7對(duì)應(yīng)的是公有網(wǎng)絡(luò)(public ip)。
所以我們正確的做法應(yīng)該是將eth6的名稱修改為eth3,將eth7的名稱修改為eth2.
注意:可能有些同學(xué)直接想當(dāng)然的不確認(rèn)mac地址直接修改錯(cuò)了,這里一定要確認(rèn)清楚,對(duì)于dba來(lái)說(shuō),任何做事情的細(xì)節(jié)都很重要。
1.首先修改/etc/udev/rules.d/70-persistent-net.rules文件:
將無(wú)關(guān)的網(wǎng)卡信息都刪除掉(如果怕誤操作也可不刪除,個(gè)人建議刪除,清楚且方便管理)
然后將eth6的名稱修改為eth3,將eth7的名稱修改為eth2。最終修改如下:
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@jyrac1 ~] # cat /etc/udev/rules.d/70-persistent-net.rules # this file was automatically generated by the /lib/udev/write_net_rules # program, run by the persistent-net-generator.rules rules file. # # you can modify it, as long as you keep each rule on a single # line, and change only the value of the name= key. # pci device 0x8086:0x100e (e1000) subsystem== "net" , action== "add" , drivers== "?*" , attr{address}== "08:00:27:bc:1b:9f" , attr{ type }== "1" , kernel== "eth*" , name= "eth3" # pci device 0x8086:0x100e (e1000) subsystem== "net" , action== "add" , drivers== "?*" , attr{address}== "08:00:27:62:cc:7b" , attr{ type }== "1" , kernel== "eth*" , name= "eth2" |
2.確認(rèn)網(wǎng)絡(luò)ifcfg-ethn配置文件,并修改信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@jyrac1 network-scripts] # cat ifcfg-eth2 device=eth2 type =ethernet onboot= yes bootproto=static ipaddr=192.168.1.61 netmask=255.255.255.0 [root@jyrac1 network-scripts] # cat ifcfg-eth3 device=eth3 type =ethernet onboot= yes bootproto=static ipaddr=10.10.10.61 netmask=255.255.255.0 |
3.reboot重啟主機(jī),網(wǎng)絡(luò)名稱成功修改并啟動(dòng)正常,如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
[root@jyrac1 ~] # ifconfig -a eth2 link encap:ethernet hwaddr 08:00:27:62:cc:7b inet addr:192.168.1.61 bcast:192.168.1.255 mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe62:cc7b /64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:377 errors:0 dropped:0 overruns:0 frame:0 tx packets:51 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:28101 (27.4 kib) tx bytes:6495 (6.3 kib) eth3 link encap:ethernet hwaddr 08:00:27: bc :1b:9f inet addr:10.10.10.61 bcast:10.10.10.255 mask:255.255.255.0 inet6 addr: fe80::a00:27ff:febc:1b9f /64 scope:link up broadcast running multicast mtu:1500 metric:1 rx packets:511 errors:0 dropped:0 overruns:0 frame:0 tx packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 rx bytes:46118 (45.0 kib) tx bytes:816 (816.0 b) lo link encap: local loopback inet addr:127.0.0.1 mask:255.0.0.0 inet6 addr: ::1 /128 scope:host up loopback running mtu:16436 metric:1 rx packets:4 errors:0 dropped:0 overruns:0 frame:0 tx packets:4 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 rx bytes:340 (340.0 b) tx bytes:340 (340.0 b) |
這樣,就可以通過(guò)securecrt連接到主機(jī)方便操作了。
下一步把主機(jī)名和/etc/hosts改一下:
主機(jī)名修改:
hostname jystdrac1 (臨時(shí)生效)
1
|
[root@jyrac1 network-scripts] # hostname jystdrac1 |
vi /etc/sysconfig/network (重啟生效)
1
2
3
|
[root@jyrac1 network-scripts] # vi /etc/sysconfig/network networking= yes hostname =jystdrac1 |
vi /etc/hosts (按照standby rac的規(guī)劃)
1
2
3
4
5
6
7
8
9
10
11
12
|
#public ip 192.168.1.61 jystdrac1 192.168.1.63 jystdrac2 #virtual ip 192.168.1.62 jystdrac1-vip 192.168.1.64 jystdrac2-vip #scan ip 192.168.1.65 jystdrac-scan #private ip 10.10.10.61 jystdrac1-priv 10.10.10.63 jystdrac2-priv |
重新登錄shell即可看到正確的主機(jī)名配置:
1
2
3
4
5
|
last login: wed aug 2 20:37:13 2017 from 192.168.1.88 [root@jystdrac1 ~] # [root@jystdrac1 ~] # hostname -i 192.168.1.61 [root@jystdrac1 ~] # |
至此,這個(gè)節(jié)點(diǎn)修改網(wǎng)卡名稱和主機(jī)名的工作就已經(jīng)全部完成,另一個(gè)節(jié)點(diǎn)同樣方法修改即可。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:http://www.cnblogs.com/jyzhao/p/7277834.html?utm_source=tuicool&utm_medium=referral