본문 바로가기

centOS - Apache - mysql - php 설치

web/server by 낼스 2019. 7. 16.

1. centOS설치
    1. CentOS 5.3 DVD 를 이용해서 아나콘다 모드로 install
    2. 파티셔닝
        /home : 40G
        /boot : 10M
        SWAP  : 1G
        /     : 나머지
    3. ssh, ftp 등 기본 설치
    4. tkekit (tkekit1234) 유저 생성 (시스템계정)

    # hostname변경
        /etc/hosts
        /etc/sysconfig/network

        그래도 안되면 여기 변경

        echo "호스트명" > /proc/sys/kernel/hostname

        /proc/sys/kernel/hostname

    # prompt(프롬프트) 변경
        vi .bash_profile
        export PS1="\e[1;37m[\e[36m\D{%Y-%m-%d %H:%M:%S}\e[37m] \
        [\e[32m\u\e[31m@\e[33m\h\e[37m] \e[34m\w\e[m\n\$ "
        source /etc/sysconfig/i18n

2. 설치 확인 & 제거 ( mysql )
    rpm -qa httdd php mysql
    yum remove -y httpd php mysql

3. 설치 준비
    /root/src/APM 디렉토리 생성
    mkdir src
    cd src
    mkdir APM
    cd APM

4. Download
    1. Apache
        다운로드 링크 확인 : ftp.kasit.ac.kr 접속 Apache/httpd 버전및 링크 주소확인
        wget http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.2.15.tar.gz

    2. php
        - 다운로드 링크 확인 : http://kr2.php.net/downloads.php
        wget http://kr2.php.net/get/php-5.2.13.tar.gz/from/this/mirror

    3. mysql ( 대만이 빠르군요 )
        - 다운로드 링크 확인 : http://dev.mysql.com/downloads/mysql/5.1.html#downloads
            Generally Available (GA) Releases - Select Platform - Source Code선택
            맨아래 Generic Linux (Architecture Independent), Compressed TAR Archive

        wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.46.tar.gz

5. 라이브러리, 컴파일러 확인 및 설치
    rpm -qa gcc* cpp* compat-gcc* flex*

    yum -y install gcc cpp gcc-c++ compat-gcc-32-g77 flex

    rpm -qa libjpeg* libpng* freetype* gd-*

    yum install libjpeg-devel libpng-devel freetype-devel gd-devel
    yum install openssl

    yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel pspell-devel net-snmp-devel


6. Install
    * Apache
        tar zxvf httpd-2.2.15.tar.gz
        ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so --enable-php --enable-apache --enable-ssl --enable-modules=ssl --enable-rewrite --with-mpm=prefork --with-mcrypt=/usr/local

        * 참고
            --prefix=설치 경로
            --enable-module=so 는 tomcat 연동이나 다른 연동시 필요하므로 꼭 추가.
        make
        make install

        # httpd.conf 수정
            - ServerName 수정
            - UTF-8 설정 추가
                AddDefaultCharset UTF-8
                AddCharset UTF-8       .utf8

                
                    DirectoryIndex index.html
                
                - ▼ 변경 ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ -
                
                    DirectoryIndex index.html index.htm index.php index.php3
                    AddType application/x-httpd-php .php .phtml
                    AddType application/x-httpd-source .phps
                

            - config test
                service httpd configtest

        # 서비스 등록하기
            cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

            vi /etc/init.d/httpd

            !bin/sh 밑에 아래 내용을 넣는다.

            # chkconfig: - 92 92
            # description: Apache Web Server Version 2.2.11

            chmod 755 /etc/rc.d/init.d/httpd
            chkconfig --add httpd
            chkconfig --level 2345 httpd on

            service httpd start

            ntsysv : 서비스 등록여부는 확인 명령어

            http://localhost



    2. mysql 설치
        tar zxvf mysql-5.1.46.tar.gz
        ./configure --prefix=/usr/local/mysql --with-charset=utf8 --enable-large-files --localstatedir=/data/mysql --sysconfdir=/etc --with-readline --with-extra-charsets=all --with-innodb --disable-shared --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --without-debug --without-docs

            --prefix=/usr/local/mysql   : 설치디렉ㅌ토리
            --with-charset=utf8         : charset
            --localstatedir=/data/mysql : mysql 데이터 파일 저장

            --with-innodb               : innoDB를 사용
            --with-mysqld-user=mysql    : mysql실행 유저
            --with-unix-socket-path=/var/lib/mysql/mysql.sock  : 소켓파일의 위치 tcp/ip대신 유닉스 소켓을 이용함.
            --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
                                        : 컴파일 옵션으로 'CXX=gcc'를 사용할 때 오류를 피하기 위해 공유 라이브러리를 사용하지 않음
                                          실행 성능을 높일 수 있다.
            --without-debug             : 질의시 디버깅 코드를 사용하지 않기 때문에 빠른 속도를 얻어낼 수 있다.

        make

        make install

        # 사용자및 권한설정 ( 1 )
            groupadd dba
            useradd -M -o -r -d /usr/local/mysql -s /sbin/nologin -c "Mysql Server" -u 27 -g dba mysql >/dev/null 2>&1 || :

            mkdir /data/mysql

            /usr/local/mysql/bin/mysql_install_db

            chown -R mysql:dba /data/mysql

            /usr/local/mysql/bin/mysqld_safe &

            /usr/local/mysql/bin/mysqladmin -u root password 'tkekit'

        # 서비스 등록
            cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
            chkconfig --add mysqld
            chkconfig --level 35 mysqld on (런레벨 35일때 자동 실행 된다)

        # 비밀번호 없는 유저 삭제
            use mysql;
            delete from user where password = "";
            flush privileges;
            flush tables;

        # 사용자및 권한설정 ( 2 )
            chown -R root:dba /usr/local/mysql
            chown -R mysql:dba -R /var/lib/mysql

        #. mysql path 설정
            PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

        # setting
            cp my-huge.cnf /etc/my.cnf
            vi my.cnf

    3. php 설치
        # 컴파일전에 깔아줘야할 라이브러리입니다.
            yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel pspell-devel net-snmp-devel
        # List of core configure options
        http://kr.php.net/manual/en/configure.about.php

        ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mod --enable-magic-quotes --disable-dmalloc --enable-bcmath --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-gd-native-ttf --enable-ftp --with-jpeg-dir --with-freetype-dir --with-curl --with-zlib --with-gd  --with-ttf --with-iconv --disable-debug --with-pcre-regex=yes

        make

        make install

        cp php.ini-dist /usr/local/apache/conf/php.ini

        service httpd restart

        # Cannot load /usr/local/apache/modules/libphp5.so into server 에러 발생
            /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server:
            /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

            1. vi /etc/sysconfig/selinux 변경
                vi /etc/sysconfig/selinux
                SELINUX=enforcing --> SELINUX=disabled
                리붓

            2. selinux 보안정책을 적용
                /sbin/restorecon -R -v /usr/local/apache/modules/libphp5.so
                /usr/bin/chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so

        # php path 설정
            PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin

        # /etc/php.ini setting
            mbstring.func_overload = 7
            mbstring.internal_encoding = UTF-8
            mbstring.http_output = UTF-8

    4. Zend Optimizer
        # 설치 절차
            1. 다운받은 ZendOptimizer를 압축을풀고.
            2. 서버에 깔린 PHP 버전에 맞는 디렉토리로 들어간후
            3. 파일한개를 특정경로에 복사하고 (cp ZendOptimizer.so /usr/lib/httpd/modules/ )
            4. php.ini 설정에 해당 경로를 넣어주고
            5. httpd 를 재시작.

        wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
        tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
        cd ZendOptimizer-3.3.9-linux-glibc23-i386/data

        ls
        4_2_0_comp  4_3_x_comp  5_0_x_comp  5_2_x_comp
        4_2_x_comp  4_4_x_comp  5_1_x_comp  poweredbyoptimizer.gif
        cd 5_2_x_comp ( php 버전에 맞는 디렉토리로 이동 )

        ls
        ZendOptimizer.so ( 학인 )

        php -v

        copy ZendOptimizer.so /usr/local/apache/modules/

        # php.ini 추가
            [Zend]
            zend_optimizer.version=3.3.9
            Zend_extension=/usr/local/apache/modules/ZendOptimizer.so

        php -v ( 에러 발생 php 모듈 인식시 발생한 에러와 유사함. )
        Failed loading /usr/local/apache/modules/ZendOptimizer.so:  /usr/local/apache/modules/ZendOptimizer.o: cannot restore segment prot after reloc: Permission denied
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

        chcon -t texrel_shlib_t /usr/local/apache/modules/ZendOptimizer.so

        php -v ( 에러 없음 )
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
            with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

    5. eAccelerator
        # eAccelerator 다운로드 (홈페이지 : http://eaccelerator.net)
            wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2 ( 0.9.6 설치는 되나, Call to undefined function eaccelerator_put  에러 발생 )
                                                                                      ( Call to undefined function eaccelerator_put ::> -with-eaccelerator-shared-memory )

            wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2

        tar jxvf eaccelerator-0.9.5.2.tar.bz2
        cd eaccelerator-0.9.5.2

        phpize ( 이거 꼭 해줘야함 모지 디렉토리에 configure 없다가 생기넹 )

        ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config --with-eaccelerator-shared-memory
        ( README 파일 읽어보면 자세히 나옴 )

        make

        make install
        Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

        mkdir -p /data/eaccelerator

        chmod 700 /data/eaccelerator

        # php.ini 수정
            extension_dir = "/usr/local/php/lib/php/extensions"

            [eAccelerator]
            extension="no-debug-non-zts-20060613/eaccelerator.so"
            eaccelerator.shm_size="16"
            eaccelerator.cache_dir="/data/eaccelerator"
            eaccelerator.enable="1"
            eaccelerator.optimizer="1"
            eaccelerator.check_mtime="1"
            eaccelerator.debug="0"
            eaccelerator.filter=""
            eaccelerator.shm_max="0"
            eaccelerator.shm_ttl="0"
            eaccelerator.shm_prune_period="0"
            eaccelerator.shm_only="0"
            eaccelerator.compress="1"
            eaccelerator.compress_level="9"

            eaccelerator.allowed_admin_path="/usr/local/apache/htdocs/eaccelerator"
            ; eaccelerator.admin.name="admin"
            ; eaccelerator.admin.password="tkekit"

            # 참고
               - eaccelerator.shm_size   = eAccelerator가 사용할 공유 메모리량. 단위 MBytes.
                 0을 지정하면 OS 기본값. default = 0
               - eaccelerator.cache_dir  = 캐싱 디렉토리를 지정. precompiled code, session data, content
                 등이 저장된다.
               - eaccelerator.enable     = eAccelerator 사용 여부. 당연히 1
               - eaccelerator.optimizer  = 최적화 여부. 1= enable, 0 = disable
               - eaccelerator.check_mtime= php 파일 변경시간을 체크하여 반영할 것인지 여부
               - eaccelerator.debug      = debug 로깅 여부
               - eaccelerator.filter     = 캐싱할 php 파일을 지정한다. *.php *.html *.php3 처럼 지정할 수
                 있으며 "" 로 비워두면 모든 php 파일이 캐싱된다.

               - eaccelerator.shm_max    = eaccelerator_put() 함수 사용할 때 최대 할당할 수 있는 공유
                 메모리 크기를 bytes단위로 표시한다. (예. 10240, 10K, 1M).  0은 제한 없음
                 eaccelerator_put() 함수는 공유메모리에 특정 데이터를 지정한 시간동안 넣어두는
                 eAccelerator 자체함수이다.
               - eaccelerator.shm_ttl    = 새 스크립트 파일을 캐싱할만한 공유 메모리가 없다면,
                 ssh_ttl 초동안 액세스가 없는 모든 스크립트를 삭제한다. default = 0. 0은 삭제안함을 의미
               - eaccelerator.shm_prune_period= 이 설정은 위의 shm_ttl 설정과 비슷하다.
                 지정한 초보다 오래전에 만들어진 스크립트를 제거한다.
                 즉, shm_ttl은 액세스시간에, shm_prune_period는 생성시간에 따라 삭제한다.
                 default = 0. 0은 삭제안함을 의미
               - eaccelerator.shm_only   = 컴파일된 스크립트를 디스크에 캐싱할 것인지 여부.
                 session data와 content 캐싱은 이설정과 무관. default = 0.
                 0이면 캐싱을 위해 디스크와 메모리를 모두 사용한다.

               - eaccelerator.compress = 캐시된 내용 압축 여부
               - eaccelerator.compress_level= 압축 레벨 지정. 9는 최대 압축 레벨


        $ php -v
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
            with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
            with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

        service httpd restart

        # Control panel 설정하기 ( 웹관리 도구 )
            mkdir /usr/local/apache/htdocs/eaccelerator
            cp [source directory]/*.php /usr/local/apache/htdocs/eaccelerator

            http://localhost/eaccelerator/control.php

    6. PDFlib
        http://www.pdflib.com/
        --> http://www.pdflib.com/download/free-software/pdflib-lite-7/

        wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5.tar.gz
        tar zxvf PDFlib-Lite-7.0.5.tar.gz
        cd PDFlib-Lite-7.0.5
        ./configure --prefix=/usr/local/pdflib

        make

        make install

        wget http://www.pdflib.com/binaries/PDFlib/801/PDFlib-8.0.1-Linux-php.tar.gz
        tar zxvf PDFlib-8.0.1-Linux-php.tar.gz

        cp libpdf_php.so /usr/local/php/lib/php/extensions/

        # php.ini 추가
            extension=libpdf_php.so

        # php_info 확인 --> PDFlib 가 보여야함.

        wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-7.0.5-Linux-php.tar.gz
        tar zxvf PDFlib-7.0.5-Linux-php.tar.gz
        cd PDFlib-7.0.5-Linux-php/bind/php5/php-520
        cp libpdf_php.so /usr/local/php/lib/php/extensions/

        # testing
            mkdir -p /usr/local/apache/htdocs/pdftest
            mkdir -p /usr/local/apache/htdocs/pdftest/data

            cp bind/php/*.* /usr/local/apache/htdocs/pdftest
            cp bind/data/* /usr/local/apache/htdocs/pdftest/data

            * 참고 : 복사한 sample 소스에서
                $searchpath = "../data";

                $searchpath = "/usr/local/apache/htdocs/pdftest/data";

    7. JPGraph ( http://www.aditus.nu/jpgraph/jpg_proversion.php )
        컴파일을 통해서 인스톨 하는 컨셉이 아님.
        # 설치 절차
            1. 압축 해제 ( jpgraph-3.0.7.tar.bz2 )
            2. src 폴더를 php inlcude 폴더로 이동
                - php.ini 수정
                    include_path = ".:/usr/local/php/include"

            3. docportal( 메뉴얼 및 샘플 )를 적절한 http documentRoot 아래로 복사
            4. 포튼 문제 발생할경우 --> MS TrueType Fonts on CentOS 5 적용
        # 설치
            1. download & unpack
                wget http://hem.bredband.net/jpgraph2/jpgraph-3.0.7.tar.bz2
                mkdir jpgraph-3.0.7
                mv jpgraph-3.0.7.tar.bz2 ./jpgraph-3.0.7
                cd jpgraph-3.0.7
                tar jxvf jpgraph-3.0.7.tar.bz2

            2. setting
                cp -rf ./src /usr/local/php/include/jpgraph
                cp -rf ./docportal /usr/local/apache/htdocs/jpgraph_doc

            3. test
                * test_jpg.php 생성
                    

                * http://localhost/test_jpg.php
                    Error 발생 : Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist
                        --> MS TrueType Fonts on CentOS 5 수행

# MS TrueType Fonts on CentOS 5 ( Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist )
    1. Install the software needed. You may need the DAG rpm repository to install cabextract - see my "Must-Have Repos" post for details.

        sudo yum install rpm-build cabextract

    2. Download the specs to build the RPM
        wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec

    # yum install cabextract 시 No package cabextract available 에러 발생
        - cabextract 설치 ( http://www.cabextract.org.uk/ : rpm으로 설치해야함 )
            wget  http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm
            rpm -i cabextract-1.2-1.i386.rpm

    3. Build the RPM
        rpmbuild -ba msttcorefonts-2.0-1.spec

    4. Install the RPM
        rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

    To use the fonts with ImageMagick, I also needed to create a link to the font installation folder as follows:
        ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/default/TrueType

        ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/truetype

# mysql What is Innodb Table space ?
    - Myisam은 rollback이 안됨( autocommit ).
   -  innodb는 오라클 처럼 shared tablespace ( ibdataN ) 와 로그파일 (ib_logfileN ) 로 구성됨
      로그파일은 트랜젝션들을 처리하는 오라클의 아카이브 로그 같이 생각 하면 된다.

# mysql Starting MySQL.Manager of pid-file quit without updating fi
    $ service mysqld restart
    MySQL manager or server PID file could not be found!       [실패]
    Starting MySQL.Manager of pid-file quit without updating fi[실패]

    # mysql 설치 초기화
    1. innodb 파일을 삭제한다. ( ibdata1  .. ibdataN )
    2. /usr/local/mysql/bin/mysql_install_db OR /usr/local/mysql/bin/mysql_install_db --user=mysql
    3. chown -R mysql:dba /data/mysql
    4. 변경할 my.cnf로 반영
    5. /usr/local/mysql/bin/mysqld_safe & OR service mysqld start
    6. /usr/local/mysql/bin/mysqladmin -u root password '비밀번호'
    7. mysql 계정 정리 (삭제 조심)
        use mysql;
        delete from user where password = "";
        flush privileges;
        flush tables;

# mysql Shared Table Space 용량 조정
   1. mysqldump로 innodb table을 백업
   2. 서버 중지
   3. innodb 파일 (ibdata1  .. ibdataN) 삭제
   4. my.cnf에서 아래 내용 수정
        innodb_data_file_path=ibdata1:1000M;ibdata2:1000M;ibdata3:1000M:autoextend
   5. 서버 재구동
   6. dump 파일을 import

# mysql 테이블 스페이스 관리
    링크 : http://adminplay.com/board/?_filter=search&mid=Mysql&search_target=title&search_keyword=inno&document_srl=2196
    아직 오라클 같이 Shared Table Space 를 온라인상에서 추가 하기 힘들다.
    오직 my.cnf 환경 파일로 생성이 되고 변경 된다.
    대량의 데이터 베이스 의 경우 3 ~ 4G 이상이 되는경우
    디폴트로 ibdata1:10M:autoextend 를 쓴다면 곤욕을 치르게 될것이다.

    다음과 같이 여러개의 파일을 이용하여 분산 하는 것을 추천 합니다.
    파일은 path을 이용 할수 도 있고 raw 디바이스를 이용 할수도 있습니다.
    /data1 .. /data4 를 각각 다른 디바이스라고 한다면 아래와 같이 사용하면 된다.
    innodb_data_home_dir=
    innodb_data_file_path = /data1/ibdata1:500M;/data2/ibdata2:500M;/data3/ibdata3:500M;/data4/ibdata4:200M:autoextend:max:2000M
    보통 백업을 위해서 오라클의 경우 500MB ~ 1GB로 데이터 파일 을 생성 하였다.
    그리고 200MB는 현재 사용량이 얼마인지 모르기 때문에 200MB -> 300MB가 되면
    다시 환경 파일을 수정하고 데이터 파일을 추가 하기 위한 방법이다.
      그러나 이것도 문제 가 많다는 것을 독자들도 알것이다.
    암튼 아직은 미약한 부분이 많다는 것을 착안 하기 바란다.
    데이처 파일을  500MB ~ 1GB로 생성 하는이유는
    예전에 OS에서 제한이 있어서 그런 적도 있었지만 , 파일이 크면 그 만큼  I/O분산이 안된다.
    그리고 파일당 백업 시간이 증가하거나 문제가 발생 하면  복구도 그만큼  힘들다.
    예로 500MB데이터 파일 하나가 사라진 경우와 1GB 데이터 파일 1개가 사라진 경우
    그안에 속한 데이터의 량은 곱절이 된다.
    즉 재난 을 최소화 하기 위해서라고 1GB이하로 쪼개는 것이 낳기 때문이다.
    그렇다고 3GB 되는 것을 100MB로 쪼개면  어떨까 performance에서  문제가 될것이다.
    그러므로 DBA의 적절한 선태이 필요하다.

# Mysql - InnoDB 사용 가능 상태 확인및 설정 ( http://develop.sunshiny.co.kr/392 )
    참고한출처 : http://www.rootman.co.kr/bbs/zboard.php?id=linux&no=1901
    InnoDB 를 사용 가능한지 확인합니다.

    show variables like 'have_innodb';

    [root@localhost ~]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.1.42-log MySQL Community Server (GPL)

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    ## 사용 가능한 상태
    mysql> show variables like 'have_innodb';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | have_innodb   | YES   |
    +---------------+-------+
    1 row in set (0.56 sec)

    ## 사용 되지 않는 상태
    mysql> show variables like 'have_innodb';
    +---------------+----------+
    | Variable_name | Value    |
    +---------------+----------+
    | have_innodb   | DISABLED |
    +---------------+----------+
    1 row in set (28.87 sec)

    InnoDB는 기본적으로 mysql 설치 시 지원됩니다.

    (1) 만일 초기 세팅 시,
    아예 InnoDB를 제외 시키려면 configuration 시 --without-innodb를 추가하시면 되고,

    (2) 데몬 구동 시 제외시키려면,
    mysqld_safe --skip-innodb 로 구동 시키며,

    (3) my.cnf 에서 제외 처리하려면,
    아래 처럼 skip-innodb를 추가해 주고, 데몬 재시작을 하면 됩니다.

    [mysqld]

    # InnoDB 사용 안할시 아래 내용추가
    skip-innodb

# 방화벽 및 포트 설정(+ SELinux)
    # system-config-firewall
    1. Samba, FTP 등 필요한 서비스 체크

    2. 신뢰하는 인터페이스 eth+ 체크

    3. 원하는 Port Open

    ( Console에서 )
    방화벽 상태 알아보기
    # /sbin/service iptables status
    방화벽 올리고 내리기
    # /sbin/service iptables stop
    # /sbin/service iptables start
    방화벽 설정 수정하기
    # vi /etc/sysconfig/iptables
    방화벽 해제정
    # iptable -F or ipchains -F
    redhat 9.0 이라면 lokkit 으로 방화벽 설정을 할 수도 있습니다.

    ( SELINUX )
    1. 수동으로 끄기 (일시적으로만 먹힘)
    system-config-securitylevel
    setenforce 0

    2. 커널 명령행에 다음 옵션 추가. (grub.conf 등에)
    selinux=0

    3. /etc/selinux/config 파일 수정 ***추천***
    SELINUX=어쩌구~ 써있는 것을 SELINUX=disabled로 수정

# php re-configure
    방법1.
        trobule -->linux "Call to undefined function mysqli_connect"
        1. 서버 중지 및 기존 php모듈 백업
            service httpd stop
            mv /usr/local/apache/modules/libphp5.so /usr/local/apache/modules/libphp5_bak.so

        2. make clear
            make clean
            make clean-dist
            rm -rf ./config.cache

        3. configure
            ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mod --enable-magic-quotes --disable-dmalloc --enable-bcmath --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-gd-native-ttf --enable-ftp --with-jpeg-dir --with-freetype-dir --with-curl --with-zlib --with-gd  --with-ttf --with-iconv --disable-debug --with-pcre-regex=yes
            make
            make install
    방법2.
        # 이것도 되나보군 (안해봄) :: yum install php-mysqli


# php extension so 생성 ( http://gmplib.org/manual/ )
    $ cd cd php-5.2.13/ext/gmp
    $ phpize5 OR phpize
    $ ./configure --enable-gmp
    $ make
    $ make test
    $ make install
    $ Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

    # php.ini 수정
        extension=no-debug-non-zts-20060613/gmp.so


# bin log 관리
    * 3일 이전의 bin log 삭제 ( 아래 명령을 쉘에서 바로 실행하면 된다 )
    mysql -uroot -e "PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 10 DAY);"

    * /etc/my.cnf 설정 - binlog 관련
    log-bin=/home/mysql_log/bin_log/bin # 빈로그 저장 설정 및 저장할 디렉토리 지정
    binlog_cache_size =  2M      # binlog cache 사이즈
    max_binlog_size =  50M        # bin로그 파일 사이즈
    expire_logs_days = 10           # 보관기간


# replication 설정
    #참고 문서
        http://adminplay.com/board/?mid=Mysql&document_srl=3452&sort_index=regdate&order_type=desc
        http://codememo.textcube.com/2
        http://hanaduri.egloos.com/2389708
        http://search.mysql.com/search?q=replication&ie=utf-8&lr=lang_en&x=0&y=0

    # maser setting
        - my.cnf 변경
            server-id = 1       # 1로 셋팅해준다.
            log-bin=mysql-bin   # 원래 앞에 주석(#) 처리가 되어있는데 주석을 삭제한다. 로깅파일명 설정

        - create replication user
            GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%'  IDENTIFIED BY 'repltkekit';
            FLUSH TABLES WITH READ LOCK;
            show master status;
            +-----------------------+----------+--------------+------------------+
            | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
            +-----------------------+----------+--------------+------------------+
            | bin-update-log.000002 |     4625 |              |                  |
            +-----------------------+----------+--------------+------------------+
            1 row in set (0.02 sec)

        - data dump ( slaver쪽에 밀어넣을 데이터로 master,slave가 동일하게하기위해서 백업 )
            /usr/local/mysql/bin/mysqldump -uroot -p --all-databases > all_db(덤프할이름).sql

        - table unlock
            UNLOCK TABLES;

        - mysql restart
            service mysqld restart

    # slave setting
        - data restore
            /usr/local/mysql/bin/mysql -uroot -p < all_db(덤프할이름).sql

        - slave 설정
            - my.cnf 변경 ( 방법1 )
                # replication slave
                master_host=172.17.160.137
                master-user=repl
                master-password=repltkekit
                master-port=3306
                replicate-do-db=test
                server-id=2

            - 명령어로 변경 ( 방법2 )
                stop slave;

                CHANGE MASTER TO
                MASTER_HOST='172.17.160.137',
                MASTER_USER='repl',
                MASTER_PORT=3306,
                MASTER_PASSWORD='repltkekit',
                MASTER_LOG_FILE='mysql-bin.000003', -- 마스터의 상태보기 명령어에서 나온 파일명을 적어준다.
                MASTER_LOG_POS=98
                ;

                flush privileges;
                flush tables;
                show slave status;

        - mysql restart
            service mysqld restart

        - 설정확인
            SHOW SLAVE STATUS;

    # master/slave 설정확인
        - master
            mysql> SHOW PROCESSLIST;
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            | Id | User | Host                | db   | Command     | Time | State                                                          | Info             |
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            |  1 | repl | 172.17.160.141:3055 | NULL | Binlog Dump |  475 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
            |  2 | root | 172.17.160.141:3246 | test | Sleep       |   93 |                                                                | NULL             |
            |  3 | root | localhost           | NULL | Query       |    0 | NULL                                                           | SHOW PROCESSLIST |
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            3 rows in set (0.00 sec)

            mysql> SHOW MASTER STATUS;
            +-----------------------+----------+--------------+------------------+
            | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
            +-----------------------+----------+--------------+------------------+
            | bin-update-log.000008 |      106 |              |                  |
            +-----------------------+----------+--------------+------------------+
            1 row in set (0.00 sec)

        - slave
            mysql> SHOW PROCESSLIST;
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            | Id | User        | Host           | db    | Command | Time | State                                                                 | Info             |
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            |  1 | system user |                | NULL  | Connect | 1515 | Waiting for master to send event                                      | NULL             |
            |  2 | system user |                | NULL  | Connect | 1422 | Has read all relay log; waiting for the slave I/O thread to update it | NULL             |
            |  3 | root        | localhost:2002 | test  | Sleep   |  685 |                                                                       | NULL             |
            |  5 | root        | localhost:3313 | mysql | Query   |    0 | NULL                                                                  | SHOW PROCESSLIST |
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            4 rows in set (0.00 sec)

            mysql> SHOW SLAVE STATUS;
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            | Slave_IO_State                   | Master_Host    | Master_User | Master_Port | Connect_Retry | Master_Log_File       | Read_Master_Log_Pos | Relay_Log_File                | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error                                                                            | Last_SQL_Errno | Last_SQL_Error |
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            | Waiting for master to send event | 172.17.160.137 | repl        |        3306 |            60 | bin-update-log.000008 |                 106 | IT-JihoonKim-relay-bin.000017 |           256 | bin-update-log.000008 | Yes              | Yes               | test,tkkorea    |                     |                    |                        |                         |                             |          0 |            |            0 |                 106 |             568 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |          2003 | error reconnecting to master 'repl@172.17.160.137:3306' - retry-time: 60  retries: 86400 |              0 |                |
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            1 row in set (0.00 sec)

    # test
        1. master / slave 에 테이블생성
            CREATE TABLE `repli_test` (
                `f1` VARCHAR(10) NULL DEFAULT NULL
            )
            ENGINE=InnoDB
            ROW_FORMAT=DEFAULT

        2. mysql restart

        3. master
            insert into `repli_test` ( f1 ) values ('1');

        4. slave ( 데이터 입력 확인 )
            select * from `repli_test`;


# 양방향 동기화 처리
    Master서버에서 Slave도 구현하고자 한다면 다음과 같은 방법으로 처리
    1. 현재 Slave서버에 replication 계정 생성
    2. 현재 Slave의 my.ini 변 경
    log-bin=mysql-bin 추가
    3. 현재 SLAVE 서버 데몬 재시작
    4. 현재 Master의 my.ini 변경
    replicate-do-db=’database name’추가
    4. 현재 Master에서 CHANGE MASTER TO 실행
    5. 현재 Master 서버 데몬 재시작

# slave replication 정지/ 시작
    mysql> stop slave
    mysql> start slave

    - 참고
        MySQL 데몬(서비스)를 재 시작하면 slave는 자동으로 시작된다.
        (my.ini에 옵션 skip-slave-start이 있으면 자동 시작 안한다.)


# 참고
    http://srue.net/80                                          apache
    http://guni.loveyust.net/124                                mysql
    http://piki.thoth.kr/?mid=blog&document_srl=807396          php,zend,eAccelerator
    http://www.ezcomponents.org/overview/requirements#pcre      php Requirements
    http://hyosub.net/21                                        eaccelerator
    http://eaccelerator.net/wiki/Settings                       eaccelerator Setting
    http://krnjevic.com/wp/?p=174                               MS TrueType Fonts on CentOS 5
        http://www.cabextract.org.uk/                           cabextract

    mysql setting
        http://adminplay.com/board/?mid=Mysql&document_srl=2196&sort_index=regdate&order_type=desc
        http://radiocom.kunsan.ac.kr/lecture/mysql/table_innodb.html
        http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html
        http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html#sysvar_innodb_log_arch_dir

    http://aesops.tistory.com/18                                firewall

    mysql replication
        http://adminplay.com/board/?mid=Mysql&document_srl=3452&sort_index=regdate&order_type=desc
        http://codememo.textcube.com/2
        http://hanaduri.egloos.com/2389708
        http://search.mysql.com/search?q=replication&ie=utf-8&lr=lang_en&x=0&y=0

1. centOS설치
    1. CentOS 5.3 DVD 를 이용해서 아나콘다 모드로 install
    2. 파티셔닝
        /home : 40G
        /boot : 10M
        SWAP  : 1G
        /     : 나머지
    3. ssh, ftp 등 기본 설치
    4. myuser (myuser1234) 유저 생성 (시스템계정)

    # hostname변경
        /etc/hosts
        /etc/sysconfig/network

        그래도 안되면 여기 변경

        echo "호스트명" > /proc/sys/kernel/hostname

        /proc/sys/kernel/hostname

    # prompt(프롬프트) 변경
        vi .bash_profile
        export PS1="\e[1;37m[\e[36m\D{%Y-%m-%d %H:%M:%S}\e[37m] \
        [\e[32m\u\e[31m@\e[33m\h\e[37m] \e[34m\w\e[m\n\$ "
        source /etc/sysconfig/i18n

2. 설치 확인 & 제거 ( mysql )
    rpm -qa httdd php mysql
    yum remove -y httpd php mysql

3. 설치 준비
    /root/src/APM 디렉토리 생성
    mkdir src
    cd src
    mkdir APM
    cd APM

4. Download
    1. Apache
        다운로드 링크 확인 : ftp.kasit.ac.kr 접속 Apache/httpd 버전및 링크 주소확인
        wget http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.2.15.tar.gz

    2. php
        - 다운로드 링크 확인 : http://kr2.php.net/downloads.php
        wget http://kr2.php.net/get/php-5.2.13.tar.gz/from/this/mirror

    3. mysql ( 대만이 빠르군요 )
        - 다운로드 링크 확인 : http://dev.mysql.com/downloads/mysql/5.1.html#downloads
            Generally Available (GA) Releases - Select Platform - Source Code선택
            맨아래 Generic Linux (Architecture Independent), Compressed TAR Archive

        wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.46.tar.gz

5. 라이브러리, 컴파일러 확인 및 설치
    rpm -qa gcc* cpp* compat-gcc* flex*

    yum -y install gcc cpp gcc-c++ compat-gcc-32-g77 flex

    rpm -qa libjpeg* libpng* freetype* gd-*

    yum install libjpeg-devel libpng-devel freetype-devel gd-devel
    yum install openssl

    yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel pspell-devel net-snmp-devel


6. Install
    * Apache
        tar zxvf httpd-2.2.15.tar.gz
        ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so --enable-php --enable-apache --enable-ssl --enable-modules=ssl --enable-rewrite --with-mpm=prefork --with-mcrypt=/usr/local

        * 참고
            --prefix=설치 경로
            --enable-module=so 는 tomcat 연동이나 다른 연동시 필요하므로 꼭 추가.
        make
        make install

        # httpd.conf 수정
            - ServerName 수정
            - UTF-8 설정 추가
                AddDefaultCharset UTF-8
                AddCharset UTF-8       .utf8

                
                    DirectoryIndex index.html
                
                - ▼ 변경 ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ -
                
                    DirectoryIndex index.html index.htm index.php index.php3
                    AddType application/x-httpd-php .php .phtml
                    AddType application/x-httpd-source .phps
                

            - config test
                service httpd configtest

        # 서비스 등록하기
            cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

            vi /etc/init.d/httpd

            !bin/sh 밑에 아래 내용을 넣는다.

            # chkconfig: - 92 92
            # description: Apache Web Server Version 2.2.11

            chmod 755 /etc/rc.d/init.d/httpd
            chkconfig --add httpd
            chkconfig --level 2345 httpd on

            service httpd start

            ntsysv : 서비스 등록여부는 확인 명령어

            http://localhost



    2. mysql 설치
        tar zxvf mysql-5.1.46.tar.gz
        ./configure --prefix=/usr/local/mysql --with-charset=utf8 --enable-large-files --localstatedir=/data/mysql --sysconfdir=/etc --with-readline --with-extra-charsets=all --with-innodb --disable-shared --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --without-debug --without-docs

            --prefix=/usr/local/mysql   : 설치디렉ㅌ토리
            --with-charset=utf8         : charset
            --localstatedir=/data/mysql : mysql 데이터 파일 저장

            --with-innodb               : innoDB를 사용
            --with-mysqld-user=mysql    : mysql실행 유저
            --with-unix-socket-path=/var/lib/mysql/mysql.sock  : 소켓파일의 위치 tcp/ip대신 유닉스 소켓을 이용함.
            --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
                                        : 컴파일 옵션으로 'CXX=gcc'를 사용할 때 오류를 피하기 위해 공유 라이브러리를 사용하지 않음
                                          실행 성능을 높일 수 있다.
            --without-debug             : 질의시 디버깅 코드를 사용하지 않기 때문에 빠른 속도를 얻어낼 수 있다.

        make

        make install

        # 사용자및 권한설정 ( 1 )
            groupadd dba
            useradd -M -o -r -d /usr/local/mysql -s /sbin/nologin -c "Mysql Server" -u 27 -g dba mysql >/dev/null 2>&1 || :

            mkdir /data/mysql

            /usr/local/mysql/bin/mysql_install_db

            chown -R mysql:dba /data/mysql

            /usr/local/mysql/bin/mysqld_safe &

            /usr/local/mysql/bin/mysqladmin -u root password 'myuser'

        # 서비스 등록
            cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
            chkconfig --add mysqld
            chkconfig --level 35 mysqld on (런레벨 35일때 자동 실행 된다)

        # 비밀번호 없는 유저 삭제
            use mysql;
            delete from user where password = "";
            flush privileges;
            flush tables;

        # 사용자및 권한설정 ( 2 )
            chown -R root:dba /usr/local/mysql
            chown -R mysql:dba -R /var/lib/mysql

        #. mysql path 설정
            PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

        # setting
            cp my-huge.cnf /etc/my.cnf
            vi my.cnf

    3. php 설치
        # 컴파일전에 깔아줘야할 라이브러리입니다.
            yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel pspell-devel net-snmp-devel
        # List of core configure options
        http://kr.php.net/manual/en/configure.about.php

        ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mod --enable-magic-quotes --disable-dmalloc --enable-bcmath --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-gd-native-ttf --enable-ftp --with-jpeg-dir --with-freetype-dir --with-curl --with-zlib --with-gd  --with-ttf --with-iconv --disable-debug --with-pcre-regex=yes

        make

        make install

        cp php.ini-dist /usr/local/apache/conf/php.ini

        service httpd restart

        # Cannot load /usr/local/apache/modules/libphp5.so into server 에러 발생
            /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server:
            /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

            1. vi /etc/sysconfig/selinux 변경
                vi /etc/sysconfig/selinux
                SELINUX=enforcing --> SELINUX=disabled
                리붓

            2. selinux 보안정책을 적용
                /sbin/restorecon -R -v /usr/local/apache/modules/libphp5.so
                /usr/bin/chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so

        # php path 설정
            PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin

        # /etc/php.ini setting
            mbstring.func_overload = 7
            mbstring.internal_encoding = UTF-8
            mbstring.http_output = UTF-8

    4. Zend Optimizer
        # 설치 절차
            1. 다운받은 ZendOptimizer를 압축을풀고.
            2. 서버에 깔린 PHP 버전에 맞는 디렉토리로 들어간후
            3. 파일한개를 특정경로에 복사하고 (cp ZendOptimizer.so /usr/lib/httpd/modules/ )
            4. php.ini 설정에 해당 경로를 넣어주고
            5. httpd 를 재시작.

        wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
        tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
        cd ZendOptimizer-3.3.9-linux-glibc23-i386/data

        ls
        4_2_0_comp  4_3_x_comp  5_0_x_comp  5_2_x_comp
        4_2_x_comp  4_4_x_comp  5_1_x_comp  poweredbyoptimizer.gif
        cd 5_2_x_comp ( php 버전에 맞는 디렉토리로 이동 )

        ls
        ZendOptimizer.so ( 학인 )

        php -v

        copy ZendOptimizer.so /usr/local/apache/modules/

        # php.ini 추가
            [Zend]
            zend_optimizer.version=3.3.9
            Zend_extension=/usr/local/apache/modules/ZendOptimizer.so

        php -v ( 에러 발생 php 모듈 인식시 발생한 에러와 유사함. )
        Failed loading /usr/local/apache/modules/ZendOptimizer.so:  /usr/local/apache/modules/ZendOptimizer.o: cannot restore segment prot after reloc: Permission denied
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

        chcon -t texrel_shlib_t /usr/local/apache/modules/ZendOptimizer.so

        php -v ( 에러 없음 )
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
            with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

    5. eAccelerator
        # eAccelerator 다운로드 (홈페이지 : http://eaccelerator.net)
            wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2 ( 0.9.6 설치는 되나, Call to undefined function eaccelerator_put  에러 발생 )
                                                                                      ( Call to undefined function eaccelerator_put ::> -with-eaccelerator-shared-memory )

            wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2

        tar jxvf eaccelerator-0.9.5.2.tar.bz2
        cd eaccelerator-0.9.5.2

        phpize ( 이거 꼭 해줘야함 모지 디렉토리에 configure 없다가 생기넹 )

        ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config --with-eaccelerator-shared-memory
        ( README 파일 읽어보면 자세히 나옴 )

        make

        make install
        Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

        mkdir -p /data/eaccelerator

        chmod 700 /data/eaccelerator

        # php.ini 수정
            extension_dir = "/usr/local/php/lib/php/extensions"

            [eAccelerator]
            extension="no-debug-non-zts-20060613/eaccelerator.so"
            eaccelerator.shm_size="16"
            eaccelerator.cache_dir="/data/eaccelerator"
            eaccelerator.enable="1"
            eaccelerator.optimizer="1"
            eaccelerator.check_mtime="1"
            eaccelerator.debug="0"
            eaccelerator.filter=""
            eaccelerator.shm_max="0"
            eaccelerator.shm_ttl="0"
            eaccelerator.shm_prune_period="0"
            eaccelerator.shm_only="0"
            eaccelerator.compress="1"
            eaccelerator.compress_level="9"

            eaccelerator.allowed_admin_path="/usr/local/apache/htdocs/eaccelerator"
            ; eaccelerator.admin.name="admin"
            ; eaccelerator.admin.password="myuser"

            # 참고
               - eaccelerator.shm_size   = eAccelerator가 사용할 공유 메모리량. 단위 MBytes.
                 0을 지정하면 OS 기본값. default = 0
               - eaccelerator.cache_dir  = 캐싱 디렉토리를 지정. precompiled code, session data, content
                 등이 저장된다.
               - eaccelerator.enable     = eAccelerator 사용 여부. 당연히 1
               - eaccelerator.optimizer  = 최적화 여부. 1= enable, 0 = disable
               - eaccelerator.check_mtime= php 파일 변경시간을 체크하여 반영할 것인지 여부
               - eaccelerator.debug      = debug 로깅 여부
               - eaccelerator.filter     = 캐싱할 php 파일을 지정한다. *.php *.html *.php3 처럼 지정할 수
                 있으며 "" 로 비워두면 모든 php 파일이 캐싱된다.

               - eaccelerator.shm_max    = eaccelerator_put() 함수 사용할 때 최대 할당할 수 있는 공유
                 메모리 크기를 bytes단위로 표시한다. (예. 10240, 10K, 1M).  0은 제한 없음
                 eaccelerator_put() 함수는 공유메모리에 특정 데이터를 지정한 시간동안 넣어두는
                 eAccelerator 자체함수이다.
               - eaccelerator.shm_ttl    = 새 스크립트 파일을 캐싱할만한 공유 메모리가 없다면,
                 ssh_ttl 초동안 액세스가 없는 모든 스크립트를 삭제한다. default = 0. 0은 삭제안함을 의미
               - eaccelerator.shm_prune_period= 이 설정은 위의 shm_ttl 설정과 비슷하다.
                 지정한 초보다 오래전에 만들어진 스크립트를 제거한다.
                 즉, shm_ttl은 액세스시간에, shm_prune_period는 생성시간에 따라 삭제한다.
                 default = 0. 0은 삭제안함을 의미
               - eaccelerator.shm_only   = 컴파일된 스크립트를 디스크에 캐싱할 것인지 여부.
                 session data와 content 캐싱은 이설정과 무관. default = 0.
                 0이면 캐싱을 위해 디스크와 메모리를 모두 사용한다.

               - eaccelerator.compress = 캐시된 내용 압축 여부
               - eaccelerator.compress_level= 압축 레벨 지정. 9는 최대 압축 레벨


        $ php -v
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
            with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
            with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

        service httpd restart

        # Control panel 설정하기 ( 웹관리 도구 )
            mkdir /usr/local/apache/htdocs/eaccelerator
            cp [source directory]/*.php /usr/local/apache/htdocs/eaccelerator

            http://localhost/eaccelerator/control.php

    6. PDFlib
        http://www.pdflib.com/
        --> http://www.pdflib.com/download/free-software/pdflib-lite-7/

        wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5.tar.gz
        tar zxvf PDFlib-Lite-7.0.5.tar.gz
        cd PDFlib-Lite-7.0.5
        ./configure --prefix=/usr/local/pdflib

        make

        make install

        wget http://www.pdflib.com/binaries/PDFlib/801/PDFlib-8.0.1-Linux-php.tar.gz
        tar zxvf PDFlib-8.0.1-Linux-php.tar.gz

        cp libpdf_php.so /usr/local/php/lib/php/extensions/

        # php.ini 추가
            extension=libpdf_php.so

        # php_info 확인 --> PDFlib 가 보여야함.

        wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-7.0.5-Linux-php.tar.gz
        tar zxvf PDFlib-7.0.5-Linux-php.tar.gz
        cd PDFlib-7.0.5-Linux-php/bind/php5/php-520
        cp libpdf_php.so /usr/local/php/lib/php/extensions/

        # testing
            mkdir -p /usr/local/apache/htdocs/pdftest
            mkdir -p /usr/local/apache/htdocs/pdftest/data

            cp bind/php/*.* /usr/local/apache/htdocs/pdftest
            cp bind/data/* /usr/local/apache/htdocs/pdftest/data

            * 참고 : 복사한 sample 소스에서
                $searchpath = "../data";

                $searchpath = "/usr/local/apache/htdocs/pdftest/data";

    7. JPGraph ( http://www.aditus.nu/jpgraph/jpg_proversion.php )
        컴파일을 통해서 인스톨 하는 컨셉이 아님.
        # 설치 절차
            1. 압축 해제 ( jpgraph-3.0.7.tar.bz2 )
            2. src 폴더를 php inlcude 폴더로 이동
                - php.ini 수정
                    include_path = ".:/usr/local/php/include"

            3. docportal( 메뉴얼 및 샘플 )를 적절한 http documentRoot 아래로 복사
            4. 포튼 문제 발생할경우 --> MS TrueType Fonts on CentOS 5 적용
        # 설치
            1. download & unpack
                wget http://hem.bredband.net/jpgraph2/jpgraph-3.0.7.tar.bz2
                mkdir jpgraph-3.0.7
                mv jpgraph-3.0.7.tar.bz2 ./jpgraph-3.0.7
                cd jpgraph-3.0.7
                tar jxvf jpgraph-3.0.7.tar.bz2

            2. setting
                cp -rf ./src /usr/local/php/include/jpgraph
                cp -rf ./docportal /usr/local/apache/htdocs/jpgraph_doc

            3. test
                * test_jpg.php 생성
                    



                * http://localhost/test_jpg.php
                    Error 발생 : Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist
                        --> MS TrueType Fonts on CentOS 5 수행

# MS TrueType Fonts on CentOS 5 ( Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist )
    1. Install the software needed. You may need the DAG rpm repository to install cabextract - see my "Must-Have Repos" post for details.

        sudo yum install rpm-build cabextract

    2. Download the specs to build the RPM
        wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec

    # yum install cabextract 시 No package cabextract available 에러 발생
        - cabextract 설치 ( http://www.cabextract.org.uk/ : rpm으로 설치해야함 )
            wget  http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm
            rpm -i cabextract-1.2-1.i386.rpm

    3. Build the RPM
        rpmbuild -ba msttcorefonts-2.0-1.spec

    4. Install the RPM
        rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

    To use the fonts with ImageMagick, I also needed to create a link to the font installation folder as follows:
        ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/default/TrueType

        ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/truetype

# mysql What is Innodb Table space ?
    - Myisam은 rollback이 안됨( autocommit ).
   -  innodb는 오라클 처럼 shared tablespace ( ibdataN ) 와 로그파일 (ib_logfileN ) 로 구성됨
      로그파일은 트랜젝션들을 처리하는 오라클의 아카이브 로그 같이 생각 하면 된다.

# mysql Starting MySQL.Manager of pid-file quit without updating fi
    $ service mysqld restart
    MySQL manager or server PID file could not be found!       [실패]
    Starting MySQL.Manager of pid-file quit without updating fi[실패]

    # mysql 설치 초기화
    1. innodb 파일을 삭제한다. ( ibdata1  .. ibdataN )
    2. /usr/local/mysql/bin/mysql_install_db OR /usr/local/mysql/bin/mysql_install_db --user=mysql
    3. chown -R mysql:dba /data/mysql
    4. 변경할 my.cnf로 반영
    5. /usr/local/mysql/bin/mysqld_safe & OR service mysqld start
    6. /usr/local/mysql/bin/mysqladmin -u root password '비밀번호'
    7. mysql 계정 정리 (삭제 조심)
        use mysql;
        delete from user where password = "";
        flush privileges;
        flush tables;

# mysql Shared Table Space 용량 조정
   1. mysqldump로 innodb table을 백업
   2. 서버 중지
   3. innodb 파일 (ibdata1  .. ibdataN) 삭제
   4. my.cnf에서 아래 내용 수정
        innodb_data_file_path=ibdata1:1000M;ibdata2:1000M;ibdata3:1000M:autoextend
   5. 서버 재구동
   6. dump 파일을 import

# mysql 테이블 스페이스 관리
    링크 : http://adminplay.com/board/?_filter=search&mid=Mysql&search_target=title&search_keyword=inno&document_srl=2196
    아직 오라클 같이 Shared Table Space 를 온라인상에서 추가 하기 힘들다.
    오직 my.cnf 환경 파일로 생성이 되고 변경 된다.
    대량의 데이터 베이스 의 경우 3 ~ 4G 이상이 되는경우
    디폴트로 ibdata1:10M:autoextend 를 쓴다면 곤욕을 치르게 될것이다.

    다음과 같이 여러개의 파일을 이용하여 분산 하는 것을 추천 합니다.
    파일은 path을 이용 할수 도 있고 raw 디바이스를 이용 할수도 있습니다.
    /data1 .. /data4 를 각각 다른 디바이스라고 한다면 아래와 같이 사용하면 된다.
    innodb_data_home_dir=
    innodb_data_file_path = /data1/ibdata1:500M;/data2/ibdata2:500M;/data3/ibdata3:500M;/data4/ibdata4:200M:autoextend:max:2000M
    보통 백업을 위해서 오라클의 경우 500MB ~ 1GB로 데이터 파일 을 생성 하였다.
    그리고 200MB는 현재 사용량이 얼마인지 모르기 때문에 200MB -> 300MB가 되면
    다시 환경 파일을 수정하고 데이터 파일을 추가 하기 위한 방법이다.
      그러나 이것도 문제 가 많다는 것을 독자들도 알것이다.
    암튼 아직은 미약한 부분이 많다는 것을 착안 하기 바란다.
    데이처 파일을  500MB ~ 1GB로 생성 하는이유는
    예전에 OS에서 제한이 있어서 그런 적도 있었지만 , 파일이 크면 그 만큼  I/O분산이 안된다.
    그리고 파일당 백업 시간이 증가하거나 문제가 발생 하면  복구도 그만큼  힘들다.
    예로 500MB데이터 파일 하나가 사라진 경우와 1GB 데이터 파일 1개가 사라진 경우
    그안에 속한 데이터의 량은 곱절이 된다.
    즉 재난 을 최소화 하기 위해서라고 1GB이하로 쪼개는 것이 낳기 때문이다.
    그렇다고 3GB 되는 것을 100MB로 쪼개면  어떨까 performance에서  문제가 될것이다.
    그러므로 DBA의 적절한 선태이 필요하다.

# Mysql - InnoDB 사용 가능 상태 확인및 설정 ( http://develop.sunshiny.co.kr/392 )
    참고한출처 : http://www.rootman.co.kr/bbs/zboard.php?id=linux&no=1901
    InnoDB 를 사용 가능한지 확인합니다.

    show variables like 'have_innodb';

    [root@localhost ~]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.1.42-log MySQL Community Server (GPL)

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    ## 사용 가능한 상태
    mysql> show variables like 'have_innodb';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | have_innodb   | YES   |
    +---------------+-------+
    1 row in set (0.56 sec)

    ## 사용 되지 않는 상태
    mysql> show variables like 'have_innodb';
    +---------------+----------+
    | Variable_name | Value    |
    +---------------+----------+
    | have_innodb   | DISABLED |
    +---------------+----------+
    1 row in set (28.87 sec)

    InnoDB는 기본적으로 mysql 설치 시 지원됩니다.

    (1) 만일 초기 세팅 시,
    아예 InnoDB를 제외 시키려면 configuration 시 --without-innodb를 추가하시면 되고,

    (2) 데몬 구동 시 제외시키려면,
    mysqld_safe --skip-innodb 로 구동 시키며,

    (3) my.cnf 에서 제외 처리하려면,
    아래 처럼 skip-innodb를 추가해 주고, 데몬 재시작을 하면 됩니다.

    [mysqld]

    # InnoDB 사용 안할시 아래 내용추가
    skip-innodb

# 방화벽 및 포트 설정(+ SELinux)
    # system-config-firewall
    1. Samba, FTP 등 필요한 서비스 체크

    2. 신뢰하는 인터페이스 eth+ 체크

    3. 원하는 Port Open

    ( Console에서 )
    방화벽 상태 알아보기
    # /sbin/service iptables status
    방화벽 올리고 내리기
    # /sbin/service iptables stop
    # /sbin/service iptables start
    방화벽 설정 수정하기
    # vi /etc/sysconfig/iptables
    방화벽 해제정
    # iptable -F or ipchains -F
    redhat 9.0 이라면 lokkit 으로 방화벽 설정을 할 수도 있습니다.

    ( SELINUX )
    1. 수동으로 끄기 (일시적으로만 먹힘)
    system-config-securitylevel
    setenforce 0

    2. 커널 명령행에 다음 옵션 추가. (grub.conf 등에)
    selinux=0

    3. /etc/selinux/config 파일 수정 ***추천***
    SELINUX=어쩌구~ 써있는 것을 SELINUX=disabled로 수정

# php re-configure
    방법1.
        trobule -->linux "Call to undefined function mysqli_connect"
        1. 서버 중지 및 기존 php모듈 백업
            service httpd stop
            mv /usr/local/apache/modules/libphp5.so /usr/local/apache/modules/libphp5_bak.so

        2. make clear
            make clean
            make clean-dist
            rm -rf ./config.cache

        3. configure
            ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mod --enable-magic-quotes --disable-dmalloc --enable-bcmath --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-gd-native-ttf --enable-ftp --with-jpeg-dir --with-freetype-dir --with-curl --with-zlib --with-gd  --with-ttf --with-iconv --disable-debug --with-pcre-regex=yes
            make
            make install
    방법2.
        # 이것도 되나보군 (안해봄) :: yum install php-mysqli


# php extension so 생성 ( http://gmplib.org/manual/ )
    $ cd cd php-5.2.13/ext/gmp
    $ phpize5 OR phpize
    $ ./configure --enable-gmp
    $ make
    $ make test
    $ make install
    $ Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

    # php.ini 수정
        extension=no-debug-non-zts-20060613/gmp.so


# bin log 관리
    * 3일 이전의 bin log 삭제 ( 아래 명령을 쉘에서 바로 실행하면 된다 )
    mysql -uroot -e "PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 10 DAY);"

    * /etc/my.cnf 설정 - binlog 관련
    log-bin=/home/mysql_log/bin_log/bin # 빈로그 저장 설정 및 저장할 디렉토리 지정
    binlog_cache_size =  2M      # binlog cache 사이즈
    max_binlog_size =  50M        # bin로그 파일 사이즈
    expire_logs_days = 10           # 보관기간


# replication 설정
    #참고 문서
        http://adminplay.com/board/?mid=Mysql&document_srl=3452&sort_index=regdate&order_type=desc
        http://codememo.textcube.com/2
        http://hanaduri.egloos.com/2389708
        http://search.mysql.com/search?q=replication&ie=utf-8&lr=lang_en&x=0&y=0

    # maser setting
        - my.cnf 변경
            server-id = 1       # 1로 셋팅해준다.
            log-bin=mysql-bin   # 원래 앞에 주석(#) 처리가 되어있는데 주석을 삭제한다. 로깅파일명 설정

        - create replication user
            GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%'  IDENTIFIED BY 'replmyuser';
            FLUSH TABLES WITH READ LOCK;
            show master status;
            +-----------------------+----------+--------------+------------------+
            | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
            +-----------------------+----------+--------------+------------------+
            | bin-update-log.000002 |     4625 |              |                  |
            +-----------------------+----------+--------------+------------------+
            1 row in set (0.02 sec)

        - data dump ( slaver쪽에 밀어넣을 데이터로 master,slave가 동일하게하기위해서 백업 )
            /usr/local/mysql/bin/mysqldump -uroot -p --all-databases > all_db(덤프할이름).sql

        - table unlock
            UNLOCK TABLES;

        - mysql restart
            service mysqld restart

    # slave setting
        - data restore
            /usr/local/mysql/bin/mysql -uroot -p < all_db(덤프할이름).sql

        - slave 설정
            - my.cnf 변경 ( 방법1 )
                # replication slave
                master_host=172.17.160.137
                master-user=repl
                master-password=replmyuser
                master-port=3306
                replicate-do-db=test
                server-id=2

            - 명령어로 변경 ( 방법2 )
                stop slave;

                CHANGE MASTER TO
                MASTER_HOST='172.17.160.137',
                MASTER_USER='repl',
                MASTER_PORT=3306,
                MASTER_PASSWORD='replmyuser',
                MASTER_LOG_FILE='mysql-bin.000003', -- 마스터의 상태보기 명령어에서 나온 파일명을 적어준다.
                MASTER_LOG_POS=98
                ;

                flush privileges;
                flush tables;
                show slave status;

        - mysql restart
            service mysqld restart

        - 설정확인
            SHOW SLAVE STATUS;

    # master/slave 설정확인
        - master
            mysql> SHOW PROCESSLIST;
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            | Id | User | Host                | db   | Command     | Time | State                                                          | Info             |
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            |  1 | repl | 172.17.160.141:3055 | NULL | Binlog Dump |  475 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
            |  2 | root | 172.17.160.141:3246 | test | Sleep       |   93 |                                                                | NULL             |
            |  3 | root | localhost           | NULL | Query       |    0 | NULL                                                           | SHOW PROCESSLIST |
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            3 rows in set (0.00 sec)

            mysql> SHOW MASTER STATUS;
            +-----------------------+----------+--------------+------------------+
            | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
            +-----------------------+----------+--------------+------------------+
            | bin-update-log.000008 |      106 |              |                  |
            +-----------------------+----------+--------------+------------------+
            1 row in set (0.00 sec)

        - slave
            mysql> SHOW PROCESSLIST;
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            | Id | User        | Host           | db    | Command | Time | State                                                                 | Info             |
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            |  1 | system user |                | NULL  | Connect | 1515 | Waiting for master to send event                                      | NULL             |
            |  2 | system user |                | NULL  | Connect | 1422 | Has read all relay log; waiting for the slave I/O thread to update it | NULL             |
            |  3 | root        | localhost:2002 | test  | Sleep   |  685 |                                                                       | NULL             |
            |  5 | root        | localhost:3313 | mysql | Query   |    0 | NULL                                                                  | SHOW PROCESSLIST |
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            4 rows in set (0.00 sec)

            mysql> SHOW SLAVE STATUS;
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            | Slave_IO_State                   | Master_Host    | Master_User | Master_Port | Connect_Retry | Master_Log_File       | Read_Master_Log_Pos | Relay_Log_File                | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error                                                                            | Last_SQL_Errno | Last_SQL_Error |
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            | Waiting for master to send event | 172.17.160.137 | repl        |        3306 |            60 | bin-update-log.000008 |                 106 | IT-JihoonKim-relay-bin.000017 |           256 | bin-update-log.000008 | Yes              | Yes               | test,tkkorea    |                     |                    |                        |                         |                             |          0 |            |            0 |                 106 |             568 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |          2003 | error reconnecting to master 'repl@172.17.160.137:3306' - retry-time: 60  retries: 86400 |              0 |                |
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            1 row in set (0.00 sec)

    # test
        1. master / slave 에 테이블생성
            CREATE TABLE `repli_test` (
                `f1` VARCHAR(10) NULL DEFAULT NULL
            )
            ENGINE=InnoDB
            ROW_FORMAT=DEFAULT

        2. mysql restart

        3. master
            insert into `repli_test` ( f1 ) values ('1');

        4. slave ( 데이터 입력 확인 )
            select * from `repli_test`;


# 양방향 동기화 처리
    Master서버에서 Slave도 구현하고자 한다면 다음과 같은 방법으로 처리
    1. 현재 Slave서버에 replication 계정 생성
    2. 현재 Slave의 my.ini 변 경
    log-bin=mysql-bin 추가
    3. 현재 SLAVE 서버 데몬 재시작
    4. 현재 Master의 my.ini 변경
    replicate-do-db=’database name’추가
    4. 현재 Master에서 CHANGE MASTER TO 실행
    5. 현재 Master 서버 데몬 재시작

# slave replication 정지/ 시작
    mysql> stop slave
    mysql> start slave

    - 참고
        MySQL 데몬(서비스)를 재 시작하면 slave는 자동으로 시작된다.
        (my.ini에 옵션 skip-slave-start이 있으면 자동 시작 안한다.)


# 참고
    http://srue.net/80                                          apache
    http://guni.loveyust.net/124                                mysql
    http://piki.thoth.kr/?mid=blog&document_srl=807396          php,zend,eAccelerator
    http://www.ezcomponents.org/overview/requirements#pcre      php Requirements
    http://hyosub.net/21                                        eaccelerator
    http://eaccelerator.net/wiki/Settings                       eaccelerator Setting
    http://krnjevic.com/wp/?p=174                               MS TrueType Fonts on CentOS 5
        http://www.cabextract.org.uk/                           cabextract

    mysql setting
        http://adminplay.com/board/?mid=Mysql&document_srl=2196&sort_index=regdate&order_type=desc
        http://radiocom.kunsan.ac.kr/lecture/mysql/table_innodb.html
        http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html
        http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html#sysvar_innodb_log_arch_dir

    http://aesops.tistory.com/18                                firewall

    mysql replication
        http://adminplay.com/board/?mid=Mysql&document_srl=3452&sort_index=regdate&order_type=desc
        http://codememo.textcube.com/2
        http://hanaduri.egloos.com/2389708
        http://search.mysql.com/search?q=replication&ie=utf-8&lr=lang_en&x=0&y=0

1. centOS설치
    1. CentOS 5.3 DVD 를 이용해서 아나콘다 모드로 install
    2. 파티셔닝
        /home : 40G
        /boot : 10M
        SWAP  : 1G
        /     : 나머지
    3. ssh, ftp 등 기본 설치
    4. myuser (myuser1234) 유저 생성 (시스템계정)

    # hostname변경
        /etc/hosts
        /etc/sysconfig/network

        그래도 안되면 여기 변경

        echo "호스트명" > /proc/sys/kernel/hostname

        /proc/sys/kernel/hostname

    # prompt(프롬프트) 변경
        vi .bash_profile
        export PS1="\e[1;37m[\e[36m\D{%Y-%m-%d %H:%M:%S}\e[37m] \
        [\e[32m\u\e[31m@\e[33m\h\e[37m] \e[34m\w\e[m\n\$ "
        source /etc/sysconfig/i18n

2. 설치 확인 & 제거 ( mysql )
    rpm -qa httdd php mysql
    yum remove -y httpd php mysql

3. 설치 준비
    /root/src/APM 디렉토리 생성
    mkdir src
    cd src
    mkdir APM
    cd APM

4. Download
    1. Apache
        다운로드 링크 확인 : ftp.kasit.ac.kr 접속 Apache/httpd 버전및 링크 주소확인
        wget http://ftp.kaist.ac.kr/pub/Apache/httpd/httpd-2.2.15.tar.gz

    2. php
        - 다운로드 링크 확인 : http://kr2.php.net/downloads.php
        wget http://kr2.php.net/get/php-5.2.13.tar.gz/from/this/mirror

    3. mysql ( 대만이 빠르군요 )
        - 다운로드 링크 확인 : http://dev.mysql.com/downloads/mysql/5.1.html#downloads
            Generally Available (GA) Releases - Select Platform - Source Code선택
            맨아래 Generic Linux (Architecture Independent), Compressed TAR Archive

        wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-5.1/mysql-5.1.46.tar.gz

5. 라이브러리, 컴파일러 확인 및 설치
    rpm -qa gcc* cpp* compat-gcc* flex*

    yum -y install gcc cpp gcc-c++ compat-gcc-32-g77 flex

    rpm -qa libjpeg* libpng* freetype* gd-*

    yum install libjpeg-devel libpng-devel freetype-devel gd-devel
    yum install openssl

    yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel pspell-devel net-snmp-devel


6. Install
    * Apache
        tar zxvf httpd-2.2.15.tar.gz
        ./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so --enable-php --enable-apache --enable-ssl --enable-modules=ssl --enable-rewrite --with-mpm=prefork --with-mcrypt=/usr/local

        * 참고
            --prefix=설치 경로
            --enable-module=so 는 tomcat 연동이나 다른 연동시 필요하므로 꼭 추가.
        make
        make install

        # httpd.conf 수정
            - ServerName 수정
            - UTF-8 설정 추가
                AddDefaultCharset UTF-8
                AddCharset UTF-8       .utf8

                
                    DirectoryIndex index.html
                
                - ▼ 변경 ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ -
                
                    DirectoryIndex index.html index.htm index.php index.php3
                    AddType application/x-httpd-php .php .phtml
                    AddType application/x-httpd-source .phps
                

            - config test
                service httpd configtest

        # 서비스 등록하기
            cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

            vi /etc/init.d/httpd

            !bin/sh 밑에 아래 내용을 넣는다.

            # chkconfig: - 92 92
            # description: Apache Web Server Version 2.2.11

            chmod 755 /etc/rc.d/init.d/httpd
            chkconfig --add httpd
            chkconfig --level 2345 httpd on

            service httpd start

            ntsysv : 서비스 등록여부는 확인 명령어

            http://localhost



    2. mysql 설치
        tar zxvf mysql-5.1.46.tar.gz
        ./configure --prefix=/usr/local/mysql --with-charset=utf8 --enable-large-files --localstatedir=/data/mysql --sysconfdir=/etc --with-readline --with-extra-charsets=all --with-innodb --disable-shared --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --without-debug --without-docs

            --prefix=/usr/local/mysql   : 설치디렉ㅌ토리
            --with-charset=utf8         : charset
            --localstatedir=/data/mysql : mysql 데이터 파일 저장

            --with-innodb               : innoDB를 사용
            --with-mysqld-user=mysql    : mysql실행 유저
            --with-unix-socket-path=/var/lib/mysql/mysql.sock  : 소켓파일의 위치 tcp/ip대신 유닉스 소켓을 이용함.
            --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
                                        : 컴파일 옵션으로 'CXX=gcc'를 사용할 때 오류를 피하기 위해 공유 라이브러리를 사용하지 않음
                                          실행 성능을 높일 수 있다.
            --without-debug             : 질의시 디버깅 코드를 사용하지 않기 때문에 빠른 속도를 얻어낼 수 있다.

        make

        make install

        # 사용자및 권한설정 ( 1 )
            groupadd dba
            useradd -M -o -r -d /usr/local/mysql -s /sbin/nologin -c "Mysql Server" -u 27 -g dba mysql >/dev/null 2>&1 || :

            mkdir /data/mysql

            /usr/local/mysql/bin/mysql_install_db

            chown -R mysql:dba /data/mysql

            /usr/local/mysql/bin/mysqld_safe &

            /usr/local/mysql/bin/mysqladmin -u root password 'myuser'

        # 서비스 등록
            cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
            chkconfig --add mysqld
            chkconfig --level 35 mysqld on (런레벨 35일때 자동 실행 된다)

        # 비밀번호 없는 유저 삭제
            use mysql;
            delete from user where password = "";
            flush privileges;
            flush tables;

        # 사용자및 권한설정 ( 2 )
            chown -R root:dba /usr/local/mysql
            chown -R mysql:dba -R /var/lib/mysql

        #. mysql path 설정
            PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

        # setting
            cp my-huge.cnf /etc/my.cnf
            vi my.cnf

    3. php 설치
        # 컴파일전에 깔아줘야할 라이브러리입니다.
            yum install libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel gmp-devel mysql-devel ncurses-devel unixODBC-devel pspell-devel net-snmp-devel
        # List of core configure options
        http://kr.php.net/manual/en/configure.about.php

        ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mod --enable-magic-quotes --disable-dmalloc --enable-bcmath --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-gd-native-ttf --enable-ftp --with-jpeg-dir --with-freetype-dir --with-curl --with-zlib --with-gd  --with-ttf --with-iconv --disable-debug --with-pcre-regex=yes

        make

        make install

        cp php.ini-dist /usr/local/apache/conf/php.ini

        service httpd restart

        # Cannot load /usr/local/apache/modules/libphp5.so into server 에러 발생
            /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server:
            /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

            1. vi /etc/sysconfig/selinux 변경
                vi /etc/sysconfig/selinux
                SELINUX=enforcing --> SELINUX=disabled
                리붓

            2. selinux 보안정책을 적용
                /sbin/restorecon -R -v /usr/local/apache/modules/libphp5.so
                /usr/bin/chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so

        # php path 설정
            PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin

        # /etc/php.ini setting
            mbstring.func_overload = 7
            mbstring.internal_encoding = UTF-8
            mbstring.http_output = UTF-8

    4. Zend Optimizer
        # 설치 절차
            1. 다운받은 ZendOptimizer를 압축을풀고.
            2. 서버에 깔린 PHP 버전에 맞는 디렉토리로 들어간후
            3. 파일한개를 특정경로에 복사하고 (cp ZendOptimizer.so /usr/lib/httpd/modules/ )
            4. php.ini 설정에 해당 경로를 넣어주고
            5. httpd 를 재시작.

        wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
        tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
        cd ZendOptimizer-3.3.9-linux-glibc23-i386/data

        ls
        4_2_0_comp  4_3_x_comp  5_0_x_comp  5_2_x_comp
        4_2_x_comp  4_4_x_comp  5_1_x_comp  poweredbyoptimizer.gif
        cd 5_2_x_comp ( php 버전에 맞는 디렉토리로 이동 )

        ls
        ZendOptimizer.so ( 학인 )

        php -v

        copy ZendOptimizer.so /usr/local/apache/modules/

        # php.ini 추가
            [Zend]
            zend_optimizer.version=3.3.9
            Zend_extension=/usr/local/apache/modules/ZendOptimizer.so

        php -v ( 에러 발생 php 모듈 인식시 발생한 에러와 유사함. )
        Failed loading /usr/local/apache/modules/ZendOptimizer.so:  /usr/local/apache/modules/ZendOptimizer.o: cannot restore segment prot after reloc: Permission denied
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

        chcon -t texrel_shlib_t /usr/local/apache/modules/ZendOptimizer.so

        php -v ( 에러 없음 )
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
            with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

    5. eAccelerator
        # eAccelerator 다운로드 (홈페이지 : http://eaccelerator.net)
            wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6.tar.bz2 ( 0.9.6 설치는 되나, Call to undefined function eaccelerator_put  에러 발생 )
                                                                                      ( Call to undefined function eaccelerator_put ::> -with-eaccelerator-shared-memory )

            wget http://bart.eaccelerator.net/source/0.9.5.2/eaccelerator-0.9.5.2.tar.bz2

        tar jxvf eaccelerator-0.9.5.2.tar.bz2
        cd eaccelerator-0.9.5.2

        phpize ( 이거 꼭 해줘야함 모지 디렉토리에 configure 없다가 생기넹 )

        ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config --with-eaccelerator-shared-memory
        ( README 파일 읽어보면 자세히 나옴 )

        make

        make install
        Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

        mkdir -p /data/eaccelerator

        chmod 700 /data/eaccelerator

        # php.ini 수정
            extension_dir = "/usr/local/php/lib/php/extensions"

            [eAccelerator]
            extension="no-debug-non-zts-20060613/eaccelerator.so"
            eaccelerator.shm_size="16"
            eaccelerator.cache_dir="/data/eaccelerator"
            eaccelerator.enable="1"
            eaccelerator.optimizer="1"
            eaccelerator.check_mtime="1"
            eaccelerator.debug="0"
            eaccelerator.filter=""
            eaccelerator.shm_max="0"
            eaccelerator.shm_ttl="0"
            eaccelerator.shm_prune_period="0"
            eaccelerator.shm_only="0"
            eaccelerator.compress="1"
            eaccelerator.compress_level="9"

            eaccelerator.allowed_admin_path="/usr/local/apache/htdocs/eaccelerator"
            ; eaccelerator.admin.name="admin"
            ; eaccelerator.admin.password="myuser"

            # 참고
               - eaccelerator.shm_size   = eAccelerator가 사용할 공유 메모리량. 단위 MBytes.
                 0을 지정하면 OS 기본값. default = 0
               - eaccelerator.cache_dir  = 캐싱 디렉토리를 지정. precompiled code, session data, content
                 등이 저장된다.
               - eaccelerator.enable     = eAccelerator 사용 여부. 당연히 1
               - eaccelerator.optimizer  = 최적화 여부. 1= enable, 0 = disable
               - eaccelerator.check_mtime= php 파일 변경시간을 체크하여 반영할 것인지 여부
               - eaccelerator.debug      = debug 로깅 여부
               - eaccelerator.filter     = 캐싱할 php 파일을 지정한다. *.php *.html *.php3 처럼 지정할 수
                 있으며 "" 로 비워두면 모든 php 파일이 캐싱된다.

               - eaccelerator.shm_max    = eaccelerator_put() 함수 사용할 때 최대 할당할 수 있는 공유
                 메모리 크기를 bytes단위로 표시한다. (예. 10240, 10K, 1M).  0은 제한 없음
                 eaccelerator_put() 함수는 공유메모리에 특정 데이터를 지정한 시간동안 넣어두는
                 eAccelerator 자체함수이다.
               - eaccelerator.shm_ttl    = 새 스크립트 파일을 캐싱할만한 공유 메모리가 없다면,
                 ssh_ttl 초동안 액세스가 없는 모든 스크립트를 삭제한다. default = 0. 0은 삭제안함을 의미
               - eaccelerator.shm_prune_period= 이 설정은 위의 shm_ttl 설정과 비슷하다.
                 지정한 초보다 오래전에 만들어진 스크립트를 제거한다.
                 즉, shm_ttl은 액세스시간에, shm_prune_period는 생성시간에 따라 삭제한다.
                 default = 0. 0은 삭제안함을 의미
               - eaccelerator.shm_only   = 컴파일된 스크립트를 디스크에 캐싱할 것인지 여부.
                 session data와 content 캐싱은 이설정과 무관. default = 0.
                 0이면 캐싱을 위해 디스크와 메모리를 모두 사용한다.

               - eaccelerator.compress = 캐시된 내용 압축 여부
               - eaccelerator.compress_level= 압축 레벨 지정. 9는 최대 압축 레벨


        $ php -v
        PHP 5.2.13 (cli) (built: May 18 2010 09:38:43)
        Copyright (c) 1997-2010 The PHP Group
        Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
            with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
            with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

        service httpd restart

        # Control panel 설정하기 ( 웹관리 도구 )
            mkdir /usr/local/apache/htdocs/eaccelerator
            cp [source directory]/*.php /usr/local/apache/htdocs/eaccelerator

            http://localhost/eaccelerator/control.php

    6. PDFlib
        http://www.pdflib.com/
        --> http://www.pdflib.com/download/free-software/pdflib-lite-7/

        wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5.tar.gz
        tar zxvf PDFlib-Lite-7.0.5.tar.gz
        cd PDFlib-Lite-7.0.5
        ./configure --prefix=/usr/local/pdflib

        make

        make install

        wget http://www.pdflib.com/binaries/PDFlib/801/PDFlib-8.0.1-Linux-php.tar.gz
        tar zxvf PDFlib-8.0.1-Linux-php.tar.gz

        cp libpdf_php.so /usr/local/php/lib/php/extensions/

        # php.ini 추가
            extension=libpdf_php.so

        # php_info 확인 --> PDFlib 가 보여야함.

        wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-7.0.5-Linux-php.tar.gz
        tar zxvf PDFlib-7.0.5-Linux-php.tar.gz
        cd PDFlib-7.0.5-Linux-php/bind/php5/php-520
        cp libpdf_php.so /usr/local/php/lib/php/extensions/

        # testing
            mkdir -p /usr/local/apache/htdocs/pdftest
            mkdir -p /usr/local/apache/htdocs/pdftest/data

            cp bind/php/*.* /usr/local/apache/htdocs/pdftest
            cp bind/data/* /usr/local/apache/htdocs/pdftest/data

            * 참고 : 복사한 sample 소스에서
                $searchpath = "../data";

                $searchpath = "/usr/local/apache/htdocs/pdftest/data";

    7. JPGraph ( http://www.aditus.nu/jpgraph/jpg_proversion.php )
        컴파일을 통해서 인스톨 하는 컨셉이 아님.
        # 설치 절차
            1. 압축 해제 ( jpgraph-3.0.7.tar.bz2 )
            2. src 폴더를 php inlcude 폴더로 이동
                - php.ini 수정
                    include_path = ".:/usr/local/php/include"

            3. docportal( 메뉴얼 및 샘플 )를 적절한 http documentRoot 아래로 복사
            4. 포튼 문제 발생할경우 --> MS TrueType Fonts on CentOS 5 적용
        # 설치
            1. download & unpack
                wget http://hem.bredband.net/jpgraph2/jpgraph-3.0.7.tar.bz2
                mkdir jpgraph-3.0.7
                mv jpgraph-3.0.7.tar.bz2 ./jpgraph-3.0.7
                cd jpgraph-3.0.7
                tar jxvf jpgraph-3.0.7.tar.bz2

            2. setting
                cp -rf ./src /usr/local/php/include/jpgraph
                cp -rf ./docportal /usr/local/apache/htdocs/jpgraph_doc

            3. test
                * test_jpg.php 생성
                    

                * http://localhost/test_jpg.php
                    Error 발생 : Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist
                        --> MS TrueType Fonts on CentOS 5 수행

# MS TrueType Fonts on CentOS 5 ( Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist )
    1. Install the software needed. You may need the DAG rpm repository to install cabextract - see my "Must-Have Repos" post for details.

        sudo yum install rpm-build cabextract

    2. Download the specs to build the RPM
        wget http://corefonts.sourceforge.net/msttcorefonts-2.0-1.spec

    # yum install cabextract 시 No package cabextract available 에러 발생
        - cabextract 설치 ( http://www.cabextract.org.uk/ : rpm으로 설치해야함 )
            wget  http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm
            rpm -i cabextract-1.2-1.i386.rpm

    3. Build the RPM
        rpmbuild -ba msttcorefonts-2.0-1.spec

    4. Install the RPM
        rpm -ivh /usr/src/redhat/RPMS/noarch/msttcorefonts-2.0-1.noarch.rpm

    To use the fonts with ImageMagick, I also needed to create a link to the font installation folder as follows:
        ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/default/TrueType

        ln -s /usr/share/fonts/msttcorefonts/ /usr/share/fonts/truetype

# mysql What is Innodb Table space ?
    - Myisam은 rollback이 안됨( autocommit ).
   -  innodb는 오라클 처럼 shared tablespace ( ibdataN ) 와 로그파일 (ib_logfileN ) 로 구성됨
      로그파일은 트랜젝션들을 처리하는 오라클의 아카이브 로그 같이 생각 하면 된다.

# mysql Starting MySQL.Manager of pid-file quit without updating fi
    $ service mysqld restart
    MySQL manager or server PID file could not be found!       [실패]
    Starting MySQL.Manager of pid-file quit without updating fi[실패]

    # mysql 설치 초기화
    1. innodb 파일을 삭제한다. ( ibdata1  .. ibdataN )
    2. /usr/local/mysql/bin/mysql_install_db OR /usr/local/mysql/bin/mysql_install_db --user=mysql
    3. chown -R mysql:dba /data/mysql
    4. 변경할 my.cnf로 반영
    5. /usr/local/mysql/bin/mysqld_safe & OR service mysqld start
    6. /usr/local/mysql/bin/mysqladmin -u root password '비밀번호'
    7. mysql 계정 정리 (삭제 조심)
        use mysql;
        delete from user where password = "";
        flush privileges;
        flush tables;

# mysql Shared Table Space 용량 조정
   1. mysqldump로 innodb table을 백업
   2. 서버 중지
   3. innodb 파일 (ibdata1  .. ibdataN) 삭제
   4. my.cnf에서 아래 내용 수정
        innodb_data_file_path=ibdata1:1000M;ibdata2:1000M;ibdata3:1000M:autoextend
   5. 서버 재구동
   6. dump 파일을 import

# mysql 테이블 스페이스 관리
    링크 : http://adminplay.com/board/?_filter=search&mid=Mysql&search_target=title&search_keyword=inno&document_srl=2196
    아직 오라클 같이 Shared Table Space 를 온라인상에서 추가 하기 힘들다.
    오직 my.cnf 환경 파일로 생성이 되고 변경 된다.
    대량의 데이터 베이스 의 경우 3 ~ 4G 이상이 되는경우
    디폴트로 ibdata1:10M:autoextend 를 쓴다면 곤욕을 치르게 될것이다.

    다음과 같이 여러개의 파일을 이용하여 분산 하는 것을 추천 합니다.
    파일은 path을 이용 할수 도 있고 raw 디바이스를 이용 할수도 있습니다.
    /data1 .. /data4 를 각각 다른 디바이스라고 한다면 아래와 같이 사용하면 된다.
    innodb_data_home_dir=
    innodb_data_file_path = /data1/ibdata1:500M;/data2/ibdata2:500M;/data3/ibdata3:500M;/data4/ibdata4:200M:autoextend:max:2000M
    보통 백업을 위해서 오라클의 경우 500MB ~ 1GB로 데이터 파일 을 생성 하였다.
    그리고 200MB는 현재 사용량이 얼마인지 모르기 때문에 200MB -> 300MB가 되면
    다시 환경 파일을 수정하고 데이터 파일을 추가 하기 위한 방법이다.
      그러나 이것도 문제 가 많다는 것을 독자들도 알것이다.
    암튼 아직은 미약한 부분이 많다는 것을 착안 하기 바란다.
    데이처 파일을  500MB ~ 1GB로 생성 하는이유는
    예전에 OS에서 제한이 있어서 그런 적도 있었지만 , 파일이 크면 그 만큼  I/O분산이 안된다.
    그리고 파일당 백업 시간이 증가하거나 문제가 발생 하면  복구도 그만큼  힘들다.
    예로 500MB데이터 파일 하나가 사라진 경우와 1GB 데이터 파일 1개가 사라진 경우
    그안에 속한 데이터의 량은 곱절이 된다.
    즉 재난 을 최소화 하기 위해서라고 1GB이하로 쪼개는 것이 낳기 때문이다.
    그렇다고 3GB 되는 것을 100MB로 쪼개면  어떨까 performance에서  문제가 될것이다.
    그러므로 DBA의 적절한 선태이 필요하다.

# Mysql - InnoDB 사용 가능 상태 확인및 설정 ( http://develop.sunshiny.co.kr/392 )
    참고한출처 : http://www.rootman.co.kr/bbs/zboard.php?id=linux&no=1901
    InnoDB 를 사용 가능한지 확인합니다.

    show variables like 'have_innodb';

    [root@localhost ~]# mysql
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 2
    Server version: 5.1.42-log MySQL Community Server (GPL)

    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

    ## 사용 가능한 상태
    mysql> show variables like 'have_innodb';
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | have_innodb   | YES   |
    +---------------+-------+
    1 row in set (0.56 sec)

    ## 사용 되지 않는 상태
    mysql> show variables like 'have_innodb';
    +---------------+----------+
    | Variable_name | Value    |
    +---------------+----------+
    | have_innodb   | DISABLED |
    +---------------+----------+
    1 row in set (28.87 sec)

    InnoDB는 기본적으로 mysql 설치 시 지원됩니다.

    (1) 만일 초기 세팅 시,
    아예 InnoDB를 제외 시키려면 configuration 시 --without-innodb를 추가하시면 되고,

    (2) 데몬 구동 시 제외시키려면,
    mysqld_safe --skip-innodb 로 구동 시키며,

    (3) my.cnf 에서 제외 처리하려면,
    아래 처럼 skip-innodb를 추가해 주고, 데몬 재시작을 하면 됩니다.

    [mysqld]

    # InnoDB 사용 안할시 아래 내용추가
    skip-innodb

# 방화벽 및 포트 설정(+ SELinux)
    # system-config-firewall
    1. Samba, FTP 등 필요한 서비스 체크

    2. 신뢰하는 인터페이스 eth+ 체크

    3. 원하는 Port Open

    ( Console에서 )
    방화벽 상태 알아보기
    # /sbin/service iptables status
    방화벽 올리고 내리기
    # /sbin/service iptables stop
    # /sbin/service iptables start
    방화벽 설정 수정하기
    # vi /etc/sysconfig/iptables
    방화벽 해제정
    # iptable -F or ipchains -F
    redhat 9.0 이라면 lokkit 으로 방화벽 설정을 할 수도 있습니다.

    ( SELINUX )
    1. 수동으로 끄기 (일시적으로만 먹힘)
    system-config-securitylevel
    setenforce 0

    2. 커널 명령행에 다음 옵션 추가. (grub.conf 등에)
    selinux=0

    3. /etc/selinux/config 파일 수정 ***추천***
    SELINUX=어쩌구~ 써있는 것을 SELINUX=disabled로 수정

# php re-configure
    방법1.
        trobule -->linux "Call to undefined function mysqli_connect"
        1. 서버 중지 및 기존 php모듈 백업
            service httpd stop
            mv /usr/local/apache/modules/libphp5.so /usr/local/apache/modules/libphp5_bak.so

        2. make clear
            make clean
            make clean-dist
            rm -rf ./config.cache

        3. configure
            ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-safe-mod --enable-magic-quotes --disable-dmalloc --enable-bcmath --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbstring --enable-mbregex --enable-gd-native-ttf --enable-ftp --with-jpeg-dir --with-freetype-dir --with-curl --with-zlib --with-gd  --with-ttf --with-iconv --disable-debug --with-pcre-regex=yes
            make
            make install
    방법2.
        # 이것도 되나보군 (안해봄) :: yum install php-mysqli


# php extension so 생성 ( http://gmplib.org/manual/ )
    $ cd cd php-5.2.13/ext/gmp
    $ phpize5 OR phpize
    $ ./configure --enable-gmp
    $ make
    $ make test
    $ make install
    $ Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

    # php.ini 수정
        extension=no-debug-non-zts-20060613/gmp.so


# bin log 관리
    * 3일 이전의 bin log 삭제 ( 아래 명령을 쉘에서 바로 실행하면 된다 )
    mysql -uroot -e "PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 10 DAY);"

    * /etc/my.cnf 설정 - binlog 관련
    log-bin=/home/mysql_log/bin_log/bin # 빈로그 저장 설정 및 저장할 디렉토리 지정
    binlog_cache_size =  2M      # binlog cache 사이즈
    max_binlog_size =  50M        # bin로그 파일 사이즈
    expire_logs_days = 10           # 보관기간


# replication 설정
    #참고 문서
        http://adminplay.com/board/?mid=Mysql&document_srl=3452&sort_index=regdate&order_type=desc
        http://codememo.textcube.com/2
        http://hanaduri.egloos.com/2389708
        http://search.mysql.com/search?q=replication&ie=utf-8&lr=lang_en&x=0&y=0

    # maser setting
        - my.cnf 변경
            server-id = 1       # 1로 셋팅해준다.
            log-bin=mysql-bin   # 원래 앞에 주석(#) 처리가 되어있는데 주석을 삭제한다. 로깅파일명 설정

        - create replication user
            GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%'  IDENTIFIED BY 'replmyuser';
            FLUSH TABLES WITH READ LOCK;
            show master status;
            +-----------------------+----------+--------------+------------------+
            | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
            +-----------------------+----------+--------------+------------------+
            | bin-update-log.000002 |     4625 |              |                  |
            +-----------------------+----------+--------------+------------------+
            1 row in set (0.02 sec)

        - data dump ( slaver쪽에 밀어넣을 데이터로 master,slave가 동일하게하기위해서 백업 )
            /usr/local/mysql/bin/mysqldump -uroot -p --all-databases > all_db(덤프할이름).sql

        - table unlock
            UNLOCK TABLES;

        - mysql restart
            service mysqld restart

    # slave setting
        - data restore
            /usr/local/mysql/bin/mysql -uroot -p < all_db(덤프할이름).sql

        - slave 설정
            - my.cnf 변경 ( 방법1 )
                # replication slave
                master_host=192.168.10.19
                master-user=repl
                master-password=replmyuser
                master-port=3306
                replicate-do-db=test
                server-id=2

            - 명령어로 변경 ( 방법2 )
                stop slave;

                CHANGE MASTER TO
                MASTER_HOST='192.168.10.19',
                MASTER_USER='repl',
                MASTER_PORT=3306,
                MASTER_PASSWORD='replmyuser',
                MASTER_LOG_FILE='mysql-bin.000003', -- 마스터의 상태보기 명령어에서 나온 파일명을 적어준다.
                MASTER_LOG_POS=98
                ;

                flush privileges;
                flush tables;
                show slave status;

        - mysql restart
            service mysqld restart

        - 설정확인
            SHOW SLAVE STATUS;

    # master/slave 설정확인
        - master
            mysql> SHOW PROCESSLIST;
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            | Id | User | Host                | db   | Command     | Time | State                                                          | Info             |
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            |  1 | repl | 172.17.160.141:3055 | NULL | Binlog Dump |  475 | Has sent all binlog to slave; waiting for binlog to be updated | NULL             |
            |  2 | root | 172.17.160.141:3246 | test | Sleep       |   93 |                                                                | NULL             |
            |  3 | root | localhost           | NULL | Query       |    0 | NULL                                                           | SHOW PROCESSLIST |
            +----+------+---------------------+------+-------------+------+----------------------------------------------------------------+------------------+
            3 rows in set (0.00 sec)

            mysql> SHOW MASTER STATUS;
            +-----------------------+----------+--------------+------------------+
            | File                  | Position | Binlog_Do_DB | Binlog_Ignore_DB |
            +-----------------------+----------+--------------+------------------+
            | bin-update-log.000008 |      106 |              |                  |
            +-----------------------+----------+--------------+------------------+
            1 row in set (0.00 sec)

        - slave
            mysql> SHOW PROCESSLIST;
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            | Id | User        | Host           | db    | Command | Time | State                                                                 | Info             |
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            |  1 | system user |                | NULL  | Connect | 1515 | Waiting for master to send event                                      | NULL             |
            |  2 | system user |                | NULL  | Connect | 1422 | Has read all relay log; waiting for the slave I/O thread to update it | NULL             |
            |  3 | root        | localhost:2002 | test  | Sleep   |  685 |                                                                       | NULL             |
            |  5 | root        | localhost:3313 | mysql | Query   |    0 | NULL                                                                  | SHOW PROCESSLIST |
            +----+-------------+----------------+-------+---------+------+-----------------------------------------------------------------------+------------------+
            4 rows in set (0.00 sec)

            mysql> SHOW SLAVE STATUS;
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            | Slave_IO_State                   | Master_Host    | Master_User | Master_Port | Connect_Retry | Master_Log_File       | Read_Master_Log_Pos | Relay_Log_File                | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error                                                                            | Last_SQL_Errno | Last_SQL_Error |
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            | Waiting for master to send event | 192.168.10.19 | repl        |        3306 |            60 | bin-update-log.000008 |                 106 | IT-JihoonKim-relay-bin.000017 |           256 | bin-update-log.000008 | Yes              | Yes               | test,mydb    |                     |                    |                        |                         |                             |          0 |            |            0 |                 106 |             568 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |          2003 | error reconnecting to master 'repl@192.168.10.19:3306' - retry-time: 60  retries: 86400 |              0 |                |
            +----------------------------------+----------------+-------------+-------------+---------------+-----------------------+---------------------+-------------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+------------------------------------------------------------------------------------------+----------------+----------------+
            1 row in set (0.00 sec)

    # test
        1. master / slave 에 테이블생성
            CREATE TABLE `repli_test` (
                `f1` VARCHAR(10) NULL DEFAULT NULL
            )
            ENGINE=InnoDB
            ROW_FORMAT=DEFAULT

        2. mysql restart

        3. master
            insert into `repli_test` ( f1 ) values ('1');

        4. slave ( 데이터 입력 확인 )
            select * from `repli_test`;


# 양방향 동기화 처리
    Master서버에서 Slave도 구현하고자 한다면 다음과 같은 방법으로 처리
    1. 현재 Slave서버에 replication 계정 생성
    2. 현재 Slave의 my.ini 변 경
    log-bin=mysql-bin 추가
    3. 현재 SLAVE 서버 데몬 재시작
    4. 현재 Master의 my.ini 변경
    replicate-do-db=’database name’추가
    4. 현재 Master에서 CHANGE MASTER TO 실행
    5. 현재 Master 서버 데몬 재시작

# slave replication 정지/ 시작
    mysql> stop slave
    mysql> start slave

    - 참고
        MySQL 데몬(서비스)를 재 시작하면 slave는 자동으로 시작된다.
        (my.ini에 옵션 skip-slave-start이 있으면 자동 시작 안한다.)


# 참고
    http://srue.net/80                                          apache
    http://guni.loveyust.net/124                                mysql
    http://piki.thoth.kr/?mid=blog&document_srl=807396          php,zend,eAccelerator
    http://www.ezcomponents.org/overview/requirements#pcre      php Requirements
    http://hyosub.net/21                                        eaccelerator
    http://eaccelerator.net/wiki/Settings                       eaccelerator Setting
    http://krnjevic.com/wp/?p=174                               MS TrueType Fonts on CentOS 5
        http://www.cabextract.org.uk/                           cabextract

    mysql setting
        http://adminplay.com/board/?mid=Mysql&document_srl=2196&sort_index=regdate&order_type=desc
        http://radiocom.kunsan.ac.kr/lecture/mysql/table_innodb.html
        http://dev.mysql.com/doc/refman/5.0/en/innodb-configuration.html
        http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html#sysvar_innodb_log_arch_dir

    http://aesops.tistory.com/18                                firewall

    mysql replication
        http://adminplay.com/board/?mid=Mysql&document_srl=3452&sort_index=regdate&order_type=desc
        http://codememo.textcube.com/2
        http://hanaduri.egloos.com/2389708
        http://search.mysql.com/search?q=replication&ie=utf-8&lr=lang_en&x=0&y=0

'web > server' 카테고리의 다른 글

사이트관리  (0) 2019.07.16
linux_서버관리  (0) 2019.07.16
curl  (0) 2019.07.16
AWS  (0) 2019.01.30
로봇배제 표준(robots.txt)  (0) 2014.05.07

댓글