오늘은 그동안 궁금했던

MYSQL 의 날짜 비교에 대하여 대량데이터를 기반으로 작성해본다.


DATETIME 형태와  Unix time을 int 형태로 디비에 저장하고,

속도 비교를 해본다.


먼저 대량 데이터를 만들기 위해서,

간단히 PHP Script 로 데이터를 생성 하였다.


1억건 이상의 데이터를 만들기 위해서

초당5건씩 1년치 데이터를 생성해 보았다.

5 * 3600sec * 24h * 365day = 157,680,000 (약 1.5억건)



MariaDB [performance_test]> LOAD DATA LOCAL INFILE '/root/testdata.txt'

    -> REPLACE INTO TABLE performance_test

    -> CHARACTER SET utf8

    -> FIELDS

    ->     TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'

    -> LINES

    ->     TERMINATED BY '\n'

    -> IGNORE 1 LINES;

Stage: 2 of 2 'End bulk insert'      0% of stage done


Query OK, 66060000 rows affected, 65535 warnings (23 min 57.18 sec)

Records: 66060000  Deleted: 0  Skipped: 0  Warnings: 66060000

 


엇. 그런데 6.6천만건만 들어갓다..;;

데이터가 잘못 만들어진것 같다.


뭐 어찌 됫건, 6천만건도 적은 데이터는 아니기 때문에, 그냥 6천만건으로 진행 해본다.


참고로 PHP로 Raw data file 를 생성하는데 이 데이터를 생성하는것도 싱글프로세스로 하게 되면,

상당히 오랜 시간이 걸리기 때문에 fork를 이용해서 멀티 쓰레드로 구현해봤다.

(참고로 fork는 Unix/Linux 계열에서만 지원하는 것이기 때문에 윈도우php에서는 안될것이다.)


검색하다가 CPU 갯수만큼 쓰래드를 생성시켜서 돌리는 소스를 갖어다가 만들었는데,

검색 창이 닫혀서 출처를 찾을 수가 없네.;


멀티프로세스에 관심있거나, 직접 테스트를 해보고 싶은 사람은 참고해 본다. 

flat 데이터 생성 프로그램은 다음과 같다



int 와 datetime 성능의 상대적인 성능차를 확인 하기 위한 테스트이기 때문에

테스트 머진 성능은 중요하지 않으나, 다음과 같다.

- Maria DB 10.x 

- CentOS 7 64 bit

- Memory 8GB

- Core : 4 Core


MySQL ini 파일은  my-innodb-heavy-4G.cnf을 변경없이 그대로 사용하였다.



실제 DB 쿼리 테스트는 다음 글에서.....

2018/02/27 - [DBMS/MySQL] - MySQL InnoDB DATETIME vs Unixtime (int type) #1 <

2018/02/27 - [DBMS/MySQL] - MySQL InnoDB DATETIME vs Unixtime (int type) #2

2018/02/27 - [DBMS/MySQL] - MySQL InnoDB DATETIME vs Unixtime (int type) #3 (1.5억건)

2018/02/27 - [DBMS/MySQL] - MySQL InnoDB DATETIME vs Unixtime (결론) #4




서버 시간 설정

[root@web102 ~]# crontab -l

MAILTO=""

0 0 * * * /usr/bin/rdate -s time.bora.net && /sbin/clock -w

 

 

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

 

yum -y install apr*  openssl-devel libtermcap-devel ncurses-devel libxml* curl-devel libjpeg* libpng* freetype-devel  libmcrypt* libmhash mhash* pcre-devel lua-devel libxml2-devel ncurses-devel zlib zlib-devel curl libtermcap-devel libc-client-devel bison gcc g++ cpp gcc-c++ freetype freetype-devel freetype-utils gd gd-devel libjpeg libjpeg-devel libpng libpng-devel curl curl-devel flex php-mbstring lrzsz libexif-devel libtool

 

 

wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz

wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2

tar jxf libmcrypt-2.5.8.tar.bz2

cd libmcrypt-2.5.8

./configure

make

make install

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

 

 

wget http://www.youtu.kr/mirror/mhash-0.9.9.9.tar.gz

wget https://ko.osdn.net/frs/g_redir.php?m=kent\&f=mhash%2Fmhash%2F0.9.9.9%2Fmhash-0.9.9.9.tar.gz


# tar zxvf mhash-0.9.9.9.tar.gz

# cd /root/setup/etc/mhash-0.9.9.9; LD_LIBRARY_PATH=/usr/local/lib ./configure --prefix=/usr/local/

# make && make install

# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

# ln -s /usr/local/lib/libmhash.so.2 /usr/lib64/libmhash.so.2

 

 

Mcrypt download

http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2Ffiles%2FMCrypt%2F2.6.8%2F&ts=1403153316&use_mirror=jaist

./configure

make && make install

 

/bin/rm: cannot remove `libtoolT': No such file or directory

# autoreconf --force --install 

# libtoolize --automake --force 

# automake --force --add-missing 

 

PHP Compile

./configure \

--with-apxs2=/usr/local/apache2/bin/apxs \

--with-config-file-path=/usr/local/apache2/conf \

--prefix=/usr/local/php \

--with-mysql=/usr/local/mysql \

--with-freetype-dir=/usr/include/freetype2/freetype \

--disable-debug \

--disable-rpath \

--enable-bcmath \

--enable-exif \

--enable-ftp \

--enable-ftp=shared \

--enable-gd-native-ttf \

--enable-inline-optimization \

--enable-mbregex \

--enable-mbstring \

--enable-sockets \

--enable-sysvsem \

--enable-sysvshm \

--enable-wddx \

--enable-zip \

--with-curl \

--with-freetype-dir=/usr \

--with-gd \

--with-gettext \

--with-iconv \

--with-jpeg-dir=/usr/local/lib \

--with-libxml-dir=/usr/lib \

--with-mcrypt \

--with-mhash \

--with-mysql \

--with-mysqli \

--with-openssl \

--with-png-dir=/usr/local/lib \

--with-libxml-dir=/usr/lib \

--with-zlib \

--with-pear

 

Note that the MySQL client library is not bundled anymore!

'./configure' \

'--with-apxs2=/svc/BVM/web/apache-2.2.23/bin/apxs' \

'--with-config-file-path=/svc/BVM/web/apache-2.2.23/conf' \

'--prefix=/svc/BVM/was/php-5.4.6' \

'--with-freetype-dir=/usr/include/freetype2/freetype' \

'--disable-debug' \

'--disable-rpath' \

'--enable-bcmath' \

'--enable-exif' \

'--enable-ftp' \

'--enable-ftp=shared' \

'--enable-gd-native-ttf' \

'--enable-inline-optimization' \

'--enable-mbregex' \

'--enable-mbstring' \

'--enable-sockets' \

'--enable-sysvsem' \

'--enable-sysvshm' \

'--enable-wddx' \

'--enable-zip' \

'--with-curl' \

'--with-freetype-dir=/usr' \

'--with-gd' \

'--with-gettext' \

'--with-iconv' \

'--with-jpeg-dir=/usr/local/lib' \

'--with-mcrypt' \

'--with-mhash' \

'--with-mysql=/svc/BVM/MYSQL/mysql-5.5.25a/' \

'--with-mysqli=/svc/BVM/MYSQL/mysql-5.5.25a/mysql_config' \

'--with-openssl' \

'--with-png-dir=/usr/local/lib' \

'--with-libxml-dir=/usr/lib' \

'--with-zlib' \

'--with-pear' \

"$@"

 

 

 

make && make install

 

 

/etc/hosts

#ORACLE

192.168.135.106 aoadb-scan

192.168.135.89  oradb1

192.168.135.90  oradb1

 

[root@aoacrm1 php-5.4.6]# cat > /usr/lib/oracle/tnsnames.ora

AOA =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = oradb1)(PORT = 1527))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = AOA)

    )

  )

 

OCI8 install

 

ln -s /svc/AOA/was/php-5.4.6/lib/php/extensions/no-debug-zts-20100525/oci8.so /svc/AOA/was/php-5.4.6/lib/php/extensions/oci8.so

 

 

 

 

cp /data/backup/php.ini /svc/AOA/web/apache-2.2.25/conf/php.ini

php -q /data/backup/test.php

 

 

 

 

오라클 설치

yum install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat

 

 

리눅스(CentOS 6.2)에 Oracle 11g 설치

 

ㅇ Package Requirements

 

binutils-2.20.51.0.2-5.11.el6.i686

compat-libcap1-1.10-1.i686

compat-libstdc++-33-3.2.3-69.el6.i686

gcc-4.4.4-13.el6.i686

gcc-c++-4.4.4-13.el6.i686

glibc-2.12-1.7.el6.i686

glibc-devel-2.12-1.7.el6.i686

ksh

libgcc-4.4.4-13.el6.i686

libstdc++-4.4.4-13.el6.i686

libstdc++-devel-4.4.4-13.el6.i686

libaio-0.3.107-10.el6.i686

libaio-devel-0.3.107-10.el6.i686

make-3.81-19.el6.i686

sysstat-9.0.4-11.el6.i686

 

 

[root@localhost ~]# yum install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat

 

 

 

ㅇ 그룹과 계정 생성

groupadd oinstall; groupadd dba;useradd -g oinstall -G dba oracle;passwd oracle

[root@localhost ~]# groupadd oinstall

[root@localhost ~]# groupadd dba    

[root@localhost ~]# id oracle       

id: oracle: No such user            

[root@localhost ~]# useradd -g oinstall -G dba oracle

[root@localhost ~]# passwd oracle

 

 

 

ㅇ 커널 파라미터 설정

 

/etc/sysctl.conf 파일 제일 아래쪽에 복사

 

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 536870912

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

 

 

ㅇ Resource Limits for Oracle

 

 etc/security/limits.conf 파일 제일 아래에 다음을 넣어준다.

 

oracle              soft    nproc   2047

oracle              hard    nproc   16384

oracle              soft    nofile  1024

oracle              hard    nofile  65536

oracle              soft    stack   10240

 

 

ㅇ 오라클 설치 디렉토리 만들기

 

[root@localhost test0]# mkdir -p /app

[root@localhost test0]# chown -R oracle:oinstall /app

[root@localhost test0]# chmod -R 775 /app

 

 

ㅇ 오라클 환경변수 만들기

 

[oracle@localhost ~]$ vi /home/oracle/bash_profile

 

(profile 파일 제일 아래에 추가)

 

export ORACLE_BASE=/app/oracle

export ORACLE_SID=CENTORA

export ORACLE_HOME=/app/oracle/dbhome

export ORACLE_HOME_LISTNER=$ORACLE_HOME/bin/lsnrctl

 

 

 

ㅇ 추가 프로그램 설치

 

# yum install unixODBC, unixODBC-devel, pdksh

 

# rpm -Uvh --nodeps pdksh-5.2.14-8.i386.rpm

 

 

 

< style type="text/css"> #hiddenmorepopup { display:block; }< /style>

아파치 2.2.x
wget
http://archive.apache.org/dist/httpd/httpd-2.2.13.tar.gz
tar -xvzf httpd-2.2.13.tar.gz
cd httpd-2.2.13
./configure --prefix=/usr/local/apache2 --enable-so \
              --enable-ssl --with-ssl=/usr/local/ssl \
              --enable-rewrite \
              --enable-suexec --with-suexec-caller=bin \
              --enable-deflate --enable-headers \
              --enable-dav \
              --with-included-apr
--enable-lib64 --libdir=/usr/lib64 \
              --with-mpm=worker

 

#--enable-lib64 --libdir=/usr/lib64 64비트 시스템일경우 추가
#--enable-ssl ssl https 인증서 사용시 필요
#--enable-rewrite 주소 재작성 모듈
#--enable-suexec cgi 실행 권한 관련
#--enable-deflate --enable-headers 압축관련(이미지등)
#--enable-dav subversion에서 사용됨
#--with-included-apr 아파치 소스에 포함된 apr을 그대로 사용하도록 지정
#--with-mpm=worker 아파치의 프로세스 동작 설정(기본 옵션은 prefork)

make && make install

 

출처: <http://wiki.nettem.co.kr/Wiki.jsp?page=Apache_Install_Linux>

+ Recent posts