블로그

  • 하드디스크의 상태보기

    [root@ns2 ~]# smartctl -a /dev/sda
    smartctl version 5.33 [i386-redhat-linux-gnu] Copyright (C) 2002-4 Bruce Allen
    Home page is http://smartmontools.sourceforge.net/

    Device: SEAGATE  ST373207LC       Version: 0003
    Serial number: 3KT04Y9500007609MM1E
    Device type: disk
    Transport protocol: Parallel SCSI (SPI-4)
    Local Time is: Thu Jul 17 19:47:11 2008 KST
    Device supports SMART and is Enabled
    Temperature Warning Enabled
    SMART Health Status: OK

    Current Drive Temperature:     28 C
    Drive Trip Temperature:        68 C
    Vendor (Seagate) cache information
      Blocks sent to initiator = 3138754649
      Blocks received from initiator = 1182413804
      Blocks read from cache and sent to initiator = 40205361
      Number of read and write commands whose size <= segment size = 1931501148
      Number of read and write commands whose size > segment size = 344679

    Error counter log:
               Errors Corrected by           Total   Correction     Gigabytes    Total
                   EEC          rereads/    errors   algorithm      processed    uncorrected
               fast | delayed   rewrites  corrected  invocations   [10^9 bytes]  errors
    read:     497069        0         0    497069     497069        111.790           0
    write:         0        0         0         0          0        329.737           0

    Non-medium error count:        2

    Error Events logging not supported

    [GLTSD (Global Logging Target Save Disable) set. Enable Save with ‘-S on’]
    No self-tests have been logged
    Long (extended) Self Test duration: 1405 seconds [23.4 minutes]
    [root@ns2 ~]#


    HP cciss 디바이스 상태보는방법

    [root@ns2 ~]# smartctl -a -d cciss,0 /dev/cciss/c0d0

    [root@ns2 ~]# smartctl -a -d cciss,1 /dev/cciss/c0d1
    smartctl version 5.36 [i686-redhat-linux-gnu] Copyright (C) 2002-6 Bruce Allen
    Home page is http://smartmontools.sourceforge.net/

    Device: ATA      ST3750330NS      Version: SN04
    Serial number:             3QK04S5Z
    Device type: disk
    Local Time is: Fri Jul 18 21:17:32 2008 EDT
    Device supports SMART and is Enabled
    Temperature Warning Disabled or Not Supported
    Log Sense failed, IE page [scsi response fails sanity test]
    Read defect list: asked for grown list but didn’t get it

    Error Counter logging not supported
    Device does not support Self Test logging

    상태가 잘 표시되지 않지만, 하드모델명정도는 알아낼 수 있다.



    (주)웹호스트

  • linux CPU,메모리 제조사, 슬롯,뱅크등 자세한 정보 알아내는 방법

    프로그램 명 : dmidecode 2.8 (시스템(bios/dmi) 정보확인)
    운영체제     LINUX,FreeBSD
    라이센스     GPL
    홈페이지     http://www.nongnu.org/dmidecode/

    1. dmidecode 를 설치함.

    홈페이지에서 최신 tar.gz 다운로드

    tar xvzfp dmidecode-2.9.tar.gz
    cd dmidecode-2.9
    make
    make install

    1. 실행해본다.

    [root@storage0001 dmidecode-2.9]# whereis dmidecode
    dmidecode: /usr/sbin/dmidecode /usr/local/sbin/dmidecode
    [root@storage0001 dmidecode-2.9]# dmidecode

    매우 복잡한 시스템정보 출력됨

    문제점

    너무 복잡해서 뭐가 뭔지 모름

    그래서, dmidecode를 쉽게 보여주는 유틸을 하나 추가설치한다.

    1. lshw 설치

    http://ezix.org/project/wiki/HardwareLiSter

    화면중간쯤에

    The latest version is B.02.13 (MD5:e94c728ed037ca706436b5ef71aa392d, SHA1:e27412d47de8efb4adb3646e46affffb95dd384f).

    이 부분 클릭하고 다운로드함

    wget http://ezix.org/software/files/lshw-B.02.13.tar.gz

    tar xvzfp lshw-B.02.13.tar.gz
    cd lshw-B.02.13
    make

    완료됨

    cd src
    ./lshw |more
    (약 2초간 대기….)

         *-cpu:1
              description: CPU
              physical id: 8
              bus info: cpu@1
              version: 15.4.3
              serial: 0000-0F43-0000-0000-0000-0000
              slot: CPU 2
              size: 18EHz
              capabilities: ht
              configuration: id=0
            *-cache:0 DISABLED
                 description: L1 cache
                 physical id: 9
                 slot: L1-Cache
            *-cache:1 DISABLED
                 description: L2 cache
                 physical id: a
                 slot: L2-Cache
            *-logicalcpu:0
                 description: Logical CPU
                 physical id: 0.1
                 capabilities: logical
            *-logicalcpu:1
                 description: Logical CPU
                 physical id: 0.2
                 capabilities: logical
         *-memory
              description: System Memory
              physical id: 36
              slot: System board or motherboard
              size: 1GiB
            *-bank:0
                 description: DIMM DDR Synchronous [empty]
                 physical id: 0
                 slot: DIMM_2A
                 width: 64 bits
            *-bank:1
                 description: DIMM DDR Synchronous [empty]
                 physical id: 1
                 slot: DIMM_2B
                 width: 64 bits
            *-bank:2
                 description: DIMM DDR Synchronous 400 MHz (2.5 ns)
                 physical id: 2
                 slot: DIMM_1A
                 size: 512MiB
                 width: 64 bits
                 clock: 400MHz (2.5ns)

    .
    .
    .

    cpu와 메모리등 보드자체의 제조사, 정확한 뱅크정보가 나온다.

    lshw를 계속 사용하려면
    cp lshw /usr/local/sbin

    처럼 복사해서 사용한다.

    (주)웹호스트 2008년 7월31일 작성

  • 서버에 접근하는 ip들 보기

    netstat -ant | awk ‘{print $5}’ | cut -f 1 -d : | sort | uniq|wc -l

    서버에 접근하는 ip들 보기

  • 내 linux 가 32bit 인지 64bit 인지 확인방법

    #uname -a

    하시면 됩니다.

    Linux kkamagi2 2.6.18-8.1.15.el5 #1 SMP Mon Oct 22 08:32:04 EDT 2007 i686 i686 i386 GNU/Linux

    32bit시에 위와 같이 뜨고..

    64bit시에는.

    x86 64로 나올 꺼예요

  • rm 으로 안지워질때 find 명령으로 삭제방법

    $ find . -name “b*” -exec rm -rf {} \;

    현재 디렉토리(.) 하부에 b로 시작하는 파일은 모두 삭제하라

    $ find . -name “*” -exec rm -rf {} \;

    이렇게 하면 현재 폴더하부모든파일 및 폴더 삭제


    -atime : 파일을 열어본 시간 또는 디렉토리에  cd 명령으로 접근한 시간
    -mtime : 파일의 내용이 변경된 시간 ls -l 에서 나오는 시간
    -ctime : 파일의 정보가 변경된 시간 chmod chown과 연관성이 있음 

    우리가 보통 사용하는 단위는 ls로 보기때문에 mtime 이 맞다.



    find . -mtime +15 -exec rm -rf {} \;

    이건 어떻게 될까요?

    15일이 지난 현재폴더하부 파일 및 폴더 모두 삭제
    기준은 ls -al 했을때 시간을 기준으로 한다.



    rm 으로 지울경우, 파일이 많아서 잘 안지워지는데 이렇게 하면 모두 삭제됩니다.


    특히 /tmp 파일에 수천개가 존재하면

    cd /tmp

    $ find . -name “sess_*” -exec rm -rf {} \;


    이런식으로 지우게 되죠




    (주)웹호스트 https://www.webhost.co.kr
    작성일 : 2008년 10월6일

  • vi 에서 색깔 설정하기

    vi color

    vi로 파일을 열때 특정 option이 자동수행되게 하려면 ~/.vimrc에 option을 미리 지정하면 됩니다.

    예를들어, 라인번호가 항상 나오게 하려면 set number 라는걸 ~/.vimrc에 넣어놓으면 됩니다.

    색깔 지정하는걸 Syntax Highlighting이라 하는데 :syntax on 하여 색상이 나오지 않으면 vi가 다 설치되지 않은것입니다.

    root로 로긴 후

    # rpm -qa | grep vim-enhanced

    라 하여 아무것도 나오지 않으면 vim-enhanced를 설치해 주어야 합니다.

    현시스템에 인스톨 되어 있는 목록

    [root@roomie001 install]# rpm -qa |grep vim

    vim-enhanced-6.3.046-0.40E.7

    vim-common-6.3.046-0.40E.7

    vim-minimal-6.3.046-0.40E.7

    vim-X11-6.3.046-0.40E.7

    http://www.rpmfind.net <= 여기 가서 알맞는 버젼을 찾아보십시오.

    설치 완료후엔 재접속 하십시오.^^;

    컬러설정 확인

    ※ 컬러 설정을 했을때 컬러부분의 문장에 언더라인으로 표시되는것은 화면이 흑백으로 인식하고 있는경우 발생.

    1. 터미널 환경

       터미널 타입이 xterm이나 vt100 으로 설정되어 있을것.

       # echo $TERM 명령으로 화면의 설정상태확인후

       # setenv TERM xterm-color  또는
       # TERM=xterm-color; export TERM

       명령으로 터미널을 컬러로 설정해 준다.

    2. profile환경

       vi명령으로 기동시 vim명령이 실행되도록 alias  추가.

       alias vi=vim

    3. .vimrc 환경파일 확인

       syntax on   <- 문장이 있는지 확인.

    [출처] vi에서 색깔 설정하기(vim)|작성자 honda20000

  • bind-9.3.6 설치와 설정하기 named 구축

    bind-9.3.6-4.P1.el5_4.2 설치

    yum -y install bind\* 하시면 bind에 대한건 다 설치합니다.

      또는

    # yum -y install bind bind-libs ypbind yp-tools bind-utils bind-chroot bind-devel

    하세요.

    yum -y install caching-nameserver 설치하면 설정 파일이 생성됩니다.

    2개 명령으로 설치 완료 입니다^^

    외부 포트허용

    # iptables -A INPUT -p tcp -m tcp –sport 53 -j ACCEPT

    # iptables -A INPUT -p tcp -m udp –sport 53 -j ACCEPT

    vi /etc/named.caching-nameserver.conf 화일을 열어서 몇가지 수정해주면 됩니다.

    options {
            listen-on port 53 { 127.0.0.1; };  >> listen-on port 53 { 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”;

            // Those options should be used carefully because they disable port
            // randomization
            // query-source    port 53; << 주석 없애기 query-source    port 53;
            // query-source-v6 port 53; << 주석 없애기 query-source-v6 port 53;
            allow-query     { localhost; }; >> allow-query     { any; };
            allow-query-cache { localhost; };
    };

    // 로그파일 쌓이는것이 필요없으신분은 logging 부분 전부를 주석처리하면됩니다.
    logging {  
            channel default_debug {
                    file “data/named.run”;
                    severity dynamic;
            };
    };
    view localhost_resolver {
            match-clients      { localhost; }; >> match-clients      { any; };
            match-destinations { localhost; }; >> match-destinations { any; };
            recursion yes; >> recursion no;
            include “/etc/named.rfc1912.zones”;
    };

    저장하고 vi /etc/named.rfc1912.zones 열어서 설정합니다.

    설정되어 있는 값들은 건들지 마시고 맨 아래줄에 추가합니다.

    여기서 자신의 IP를 반대로 적으면됩니다.

    112.175.232.xxx 였다면 아래와 같이 적으면됩니다. file명을 알아서.rev로 만드세요.

    zone “232.175.112.in-addr.arpa” IN { type master; file “xxkr.com.rev”; allow-update { none; }; };

    호스트네임으로 사용하는 도메인을 잴 먼저 적습니다.

    in이 들어가 있는것이 다름니다.

    zone “xxkr.com” IN { type master; file “196.zone”; allow-update { none; }; };

    다음줄부터는 사용할 도메인을 쭉~ 적어 넣으면됩니다.

    ah.to도메인을 설정할때 아래와 같이 합니다.

    zone “ah.to”{ type master; file “xx2.zone”; allow-update { none; }; };

    이제 cd /var/named/chroot/var/named 로 이동해서 위에적었던 파일을 생성해 주면 끝나요.

    vi xxkr.com.rev 안에 내용에 아래와 같이 적으면됩니다.

    앞에 숫자는 위에서 IP 꺼꾸로 적고 맨마지막건 안적었는데 여기에 넣으면됩니다.

    165             IN      PTR     xx.xxkr.com. 이렇게요.

    == 카피할 부분 ==

    $TTL    86400
    @               IN      SOA     xx2.xxkr.com.       root.xxkr.com. (
                            31 ; serial
                            3H     ; refresh
                            15M       ; retry
                            1W    ; expire
                            1D      ; Minimun
                            )
                    IN      NS      xx.xxkr.com
                    IN      NS      xx2.xxkr.com.
                    IN      NS      ns.ssanhost.com.
                    IN      NS      ns1.ssanhost.com.

    localhost       IN      A       127.0.0.1
    165             IN      PTR     xx.xxkr.com.
    167             IN      PTR     xx2.xxkr.com.
    165             IN      PTR     ns.ssanhost.com.
    167             IN      PTR     ns1.ssanhost.com.

    저장하고 나와서 위에 file 에 적인 vi xx2.zone 해서 아래와 같이 만듭니다.

    $TTL    14400
    @               IN      SOA     xx2.xxkr.com.        root.xxkr.com. (
                            23 ; serial
                            3H     ; refresh
                            15M       ; retry
                            1W    ; expire
                            1D      ; Minimun
                            )
                    IN      NS      xx.xxkr.com.
                    IN      NS      xx2.xxkr.com.
                    IN      MX  10  mail
    ;
    @               IN      A       114.108.132.211
    xx              IN      A       112.175.232.165
    xx2             IN      A       114.108.132.211
    www             IN      A       114.108.132.211
    *               IN      A       114.108.132.211

    저장하고

    chown root:named *  꼭해주세요.

    /etc/init.d/named restart 엔터하면 설치가 끝났습니다.

    dig 로 작동여부 확인

    # dig 도메인

    버전확인

    # dig @ns.rain.iss txt version.bind

  • 2차네임서버 구축실무

    1. /etc/named.conf

    options {
            directory “/var/named”;
    };


    controls {
             inet 127.0.0.1 port 953  allow { localhost; } keys { rndckey; };
    };

    zone “.” {
            type hint;
            file “named.ca”;
    };

    zone “0.0.127.in-addr-arpa” {
            type master;
            file “named.local”;
    };
    zone “webhost.co.kr” {
            type slave;
            file “webhost.zone”;
            masters {
                    110.45.100.2; //마스터 ip address
            };
    };

    include “/etc/rndc.key”;


    2. named.local 과 named.ca 준비

    /var/named
    named.local
    named.ca


    3. 1차네임서버에서 2차서버 ip 허용

    vi named.conf

    controls {
             inet 127.0.0.1 port 953  allow { localhost; 110.45.100.3; } keys { rndckey; };
            };

    110.45.100.3 은 2차네임서버이다.



    4. 2차네임서버 구동후 존파일생성 확인

  • bind9 네임서버 소스로 설치하기

    bind 소스받기


    https://www.isc.org/

    상단첫번째 DOWNLOADS > BIND 에서 최신버전 tar.gz 다운로드



    1. 파일 다운로드 받고 컴파일 하기  

    # gzip  -dc   bind-9.3.0.tar.gz  |  tar  xvf   –
    # cd  bind-9.3.0
    # ./configure  
    # make
    # make install



    2. /etc/rndc.key 생성하기

    solaris10[/bind/bin/rndc] # ./rndc-confgen -a -k rndckey
    solaris10[/bind/bin/rndc] #  cat /etc/rndc.key
    # Start of rndc.conf
    key “rndckey” {
             algorithm hmac-md5;
             secret “Y9iC3cahZ7I3+3NrtlG6nQ==”;
    };
    생성 끝.



    3. /etc/named.conf 구성하기
    ======================================================


    vi /etc/named.conf


    // generated by named-bootconf.pl

    options {
            directory “/var/named”;
            /*
             * If there is a firewall between you and nameservers you want
             * to talk to, you might need to uncomment the query-source
             * directive below.  Previous versions of BIND always asked
             * questions using port 53, but BIND 8.1 uses an unprivileged
             * port by default.
             */
            //query-source address * port 53;
    };


            controls {
             inet 127.0.0.1 port 953  allow { localhost; } keys { rndckey; };
            };

           
    zone “.” {
            type hint;
            file “named.ca”;
    };


    zone “domain.co.kr” {
            type master;
            file “primary/domain.zone”;
            allow-update { none; };
    };

    (중략) 같은 도메인들 리스트추가


    include “/etc/rndc.key”;






    4. bind 구동
    /usr/local/sbin/named

    에러가날경우

    cd /usr/local/sbin
    ./named-checkconf 로 확인할것






    5.rndc 구동하기

    /bind/bin/rndc/#rndc reload  

    를 수행하여 rndc를 구동할 수 있다. 이 때 named는 반드시 구동되어 있어야 한다.




    6. 장애 처리 하기

    #tail -f /var/adm/messages



    이상 소스로 bind설치끝

  • rocky linux ssh 언어설정

    rocky linux8 ssh 에서 한국어 언어설정입니다.

    # vim /etc/locale.conf

    LANG=”ko_KR.UTF8″

    저장후

    # source /etc/locale.conf

    또는 서버 reboot

    설정확인하기

    # localectl status

    System locale: LANG=ko_KR.UTF8

    VC keymap: us

    X11 Layout: us

    #

    작성일자 : 2025.03.20