新聞中心
在Linux系統(tǒng)中,使用機器名是非常重要的一件事情,在網(wǎng)絡環(huán)境中可以通過機器名來識別不同的主機,也可以方便地進行文件共享和遠程訪問等操作。但是,一些Linux系統(tǒng)在安裝時并沒有為用戶分配一個默認的機器名,造成一些不必要的困擾。因此,在使用Linux系統(tǒng)時,添加機器名是必須的一步。

華龍網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、APP開發(fā)、成都響應式網(wǎng)站建設公司等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)公司成立與2013年到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設就選創(chuàng)新互聯(lián)公司。
本文將介紹,包括以下幾個方面:
1. 查看當前機器名
2. 修改 /etc/hostname 文件
3. 更新 /etc/hosts 文件
4. 重啟 Linux 系統(tǒng)
1. 查看當前機器名
我們需要確定當前系統(tǒng)正在使用的機器名,可以通過打開終端并使用以下命令來查看:
“`
hostnamectl
“`
該命令將顯示當前正在使用的機器名。
2. 修改 /etc/hostname 文件
接下來,我們需要編輯 /etc/hostname 文件以添加新的機器名。該文件存儲了系統(tǒng)當前正在使用的機器名,通過以下命令打開該文件進行編輯:
“`
sudo nano /etc/hostname
“`
在該文件中,可以找到當前正在使用的機器名,并用新的機器名替換它。替換后,保存并關閉文件。
3. 更新 /etc/hosts 文件
確保你在 /etc/hosts 文件中將舊的機器名都更新為新的機器名。打開該文件以進行編輯:
“`
sudo nano /etc/hosts
“`
在該文件中,可以找到一些與機器名相關的行。確保將這些行上的舊機器名都替換為新機器名,并且保存并關閉文件。
4. 重啟 Linux 系統(tǒng)
要想新機器名生效,需要重新啟動 Linux 系統(tǒng)。使用以下命令重啟系統(tǒng):
“`
sudo reboot
“`
重啟后,你就可以看到新的機器名正在使用。
在Linux系統(tǒng)中,添加機器名是非常重要的一步,能夠方便地進行文件共享和遠程訪問等操作。在本文中,我們介紹了如何在Linux中添加新的機器名。具體來說,包括查看當前機器名、修改 /etc/hostname 文件、更新 /etc/hosts 文件和重啟系統(tǒng)等步驟。如果你正在使用Linux系統(tǒng)并需要添加新的機器名,可以根據(jù)上述步驟來進行操作。
相關問題拓展閱讀:
- 虛擬機Linux上部署DB2pureScale過程
- 修改linux的網(wǎng)絡配置方式有哪些?步驟?
虛擬機Linux上部署DB2pureScale過程
在Linux 操作系統(tǒng) 中,可在虛擬機上搭建DB2 pureScale,那么搭建的步驟是怎么樣的呢?DB2 pureScale又有什么用呢?下面隨我一起來了解下Linux系統(tǒng)如何在虛擬機上部署DB2 pureScale。
在虛擬機Linux上部署DB2pureScale實踐過程
、環(huán)境準備
硬件環(huán)境:3 臺 x86-64虛擬機,內(nèi)存要求 1.5G 或以上(主要針對虛擬機,內(nèi)存過低會造成數(shù)據(jù)庫實例啟動失敗)
操作系統(tǒng):Suse Linux Enterprise Server 11.3
DB2 版本:DB2 v10.5
機器名:node01 node02 node03
IP:192.168.18..168.18..168.18.203
網(wǎng)關:192.168.18.2
利用iscsi服務來做共享存儲功能,其中node01 作為 iscsi 的 Server,node01、node02和 node03 作為 iscsi Client,這樣三臺虛擬機上都能看到相同的磁盤了(按照developer workers上的 文章 :非 InfiniBand 環(huán)境下搭建 DB2 pureScale,我用DB2 v10.5時啟動實例失敗,可能10.5做了限制,CF與member在同一臺機器啟動失敗,幫多了一臺虛擬機)。
、操作系統(tǒng)安裝:
Node01預留出一塊分區(qū),不進行格式化(文件類型為0x83 Linux)做為 pureScale 集群的 Sharing Disk 使用,Node02與Node03跟node01 其帆戚它 相同就可,
安裝必要的包:
libstdc++(32 位和 64 位庫)
glibc(32 位和 64 位庫)
cpp
差轎手gcc
gcc-c++
kernel-source
binutils
ksh-93u-0.8.1
openssh
ntp
完成SUSE 11 SP3的安裝。
驗證:檢查/lib/modules/3.0.76-0.11-default/build/include/linux有無autoconf.h,如果沒有autoconf.h,安裝DB2時會報Compiling GPL :…….Failure錯誤。
解決 方法 :cp –v /usr/src/linux-3.0.76-0.11-obj/x86_64/default/include/generated /lib/modules/3.0.76-0.11-default/build/include/linux
、添加用戶和用戶組
三臺機器全部執(zhí)行如下命令(如果虛嫌不做特殊說明,以#表示root身份登錄,以$表示db2inst1身份,以下相同)。
#groupadd -g 1001 db2fadm1
#groupadd -g 1002 db2iadm1
#useradd -g db2fadm1 -um -d /home/db2fenc1 -p db2fenc1 db2fenc1
#useradd -g db2iadm1 -um -d /home/db2inst1 -p db2inst1 db2inst1
#mkdir /root/.ssh
# su – db2inst1 -c “mkdir -p /home/db2inst1/.ssh”
、配置ssh 信任連接
ssh信任通俗的說就是直接ssh不用輸入密碼
在/etc/hosts添加另外兩臺機器的IP地址及機器名(確保3臺機器名與ip地址全部出現(xiàn)在hosts文件中)
例如我的機器hosts如下:
.0.0.1 localhost
.168.18.201 node01.site node01
.168.18.202 node02.site node02
.168.18.203 node03.site node03
node01執(zhí)行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id01
#scp /root/.ssh/id01 node02:/root/.ssh
#scp /root/.ssh/id01 node03:/root/.ssh
#su – db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id01
$scp /home/db2inst1/.ssh/id01 node02:/home/db2inst1/.ssh
$scp /home/db2inst1/.ssh/id01 node03:/home/db2inst1/.ssh
node02執(zhí)行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id02
#scp /root/.ssh/id02 node01:/root/.ssh/
#scp /root/.ssh/id02 node03:/root/.ssh/
#su – db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id02
$scp /home/db2inst1/.ssh/id02 node01:/home/db2inst1/.ssh/
$scp /home/db2inst1/.ssh/id02 node03:/home/db2inst1/.ssh/
node03執(zhí)行如下命令:
#ssh-keygen -t rsa
#cp -v /root/.ssh/id_rsa.pub /root/.ssh/id03
#scp /root/.ssh/id03 node01:/root/.ssh
#scp /root/.ssh/id03 node02:/root/.ssh
#su – db2inst1
$ssh-keygen -t rsa
$cp -v /home/db2inst1/.ssh/id_rsa.pub /home/db2inst1/.ssh/id03
$scp /home/db2inst1/.ssh/id03 node01:/home/db2inst1/.ssh/
$scp /home/db2inst1/.ssh/id03 node02:/home/db2inst1/.ssh/
分別在node01、node02、node03執(zhí)行如下命令
#cd /root/.ssh
#cat id01 id02 id03 > authorized_keys
#chmod 600 authorized_keys
#su – db2inst1
$cd /home/db2inst1/.ssh
$ cat id01 id02 id03 > authorized_keys
測試是否配置成功
臺機器分別以root與db2inst1執(zhí)行:
#ssh node01 ls
#ssh node02 ls
#ssh node03 ls
#su – db2inst1
$ssh node01 ls
$ssh node02 ls
$ssh node03 ls
確保不用輸入密碼,則配置成功。
、ISCSI 共享存儲配置
Iscsi server端配置(node01上執(zhí)行):
修改/etc/ietd.conf,添加如下內(nèi)容:
Target iqn..node01.site:scsidisk01
Lun 0 Path=/dev/sda4,Type=fileio
注意:我的未分區(qū)硬盤為/dev/sda4,你的可能不一樣的@_@~~~~
添加自啟動
#chkconfig -a iscsitarget
檢查是否成功
#chkconfig -l iscsitarget
結果:iscsitarget 0:off 1:off 2:off 3:on 4:off 5:on 6:off
重啟iscsitarget服務
# /etc/init.d/iscsitarget restart
iscsi client端配置(node01、node02、node03執(zhí)行,):
iscsitarget文件內(nèi)容如下:
#! /bin/sh
### BEGIN INIT INFO
# Provides: iscsiclsetup
#node02與node03上如果未裝iscsitarget需將下下行的$iscsitarget
# Required-Start: $network $syslog $iscsitarget $remote_fs artd
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: ISCSI client setup
### END INIT INFO
case “$1” in start)
iscsiadm –mode discoverydb –type sendtargets –portal 192.168.18.201 –discover
iscsiadm –m node –targetname iqn..node01.site:scsidisk01 –portal 192.168.18.201:login
;;
stop)
iscsiadm -m node -T iqn..node01.site:scsidisk01 -p 192.168.18.201 –logout
;;
restart) ## Stop the service and regardless of whether it was ## running or not, start it again.
$0 stop
$0 start
;;
*)
Esac
保存后執(zhí)行:#/etc/init.d/iscsiclient restart
驗證iscsiclient是否啟動成功:
#fdisk -l
檢查有無/dev/sdb出現(xiàn)
、配置Linux環(huán)境變量
/etc/profie.local添加內(nèi)容
alias sl=’tail -f /var/log/messages’
alias fc=’fcslogrpt /var/log/messages’
export PATH=/root/bin:/usr/in/rsct/bin:/opt/ibm/db2/v10.5/bin:$PATH
export PATH=/usr/lpp/mmfs/bin:$PATH
export DB2USENONIB=TRUE
export DB2_CFS_GPFS_NO_REFRESH_DATA=true
然后執(zhí)行# . /etc/profile.local,完成后你就可以安裝purescale了,我猜測應該是設置了變量DB2USENONIB,使purescale不再要求你強制InfiniBand或萬兆網(wǎng)卡,使我等窮人可以有機會玩這種高檔、洋氣、上檔次的數(shù)據(jù)庫。。。
、DB2 V10.5 的安裝:
node01:~/server_t # ./db2_install
DBI1324W Support of the db2_install command is deprecated. For
more information, see the DB2 Information Center.
Default directory for installation of products – /opt/ibm/db2/V10.5
***********************************************************
Install into default directory (/opt/ibm/db2/V10.5) ?
yes
Specify one of the following keywords to install DB2 products.
SERVER
CONSV
EXP
CLIENT
RTCL
Enter “help” to redisplay product names.
Enter “quit” to exit.
***********************************************************
server
***********************************************************
Do you want to install the DB2 pureScale Feature?
Yes
曾經(jīng)出現(xiàn)的錯誤:
ERROR: An error occurred while compiling IBM General Parallel File System
(GPFS) Portability Layer (GPL) on host “node01”. Return code “2”. GPL
compilation log file location “/tmp/compileGPL.log.000”. The GPFS file system
cannot be mounted properly until the GPL module is successfully compiled on
this host. For details, see the specified GPL compilation log. After fixing
the problems shown in the log file, re-run the DB2 installer. For information
regarding the GPFS GPL module compile, see DB2 Information Center.
Compiling GPL :…….Failure
ERROR: A major error occurred while installing “DB2 Server Edition ” on this
computer.
解決方案:
查看錯誤日志:compileGPL.log.000,為以下內(nèi)容:
cd /usr/lpp/mmfs/src/config; ./configure –genenvonly; if ; then /usr/bin/cpp -P def.mk.proto > ./def.mk; exit $? || exit 1; else exit $?; fi
手工執(zhí)行時會發(fā)現(xiàn)在./configure –genenvonly; 這一步報找不到
/usr/bin/diff: /lib/modules/3.0.76-0.11-default/build/include/linux/autoconf.h: No such file or directory
Kernel source tree does not have the correct autoconf.h file.
See /usr/lpp/mmfs/src/README for further information
手工拷唄一下autoconf.h文件即可
#cp –v /usr/src/linux-3.0.76-0.11-obj/x86_64/default/include/generated/autoconf.h /lib/modules/3.0.76-0.11-default/build/include/linux/
GPFS 文件系統(tǒng)配置與掛載
方法1:使用db2cluster_prepare
node01上執(zhí)行:
#/opt/ibm/db2/v10.5/instance/db2cluster_prepare -instance_shared_dev /dev/sdb
DBI1446I The db2cluster_prepare command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 1
Total estimated time for all tasks to be performed: 60 second(s)
Task #1 start
Description: Creating IBM General Parallel File System (GPFS) Cluster and Filesystem
Estimated time 60 second(s)
Task #1 end
The execution completed successfully.
For more information see the DB2 installation log at
”/tmp/db2cluster_prepare.log”.
DBI1070I Program db2cluster_prepare completed successfully.
此時df -l查看一下會發(fā)現(xiàn)多了一個掛載點
node01:/opt/ibm/db2/V10.5/instance # df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda44% /
udev8568 1% /dev
tmpfs612 1% /dev/shm
/dev/sda% /home
/dev/db2fs% /db2sd_
曾經(jīng)出現(xiàn)報錯:
DBI20232E The DB2 installer detected that the variable record “GPFS_CLUSTER” is
defined in the global registry. However, the GPFS cluster does not exist on
host “node01”.
Creating IBM General Parallel File System (GPFS) Cluster and Filesystem :…….Failure
查看/tmp/ibm.db2.cluster.GuOypP發(fā)現(xiàn)有如下內(nèi)容報錯:
1-10.26.12.358494+480 I5385E400 LEVEL: Warning
PID : 7469 TID :12 PROC : db2cluster
INSTANCE: NODE : 000
HOSTNAME: node01
FUNCTION: DB2 UDB, oper system services, sqloMessage, probe:1
MESSAGE : Cannot obtain registry variables
DATA #1 : Hexdump, 4 bytes
x00007FFF: B400 0F87
解決方案:由于此前我在此機器上試過N次db2cluster_prepare,包括V9.8、V10.1,V10.5安裝,導致全局注冊表變量沒有刪除干凈,使用db2greg -dump
V,GPFS_CLUSTER,NAME,db2cluster_.site,-,DB2_CREATED將其刪除。
#cp -v /var/db2/global.reg /var/db2/global.reg_
#db2delgreg -delvarrec service= GPFS_CLUSTER
總結 :db2cluster_prepare這個命令失敗時
檢查iscsi client是否準備好,fdisk -l查看一下是否有/dev/sdb
全局注冊表變量是否未刪除干凈 ,db2greg -dump查看
檢查一下是否tsa的domain存在,lsrpdomain,使用rmrpdomain將其刪掉,如果其node為活動需先將其node停掉。具體參考tsa相關命令,
檢查一下gpfs cluster domain是否未清理干凈,如果未清理干凈,需要使用將fs、nsd、node清理掉,具體命令參考gpfs信息中心。
方法2:手工掛載GPFS
遇到過使用db2cluster_prepare時無法成功,手工安裝(不確定是否遇到了 傳說 中的bug)。
創(chuàng)建cluster,不加-filesystem -disk選項:
node01:
#db2cluster -cfs -create -domain mydomain -host node01
#db2cluster -cfs -add -host node02
# db2cluster -cfs -add -host node03
說明:上面如果不出故障當然可以加上-filesystem –disk參數(shù),當然也可以用mmaddnode –N XXX來添加節(jié)點
添加許可協(xié)議:
提供兩種方法
#mmchlicense server –accept -N node01,node02,node03
#/opt/ibm/db2/v10.5/bin/db2cluster -cfs -add -license
創(chuàng)建nsd:任意node執(zhí)行
編寫newNSD文件內(nèi)容如下
%nsd:
device=/dev/sdb
nsd=nsd1
usage=dataAndMetadata
#mmcrnsd -F /tmp/newNSD (-v no)
如果報mmcrnsd: Disk device sdb refers to an existing NSD,而使用mmlsnsd 又查找不到相應的nsd,添加-v no可以跳過此驗證。
#mmlsnsd 查看創(chuàng)建的nsd名稱,記下,在第3步時需要用到.
創(chuàng)建Cluster File System并掛載
啟動所有node,任意node執(zhí)行
#mmstartup -a
#mmgetstate -a
確保所有node全部啟動成功為active
# mmcrfs -T /db2sd_db2sd_nsd1(此處的nsd1為第2步的nsd名稱)
#mmmount all -a
曾經(jīng)出現(xiàn)的錯誤:mmstartup -a無響應
,查看日志/var/adm/ras/mmfs.log.previous
Tue Apr 1 22:02:11 CST 2023: runmmfs starting
Removing old /var/adm/ras/mmfs.log.* files:
Unloading modules from /lib/modules/3.0.76-0.11-default/extra
runmmfs: The /lib/modules/3.0.76-0.11-default/extra/mmfslinux.ko kernel extension does not exist.
runmmfs: Unable to verify kernel/module configuration.
Loading modules from /lib/modules/3.0.76-0.11-default/extra
runmmfs: The /lib/modules/3.0.76-0.11-default/extra/mmfslinux.ko kernel extension does not exist.
runmmfs: Unable to verify kernel/module configuration.
Tue Apr 1 22:02:11 CST 2023 runmmfs: error in loading or unloading the mmfs kernel extension
Tue Apr 1 22:02:11 CST 2023 runmmfs: stopping GPFS
解決方案:重新編譯一下gpfs的源碼,因為手工卸載gpfs。
/usr/lpp/mmfs/src/README有詳細的編譯方法:主要命令方法如下:
#cd /usr/lpp/mmfs/src
#make Autoconfig
#make InstallImages
make InstallImages會在/lib/modules/`uname -r`/extra目錄生成3個文件,大功告成.
創(chuàng)建實例
創(chuàng)建實例前:
node02#/opt/ibm/db2/V10.5/instance/db2icrt -cf node01 -cfnet node01
m node02 -mnet node02 -instance_shared_dir /db2sd_
tbdev 192.168.18.2 -u db2fenc1 db2inst1
tbdev 官方解釋為:Specifies a shared device path for a device that will act as a tiebreaker in the DB2 pureScale environment to ensure that the integrity of the data is maintained. 通俗的講就是在member出現(xiàn)故障時,判斷哪個member可以恢復服務,窮絲們就用網(wǎng)關IP來代替了,只要能 ping 通即可判斷為可用。
此時執(zhí)行:# db2instance -instance db2inst1 -list可以查看
node01:/opt/ibm/db2/V10.5/instance # mmlscluster
GPFS cluster information
========================
GPFS cluster name: db2cluster_.site
GPFS cluster id:235332
GPFS UID domain: db2cluster_.site
Remote shell command: /var/db2/db2ssh/db2locssh
Remote file copy command: /var/db2/db2ssh/db2scp
GPFS cluster configuration servers:
Primary server: node01.site
Secondary server: node02.site
Node Daemon node name IP address Admin node name Designation
——
node01.site 192.168.18.201 node01.site quorum-manager
node02.site 192.168.18.202 node02.site quorum-manager
曾經(jīng)出現(xiàn)報錯:
錯誤1、報、,此類錯誤為創(chuàng)建tsa domain時的錯誤,原因在于虛擬機是拷貝的,不是重新安裝的。
解決方法:#/usr/in/rsct/install/bin/recfgct
啟動實例
node01:$/home/db2inst1/sqllib/adm/db2start
怎么樣,報錯了吧,應該是SQL1721N
SQL1721N Starting the DB2 database manager failed because of a problem with a configuration file that is needed by RDMA.受打擊吧。
你裝完了實例啟動不了,沒關系,這么高檔的玩意怎么能讓你這么快啟動啊。
你得設置兩個注冊表變量才能用普通網(wǎng)絡.
$db2set DB2_SD_SOCKETS_RESTRICTIONS=false
$db2set DB2_CA_TRANSPORT_METHOD=SOCKETS
使用如下命令可以查看CF與member的狀態(tài)。
#db2instance -instance db2inst1 -list
node01:/home/db2inst1 # db2instance -instance db2inst1 -list
ID TYPE STATE HOME_HOST CURRENT_HOST ALERT PARTITION_NUMBER LOGICAL_PORT NETNAME
—
MEMBER STARTED node02 node02 NO 0 0 node02
CF PRIMARY node01 node01 NO – 0 node01
HOSTNAME STATE INSTANCE_STOPPED ALERT
–
node01 ACTIVE NO NO
node02 ACTIVE NO NO
此時你可以使用lssam查看tsa的兩個節(jié)點的狀態(tài)。
#lssam
添加成員
將node03添加為另一個member,如果實例沒有啟動會自動啟動實例,所以預先將上一步的兩臺機器上的db2set執(zhí)行完畢先。
node01:
#/opt/ibm/db2/v10.5/instance/db2iupdt -d -add -m node03 –mnet node03 db2inst1
#su – db2inst1 -c “db2start member 1”
開啟你的purescale之旅
#db2sampl
修改linux的網(wǎng)絡配置方式有哪些?步驟?
圖形界面就不說了 說下shell
—修改ip地址—
即時生效:
# ifconfig eth0 192.168.1.155 netmask 255.255.255.0
重啟生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0
—修改default gateway—
即時生效:
# route add default gw 192.168.1.1
重啟生效:
修改/etc/sysconfig/network-scripts/ifcfg-eth0
—修改dns—
修改/etc/基含resolv.conf
修改后即時生效,重啟同樣有效
—修改host name—
即時生效好鋒旦:
# hostname test1
重啟生效:
修改友擾/etc/sysconfig/network
在實際配置時,可以采用四種方法:
其一,基于控制面板法;
其二,基于X的linuxconf法;
三,基于Web瀏覽器的linuxconf法;
其四,手工使用命令法。
二、基于控制面板法
Linux的控制面板中的Network Configuration提供了易于掌握的集成化配置環(huán)境。首先檢查在安裝Red Hat Linux時是否安裝了控制面板。
# rpm –ga grep control
如果安裝了控制面板,則屏幕上顯示:contrl –panel-3.7-7
如果未安裝這個軟件包,則鍵入如下命令:
# rpm –i /mnt/cdrom/Red Hat /rpms /usercfg-3.5-6.i386.rpm
單擊控制面板窗口中的Network Configuration按鈕,出現(xiàn)網(wǎng)絡配置器窗口(如圖1所示)。
1)Names標簽
該標簽提供了四個方面的信息:
(1) Hostname(主機名)
包括機器名和機器所在的完整域名。格式為:localhost.local domain,例如,
www.jbxue.com
,其中www為本地機主名字,jbxue.com為本機所在域名。
(2) Domain(域名)
機器所在的完整域名,即為主機名中的“?!焙竺娌糠帧_@里輸入:linux.net
(3) Search for hostnames in additional domains(在其它域名中尋找主機名)
該項可不填。
(4) Nameservers(名字服務器)
即 DNS,這項列出了向網(wǎng)絡提供域名服務的計算機名單,每行一個。若要提供名字服務器清單,則應給出ISP服務商提供的域名服務器的IP地址。例如:163.1.1.4、10.55.0.33 。
2) Hosts標簽
該標簽提供計算機的主機表,主機表放在/etc/host文件中。單擊Hosts標簽,并單擊“Add”按鈕,彈出對話框(圖2)。
主機表文件包含機器名,IP地址及計算機替換名字。如果在小型網(wǎng)中,沒有域名服務器,則主機表應包含所在網(wǎng)絡中所有機器的名字和各自的IP地址。在連網(wǎng)的機器上緩槐至少有IP和name兩項。對該表的操作包括增加(Add),編輯(edit),刪除(remove)等操作。
首先編輯本地機項目,在IP欄輸入163.1.5.125,Name欄輸入
www.jbxue.com
,在nickname 欄中,可以
3)Interfaces標簽
這是一個網(wǎng)絡接口的配置標簽。在缺省情況,該表中提供一個lo項目(本地回環(huán)設備),該項目不要刪除,它是Linux網(wǎng)絡工作時必需具備的一個項目,對應的IP地址為127.0.0.1。
如果用戶現(xiàn)欲通過以太網(wǎng)卡接入Internet時,請選中表中eth0項目(注:之一個網(wǎng)卡設備名為 eth0, 第二個為eth1,依次類推)。單擊“Remove”按鈕,刪除掉,然后單擊“Add”按鈕,彈出接口類型對話框(圖3)。
請選中“Ethernet”單選項,單擊“OK”按鈕,出現(xiàn)edit Ethernet/Bus interface對話框。該對讓猛話框包含以下內(nèi)容:
(1) IP段 輸入網(wǎng)卡物理地址,即本機IP地址。如163.1.5.125。
(2) Netmask字段 輸入子網(wǎng)掩碼,如255.255.0.0。
(3) Network字段 自動給出163.1.5.0。
(4) Broadcast字段 自動給出
(5) Activate interface at boot time單選項 在每次啟動時,激活接口,以便使用網(wǎng)絡,建議選擇該項。
(6) Allow any user to (de)activate interface選項 允許任一用戶激活或關閉網(wǎng)絡接口。對于PPP之類的撥號接口中,每個用戶都要建立網(wǎng)絡連接,因此可以選擇該項。對于以太網(wǎng)連接的用戶,則不必選擇該項。
(7) Interface configuration protocol選項 接口配置協(xié)議。指定服務器向工作站提供網(wǎng)絡操作所需信息??勺尡緳C在每次激活接口時從服務器取得配置。它有none,BOOT和DHCP三個選項。一般選擇“none”。
4)Routing標簽
該標簽用于配置路由。告訴計算機如何把某些數(shù)據(jù)傳到網(wǎng)絡上的目標主機。如果網(wǎng)絡使用缺省網(wǎng)關,則只要指出缺省網(wǎng)關IP地址以及本機網(wǎng)卡etho。
對以上四個標簽操作完成后,單擊網(wǎng)絡配置器窗口中的“save”按鈕,存盤退出。
三、基于X的linuxconf法
首先由root用戶登錄Linux系統(tǒng),在Gnome環(huán)境中,單擊腳印按鈕,指向“system”,選擇“control-panel”子項,以便啟動控制面板,然后單擊System Configuration圖標。或者單擊腳印按鈕,指向“system”選項,選擇linuxconf選項),出現(xiàn)linuxconf在xterm中的工作界面(見圖4)。
⑴打開“Networking / Client tasks / Basic host Information”分支,選擇Host name標簽,輸入主機名字;選擇Adaptor 1標簽,選中“enable”選項,表示能夠使用之一個網(wǎng)卡;選擇配置方式為Manual;然后分別填寫:Primary name + domain(主機名。域名,如:lgx.linux.net)、IP address(主機的IP地址,如:163.1.5.125)、Net mask(子網(wǎng)掩碼,如:255.255.0.0)、Net device(網(wǎng)絡設備名eth0)、Kernel module(內(nèi)核模塊,如果是ne2023的網(wǎng)卡,那么應輸入ne)、 I/O port(I/O端口地址,如0x300)、Irq>(中斷號,如3)等選項。
⑵打開“Networking / Client tasks / Name Server Specification(DNS)”分支,彈出Resolve configuration對話框,選中“DNS is required for normal operation”;然后填寫:Default domain (缺省域名)和Nameserver1(之一個DNS服務器的IP地址,如:163.1.1.4;在下一行,還可填寫第二個DNS服務器的IP地址,如10.55.0.33)選項。
⑶打開“Config / Networking / Routing and gateways”選項,彈出的Defaults對話框,在Default gateway字段填寫缺省的網(wǎng)關IP值,如:163.1.1.254,并選中“enable routing”選項。
⑷接受以上寫入值,激活并退出。
注:在提示符“#”下,若執(zhí)行l(wèi)inuxconf,則在xterm終端下配置方法與之相類似。
四、基于Web的Linuxconf法
在Red Hat Linux 6.0中,linuxconf也可工作在Web瀏覽器環(huán)境,操作方法是:
⑴在gnome-linuxconf對話框中,打開“Config / Networking / Misc / Linuxconf network access”分支。
⑵在對話框中輸入任何允許使用Linuxconf的計算機的主機名,包括用戶主機名字。
⑶選擇“Accept”按鈕,并按空格鍵,單擊“Quit”按鈕。
⑷啟動Netscape瀏覽器,在URL欄鍵入:
其中,必選項hostname應換成用戶計算機的主機名。
⑸選擇瀏覽器頁面底部的“Start”按鈕,在彈出的口令驗證框中,分別輸入root和相應的口令,如果口令正確,
則進入如圖5所示的Linuxconf工作環(huán)境。
⑹點擊config框下的“Networking”選項,彈出Network Configurator頁面,在其中的Client tasks框內(nèi),點擊“Basic host information”、“Name server specification(DNS)”、“Routing and gateways”,分別輸入主機信息、名字服務器及路由和網(wǎng)關等信息。
⑺操作完成后,存盤退出。
五、手工使用命令法
手工使用命令法是基于以太網(wǎng)卡已裝入的情況下,編輯配置文件來配置網(wǎng)絡的方法。具體步驟如下:
⑴ 編輯/etc/rc.d/rc.local文件
在該文件中加入類似下列各行:
#配置之一個以太網(wǎng)卡eth0的IP地址,子網(wǎng)掩碼,UP起激活作用
/in/ifconfig,etho 163.1.5.125 netmask 255.255.0.0 UP
#配置并激活回環(huán)設備lo
/in/ifconfig lo 127.0.0.1 UP
/in/route add –host 127.0.0.1 lo
#讓Linux將本地網(wǎng)的信息發(fā)送到eth0接口
/in/route add –net 163.1.5.125 netmask 255.255.0.0 eth0
#指定訪問遠程網(wǎng)絡的缺省網(wǎng)關,假定缺省網(wǎng)關的IP地址為163.1.1.254
/in/route default gw 163.1.1.254 eth0
⑵ 編輯/etc/resdv.conf文件
該文件作用是設置名稱服務器??杉尤胂铝袃?nèi)容。
#指定本機域名為jbxue.com。
Domain jbxue. com
#域名稱服務器(DNS),可以是本地網(wǎng),也可以是遠程網(wǎng)上的。按nameserver的順序#逐一查找。若未找到,則Linux放棄尋找。
Nameserver 163.1.1.4
Nameserver 10.55.0.33
⑶ 編輯/etc/hosts.conf文件
設置主機文件表??杉尤肴缦滦校?/p>
order hosts,bind
multi on
163.1.5.125
www.jbxue.com
www
之一行表示:查找名稱時,首先檢查本地主機文件(hosts),然后按/etc/resolv.conf所指定的Nameservers順序查找。
第三行列出主機IP地址、主機名和別名。
對/etc/rc.d/rc.local,/etc/hosts.conf,/etc/resolv.conf三個文件編輯后,必須重新啟動機器。
五、結束語
綜上所述,只要采用其中的任意一種方法,定義主機名字、主機表、網(wǎng)絡接口設備及路由等參數(shù),配置好Linux以太網(wǎng),就能接入Internet,享受Internet提供的服務。
linux添加機器名的介紹就聊到這里吧,感謝你花時間閱讀本站內(nèi)容,更多關于linux添加機器名,如何在Linux中添加機器名,虛擬機Linux上部署DB2pureScale過程,修改linux的網(wǎng)絡配置方式有哪些?步驟?的信息別忘了在本站進行查找喔。
成都創(chuàng)新互聯(lián)科技有限公司,是一家專注于互聯(lián)網(wǎng)、IDC服務、應用軟件開發(fā)、網(wǎng)站建設推廣的公司,為客戶提供互聯(lián)網(wǎng)基礎服務!
創(chuàng)新互聯(lián)(www.cdcxhl.com)提供簡單好用,價格厚道的香港/美國云服務器和獨立服務器。創(chuàng)新互聯(lián)——四川成都IDC機房服務器托管/機柜租用。為您精選優(yōu)質(zhì)idc數(shù)據(jù)中心機房租用、服務器托管、機柜租賃、大帶寬租用,高電服務器托管,算力服務器租用,可選線路電信、移動、聯(lián)通機房等。
本文名稱:如何在Linux中添加機器名(linux添加機器名)
網(wǎng)站鏈接:http://www.dlmjj.cn/article/dhhoieg.html


咨詢
建站咨詢
