MariaDB/README
Pnuskgh (토론 | 기여)님의 2020년 2월 3일 (월) 17:43 판 ("MariaDB/README" 문서를 보호했습니다 ([편집=관리자만 허용] (무기한) [이동=관리자만 허용] (무기한)))
MariaDB
제한 사항
- <a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-restrictions.html" target="_blank">https://dev.mysql.com/doc/refman/8.0/en/innodb-restrictions.html</a>
- <a href="https://dev.mysql.com/doc/refman/5.7/en/column-count-limit.html" target="_blank">https://dev.mysql.com/doc/refman/5.7/en/column-count-limit.html</a>
- Table with InnoDB
- Row with InnoDB
- 최대 컬럼 갯수 : 1,017개
- 최대 레코드 크기 : Page Size의 1/2 (Default 8 KB (8,196 bytes))
- Default page size (innodb_page_size) : 16 KB (16,384 bytes)
- 별도로 저장되는 column은 8~ 12 bytes를 차지 한다.
- Row
- 최대 컬럼 갯수 : 4,096개
- 최대 레코드 크기 : 64 KB (65,536 bytes)
- Column
- varchar : 64 KB. 동일한 공간에 저장. 인덱스 생성 가능
- varbinary : 64 KB. 동일한 공간에 저장
- text : 별도 공간에 text 데이터 저장. Full text 검색 가능
- tinytext : 256 bytes
- text : 64 KB (65,536 bytes)
- mediumtext : 16 MB
- longtext : 4GB
- blob : 별도 공간에 바이너리 데이터를 저장
- tinyblob : 256 bytes
- blob : 64 KB (65,536 bytes)
- mediumblob : 16MB
- longbolb : 4GB
MariaDB 설치
<code class="bash">#--- MariaDB 설치 # yum -y install mariadb mariadb-server yum -y install mariadb103 mariadb103-server mariadb103-backup # yum -y install mariadb103-server-galera systemctl enable mariadb.service systemctl restart mariadb.service mysql_secure_installation vi /etc/my.cnf [mysqld] #--- Charset Setting init_connect="SET collation_connection=utf8_general_ci" init_connect="SET NAMES utf8" character-set-server=utf8 collation-server=utf8_general_ci skip-character-set-client-handshake innodb_log_file_size=5M #--- InnoDB Setting default-storage-engine=InnoDB innodb_file_per_table=1 #--- binlog setting log-bin=/var/lib/mysql/binlog max_binlog_size=1G #--- 로그 파일 하나당 크기 # expire_log_days=30 #--- 30일간 보관 vi /etc/my.cnf.d/client.cnf [client] default-character-set=utf8 [client-mariadb] default-character-set=utf8 vi /etc/my.cnf.d/mysql-clients.cnf [mysql] default-character-set=utf8 [mysqldump] default-character-set=utf8 systemctl restart mariadb.service mysql -uroot -p${PASSWD} mysql -e "show variables like 'c%'" mysql -uroot -p${PASSWD} mysql -e "show variables like 'log_bin'" mysql -V #--- 방화벽 설정 firewall-cmd --permanent --add-service=mysql firewall-cmd --reload firewall-cmd --list-all</code>
Monitoring
<code class="mariadb">-- scadadb 데이터베이스에 포함된 테이블별 크기SELECT TABLE_NAME, round(((data_length + index_length) / 1024 / 1024), 2) "MB"
FROM information_schema.TABLES WHERE table_schema = "scadadb" ORDER BY (data_length + index_length) DESC;-- scadadb 데이터베이스에 포함된 테이블별 레코드 수 SELECT TABLE_NAME, TABLE_ROWS
FROM information_schema.TABLES WHERE table_schema = "scadadb"ORDER BY TABLE_ROWS DESC;</code>
Connection 갯수 설정
<code class="bash">#--- 최대 접속 수 확인과 Online 설정 mysql -uroot -p비밀번호 mysql #--- open_files_limit >= 10 + max_connections + table_cache_size * 2 #--- open_files_limit가 1024이고 table_cache_size가 400인 경우 #--- 최대 214 max_connections이 가능 show variables like 'open_files_limit'; show variables like 'table_open_cache'; show variables like 'max_connections'; set global max_connections=256; #--- Online에서 최대 접속 수 설정 exit; #--- 설정 파일에서 최대 접속 수 설정 vi /etc/my.cnf.d/server.cnf [mysqld] max_connections = 256 #--- open_files_limit 수정 방법 ulimit -a | grep 'open files' vi /etc/security/limits.conf * soft nofile 65536 * hard nofile 65536 vi /lib/systemd/system/mariadb.service [Service] LimitNOFILE=4096 systemctl daemon-reload systemctl mariadb restart</code>
참고 문헌
- <a href="https://www.jopenbusiness.com/mediawiki/MySQL" target="_blank">오픈소스비즈니스 컨설팅 - MySQL</a>
- <a href="https://www.jopenbusiness.com/mediawiki/MariaDB" target="_blank">오픈소스비즈니스 컨설팅 - MariaDB</a>
- <a href="https://www.jopenbusiness.com/cms/MariaDB/MySQL.md">MySQL</a>
참조 : MariaDB/README