<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>서버관리 &amp;gt; Database &amp;gt; MariaDB</title>
<link>https://www.blog.uidc.co.kr/mariadb</link>
<language>ko</language>
<description>MariaDB (2025-04-28 13:57:06)</description>

<item>
<title>MariaDB - DB 백업 및 복구하기</title>
<link>https://www.blog.uidc.co.kr/mariadb/mariadb-db-%EB%B0%B1%EC%97%85-%EB%B0%8F-%EB%B3%B5%EA%B5%AC%ED%95%98%EA%B8%B0/</link>
<description><![CDATA[<pre></pre><h3>MariaDB 백업 방법</h3>
<p>MariaDB 데이터베이스를 백업하는 방법 중 두 가지 자주 사용하는 백업 방법을 알아봅니다.</p>
<p><b>1. mysqldump 명령어를 이용한 백업 방법</b></p>
<ul>
<li>mysqldump 명령어를 사용하면 MariaDB 데이터베이스의 백업 파일을 생성할 수 있습니다.</li>
<li>다음 명령어를 터미널 또는 명령 프롬프트에서 실행합니다.</li>
</ul>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysqldump -u 사용자이름 -p 데이터베이스이름 &gt; 백업파일.sql</span></code></pre>
<ul>
<li><span style="color:#409d00;"><i><b>사용자이름은 MariaDB에 접속 가능한 계정</b></i></span></li>
<li><span style="color:#409d00;"><i><b>데이터베이스이름은 백업하려는 데이터베이스이름</b></i></span></li>
</ul>
<p><b>1-1. DB 전체 백업</b></p>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysqldump -u 사용자이름 -p -A &gt; full_backup.sql</span>
<span class="hljs-meta">#</span><span class="bash"> mysqldump -u 사용자이름 -p --all-databases &gt; full_backup.sql</span></code></pre>
<p><b>1-2. 특정 DB만 백업</b></p>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysqldump -u 사용자이름 -p --databases samsodb &gt; samsodb.sql</span></code></pre>
<ul>
<li><span style="color:#409d00;"><i><b>--databases 옵션을 넣어야 CREATE DATABASE 명령어가 포함된다.</b></i></span></li>
</ul>
<p><b>1-3. 특정 DB의 특정 테이블만 백업</b></p>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysqldump -u 사용자이름 -p samsodb tb_user &gt; tb_user.sql</span></code></pre>
<p><b>2-1. 파일 복사를 통한 백업</b></p>
<ul>
<li>MariaDB 데이터베이스의 데이터 파일을 직접 복사하여 백업하는 방법입니다.</li>
<li>MariaDB의 데이터 파일은 기본 설치 시 (/var/lib/mysql or /var/mysql 등) 에 저장됩니다.<br /><span style="color:#409d00;"><b><a style="background-color:rgb(230,245,255);color:rgb(64,157,0);" href="https://samso.tistory.com/34" rel="nofollow">[DB/Mysql(MariaDB)] - Linux - MariaDB 설치 (컴파일 / yum)</a> 이 글을 보고 컴파일 설치 했다면? </b></span> <b><span style="color:#409d00;">/SAMSODIR/MariaDB/data 경로가 됩니다.</span></b></li>
<li>백업을 원하는 데이터베이스 <b><span style="color:#ee2323;">디렉토리</span></b>를 복사하면 그 파일이 백업 데이터가 됩니다.</li>
</ul>
<span><img src="https://blog.uidc.co.kr/data/editor/2504/2112909965_4KXR7LOE_0efab2e68ad79683633df08f8a15b354aa6b49e2.png" width="685" height="82" alt="2112909965_4KXR7LOE_0efab2e68ad79683633df08f8a15b354aa6b49e2.png" /></span><p><br /></p><pre></pre><h3>MariaDB 복구 방법</h3>
<p style="color:rgb(51,51,51);">MariaDB 데이터베이스를 복구하는 방법 중 위의 두 가지 백업을 통한 복구 방법을 알아봅니다.</p>
<p style="color:rgb(51,51,51);"><b>1. mysqldump 명령어를 이용한 백업 파일 복구 방법</b></p>
<ul>
<li>mysqldump 백업한 SQL 파일을 사용하여 데이터베이스를 복구할 수 있습니다.</li>
<li>다음 명령어를 터미널 또는 명령 프롬프트에서 실행합니다.</li>
</ul>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysql -u 사용자이름 -p 데이터베이스이름 &lt; 백업파일.sql</span></code></pre>
<p><b>1-1. DB 전체 복구</b></p>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysql -u 사용자이름 -p &lt; 백업파일.sql</span></code></pre>
<p><b>1-2. 특정 DB만 복구 / <b>특정 DB의 특정 테이블 복구</b></b></p>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysql -u 사용자이름 -p 데이터베이스이름 &lt; 백업파일.sql</span></code></pre>
<p><b>1-3. Source 명령어를 통한 복구</b></p>
<pre class="shell"><code class="hljs"><span class="hljs-meta">#</span><span class="bash"> mysql -u 사용자이름 -p</span>
MariaDB [(none)]&gt; source samsodb.sql;
MariaDB [(none)]&gt; source /root/tb_user.sql;</code></pre>
<ul>
<li>MariaDB에 계정 접속한 뒤 source 명령어를 통해 복구할 수 있다.</li>
<li><span style="color:#ee2323;"><b>MariaDB에 접속한 경로에 samsodb.sql이 있으면 복구되지만 그 경로에 없으면 절대경로 입력!</b></span></li>
</ul>
<p><b>2-1. 파일 복사를 통한 복구</b></p><div class="google-auto-placed ap_container" style="width:100%;height:auto;clear:both;text-align:center;"><ins class="adsbygoogle adsbygoogle-noablate" style="margin:auto;height:0px;"><div style="border:none;height:0px;width:860px;margin:0px;padding:0px;"><iframe style="border-width:0px;width:860px;height:0px;" width="860" height="0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" title="Advertisement"></iframe></div></ins></div>
<ul>
<li>파일 복사를 통해 백업한 데이터 디렉토리를 원래 위치로 복사하여 데이터베이스를 복구합니다.</li>
<li>복사한 데이터 디렉토리를 MariaDB의 데이터 디렉토리에 덮어씌웁니다.</li>
<li>이후 MariaDB를 재시작하면 데이터베이스가 복구됩니다.</li>
</ul>
<p> </p>
<hr />
<h3>MariaDB 백업 스크립트 / 배치파일</h3>
<p><b>1. MariaDB 백업 스크립트</b></p>
<pre class="bash"><code class="hljs"><span class="hljs-meta">#!/bin/sh</span>
LANG=ko_KR.UTF-8
<span class="hljs-built_in">export</span> LANG
yy=`date +%Y`
dd=`date +%d`
mm=`date +%m`
FSVR=<span class="hljs-variable">${yy}</span><span class="hljs-variable">${mm}</span><span class="hljs-variable">${dd}</span>
FSVR1=`date +%Y%m%d --date <span class="hljs-string">'1 days ago'</span>`
BACKUPDIR=<span class="hljs-string">"/DB_BACKUP"</span>
USER=<span class="hljs-string">"root"</span>
PASSWORD=<span class="hljs-string">"samso"</span>
MYSQLDUMP=<span class="hljs-string">"/SAMSODIR/MariaDB/bin/mysqldump"</span>
DB=samsodb
<span class="hljs-variable">$MYSQLDUMP</span> --force --opt --user=<span class="hljs-variable">$USER</span> --password=<span class="hljs-variable">$PASSWORD</span> --master-data=2 --single-transaction --databases <span class="hljs-variable">$DB</span> --ignore-table=argo.t_report_action_manage_history --ignore-table=argo.t_report_history --ignore-table=argo.t_report_history_chunk --ignore-table=argo.t_token_buy_fail_history --ignore-table=argo.t_token_use_history  &gt; <span class="hljs-variable">${BACKUPDIR}</span>/<span class="hljs-variable">${FSVR}</span>_argo.dump

<span class="hljs-comment">#tar zcf ${BACKUPDIR}/${FSVR1}_argo.dump.tar ${BACKUPDIR}/${FSVR1}_samsodb.dump</span>
gzip <span class="hljs-variable">${BACKUPDIR}</span>/<span class="hljs-variable">${FSVR1}</span>_samsodb.dump

find <span class="hljs-variable">${BACKUPDIR}</span> -name <span class="hljs-string">"*.dump.gz"</span> -mtime +7 -<span class="hljs-built_in">exec</span> rm -f {} \;</code></pre>
<p><b>2. MariaDB 백업 배치파일</b></p>
<pre class="bash"><code class="hljs">@<span class="hljs-built_in">echo</span> off

<span class="hljs-built_in">set</span> TIME2=%TIME: =0%

<span class="hljs-built_in">set</span> TIME3=%TIME2:~0,2%%TIME2:~3,2%

C:\MariaDB\bin\mysqldump -uroot -psamso --master-data=2 --single-transaction --all-databases &gt; C:\DBBACKUP\%DATE%_%TIME3%_full.sql


forfiles /P <span class="hljs-string">"C:\DBBACKUP"</span> /M *.sql /D -7 /C <span class="hljs-string">"cmd /c del @file"</span></code></pre>
<p>위의 백업 스크립트 / 배치에 사용된 <b><span style="color:#0000ff;">dump 옵션</span></b></p><div class="google-auto-placed ap_container" style="width:100%;height:auto;clear:both;text-align:center;"><ins class="adsbygoogle adsbygoogle-noablate" style="margin:auto;height:0px;"><div style="border:none;height:0px;width:860px;margin:0px;padding:0px;"><iframe style="border-width:0px;width:860px;height:0px;" width="860" height="0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" title="Advertisement"></iframe></div></ins></div>
<ul style="background-color:rgb(255,255,255);color:rgb(68,68,68);">
<li><b>--single-transaction : </b><br />dump를 하나의 트랜잭션을 이용해서 실행함<br />(InnoDB 스토리지 엔진을 사용하는 테이블에 대해서는 <b><span style="color:#ee2323;">Lock 없이 일관된 덤프</span></b>를 받는다)</li>
<li><b>--master-data : </b><br />이 옵션이 명시되면, dump 파일의 헤더 부분에 CHANGE MASTER TO 구문을 포함시키며,<br />이 구문에는 덤프 시작 시점의 Binary log 파일명과 위치 정보 및 호스트 정보를 포함하고 있다.<br />이 값을 1로 설정하면 CHANGE MASTER TO 구문이 실제 실행 가능한 형태로 포함되며,<br />2로 설정되면 SQL 코멘트 형태로 참조만 할 수 있도록 포함된다.<br /><br /><b><span style="color:#409d00;">이 옵션은 Replication 설정이 되어 서버 이중화가 되어 있는 경우 slave 복구용으로 사용</span></b></li></ul>]]></description>
<dc:creator>최고관리자</dc:creator>
<dc:date>2025-04-28T13:57:06+09:00</dc:date>
</item>


<item>
<title>mariadb, mysql - mysql 5.x my.cnf 설정 튜닝</title>
<link>https://www.blog.uidc.co.kr/mariadb/mariadb-mysql-mysql-5x-mycnf-%EC%84%A4%EC%A0%95-%ED%8A%9C%EB%8B%9D/</link>
<description><![CDATA[<p><span style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;white-space:pre;color:rgb(255,0,0);"><strong>my.cnf</strong></span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">


skip_name_resolve                       </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 역DNS 검색 비활성</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
skip-external-locking                    </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 외부(TCP/IP) 잠금비활성</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
max_connections = 300              </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 최대 동시접속 연결 갯수</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
max_connect_errors = 100000   </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 서버가 차단되기 전에 최대 연결 오류수</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
max_allowed_packet = 16M       </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 요청된 쿼리의 최대길이의 값</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
key_buffer_size = 1G                   </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 인덱스를 메모리에 저장하는 버퍼의 크기 (myisam 을 사용할 경우 크게,</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
table_open_cache = 512             </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 각 쓰레드별 오픈할 테이블수</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
sort_buffer_size = 2M                  </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 정렬에 필요한 버퍼의 크기 ORDER BY 또는 GROUP BY 연산 속도와관련</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
join_buffer_size = 4M                  </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 적절한 조인 조건이 없어서, 조인이 테이블을 풀스캔 하기위해 사용하는 버퍼크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
read_buffer_size = 2M                 </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 테이블 스캔에 필요한 버퍼크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
read_rnd_buffer_size = 8M         </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># order by 절을 사용할 경우 디스크 사용을 피하기 위하여 사용하는 메모리 버퍼 크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
thread_cache_size = 16               </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 재사용을 위해 캐쉬될 쓰레드의 수</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
read_rnd_buffer_size = 16M       </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 인덱스를 사용해 정렬할 수 없을 경우 정렬된 데이터를 메모리에 저장하여</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
                                                          디스크 검색을 피하기위한 랜덤 읽기 버퍼크기
myisam_sort_buffer_size = 128M
query_cache_size = 1G               </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 쿼리 결과를 캐싱하기 위해 할당된 메모리크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
query_cache_limit = 4M              </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 이 변수 값보다 큰 값은 캐싱이 안됨, 설정저장가능한 최대 results크기(디폴트:1M)</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
                                                        보통  query_cache_size의 1~10%정도 설정
tmp_table_size = 128M               </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 메모리 내의 임시테이블 크기 초과시 디스크에 저장,group by 시 디스크를 사용하지</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
                                                         않고  임시 테이블을 만들기 위해 사용되는 메모리 크기
max_heap_table_size = 128M     </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># MEMORY 테이블의 최대크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
thread_concurrency = 8               </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 동시 쓰레드 갯수</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
back_log = 100                             </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 동시접속시 대기시킬수있는 커넥션 갯수</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
wait_timeout = 30                        </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 커넥션 최대 대기시간(초),</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
                    종료전까지 요청이 없이 기다리는 시간 ( TCP/IP 연결, Shell 상의 접속이 아닌 경우 )

slow-query-log = 1                        </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 슬로우 쿼리로그 활성화</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
long_query_time = 3                     이 변수값보다 쿼리처리가 길게 걸린다면 슬로우쿼리 로그에 기록
log-slow-queries = /path_to_log/mysql-slow.log             </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 슬로우 쿼리 로그파일 경로</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">

binlog_cache_size = 1M               </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;">#binlogchase 사이즈</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
max_binlog_size = 500M             </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># bin로그 max 사이즈</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
expire_logs_days = 10                  </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;">#보관기간</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">

</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># innodb</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_data_home_dir = /Data               </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># innodb 홈디렉터리 경로</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_data_file_path = ibdata1:1000M;ibdata2:1000M;ibdata3:1000M:autoextend            
                                                                   </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 파일명 : 초기용량 : 자동증가 : 최대사이즈</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_autoextend_increment = 100     </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;">#테이블 스페이스 자동 확장시 크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># You can set .._buffer_pool_size up to 50 - 80 %</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># of RAM but beware of setting memory usage too high</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_buffer_pool_size = 2G                 </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># innodb에서 사용할 메모리 양으로 전체 메모리의 50~80% 정도로 설정</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_additional_mem_pool_size = 20M          </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 데이터 디렉토리 정보와 내부 데이타 구조를 저장하는 메모리 풀의 크기</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># Set .._log_file_size to 25 % of buffer pool size</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_log_file_size = 100M                                </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 로그 파일 사이즈로 버퍼풀 사이즈의 25% 정도로 설정</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_log_buffer_size = 16M                             </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 리두 로그를 파일에 직접 기록하기 전 메모리상에서 버퍼링을 하는데</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
                                                                                   이를 위한 버퍼 사이즈

</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># Redo logs</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 0 인 경우, MySQL 이나 OS가 갑자기 crash 된다면 최대 1초동안의 트랜잭션을 잃을 수 있다.</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 1 인 경우, 안전하다.</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 2 인 경우, OS가 갑자기 crash 된다면 최대 1초동안의 트랜잭션을 잃을 수 있다. 하지만 MySQL 장애시에는</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
  이미 OS 영역으로 데이터는 넘어갔기 때문에 안전할 수 있다.
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 각 값에 따라, 엄청난 성능을 보일 수 있다.</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 많은 양의 log를 위하여, 해당값을 1에서 0으로 수정함에 따라 성능이 엄청 향상될 수 있다.</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 단순 select용의 slave나, 최대 1초정도의 트랜잭션은 무시할 수 있는 서비스 혹은 log를 저장할 서버라면</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
   해당값을 1에서 0으로 변경할 수 있다.
</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># MySQL을 가장 빠르고 쉽게 튜닝할 수 있는 parameter 중의 하나이다.</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_flush_log_at_trx_commit = 1    </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 1=트랜젝션 실행할때마다 로그 파일에 기록되고 디스크 플러시가 실행</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_support_xa = OFF                       </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 트렌젝션 two-phase commit 지원, 디스크 플러시 횟수를 줄여 성능항상</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_lock_wait_timeout = 50             </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 롤백이 진행되기 전에 LOCK을 대기하는 시간(초)</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_file_per_table = 1                        </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;"># 테이블 단위로 테이블스페이스 할당, 활성시 확장자 .ibd 파일이생성됨</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
innodb_flush_method = O_DIRECT </span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;">#</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">

</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;">#DB별 데이터 사용량 체크</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
mysql&gt; select information_schema.tables.table_schema, sum(data_length)
         -&gt; from information_schema.tables
         -&gt; group by information_schema.tables.table_schema;

</span><span class="hljs-comment" style="font-family:'Nanum Gothic', sans-serif;font-size:13.3333px;color:rgb(136,0,0);white-space:pre;">#모니터링 및 초기화 명령어</span><span style="font-family:monospace;font-size:13.3333px;white-space:pre;background-color:rgb(255,255,255);">
mysql&gt; show status  - MySQL 데이타베이스의 현재 상황
mysql&gt; show Processlist  - MySQL 프로세스 목록
mysql&gt; show variables  - 설정 가능한 모든 변수 목록
mysql&gt; flush logs  - MySQL의 로그파일 초기화
mysql&gt; flush status  - MySQL 상태정보 초기화
mysql&gt; flush thread  - 쓰레드 캐시에 저장된 쓰레드 초기화
mysql&gt; flush tables  - MySQL에 캐싱된 테이블 초기화
mysql&gt; flush privileges  - 권한정보 재 설정</span></p>]]></description>
<dc:creator>최고관리자</dc:creator>
<dc:date>2025-02-07T07:26:35+09:00</dc:date>
</item>


<item>
<title>[MYSQL] 구동 시 Active: failed (Result: exit-code) 해결법</title>
<link>https://www.blog.uidc.co.kr/mariadb/mysql-%EA%B5%AC%EB%8F%99-%EC%8B%9C-active-failed-result-exit-code-%ED%95%B4%EA%B2%B0%EB%B2%95/</link>
<description><![CDATA[<pre></pre><p>서버 업데이트 후 재부팅하는 과정에서 Mysql이 구동되지 않았다.</p><p><br /></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">$ service mysql status</span></p><p><br /></p><p>명령어를 통해 상태를 확인해보니 아래와 같았다.</p><p> </p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">● mysql.service - LSB: Start and stop the mysql database server daemon           </span></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">  Loaded: loaded (/etc/init.d/mysql)                                                            </span></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">  Active: </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0);">failed </span><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">(Result: exit-code) since Thu 2018-02-22 08:28:48 KST; 7s ago       </span></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">  Process: 2693 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)</span></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">  Process: 2761 ExecStart=/etc/init.d/mysql start </span><span style="color:rgb(255,0,0);background-color:rgb(0,0,0);">(code=exited, status=1/FAILURE) </span></p><div><br /></div><p>mysql error log를 확인해 보자.</p><p><br /></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">$ cd /var/log/mysql</span></p><p><span style="background-color:rgb(0,0,0);color:rgb(255,255,255);">$ vi error.log         </span></p><p><br /></p><p>맨 아래에 보니 다음과 같은 에러가 있었다.</p><p><br /></p><p class="configtext notranslate" style="margin-bottom:10px;background-color:rgb(249,249,249);padding-right:5px;padding-left:5px;font-size:14px;border:1px solid #D3D3D3;min-width:10%;max-width:90%;font-family:Menlo;">mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql<br />/usr/libexec/mysqld: Incorrect file format 'plugin'<br />[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.<br />InnoDB: Initializing buffer pool, size = 8.0M<br />InnoDB: Completed initialization of buffer pool<br />InnoDB: The log sequence number in ibdata files does not match<br />InnoDB: the log sequence number in the ib_logfiles!<br />InnoDB: Database was not shut down normally!<br />InnoDB: Starting crash recovery.<br />InnoDB: Reading tablespace information from the .ibd files...<br />InnoDB: Restoring possible half-written data pages from the doublewrite<br />InnoDB: buffer...<br />InnoDB: Started; log sequence number 0 2248162432<br />[ERROR] Fatal error: Can't open and lock privilege tables: Incorrect file format 'host'</p><h2 style="font-family:Lato, sans-serif;font-weight:500;line-height:1.1;color:rgb(51,51,51);margin-top:20px;margin-bottom:10px;font-size:30px;"><span style="font-family:'맑은 고딕', sans-serif;font-size:10pt;"></span><span style="font-family:'맑은 고딕', sans-serif;font-size:10pt;">구글링을 통해 다음과 같이 해결했다.</span></h2><p><br /></p><p>1. MySQL config 파일을 수정한다. 경로는</p><p style="margin-left:2em;"><code style="font-family:Menlo, Monaco, Consolas, 'Courier New', monospace;font-size:13.5px;color:rgb(199,37,78);padding:2px 4px;"><span style="color:rgb(51,51,51);font-family:Lato, sans-serif;font-size:15px;">CentOS/RHEL/CloudLinux  : </span>/etc/my.cnf</code><span style="color:rgb(51,51,51);font-family:Lato, sans-serif;font-size:15px;"> </span><br style="color:rgb(51,51,51);font-family:Lato, sans-serif;font-size:15px;" /><code style="font-family:Menlo, Monaco, Consolas, 'Courier New', monospace;font-size:13.5px;color:rgb(199,37,78);padding:2px 4px;"><span style="color:rgb(51,51,51);font-family:Lato, sans-serif;font-size:15px;">Ubuntu/Debian               :</span>/etc/mysql/my.cnf</code></p><p style="margin-left:2em;"><span style="color:rgb(51,51,51);font-family:Lato, sans-serif;font-size:15px;"><br /></span></p><p style="margin-left:2em;"><span style="color:rgb(51,51,51);font-family:'맑은 고딕', sans-serif;font-size:10pt;">파일을 열면 </span><code style="font-family:Menlo, Monaco, Consolas, 'Courier New', monospace;font-size:13.5px;color:rgb(199,37,78);padding:2px 4px;"><span style="font-family:'맑은 고딕', sans-serif;font-size:10pt;">[mysqld]</span></code><span style="color:rgb(51,51,51);font-family:'맑은 고딕', sans-serif;font-size:10pt;"> section에서 skip-grant-tables 를 추가한다.</span></p><p style="margin-left:2em;"><span style="color:rgb(51,51,51);"><span style="font-size:13.3333px;">ex.</span></span></p><p style="margin-left:2em;"><span style="color:rgb(51,51,51);"><span style="font-size:13.3333px;"><br /></span></span></p><table class="txc-table" width="864" cellspacing="0" cellpadding="0" border="0" style="border:none;border-collapse:collapse;"><tbody><tr><td style="border-bottom:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-left:1px solid #ccc;"><p>[mysqld]</p><p>#</p><p># * Basic Settings</p><p>#</p><p>user            = mysql</p><p>port            = 3306</p><p>...</p><p><span style="color:rgb(255,0,0);">skip-grant-tables</span></p><p> </p></td>
</tr>
</tbody></table><p><span style="color:rgb(51,51,51);"><span style="font-size:13.3333px;"><br /></span></span></p><p><span style="color:rgb(51,51,51);"><span style="font-size:13.3333px;">2. Mysql 을 재시작한다.</span></span></p><p style="margin-left:2em;"><span style="color:rgb(51,51,51);"><span style="font-size:13.3333px;background-color:rgb(0,0,0);color:rgb(255,255,255);">$ service mysql restart</span></span></p>]]></description>
<dc:creator>최고관리자</dc:creator>
<dc:date>2025-01-07T17:48:39+09:00</dc:date>
</item>

</channel>
</rss>
