반응형

MariaDB와 Mysql 성능을 테스트하기 위해

 

HammerDB를 사용하다가

 

보니...

 

정작 중요한 my.cnf 설정이 정상적인가? 물음에 도달하게 되었습니다.

 

정확한 설정값을 위해 자동 튜닝 스크립트를 제공하는 사이트를 발견하였습니다.

 

보통 정상적으로 튜닝 범주라고 체크 할려면 48시간이상 이용해야 한다는 사실은 존재합니다.

 


 

virtualbox 상에서 실행한 결과 (OK : 정상 / !! 설정 이상 / -- SKIP)

 

 >>  MySQLTuner 1.7.15 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials passed on the command line
[OK] Currently running supported MySQL version 10.3.17-MariaDB
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/lib/mysql/hammerdb.err(0B)
[!!] Log file /var/lib/mysql/hammerdb.err doesn't exist
[!!] Log file /var/lib/mysql/hammerdb.err isn't readable.

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in InnoDB tables: 999.9M (Tables: 9)
[OK] Total fragmented tables: 0

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'root@%' does not specify hostname restrictions.
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 34m 1s (279K q [136.873 qps], 133 conn, TX: 74M, RX: 38M)
[--] Reads / Writes: 50% / 50%
[--] Binary logging is disabled
[--] Physical Memory     : 1.8G
[--] Max MySQL memory    : 15.2G
[--] Other process memory: 0B
[--] Total buffers: 1.4G global + 28.2M per thread (500 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 1.7G (94.00% of installed RAM)
[!!] Maximum possible memory usage: 15.2G (845.58% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (0/279K)
[OK] Highest usage of available connections: 2% (11/500)
[OK] Aborted connections: 1.50%  (2/133)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[!!] Query cache efficiency: 0.0% (0 cached / 1M selects)
[OK] Query cache prunes per day: 0
[OK] No Sort requiring temporary tables
[OK] No joins without indexes
[OK] Temporary tables created on disk: 0% (22 on disk / 37K total)
[OK] Thread cache hit rate: 90% (13 created / 133 connections)
[OK] Table cache hit rate: 95% (141 open / 147 opened)
[OK] Open file limit used: 1% (59/4K)
[OK] Table locks acquired immediately: 100% (108 immediate / 108 locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 2 thread(s).
[--] Using default value is good enough for your version (10.3.17-MariaDB)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.2% (24M used / 134M cache)
[OK] Key buffer size / total MyISAM indexes: 128.0M/123.0K
[OK] Read Key buffer hit rate: 98.9% (180 cached / 2 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 4
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 1.0G/999.9M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (99.609375 %): 340.0M * 3/1.0G should be equal to 25%
[!!] InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1).
[--] Number of InnoDB Buffer Pool Chunk : 8 for 8 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 99.84% (26160668 hits/ 26202270 total)
[!!] InnoDB Write Log efficiency: 83.1% (617680 hits/ 743341 total)
[OK] InnoDB log waits: 0.00% (0 waits / 125661 writes)

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Restrict Host for user@% to user@SpecificDNSorIp
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    Performance schema should be activated for better diagnostics
    Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
    Consider installing Sys schema from https://github.com/good-dba/mariadb-sys for MariaDB
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (=0)
    query_cache_type (=0)
    query_cache_limit (> 1M, or use smaller result sets)
    performance_schema = ON enable PFS
    innodb_log_file_size should be (=85M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
    innodb_buffer_pool_instances (=1)

 


Perl로 작성된 쉘이 아래 주소에 있으며,

 

https://github.com/major/MySQLTuner-perl

 

major/MySQLTuner-perl

MySQLTuner is a script written in Perl that will assist you with your MySQL configuration and make recommendations for increased performance and stability. - major/MySQLTuner-perl

github.com

 

2019.08.14 

mysqltuner.pl
0.22MB

 

실행법

#> perl mysqltuner.pl --user root --pass='root'

 

지원하는 DB는

 

Test result are available here: Travis CI/MySQLTuner-perl

  • MySQL 8 (partial support, password checks don't work)
  • MySQL 5.7 (full support)
  • MySQL 5.6 (full support)
  • MariaDB 10.3 (full support)
  • MariaDB 10.2 (full support)
  • MariaDB 10.1 (full support)
  • MariaDB 10.0 (full support, 6 last month support)
  • Percona Server 5.7 (full support)
  • Percona Server 5.6 (full support)
  • Percona XtraDB cluster (full support)
  • MySQL 3.23, 4.0, 4.1, 5.0, 5.1, 5.5 (partial support - deprecated version)
  • Perl 5.6 or later (with perl-doc package)
  • Unix/Linux based operating system (tested on Linux, BSD variants, and Solaris variants)
  • Windows is not supported at this time (Help wanted !!!!!)
  • Unrestricted read access to the MySQL server (OS root access recommended for MySQL < 5.1)
  • CVE vulnerabilities detection support from https://cve.mitre.org

 

반응형
반응형


/etc/cron.daily 에 파일을 만들어 두거나

crond 에 등록해서 사용하시면 됩니다.

[기능요약]

1.root 계정으로 전체 디비를 디비별로 백업 가능함
2.옵션으로 테이블 별 백업 가능함.
3.보존 설정 기간 이후 자동 삭제

--------------------------------------------source----------------------------------------------------------

#!/bin/sh

############################################################################
#
# By 질주본능 2009/06/03
#
#    V 2.0
#
# 데이터 베이스별 혹은 테이블 별로 백업 받을 수 있도록 변경했으며
# 30 LINE 에 명기된 배열에 속하는 디비들만 테이블 별로 백업 받는다.
#
# 데이터베이스 단위로 받은 파일은 DB. 으로 시작하고
# 테이블 단위는 TB. 으로 시작하는 파일명을 갖는다.
#
# 백업 파일은 dump.gz 로 형성 되며 설정된 보존 기간이 지나면 자동 삭제 된다.
#
#############################################################################

##### SET VARIABLES ############ 전체를 백업 받으려면 여기에 root 계정을 입력한다.
DBHOST="yourhost"
DBUSER="yourid"
DBPWD="yourpassword"

#백업 경로
BACKUPDIR="/home/your_backup_dir/"
#로그 작성 경로
LOGDIR="/home/your_backup_log_dir/"
#로그 파일 앞에 붙을 특정 텍스트
LOGNAME="log_"

###### SET DB NAMES which BACKUP by TABLES ###### 여기 표시된 DB 들은 테이블 별로 백업된다.
DB_TBARR=(dbname1 dbname2 dbname3)

#백업 옵션을 원하는 대로 설정
#routine 옵션은 5버전 이상에서만 사용(function 등을 백업함)
OPTIONS="--skip-comments --default-character-set=euckr --routines"

##### SET CHARGE LIMIT ########## 백업 파일 저장 기간(일단위)
CHARGE_LMT=3

##### DELETE OLD_BACKUP FILES #######
find ${BACKUPDIR} -name "*.gz" -mtime +${CHARGE_LMT} -exec rm -rf {} \;

##### START LOG CREATE ##########
YMD_S=`date +%Y%m%d%H%M%S`
touch ${LOGDIR}${LOGNAME}${YMD_S}.start

##### DB LIST GET ###############
#IF YOU WANT TO EXCEPT SOME DATABASE ADD THIS
#grep -v Database | grep -v somename | grep -v somename`
#

#grep -v dbname 하면 백업 시 제외 된다.

RESULT=`mysql -u$DBUSER -p$DBPWD -h$DBHOST -e "show databases" | grep -v Database`

for DB in $RESULT; do

    sw=0
    ##### compare DB to TBARR #####
    for i in ${DB_TBARR[@]}; do
        if [ $i = $DB ]; then
            let "sw=sw+1"
        fi
        done

    if [ $sw = 0 ]; then
        # BACKUP by DB
        FNAME=${BACKUPDIR}DB.${DB}_${YMD_S}.dump
        #echo $FNAME
        touch $FNAME
        echo "set foreign_key_checks=0;" >> $FNAME
        mysqldump -u$DBUSER -p$DBPWD -h$DBHOST $OPTIONS $DB >> $FNAME
        echo "set foreign_key_checks=1;" >> $FNAME
        gzip --rsyncable $FNAME

    else
        # BACKUP by TABLES
                RESULT_TB=`mysql -u$DBUSER -p$DBPWD -h$DBHOST $DB -e"show tables" | grep -v heap | grep -v Tables_in `
                for TB in $RESULT_TB; do

                        FNAME=${BACKUPDIR}TB.${DB}.${TB}_${YMD_S}.dump
            #echo $FNAME
            touch $FNAME
            echo "set foreign_key_checks=0;" >> $FNAME
            mysqldump -u$DBUSER -p$DBPWD -h$DBHOST $OPTIONS $DB $TB >> $FNAME
            echo "set foreign_key_checks=1;" >> $FNAME
            gzip --rsyncable $FNAME

                done        
    fi

done

##### END LOG CREATE ###########
YMD_E=`date +%Y%m%d%H%M%S`

touch ${LOGDIR}${LOGNAME}${YMD_E}.end

 

출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=70556&page=2
반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
무료 접속 툴 (Free Tool)  (0) 2009.03.06
C를 이용한 성적관리 예제  (0) 2009.03.06
mysql(latin1 -> euckr 변경)  (0) 2009.03.06
반응형

1. 나비켓 (Navicat mysql)  

   (속도도 빠르고 좋다고 함) ->   유료

    http://www.sendspace.com/file/6h3q6v

    http://filebeam.com/8b6e269bc3325283fbe2a13d3601d75e

 

2. SQLyog(프리웨어)

    http://www.webyog.com/en/

 

3. Mysql-Front (프리웨어) -> 강추

    http://www.sql-front.com/

 

4. PHPMYADMIN (프리웨어) -> 강추

    http://www.phpmyadmin.net/

 

5. YourSQL

    http://www.mludi.net/YourSQL/

 

6. EMS(프리웨어) -> 강추

    http://www.snapfiles.com/get/emsmysqllite.html

 

7. Toad for mysql(프리웨어) -> 강추

   http://www.toadsoft.com/toadmysql/FreewareDownload.htm

난 oracle 을 사용할 때 DBA가 지원되는 최상위 버젼 토드를 써서 그런지...

왠지 Toad for mysql 조차도 너무 좋음....

단 DBA 관점이라는거....

반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
MySQL 백업용 쉘스크립트입니다.  (0) 2010.01.18
C를 이용한 성적관리 예제  (0) 2009.03.06
mysql(latin1 -> euckr 변경)  (0) 2009.03.06
반응형

#include <mysql/mysql.h>
#include <string.h>
#include <stdio.h>
#define DB_HOST "127.0.0.1"
#define DB_USER "root"
#define DB_PASS "1234"
#define DB_NAME "sungjuk"
#define CHOP(x) x[strlen(x)-1] = ' '
typedef struct {
                char name[10];
                int jumsu[3];
                float ave;
                int total;
} _sungjuk;
void input_data(_sungjuk *sungjuk);
int insert(MYSQL *, _sungjuk sungjuk);
int search(MYSQL *);
int print(MYSQL *);
int main(void)
{
    int         i, n;
    MYSQL       *connection=NULL, conn;
    MYSQL_RES   *sql_result;
    MYSQL_ROW   row;
    int         field;
    int         query_stat;
    mysql_init(&conn);
    connection = mysql_real_connect(&conn, DB_HOST, DB_USER, DB_PASS, DB_NAME, 3306, (char *)NULL, 0);
    if(connection == NULL){
        printf("connect error!\n");
        exit(1);
    }
_sungjuk sungjuk[5];
    printf("Enter the mode:\n");
    printf("1 : input mode\n");
    printf("2 : seaching mode\n");
    printf("3 : print all\n");
    scanf("%d", &n);
    switch(n)
    {
        case 1:
            for(i=0;i < 2;i++)
                input_data(&sungjuk[i]);
            for(i=0;i < 2;i++){
                printf("%p\n", connection);
                insert(connection, sungjuk[i]);
            }
            break;
        case 2:
            search(connection);
            break;
        case 3:
            print(connection);
            break;
        default :
            exit(1);
    }
    mysql_close(connection);
}




void
input_data(_sungjuk *sungjuk) { printf("input name\n"); scanf("%s", sungjuk->name); getchar(); printf("input KOREAN score\n"); scanf("%d", &sungjuk->jumsu[0]); printf("input ENGLISH score\n"); scanf("%d", &sungjuk->jumsu[1]); printf("input MATH score\n"); scanf("%d", &sungjuk->jumsu[2]);
         sungjuk->total = sungjuk->jumsu[0] + sungjuk->jumsu[1] + sungjuk->jumsu[2];
         sungjuk->ave = (float) sungjuk->total / 3.0;
}


int 
insert(MYSQL *con, _sungjuk sungjuk) { char buff[255]; sprintf(buff,
"insert into test values ('%s', '%d', '%d', '%d','%d','%f')",
sungjuk.name,
sungjuk.jumsu[0],
sungjuk.jumsu[1],
sungjuk.jumsu[2],
sungjuk.total,
sungjuk.ave); printf("%s : %p: %d\n", buff, con, mysql_query(con, buff)); } int
search(MYSQL *con) { int j; char buff2[255]; char name[20];
    MYSQL_RES *sql_result;
    MYSQL_ROW row;
    int field;
    printf("insert name : ");
    scanf("%s", name);
    sprintf(buff2, "select * from test where name = '%s'", name);
    mysql_query(con, buff2);
    sql_result = mysql_store_result(con);
    field = mysql_num_fields(sql_result);
    printf("%12s%12s%12s%12s%12s%12s","name","KREAN","ENGLISH","MATH","SUM","AVER");
    while((row=mysql_fetch_row(sql_result))){
        for(j=0; j<field; j++) printf("%12s",row[j]);
        printf("\n");
    }
}


int 
print(MYSQL *con) { int k; MYSQL_RES *sql_result; MYSQL_ROW row; int field;
        mysql_query(con, "select * from test");
        sql_result = mysql_store_result(con);
        field = mysql_num_fields(sql_result);
        printf("%12s%12s%12s%12s%12s%12s","name","KREAN","ENGLISH","MATH","SUM","AVER");
        while((row=mysql_fetch_row(sql_result))){
            for(k=0; k<field; k++)
                 printf("%12s", row[k]);
            printf("\n");
        }
}


/*by nuno*/
출처 : http://blog.naver.com/jujac?Redirect=Log&logNo=20035738613
반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
MySQL 백업용 쉘스크립트입니다.  (0) 2010.01.18
무료 접속 툴 (Free Tool)  (0) 2009.03.06
mysql(latin1 -> euckr 변경)  (0) 2009.03.06
반응형

Pc에 mysql  설치한후 bin 디렉토리에서 실행또는 호스팅서버에 텔넷접속후 실행

mysql -h ip -u id -p password  <--db 원격 접속: 

mysql>\s

--------------
mysql  Ver 12.22 Distrib 4.0.16, for pc-linux (i686)

Connection id:          1612
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Server version:         4.0.16-Max
Protocol version:       10
Connection:             Localhost via UNIX socket
Client characterset:    latin1
Server characterset:    latin1

UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 9 hours 47 min 20 sec

Threads: 6  Questions: 506708  Slow queries: 0  Opens: 16  Flush tables: 1  Open tables: 10  Queries per second avg: 14.379

--------------------------------------------------------------------------------------------------------------

설정하기

아래 euckr을 utf-8 로 변경해서 입력

mysql> SET character_set_client = euckr;
mysql> SET character_set_results = euckr;
mysql> SET character_set_connection = euckr;
mysql> ALTER DATABASE [DB명] DEFAULT CHARACTER SET euckr;
commit;

 

이렇게 하면 한글 잘됩니다.

환경은 Linux + MySQL 4.1.8입니다. ^^

---------------------------------------------------------------------------------------------------------------

환경설정화일에 직접 설정하기<----서버운용자가 반대할수있겠죠

my.ini 를 열고 편집

[mysqld]

default-character-set=euckr
character-set-client-handshake = FALSE
---------------------------------------------------------------------

반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
MySQL 백업용 쉘스크립트입니다.  (0) 2010.01.18
무료 접속 툴 (Free Tool)  (0) 2009.03.06
C를 이용한 성적관리 예제  (0) 2009.03.06

+ Recent posts