2014年10月10日 星期五

CentOS 7 基本安裝及網路網卡設定

1.下載 centos 7 dvd iso 檔及安裝。

http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7.0-1406-x86_64-DVD.iso

使用 CentOS-7.0-1406-x86_64-DVD.iso 最小安裝,無圖型介面。

參考:
http://shaurong.blogspot.tw/2014/07/centos-linux-701406.html

重要變更

kernel 更新至 3.10.0
  支持 Linux 容器
  Open VMware Tools 及 3D 圖像能即裝即用
  OpenJDK-7 作為預設 JDK
  原地升級 6.5 至 7.0
  ext4 及 XFS 的 LVM 快照
**轉用 systemd、firewalld 及 GRUB2
**XFS 作為預設檔案系統
  內核空間內的 iSCSI 及 FCoE
  支持 PTPv2
  支援 40G 乙太網路卡

版本查詢:
# cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)

# uname -a
Linux centos7.jwin.com 3.10.0-229.7.2.el7.x86_64 #1 SMP Tue Jun 23 22:06:11 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

位元
# getconf LONG_BIT
64


已知問題

#預設的 NetworkManager 工具不會啟用乙太網路介面,安裝時必須以人手啟用。

使用指令:
#nmtui    文字圖形介面,網路設定。

#nmcli   命令模式,網路設定。
#nmcli  device status

http://dywang.csie.cyut.edu.tw/moodle23/dywang/rhel7/node19.html


#最小安裝,沒有ifconfig指令(待退集),需用ip addr 及 ip link 查詢
補充ifconfig 指令集:

# yum install  net-tools


2.更改網卡名稱及設定固IP

參考:http://blog.ilc.edu.tw/blog/blog/25793/post/78462/511822
參考:http://wiki.centos.org/zh-tw/FAQ/CentOS7

CentOS 7 的網路卡代號捨棄了原本熟悉的 ethx
# ls -l /etc/sysconfig/network-scripts/ifcfg-*

網路卡設定
# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736

修改 /etc/default/grub
在 GRUB_CMDLINE_LINUX 後加上 net.ifnames=0 biosdevname=0
# vim /etc/default/grub

產生新的 grub 設定檔
# grub2-mkconfig -o /boot/grub2/grub.cfg

直接把 ifcfg-enoxxx 改成 ifcfg-eth0
# mv /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eth0

修改網路卡代號
# sed -i 's/eno16777736/eth0/g' /etc/sysconfig/network-scripts/ifcfg-eth0

重新開機
# sync;sync;sync;sync;reboot

網路卡代號已更改
# ifconfig eth0


3. 啟用網卡,
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth0 (名稱因設備不同而異)
ONBOOT=yes


4.修改hostname

#cat /etc/hostname
#vi  /etc/hostname

5. 修改本機hosts

#vi /etc/hosts

6. dns 設定表
#cat  /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8.8.8

7.NetworkManager 指令用法:
#nmuti
文字圖型介面設定

#nmcli
命令指行
#nmcli device show


8.若是要停用 NetworkManager

# systemctl stop NetworkManager
# systemctl disable NetworkManager
# systemctl restart network


9. systemctl 指令對照表:

10.固定ip設定值參考:

NAME="eth0"
HWADDR="8C:89:A5:52:E9:1C"
TYPE="Ethernet"
ONBOOT="yes"
NM_CONTROLLED="no"
BOOTPROTO="static"
#
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
#
# the GATEWAY is sometimes in: /etc/sysconfig/network
#

Services

Sysvinit CommandSystemd CommandNotes
service frobozz startsystemctl start frobozz.serviceUsed to start a service (not reboot persistent)
service frobozz stopsystemctl stop frobozz.serviceUsed to stop a service (not reboot persistent)
service frobozz restartsystemctl restart frobozz.serviceUsed to stop and then start a service
service frobozz reloadsystemctl reload frobozz.serviceWhen supported, reloads the config file without interrupting pending operations.
service frobozz condrestartsystemctl condrestart frobozz.serviceRestarts if the service is already running.
service frobozz statussystemctl status frobozz.serviceTells whether a service is currently running.
ls /etc/rc.d/init.d/systemctl list-unit-files --type=service (preferred)
ls /lib/systemd/system/*.service /etc/systemd/system/*.service
Used to list the services that can be started or stopped
Used to list all the services and other units
chkconfig frobozz onsystemctl enable frobozz.serviceTurn the service on, for start at next boot, or other trigger.
chkconfig frobozz offsystemctl disable frobozz.serviceTurn the service off for the next reboot, or any other trigger.
chkconfig frobozzsystemctl is-enabled frobozz.serviceUsed to check whether a service is configured to start or not in the current environment.
chkconfig --listsystemctl list-unit-files --type=service(preferred)
ls /etc/systemd/system/*.wants/
Print a table of services that lists which runlevels each is configured on or off
chkconfig frobozz --listls /etc/systemd/system/*.wants/frobozz.serviceUsed to list what levels this service is configured on or off
chkconfig frobozz --addsystemctl daemon-reloadUsed when you create a new service file or modify any configuration
Note that all /sbin/service and /sbin/chkconfig lines listed above continue to work on systemd, and will be translated to native equivalents as necessary. The only exception is chkconfig --list.