公告版位

目前分類:Linux (140)

瀏覽方式: 標題列表 簡短摘要

由於工作需求,主管要我另起一台DNS server,但這台新的DNS server要把舊的DNS server資料全部copy過來,於是我參考了一些文章,自己來記錄一下過程!

step1: 在新的CentOS 5.5 安裝所需之packages
        # yum install bind-utils bind-chroot bind bind-libs 

step2: 先停止舊的DNS service
        # service named stop 

step3: 將舊的DNS server的/var/named/chroot下的var與etc目錄皆複製到新的CentOS的/var/named/chroot也就是要有以下這兩個目錄! 因為DNS主要的設定檔皆在裡面!
        - /var/named/chroot/var
        - /var/named/chroot/etc

step4: 啟動新的CentOS裡的DNS service,指令如下!
        # service named start 

 

參考資料來源:
1. http://blog.faq-book.com/?p=2969
2. http://linux.vbird.org/linux_basic/0580backup/0580backup-fc4.php
3. http://ithelp.ithome.com.tw/question/10072913 

dreamtails 發表在 痞客邦 留言(0) 人氣()

OpenIPMI command

Packages are OpenIPMI, OpenIPMI-tools, OpenIPMI-libs.

$ ipmitool -U username -P password -H 192.168.1.5 chassis power on
$ ipmitool -U username -P password -H 192.168.1.5 chassis power off
$ ipmitool -U username -P password -H 192.168.1.5 chassis power cycle
$ ipmitool -U username -P password -H 192.168.1.5 chassis power soft
$ ipmitool -U username -P password -H 192.168.1.5 chassis power status

$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev pxe
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev bios
$ ipmitool -U username -P password -H 192.168.1.5 chassis bootdev disk

$ ipmitool -U username -P password -H 192.168.1.5 bmc info
$ ipmitool -U username -P password -H 192.168.1.5 lan print
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 ipsrc static
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 ipaddr 192.168.1.5
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 netmask 255.255.255.0
$ ipmitool -U username -P password -H 192.168.1.5 lan set 1 defgw ipaddr 192.168.1.254
$ ipmitool -U username -P password -H 192.168.1.5 mc info
$ ipmitool -U username -P password -H 192.168.1.5 mc reset cold

$ ipmitool -U username -P password -H 192.168.1.5 sdr
$ ipmitool -U username -P password -H 192.168.1.5 sel list

dreamtails 發表在 痞客邦 留言(0) 人氣()

smartctl看有關HDD資訊

看smart的log:
$ less /var/log/messages

看HDD是否支援S.M.A.R.T:
$ smartctl -i /dev/sda

若HDD有支援S.M.A.R.T,則啟動S.M.A.R.T功能:
$ smartctl -s on -d ata /dev/sda

看HDD支援哪些self-test routine,通常有short, conveyance與long三種self-test:
$ smartctl -c /dev/sda

使用long self-test routine取得較正確的結果(P.S. 一次只能執行一個測試):
$ smartctl -t long /dev/sda

smartctl不會顯示測試進度,但會回報這個測試要執行多久。等時間差不多後就確認測試進度:
$ smartctl -l selftest /dev/sda

看測試結果:
$ smartctl -a /dev/sda

看測試結果中,健康狀況的部份:
$ smartctl -H /dev/sda

看測試結果中,error log的部份:
$ smartctl -l error /dev/sda



請注意以下這一段:
===============================================
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
............
............
SMART Error Log Version: 1
No Errors Logged
===============================================

***若ID# 5、7、10、11、196~200這幾個項目的RAW_VALUE不為0,且持續增加,應立即備分並更換硬碟。

以上來源出自:http://sites.google.com/site/lab586/linuxnote/hddchecktip

dreamtails 發表在 痞客邦 留言(0) 人氣()

badblocks 指令檢測損壞磁區 (P.S. 讀寫次數龐大,常用會損害硬碟壽命)

語法:
badblocks [ -svwnf ] [ -b block-size ] [ -c blocks_at_once ] [ -e max_bad_blocks ] [ -d read_delay_factor ]
[-i input_file ] [ -o output_file ] [ -p num_passes ] [ -t test_pattern ] device [ last-block ] [ first-block ]

常用選項:
(default): non-destructive read-only mode 無損唯讀模式,較快。
-n: non-destructive read-write mode 無損讀寫模式,速度最慢。掛載中硬碟需加 -f 強制執行 (會有硬碟/檔案系統毀損的風險)
-w: destructive write test 毀滅性寫入測試。會將檔案全部抹銷!掛載中硬碟需加 -f 強制執行
-f: 強制執行,與 -n 或 -w 配合使用
-v: 執行中回報進度
-s: 將檢測出的壞磁區顯示在螢幕上
-i input_file: 略過不檢測 input_file 裡的已知 badblocks,這些已知 badblocks 同樣不會顯示在檢測結果中。
-o output_file: 將檢測出的 badblocks 寫在 output_file 上。

通常為求速度與資料安全,會使用預設的無損唯讀模式進行掃描。例如:
$ badblocks -v /dev/sda -o badblocks.txt

以上command為對 /dev/sda 進行無損唯讀模式掃描,-v 選項令 badblocks 在執行中回報進度,並以 -o 選項將檢測出的損壞磁區寫在 badblocks.txt 檔案裡。

dreamtails 發表在 痞客邦 留言(0) 人氣()

查詢Linux的版本與硬體資訊指令如下:

一.查詢Linux版本資訊
[root@mis~]# lsb_release -a
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5 (Final)
Release: 5
Codename: Final

二.查詢主機硬體資訊
[root@mis~]# dmidecode --type
Type number or keyword expected
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot

dmidecode下載與詳細說明網址:http://www.nongnu.org/dmidecode/

以上來源出自:http://jojochen.blog.ithome.com.tw/summary.php?op=UserProfile&userId=2530

dreamtails 發表在 痞客邦 留言(0) 人氣()

如何查詢Linux主機CPU, RAM與HDD硬體規格指令:


有兩種方式:

方式一:在/proc之下執行
$ cat cpuinfo
$ cat meminfo


方式二:執行指令
$ dmidecode -t processor
$ dmidecode -t memory

以上來源出自:http://jojochen.blog.ithome.com.tw/post/2529/63418


方式三:
$ grep -A 3 "model name" /proc/cpuinfo |egrep -v '(stepping|cache|--)'|awk -F: '{print $2}'
$ dmesg | grep "Memory:"
$ fdisk -l 2> /dev/null|grep '^Disk'
$ cat /proc/scsi/scsi

dreamtails 發表在 痞客邦 留言(0) 人氣()

Linux command for HDD:

[dd] 將硬碟直接備份到另外一顆硬碟
$ dd if=/dev/hda of=/dev/sda conv=noerror,sync bs=4k

[kill][killall] 查看DD的執行進度
$ kill -SIGUSR1 9218
# 9218 is PID
$ killall -SIGUSR dd編輯

dreamtails 發表在 痞客邦 留言(0) 人氣()

sed 指令:

$ cat string.txt|sed -n 20p
顯示第20列文字編輯

dreamtails 發表在 痞客邦 留言(0) 人氣()

awk 指令:

$ awk -F ":" '{print $1}' string.txt
文字切割,只要有":"的都切開

$ awk '{print $1}' string.txt
文字切割,只要有空白字元的都切開編輯

dreamtails 發表在 痞客邦 留言(0) 人氣()

grep 指令:

$ grep -A 3 "model name" /proc/cpuinfo
抓出model name的這一列,並顯示它下面的其他三列

dreamtails 發表在 痞客邦 留言(0) 人氣()

硬體資訊取得指令(內容較多):dmidecode

[root@mis~]# dmidecode --type
[root@mis~]# dmidecode --type bios
[root@mis~]# dmidecode -t bios
[root@mis~]# dmidecode -t 0
[root@mis~]# dmidecode -t 1

Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot

Type Information:
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
40 Additional Information
41 Onboard Device

以上來源出自:http://www.ha97.com/4120.html

dreamtails 發表在 痞客邦 留言(0) 人氣()

在CentOS開機進GRUB的畫面後,選擇完要進入的kernel,之後就按"i",就會進入Interactive mode。以往開機時,service會自動啟動並show上"ok"的字樣,而在Interactive mode下,每個service在準備要啟動時,系統會先問你是否要啟動,若要啟動請按"y",若不啟動請按"n"。

dreamtails 發表在 痞客邦 留言(0) 人氣()

ethtool

如同: ethtool eth0 或 ethtool eth1

 

Link detected欄位顯示為yes,則表示有接上網路線

如同: Link detected: no

dreamtails 發表在 痞客邦 留言(0) 人氣()

在輸出檔案後加上2>&1

如同: tar zxvf testfile.tar.gz >> output.log 2>&1

dreamtails 發表在 痞客邦 留言(0) 人氣()

1. # ping 10.1.1.6

      (先ping想要得知MAC的IP address)

 

2. # arp

      (再查看IP address的MAC address屬於哪一個)

dreamtails 發表在 痞客邦 留言(0) 人氣()

# dd if=/dev/zero of=/tmpfile bs=2M count=2000

      (產生一個大檔案)

      if: input file

      of: output file

      bs: 一個block的大小

      count: 共有幾個block

 

 

# dd if=/dev/hda of=/dev/hdb 

      (將第一顆硬碟備份至第二顆硬碟的指令)

dreamtails 發表在 痞客邦 留言(0) 人氣()

1. # fdisk /dev/sda

    (磁區分割)

 

2. # mkfs.xfs /dev/sda1

    (格式化為xfs) 

    但mkfs.xfs需要自行安裝格式化工具,mkfs.ext3則否。

 

3. # mount /dev/sda1 /mnt

    (把sda1掛載到mnt目錄下)

 

4. # mount

    (看掛載是否成功為xfs)

dreamtails 發表在 痞客邦 留言(0) 人氣()

設定IP與Netmask:

# ifconfig eth0 10.1.1.2 netmask 255.255.0.0

     (eth0為interface的名稱)

 

設定Gateway:

#route add default gw 10.1.0.254

dreamtails 發表在 痞客邦 留言(1) 人氣()

cp /dev/zero /dev/mem

dreamtails 發表在 痞客邦 留言(0) 人氣()

好久沒有碰Linux了,現在是因為想要在Linux下寫C語言,所以才會又動到Linux

我選擇了這幾年大為流行的Linux,也就是Ubuntu

而剛裝好之後有很多套件尚未更新,因此我們可以使用Ubuntu內建的apt-get指令來完成更新

dreamtails 發表在 痞客邦 留言(1) 人氣()