perl에서 데이터베이스 접근을 위한 모듈을 설치한다.
사용자는 DBI모듈 불러오고 이 DBI모듈이 DBD::mysql 모듈을 불러와 DB에 접근할 수 있다.

모듈정보를 확인한다.

# perl -MDBI -e 'print "$DBI::VERSION\n"'
Can't locate DBI.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.8.6/mach /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.6/BSDPAN /usr/local/lib/perl5/5.8.6/mach /usr/local/lib/perl5/5.8.6 .).
BEGIN failed--compilation aborted.

# perl -MDBD::mysql -e 'print "$DBD::mysql::VERSION\n"'
Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/lib/perl5/site_perl/5.8.6/mach /usr/local/lib/perl5/site_perl/5.8.6 /usr/local/lib/perl5/site_perl /usr/local/lib/perl5/5.8.6/BSDPAN /usr/local/lib/perl5/5.8.6/mach /usr/local/lib/perl5/5.8.6 .).
BEGIN failed--compilation aborted.

# cpan
cpan> i /DBI/
cpan> install DBI
cpan> exit
# perl -MDBI -e 'print "$DBI::VERSION\n"'
1.607

DBI 모듈이 설치되었다.

DBD::mysql 모듈을 설치한다.

# cpan
cpan> install DBD::mysql
...
mysql_config 를 찾지못한다고 오류가나면서 종료된다.
$PATH를 추가하고 다시 한다.

이번에는 DB 테스트하는 과정에서 오류가 난다.
테스트를 건너뛰고 모듈을 설치할 수도 있겠지만 어떻게 하는지는 모르겠다.
기본 DB가 test인데 내가 가지고 있는 mysql 서버에는 test DB조차 없다.
root 계정도 비밀번호가 있어서 어쨌든 DB 테스트는 실패로 끝났다.

$HOME/.cpan/ 디렉토리의 설치문서를 본다.

$ vi /root/.cpan/build/DBD-mysql-4.008/INSTALL.html

이런 부분이 있다.

CPAN installation

.....
If you cannot get the CPAN module working, you might try manual installation. If installation with CPAN fails because the your local settings have been guessed wrong, you need to ensure MySQL's mysql_config is on your path (see SOURCE INSTALLATION) or alternatively create a script called mysql_config. This is described in more details later. Configuration.
....

또 이런 부분도 있다.

Configuration

The install script ``Makefile.PL'' can be configured via a lot of switches. All switches can be used on the command line. For example, the test database:

  perl Makefile.PL --testdb=<db>

If you do not like configuring these switches on the command line, you may alternatively create a script called mysql_config. This is described later on.

Available switches are:

testdb

   Name of the test database, defaults to test.

testuser

   Name of the test user, defaults to empty. If the name is empty, then the currently logged in users name will be used.

testpassword

   Password of the test user, defaults to empty.

testhost

   Host name or IP number of the test database; defaults to localhost.

testport

   Port number of the test database

ps-protcol=1 or 0

   Whether to run the test suite using server prepared statements or driver emulated prepared statemetns. ps-protocol=1 means use server prepare, ps-protocol=0 means driver emulated.

cflags

   This is a list of flags that you want to give to the C compiler. The most important flag is the location of the MySQL header files. For example, on Red Hat Linux the header files are in /usr/include/mysql and you might try

     -I/usr/include/mysql

   On Windows the header files may be in C:\mysql\include and you might try

     -IC:\mysql\include

   The default flags are determined by running

     mysql_config --cflags

   More details on the C compiler flags can be found in the following section. Compiler flags.

libs

   This is a list of flags that you want to give to the linker or loader. The most important flags are the locations and names of additional libraries. For example, on Red Hat Linux your MySQL client libraries are in /usr/lib/mysql and you might try

     -L/usr/lib/mysql -lmysqlclient -lz

   On Windows the libraries may be in C:\mysql\lib and

     -LC:\mysql\lib -lmysqlclient

   might be a good choice. The default flags are determined by running

     mysql_config --libs

   More details on the linker flags can be found in a separate section. Linker flags.

If a switch is not present on the command line, then the script mysql_config will be executed. This script comes as part of the MySQL distribution. For example, to determine the C compiler flags, we are executing

  mysql_config --cflags
  mysql_config --libs

If you want to configure your own settings for database name, database user and so on, then you have to create a script with the same name, that replies

 
=head2 Compiler flags

Note: the folling info about compiler and linker flags, you shouldn't have to use these options because Makefile.PL is pretty good at utilising mysql_config to get the flags that you need for a successful compile.

It is typically not so difficult to determine the appropriate flags for the C compiler. The linker flags, which you find in the next section, are another story.

The determination of the C compiler flags is usually left to a configuration script called mysql_config, which can be invoked with

  mysql_config --cflags

When doing so, it will emit a line with suggested C compiler flags, for example like this:

  -L/usr/include/mysql

The C compiler must find some header files. Header files have the extension .h. MySQL header files are, for example, mysql.h and mysql_version.h. In most cases the header files are not installed by default. For example, on Windows it is an installation option of the MySQL setup program (Custom installation), whether the header files are installed or not. On Red Hat Linux, you need to install an RPM archive mysql-devel or MySQL-devel.

If you know the location of the header files, then you will need to add an option

  -L<header directory>

to the C compiler flags, for example -L/usr/include/mysql.


# cd ~/.cpan/build/DBD-mysql-4.008
# perl Makefile.PL --testdb=xxxx --testuser=xxxx --testpassword=xxxx --testhost=localost
# make
# make test
테스트할때 중간쯤 오래걸릴때가 있다. 그럴땐 가볍게 Ctrl-C..

# make install
# perl -MDBD::mysql -e 'print "$DBD::mysql::VERSION\n"'
4.008

운영체제는 FreeBSD 5.4 이고 perl 버전은 5.8.6, mysql 버전은 4.1.18 이다.
1. 개요
gentoo에서 qmail 및 관련 패키지를 설치하고 mail client(thunderbird) 설정을 다룬다.


2. 현재상황 및 시스템 상태
kernel : gentoo-2.6.18 (전부 다)

나의 사설네트워크의 dns서버가 세팅되어 있다. http://innu.pe.kr/tt/397 참조.
zone 파일의 MX 레코드에 1차로 mail.ddong.ac.kr, 2차로 mail2.ddong.ac.kr로 설정되었다.
우선, mail.ddong.ac.kr 세팅을 한다.
pop3서버는 mail.ddong.ac.kr과 IP는 동일하고 호스트명만 A 레코드에 추가를 하였다.
db.ddong.ac.kr에 mysql이 설치되어 있어야 한다.

즉, 이 작업이 이뤄지기 위해선,
- dns 설치(ns.ddong.ac.kr)
- mysql 설치(db.ddong.ac.kr)

이 반드시 선행되어져야 한다.


3. 설치
qmail 설치에 앞서 우선 USE flag를 손본다.

사용자 삽입 이미지



# cat /etc/make.conf
...
USE="-X -xorg -kde -gnome -gtk -gtk2 -ipv6"
# cat /etc/portage/package.use
mail-mta/netqmail maildir ssl imap mysql
net-mail/vpopmail mysql
net-mail/courier-imap berkdb fam gdbm nls -debug -ipv6


qmail 설치

qmail을 emerge 한다.
# emerge mail-mta/netqmail


/var/qmail/control/servercert.cnf 파일의 [ req_dn ] 블록을 수정한다
# cat /var/qmail/control/servercert.cnt
...
C=KO
ST=SE
L=Seoul
O=Gogi Mail Systems
OU=Automatically-generated Qmail SMTP SSL key
CN=mail.ddong.ac.kr
emailAddress=gogisnim@gmail.com


qmail의 config 파일을 emerge한다.
# emerge --config netqmail


qmail의 alias 설정을 한다.
참고로, qmail은 root로 메일을 보낼 수 없다. 그래서 root를 비롯한 타 계정으로 가는 메일을 다른 메일로 forward 시킨다. 여기선 gogisnim으로 forward 시켰다.
# cd /var/qmail/alias
# echo gogisnim > .qmail-root
# echo gogisnim > .qmail-postmaster
# echo gogisnim > .qmail-mailer-daemon


qmail 시스템의 전체적인 총괄을 담당(?)하는 데몬을 구동시킨다.
그리고, /service/ 아래에 qmail-send 심볼릭 링크를 걸어준다.
# /etc/init.d/svscan start
# rc-update add svscan default
# ln -s /var/qmail/supervise/qmail-send /service/qmail-send


qmail 설치가 끝났다. 로컬에서 gogisnim으로 메일을 보내본다.
이상이 없으면 다음으로 진행..
# ssh gogisnim@localhost
$ maildirmake .maildir
$ qmail-inject root << EOF
> test mail to root
> EOF
$ qmail-inject postmaster << EOF
> test mail to postmaster
> EOF
$ qmail-inject gogisnim << EOF
> test mail to gogisnim
> EOF
$ mutt
gogisnim에게 3통의 메일이 수신되었으면 정상이다.


vpopmail 설치

vpopmail은 다른 MTA가 시스템계정 == 메일계정 방식의 계정관리 방식에서 보다 유연하게 DB로 관리할 수 있게 한다. 무엇보다도 가상 도메인을 지원하기때문에 하나의 qmail 시스템에서 수십, 수백, 수천개의 도메인, 계정을 관리할 수 있다.
mysql이 필요한 시점이 지금이다.

# emerge vpopmail
# mysql -uroot -hdb.ddong.ac.kr -p << EOF
> create database vpopmail;
> use mysql;
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@mail.ddong.ac.kr identified by 'vpoppw';
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@smtp.ddong.ac.kr identified by 'vpoppw';
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@pop3.ddong.ac.kr identified by 'vpoppw';
> grant select,insert,update,delete,create,drop on vpopmail.* to vpopmail@mail2.ddong.ac.kr identified by 'vpoppw';
> flush privileges;
> EOF

위 내용은 gentoo.org의 qmail 세팅 매뉴얼에 나와있는 내용이지만 나는 이렇게 작업하지 않고 mysql_setpermission 스크립트를 이용해서 간단하게 작업했다.


vpopmail 설정파일을 수정한다.
호스트|포트|mysql사용자|mysql비번|DB명
# cat /etc/vpopmail.conf
...
# Read-only DB
db.ddong.ac.kr|0|vpopmail|vpoppw|vpopmail
# Write DB
db.ddong.ac.kr|0|vpopmail|vpoppw|vpopmail


파일의 사용자,권한을 체크한다.
gentoo에서는 이 작업이 필요없다. 확인만 한다.
# chown root:vpopmail /etc/vpopmail.conf
# chmod 640 /etc/vpopmail.conf
# chown root:vpopmail /var/vpopmail/bin/vchkpw
# chmod 4711 /var/vpopmail/bin/vchkpw


설정환경을 업데이트 한다.
# env-update && . /etc/profile


가상도메인을 추가한다.
내가 사용할 user@ddong.ac.kr 형식의 가상도메인을 여기서 설정한다.
아울러, 사용자도 추가해준다.
# /var/vpopmail/bin/vadddomain ddong.ac.kr
Password for postmaster: 1111
# /var/vpopmail/bin/vadduser gogisnim@ddong.ac.kr
Password for gogisnim@ddong.ac.kr: 2222
# /var/vpopmail/bin/vadduser ji@ddong.ac.kr
Password for ji@ddong.ac.kr: 3333

도메인삭제는 vdeldomains, 사용자삭제는 vdeluser이다.
이처럼 /var/vpopmail/bin/에 있는 vpopmail 관련 명령어들은 직관적이어서 쉽게 사용할 수 있다.
vpopmail 설정이 끝났다.
간혹, mysql/vpopmail 연동해서 permission 관련 오류가 발생하면 mysql 데몬을 재시동 시켜준다.
db # /etc/init.d/mysql restart


courier-imap 설치

courier-imap 패키지는 pop3/pop3-ssl, imap/imap-ssl 모두를 지원하는 MDA이다.
반드시 vpopmail 설치후 courier-imap를 설치해야 한다.

# emerge courier-imap
# cat /etc/courier/authlib/authdaemonrc
...
authmodulelist = "authvchkpw"
...
# cat /etc/courier-imap/pop3d.cnf
...
[ req_dn ]
C=KO
ST=SE
L=Seoul
O=Gogi Mail Systems
OU=Automatically-generated Qmail SMTP SSL key
CN=mail.ddong.ac.kr
emailAddress=gogisnim@gmail.com
...
# cat /etc/courier-imap/imap.cnf
...
[ req_dn ]
C=KO
ST=SE
L=Seoul
O=Gogi Mail Systems
OU=Automatically-generated Qmail SMTP SSL key
CN=mail.ddong.ac.kr
emailAddress=gogisnim@gmail.com
...

# mkpop3dcert
# mkimapdcert

# /etc/init.d/courier-pop3d start
# /etc/init.d/courier-imapd start
# /etc/init.d/courier-pop3d-ssl start
# /etc/init.d/courier-imap-ssl start
# rc-update add courier-pop3d default
# rc-update add courier-imapd default
# rc-update add courier-pop3d-ssl default
# rc-update add courier-imapd-ssl default

qmail 서버에서 pop3(110), pop3-ssl(995), imap(143), imap-ssl(993) 전부 대기하게 만든다.
사용자가 mail client를 입맛대로 설정할 수 있다.
courier-imap 패키지 설치와 설정이 끝났다.


마무리작업

# cat /var/qmail/control/conf-smtpd
...
QMAIL_SMTP_CHECKPASSWORD="/var/vpopmail/bin/vchkpw"
...
# mkservercert
# ln -s /var/qmail/supervise/qmail-smtpd /service/qmail-smtpd


mail client(thunderbird) 설정

현재 thunderbird 2.0.0.6 영문버전을 사용하고 있다.

사용자 삽입 이미지
계정세팅 이미지


사용자 삽입 이미지
pop3-ssl 설정 이미지


사용자 삽입 이미지
smtp 설정 이미지


4. 후기
qmail 설치작업은 한마디로 삽질의 연속이었다.
gentoo wiki, gentoo.org, qmail.kldp.org 그리고 googling 까지..
될듯될듯 하면서도 마지막 mail client의 사용자 인증부분에서 좌절을 겪고 또 설치하고, 테스트하고..

메일세팅 작업의 노하우를 간단히 얘기하면,

MTA를 설치하고 반드시 localhost에서 주고 받는데 이상이 없는지 테스트를 한다.
테스트 하는데는 mutt와 telnet client가 좋다.(mutt로 메일보내고 telnet으로 110번 접속해서 확인)
localhost에서 이상이 없으면 다른 호스트에서 테스트를 한다.
mail client 설정할때 반드시 Thunderbird, Outlook (Express)를 비롯한 여러 프로그램에서 테스트 해본다.
처음, Outlook에서는 인증이 되는데 Thunderbird에서는 인증이 되지않아 애를 먹었다.

스팸처리와 webmail구현은 다음에 작업해서 문서로 남긴다.


5. 참조 url
http://www.gentoo.org/doc/en/qmail-howto.xml
http://gentoo-wiki.com/HOWTO_Setup_QMAIL_RELAY-CTRL_VPOPMAIL_%26_QMAILADMIN_with_a_minimum_amount_of_fuss.
http://qmail.kldp.org/
http://www.mozilla.or.kr/products/thunderbird/
http://forums.gentoo.org/viewtopic-t-539101.html
1. 개요
OpenVZ host system(www)에 apache와 php를 설치한다.
OpenVZ guest system(db)에 mysql을 설치한다.

2. 현재상황 및 시스템 상태
kernel : gentoo-2.6.18
특별한 커널 작업은 없다.

3. 설치

db 호스트에 mysql을 설치한다.
mysql을 USE 변수보다 package.use 파일에 flag를 기입하는것을 권장한다.

It is *strongly* recommended that you use the /etc/portage/package.* files instead of USE=" " on the command line if you want to enable a USEflag for one package. The biggest benefit of this is that on future upgrades of the package, your same use flags will be applied.

To add custom use flags to a package, first create the /etc/portage directory. It does not exist by default. Next, create a package.use file. The format of this file is very simple, do not add the version number to the packagename.



db # emerge dev-db/mysql

기본적인 데이터베이스를 설치한다
db # emerge --config dev-db/mysql

mysql 데몬을 구동한다
db # /etc/init.d/mysql start
db # rc-update add mysql default

mysql 보안관련 세팅을 한다
db # mysql_setpermission

mysql_setpermission은 perl로 만들어진 보안관련 스크립트이다.
기존, mysql 설치작업 후 호스트, 사용자, db 등등의 작업을 수동으로 해주었는데 이 스크립트는 대화식 모드에서 손쉽게 보안설정을 하게 해준다.



www에 apache2를 설치한다.

/etc/make.conf USE 변수에 "apache2"를 추가한 다음 emerge 한다.
www # emerge apache

apache를 기동한다.
www # /etc/init.d/apache2 start
www # rc-update add apache2 default

참고로 apache 버전 2.0.54-r10 부터 설정파일 디렉토리 구조가 바뀌었다.

Use Old Path New Path
Server Root /etc/apache2/ /usr/lib/apache2/
Configuration Directory /etc/apache2/conf/ /etc/apache2/
Configuration /etc/apache2/conf/apache2.conf /etc/apache2/httpd.conf
Configuration /etc/apache2/conf/commonapache2.conf /etc/apache2/httpd.conf
Vhosts Configuration /etc/apache2/conf/vhosts/ /etc/apache2/vhosts.d/
Modules Configuration /etc/apache2/conf/modules.d/ /etc/apache2/modules.d/
Module Binaries /usr/lib/apache2-extramodules/ /usr/lib/apache2/modules/



www에 php5를 설치한다.

www # cat /etc/portage/package.use
dev-lang/php apache apache2 mysql ctype unicode pcre session gd ftp cli iconv truetype xml

기타 필요한 flag는 알아서 추가한다.
USE flag 는 다음 url에서 참조한다.

http://gentoo-wiki.com/USE_Flags_explained

www # emerge dev-lang/php

/etc/conf.d/apache2 파일을 수정한다.
www # cat /etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5"
www # /etc/init.d/apache2 restart


www에 phpmyadmin을 설치한다
www # cat /etc/portage/package.use
dev-db/phpmyadmin vhosts
www # emerge phpmyadmin

mysql_setpermission으로 www의 ip에서 root로 접속할 수 있게 권한을 준다.
webapp-config 를 실행한다.

www # man webapp-config
www # webapp-config -I -d /phpmyadmin/ phpmyadmin 2.10.1

브라우저로 접속한다.
http://www.ddong.ac.kr/phpmyadmin/

접속실패 나오고 configuration file 설정하면 다음부터 웹에서 원격으로 mysql을 컨트롤 한다.


4. 참조 url
http://gentoo-wiki.com/Apache2_Install
http://gentoo-wiki.com/Apache_Modules_PHP
http://gentoo-wiki.com/HOWTO_MySQL


#!/bin/bash


# 현재 서버에서 모든 db 서버에 3306 port 스캔한다

# 스캔된 내용을 임시 텍스트 파일에 저장한다

# 저장된 임시 텍스트 파일에 특정 문자열이 있는지 조사한다

# grep 리턴값이 0이 나오지 않으면 문자메세지를 보낸다


# 스캔도구는 nmap 2.12 를 사용했고 출력값이 다를 수 있기때문에 nmap의 다른버전에서는 어떤

# 결과가 나올지 장담할 수 없다


HOST=("db1.innu.com" "db2.innu.com" "db3.innu.com" "db4.innu.com" "db5.innu.com" "db6.
innu.com");
PORT="3306"
NMAP="/usr/local/bin/nmap"
PHP="/usr/local/bin/php"
FLAG=0
TOTAL_ARRAY_NUM=${#HOST[@]}


while [ "$FLAG" -lt "$TOTAL_ARRAY_NUM" ]
do
   $NMAP -P0 -p $PORT ${HOST[$FLAG]} > a

   /bin/grep -r $PORT a > /dev/null 2>&1
   retVAL=$?

   if [ "$retVAL" != "0" ]; then
       $PHP -f /www/htminc/db_server_alive.php ${HOST[$FLAG]}
   fi

   rm -f a
   let "FLAG = $FLAG + 1"
done

exit 0

mysql 구동

컴퓨터/System 2005/05/26 22:33

# cat m4

./safe_mysqld  -O table_cache=512  -O max_connections=400 -O wait_timeout=200

-O key_buffer=384M -O  sort_buffer=4M -O record_buffer=4M  &

TAG mysql

Starting with MySQL 4.0.4, you can also perform UPDATE operations that cover multiple tables:

UPDATE items,month SET items.price=month.price WHERE items.id=month.id; 

The example shows an inner join using the comma operator, but multiple-table UPDATE statements can use any type of join allowed in SELECT statements, such as LEFT JOIN.


Note: You cannot use ORDER BY or LIMIT with multiple-table UPDATE.


Before MySQL 4.0.18, you need the UPDATE privilege for all tables used in a multiple-table UPDATE, even if they were not updated. As of MySQL 4.0.18, you need only the SELECT privilege for any columns that are read but not modified.

If you use a multiple-table UPDATE statement involving InnoDB tables for which there are foreign key constraints, the MySQL optimizer might process tables in an order that differs from that of their parent/child relationship. In this case, the statement fails and rolls back. Instead, update a single table and rely on the ON UPDATE capabilities that InnoDB provides to cause the other tables to be modified accordingly.


Currently, you cannot update a table and select from the same table in a subquery.


출처: http://dev.mysql.com/doc/

TAG mysql

#!/bin/sh


# 해당 디렉토리에 있는 모든 테이블을 조사한다

# 첫번째 인자로 db명을 입력받는다


if [ -z $1 ]; then

  echo "usage: $0 DB_NAME"

  exit 1

fi


FILES=`ls /home/mysql/data/$1/*{ISM,MYI} 2> /dev/null`


for target_file in $FILES; do

  if [ "X${target_file##*.}" = "XISM" ]; then

     chktool="isamchk"

  else

     chktool="myisamchk"

  fi

  /home/mysql/bin/$chktool --recover $target_file

  echo "$target_file check success !!!"

done


exit 0

mysql> desc tbl_money;

+--------------+-------------+------+-----+---------+-------+
| Field        | Type        | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+-------+
| id               | varchar(64) |      | MUL |         |       |
| money        | int(11)     |      |     | 0       |       |
| make_time   | datetime  |      | MUL | 0       |       |
+--------------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)


mysql> select left(make_time,7) as mt,sum(money) from tbl_money group by mt having mt not in ('0000-00','2005-03');

................

| 2004-05 |    2092260 |
| 2004-06 |    1771030 |
| 2004-07 |    1182540 |
| 2004-08 |    1198620 |
| 2004-09 |    4917540 |
| 2004-10 |    6891670 |
| 2004-11 |    3110140 |
| 2004-12 |    3425810 |
| 2005-01 |    2958977 |
| 2005-02 |    1913150 |
+---------+------------+
45 rows in set (8.95 sec)

며칠전... (지난 목요일이구나)

엄청난 사고를 쳤다가 수습한 내용을 간략히 적어본다.


예전에 메인 db 서버의 데이터를 delete 문으로 삭제를 한 적이 있다.

삭제를 한 이유는 테이블에 있는 데이터의 용량이 거의 2G를 육박하고 있었기 때문이었다.

참고로 메인 db서버엔 고객db, 회사에서 주력으로 서비스하고 있는 db의 내용이 있어 한마디로 엄청난 압박을 가지고 만져야 하는 서버다.

그래서 여태껏 커널 업그레이드도 못하고, mysql 업그레이드도 못하고 있다.(부담스러워서...)


지난번 delete 문으로 짠 스크립트 cron으로 돌릴때도 거의 뜬눈으로 밤을 새다시피 했었다.

다행히 cron은 제대로 돌았고 데이터의 내용은 날씬해졌지만 데이터 용량의 크기는 마찬가지였다.

검색을 해보니 isam 체크를 해주어야 한다고 했다.

isam 체크를 한다고 한다고 하다 결국은 2달여가 지나갔고 2005년 2월 17일 목요일 새벽 4시 40분에 cron으로 예약해놓고 그날은 푹 쉴 수(?) 있었다.


다음날 아침 출근하니 회사 웹서버가 개판 오분전 이었다.


메인 db 서버의 mysql 데몬이 죽어 있었다.... OTL ... OTL ...

하늘이 노래지는거 같았다.


일단 수습을 하기위해서 mysql데몬을 띄우고 db의 특정 table에 insert 를 못하게 막았다.(서비스는 되어야 하기때문에 데몬을 죽일수는 없다)

침착하게 isam 체크를 해나갔다.

헉..... 그런데 isam 체크도중 에러를 내뿜는 것이었다. 침착하고 계속 추이를 지켜봤다.

isam 체크를 끝내고 mysql 데몬을 죽였다 살렸다.

그리고 체크한 테이블을 테스트 했다..... 헉...

모든 index가 죽어 있었다.... OTL .. OTL ..

진짜 하늘이 노래졌다.


............


문제의 테이블 데이터파일들을 다른 서버(mysql 설치는 되어 있지만 서비스 되지않는)로 옮겼다.
거기서 mysql 데몬을 죽이고 isam 체크를 진~ 하게 했다.

서비스가 되지 않아서 그런지 체크는 20분을 넘기지 않았다.

체크한 파일의 용량을 살펴보니 확실히 날씬해져 있었다.

그 파일들을 다시 메인 db서버에 옮기고 데몬을 재실행 시키니 그제서야 정상적인 결과가 나올 수 있었다.

TAG isam, mysql
사용자 삽입 이미지