레지스트리 편집기 (regedit) 에서


HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\
에서 자신의 사용기록을 IP를 찾아 지우신 후


HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Servers

에서도 싹 지워버리시면 됩니다


System을 운영 하다보면 Hard disk의 장애로 인하여 곤란한 상황에 처할때가 간혹 있다.

어느날 갑자기 Log를 write 하는 성능이 급격하게 저하 된다거나, 멀쩡한 파일을 read하는데 실패한다거나 하는 증상을

 

만나게 되면 Hard disk의 상태를 점검해볼 필요가 있다.

Linux system에서 Hard disk를 점검하기 위해서 사용되는 Tool로는 smartctl 이라는 것이 제공된다.
 

사용법  


  

굳이 여기에 기술할 필요는 없을듯.. ㅎㅎ

"--help" 옵션이나, "man" 을 이용해서 사용법 및 옵션 확인

 

결과 확인 방법



"/dev/sda" 를 "smartctl --all /dev/sda" 명령을 이용해서 분석한 결과는 다음과 같다.
 

[kabang@Home:~]$ su -
Password:
[root@Home ~]# smartctl --all /dev/sda
smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Caviar Second Generation Serial ATA family
Device Model:     WDC WD5000AAKS-00A7B2
Serial Number:    WD-WCASY7521049
Firmware Version: 01.03B01
User Capacity:    500,107,862,016 bytes
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Wed Jun  1 19:55:45 2011 KST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x84) Offline data collection activity
                                        was suspended by an interrupting command from host.
                                        Auto Offline Data Collection: Enabled.
Self-test execution status:      (   0) The previous self-test routine completed
                                        without error or no self-test has ever
                                        been run.
Total time to complete Offline
data collection:                 (11160) seconds.
Offline data collection
capabilities:                    (0x7b) SMART execute Offline immediate.
                                        Auto Offline data collection on/off support.
                                        Suspend Offline collection upon new
                                        command.
                                        Offline surface scan supported.
                                        Self-test supported.
                                        Conveyance Self-test supported.
                                        Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                                        General Purpose Logging supported.
Short self-test routine
recommended polling time:        (   2) minutes.
Extended self-test routine
recommended polling time:        ( 131) minutes.
Conveyance self-test routine
recommended polling time:        (   5) minutes.
SCT capabilities:              (0x303f) SCT Status supported.
                                        SCT Feature Control supported.
                                        SCT Data Table supported.

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

  1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
  3 Spin_Up_Time            0x0027   163   162   021    Pre-fail  Always       -       4825
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       259
  5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
  7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
  9 Power_On_Hours          0x0032   085   085   000    Old_age   Always       -       11533
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       254
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       237
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       259
194 Temperature_Celsius     0x0022   109   086   000    Old_age   Always       -       38
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   200   200   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   200   200   000    Old_age   Offline      -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]


SMART Selective self-test log data structure revision number 1
  SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

[root@Home ~]#



위와 같이 장문의 결과가 나온다.

이중에서 붉은색 박스로 표시한 부분을 확인하면 되며 각 항목에 대해서 설명을 하자면 아래 표와 같다.

빨간색 항목은 정상적인 Hard disk 라면 반드시 0을 가지고 있어야 하는 항목들이다.

그리고 숫자가 높을수록 상태가 삐리한거다.
 

Raw_Read_Error_Rate
디스크 표면이로부터 데이터를 읽는 과정에서 문제가 있을때 (주로 물리적인 충격으로 유발됨)
Spin_Up_Time
플레터 회전이 제로 rpm에서 최대 rpm에 도달하는데 걸리는 평균 시간
Start_Stop_Count
플레터가 회전하고 정지한 횟수
Reallocated_Sector_Ct
섹터에 문제가 생겨서 스페어영역의 섹터로 대체한 횟수
Seek_Error_Rate
탐색 오류율
Power_On_Hours
하드에 전원이 인가된 시간
Spin_Retry_Count
최대rpm에 도달하기위해서 회전을 시도하는 횟수 (정상이라면 1번에 끝나야한다)
Power_Cycle_Count
전원 on/off 횟수
Power-Off_Retract_Count
헤드가 플레터(디스크)에서 벗어나는 횟수 (간단하게 parking 위치로 이동한 횟수)
Load_Cycle_Count
헤드가 플레터위로 진입한 횟수
Temperature_Celsius
하드디스크 온도
Reallocated_Event_Count
스페어영역으로 대체된 섹터로 부터 데이터를 읽어간 횟수
hardware ecc recovered
ECC 오류검출로 인하여 복구된 횟수
Current_Pending_Sector
불안정적인 섹터로 스페어영역 섹터로 remap을 준비중이거나 읽는 과정에 문제가 생긴 섹터 (준 배드섹터)
Offline_Uncorrectable
읽기/쓰기에 문제가 생긴 섹터, 즉 디스크 표면이 손상됨. (한마디로 배드섹터)
UDMA_CRC_Error_Count
하드디스크 인터페이스를 통해 데이타 전송과정에 발생한 CRC 오류 횟수
Multi_Zone_Error_Rate
섹터에 쓰기과정에 발생한 에러가 검출된 횟수


 

예제



아래와 같은 에러 메시지가 발생하는 Linux system있다. 이 System을 smartctl을 통해 분석한다.

ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
ata1.00: irq_stat 0x40000001
ata1.00: cmd 06/01:01:00:00:00/00:00:00:00:00/a0 tag 0 dma 69632 out
         res 51/04:01:00:00:00/00:00:00:00:00/a0 Emask 0x1 (device error)
ata1.00: status: { DRDY ERR }
ata1.00: error: { ABRT }
ata1.00: device reported invalid CHS sector 0
end_request: I/O error, dev sda, sector 533248

 


"DRDY ERR" 가 발생을 하고 있다.. DRDY(설명 : Hard disk의 status register 에 Drive ready error를 확인함)

여기서 /dev/sda에 대한 smartctl 결과는 아래와 같다. 빨간색으로 표시한 부분은 문제가 있는 부분이다.
 


# sudo smartctl --all /dev/sda
smartctl 5.40 2010-03-16 r3077 [x86_64-unknown-linux-gnu] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Device Model:     SSD128GNOB-HSM1
Serial Number:    <censored>
Firmware Version: 1571
User Capacity:    128.035.676.160 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   7
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Fri Jan  7 23:14:19 2011 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (   0) seconds.
Offline data collection
capabilities: (0x1d) SMART execute Offline immediate.
No Auto Offline data collection support.
Abort Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
No Conveyance Self-test supported.
No Selective Self-test supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability:        (0x00) Error logging NOT supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: (   0) minutes.
Extended self-test routine
recommended polling time: (   0) minutes.

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
  1 Raw_Read_Error_Rate     0x0000   007   000   000    Old_age   Offline      -       0
  9 Power_On_Hours          0x0000   202   001   000    Old_age   Offline      -       0
12 Power_Cycle_Count       0x0000   169   000   000    Old_age   Offline      -       0
184 End-to-End_Error        0x0000   018   000   000    Old_age   Offline      -       0
195 Hardware_ECC_Recovered  0x0000   000   000   000    Old_age   Offline      -       0
196 Reallocated_Event_Count 0x0000   000   000   000    Old_age   Offline      -       0
197 Current_Pending_Sector  0x0000   000   000   000    Old_age   Offline      -       0
198 Offline_Uncorrectable   0x0000   131   213   000    Old_age   Offline      -       38503
199 UDMA_CRC_Error_Count    0x0000   021   007   000    Old_age   Offline      -       39935
200 Multi_Zone_Error_Rate   0x0000   016   197   000    Old_age   Offline      -       401
201 Soft_Read_Error_Rate    0x0000   197   047   000    Old_age   Offline      -       173
202 Data_Address_Mark_Errs  0x0000   164   115   000    Old_age   Offline      -       2
203 Run_Out_Cancel          0x0000   030   103   000    Old_age   Offline      -       2
204 Soft_ECC_Correction     0x0000   000   000   000    Old_age   Offline      -       0
205 Thermal_Asperity_Rate   0x0000   160   134   000    Old_age   Offline      -       1
206 Flying_Height           0x0000   001   000   000    Old_age   Offline      -       0
207 Spin_High_Current       0x0000   219   006   000    Old_age   Offline      -       0
208 Spin_Buzz               0x0000   067   000   000    Old_age   Offline      -       0
209 Offline_Seek_Performnce 0x0000   100   000   000    Old_age   Offline      -       0
210 Unknown_Attribute       0x0000   238   000   000    Old_age   Offline      -       0
211 Unknown_Attribute       0x0000   000   000   000    Old_age   Offline      -       0

Warning: device does not support Error Logging
Warning! SMART ATA Error Log Structure error: invalid SMART checksum.
SMART Error Log Version: 1
No Errors Logged

Warning! SMART Self-Test Log Structure error: invalid SMART checksum.
SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]


Device does not support Selective Self Tests/Logging


smartctl의 결과에 의해서 배드섹터가 38503개가 있으며 Cable상 오류도 발생하는 것을 찾을수 있다.

이런 상태라면.. 만약 Hart disk의 보증기간이 남아 있을 경우 RMA를 받도록 하자~ ^^ 


붉은색은 자주 쓰는 함수

 ▶ 문자열 다듬기

 
 - trim(), ltrim(), chop()에서 지우는 공백은 스페이스, '\n'(줄바꿈), '\t'(가로 탭), '\v',

 ○ trim();
      - 문자열의 처음과 끝에 있는 공백을 지운다.

 ○ ltrim();
      - 문자열의 처음에 있는 공백을 지운다.
 ○ chop();
      - 문자열의 끝에 있는 공백을 지운다.
 
 
 
 ▶ 문자열 정돈
 
 ○ nl2br();
      - 문자열중 줄바꿈문자(\n)를 XHTML에서의 줄바꾸기인 <br/>태그로 바꾸어 준다.(4.0.5 이전의 HTML에서는 <br>태그)
 
 
 ▶ 문자열의 대소문자 관련 함수
 
 ○ strtoupper();
      - 모든 알파벳을 대문자로
 ○ strtolower();
      - 모든 알파벳을 소문자로
 ○ ucfirst();
      - 문장의 처음이 알파벳이면 그것만 대문자로
 ○ ucword();
      - 각 단어의 첫 알파벳을 대문자로
 
 
 
 ▶ 문자열 나누고 합치기
 
 ○ explode();
      - 지정 문자를 기준으로 문자열의 전, 후를 나누어 배열로 저장한다.
 
      ex) $email =
'email@email.com';     $email_array = explode('@', $email);
           $email_array[0] → 'email';     $email_array[1] → 'email.com';
 
 ○ implode();, join();
      - 지정 문자를 기준으로 배열을 전, 후에 배치하여 문자열을 합친다.
 
      ex) $new_email = implode('@', email_array);     $new_email → 'email@email.com';
 
 
 
 ○ strtok();
      - 지정 토큰문자로 토큰화 해서 구분

ex)
     $token = strtok($feedbak, ' ') // 처음 토큰화 하기
      echo $token.'<br />';
      while ($token!= ''){
            $token = strtok(' '); // 두번째 토큰화 (토큰화하고 싶은)
            echo $token.'<br />';
       }

 ○ substr();
 
      - 문자열 중 특정 시작부분과 끝부분 사이의 문자열을 추출하는데 사용한다.
      ex) $test = 'PHP Webprogramming';
           $test1 = substr($test, 1);     $test2 = substr($test, -1);     $test3 = substr($test, 5, 8);     $test4 = substr($test, 4, -2);
 
           $test1 → 'HP Webprogramming'(앞에서 1번 부터)
           $test2 → 'g'(뒤에서 1번 부터)
           $test3 → 'ebprogra'(앞에서 5번부터 8개)
           $test4 → 'Webprogrammi'(앞에서 4번부터 뒤에서 2번까지)

 
 
 
 ▶ 문자열 비교하기
 
 ○ strcmp();
      - C언어에서의 함수와 같다. 앞의 문자열을 기준으로 같으면 0을, 우선순위가 높으면 -1을, 반대의 경우에는 1을 리턴한다.
      - 단, 대문자와 소문자의 경우 소문자가 우선순위가 더 높다.(ASCII코드의 대소관계를 생각하면 쉽다.)

 ○ strcasecmp();
      - C언어에서의 stricmp()와 같다. 두 문자열을 비교하는 것은 strcmp()와 같지만 대소문자를 구분하지 않는다.
 ○ strnatcmp(); & strnatcasecmp();
      - 이 두 함수는 문자열을 좀더 자연스러운 기준에서 비교한다.(strnatcmp("12","2")의 결과는 1이다.)
      - 이 두 함수의 차이는 대소문자의 구분여부이다.(이 두 함수의 차이는 case의 유무여부이다.)
 
 
 
 ▶ 문자열의 길이 확인하기
 ○ strlen();
      - C언어에서의 함수와 같다. 문자열의 길이를 정수값으로 리턴해준다.

 
 
 ▶ 문자열 안에서 문자열 찾기
 ○ strstr();
      - 문자열 안에서 특정 문자열과 일치하는 부분이 있는지 찾아내는데 쓰이는 함수이다.
      - 일치하는 문자열이 있을 때는 해당 문자열이나 문자를 포함하여 이후 문자열을 리턴한다.
      - 일치하는 문자열이 없을 시에는 false를 리턴한다.
 
      ex) $str='Lion sleep to night';     $res = strstr($str, 'sleep');
           $res → 'sleep to night'
 
 ○ stristr();
      - strstr()과 같으나 대소문자를 구분하지 않는다.(ABC, Abc, aBC모두 같은 것으로 취급한다.)
 
 ○ strchr();
      - strstr()과 같으나 문자열대신 문자를 찾는다.
 
 ○ strrch();
      - strchr()과 같으나 뒤에서 부터 일치하는 문자를 찾기 때문에 마지막으로 나타난 문자부터 문자열을 출력한다.
 
 
 
 ▶ 문자열의 위치 찾아내기
 
 ○ strpos();
      - 문자열 내에서 일치하는 문자열이나 문자를 찾아 문자열 대신 해당 위치를 숫자로 알려준다.
      ex) $test = 'Ice cream';     $res1 = strpos($test, 'a');     $res2 = strpos($test, 'e');
           $res1 → 7(0부터 시작한다.)     $res2 = 2(일치하는 문자나 문자열이 많을 경우 가장 앞의 것을 기준으로 한다.)
      ex) $test = 'Ice cream';     $res = strpos($test, 'e', 4);
           $res = 6(앞에서부터 4번째에 있는 c부터 해당문자열의 위치를 찾는다.)

     
 ○ strrpos();
 
      - strpos와 비슷하나 찾는 문자가 가장 마지막에 보이는 곳의 위치를 리턴한다.
       
 ※ 두 함수 모두 만약 문자열에 needle(찾는 문자나 문자열)이 없으면 false를 리턴하는데 PHP에서는 false를 0과 같다고 보기 때문에
 
      위치 0을 리턴한것인지 false를 리턴한 것인지 구분할 수가 없다. 이 문제는 === 연산자를 사용하여 해결할 수 있다.
 ex) $res = strpos('Hello world', 'H');     //이 경우에는 가장 앞에 'H'가 있기 때문에 0을 리턴하지만 PHP는 false와 구분하지 못한다.
 
      if($res === false)
           echo 'Not found';
      else
           echo 'Found at position 0';
 
 
 
 ▶ 문자열 대체하기
 
 ○ str_replace();
      - 문자열에서 문자열를 찾아 대체문자열로 바꾸어 리턴한다.
      ex) $test = 'Change';     $res = str_replace('g', 'c', $test);
           $res → 'Chance'

 
 ○ substr_replace();
      - 특정 위치의 문자열을 대체문자열로 바꾸어 리턴한다.
      ex) $test = 'Vitamin A'; $res = substr_replace($test, 'C', -1);
           $res → 'vitamin C'



출처 : http://www.webmadang.net/index/main.jsp


XpressEngine을 쓰고 있는 웹호스팅 계정의 파일과 자료방들을 점검하다가 어딘지 몰라도 엄첨나게 많은 파일들이 쌓여 있다는 것을 
알게 되었다. 하나씩 뒤져서  xe/files/member_extra_info/point에 셀 수 없는 파일들이 들어 있는 것을 알아 냈다.

 '4.cache.txt' 같은 이름이 붙은 겨우 3~4바이트로 된 txt 파일들이었다.

파일 수가 너무 많아서 파일 목록을 다 확인하는 건 엄두도 낼 수 없었고, 'du -sm'으로 차지한 용량만 확인하는 것도 한참 걸렸다.

저마다 다른 자료방(디렉토리)에 파일들이 담겨 있다 보니 심각함을 깨닫기 어려웠는데, 파일과 자료방들이 차지한 공간이 700MB가 넘었다. 

이 파일들은 XE에서 DB를 조회할 때 생기는 부하를 줄이려고 포인트 정보를 옮겨 놓은 시렁(캐시)이라고 한다. 그 동안 스팸을 올릴 목적으로 마구마구 자동 가입한 유령 회원들이 꽤 있었는데, 나중에 그 회원 정보들은 모두 지웠지만 그들의 포인트 캐시 파일은 그대로 남아서 쌓였던 듯하다.

files/member_extra_info/point 안의 파일들은 시렁으로 쓰이므로 지우더라도 아무런 문제되지 않는다.

'rm -rf /www/xe/files/member_extra_info/point/*' 명령으로 파일들을 지우기는 했으나, 명령을 걸어 놓고 기다리다 못해 한숨 자고 일어났을 만큼 한참이 걸렸다. 그래도 내 경우는 XE는 기가바이트가 넘게 쌓이지는 않았는데, XE 게시판에서 보니 시렁 파일이 기가바이트를 넘겨 쌓여 있었던 사례도 있었다. 100~500MB쯤 되는 작은 디스크 공간으로 운영되는 웹 호스팅 환경에서는 50MB 이하가 쌓여도 타격이 클 수 있다.

지난날에 스팸 게시물을 올릴 가입한 회원이 많았던 적이 있는 XE 게시판이라면, 쓸데없이 시렁 파일이 쌓이지 않았는지 살펴 볼 필요가 있어 보인다.

※ 참고할 만한 글 : https://www.xpressengine.com/qna/22995237

[출처] http://pat.im/1117


파일수가 많은 경우를 삭제하려고 시도할 때 나타나는 메세지이다.
rm 명령어에서 getopt function의 아규먼트 파싱하는데에 최대 수치를 넘어선 것으로 기본적으로 1024개 이상을 핸들링하지 못한다.
이에 대한 대처로 다음과 같은 명령어를 쓸 수 있다.

1. find . -name '파일타입' | xargs rm 또는 find . -name '파일타입' -exec rm -rf {};


2. find . -name '*' -exec rm {} \;



예시) /var/spool/mqueue 디렉토리 하위의 파일들이 삭제되지 않을 경우
find ./q*/ -print | xargs rm