Mysql, Maria DB
-
maria db column 추가Mysql, Maria DB 2019. 7. 22. 12:17
- 테이블명 : test - 컬럼명 : Col2 - 데이터타입 : varchar (255) ALTER TABLE `test` ADD COLUMN `Col2` varchar(255) 기본값 추가 (디폴트값 Null) ALTER TABLE `test` ADD COLUMN `Col2` varchar(255) NULL DEFAULT NULL 캐릭터 Set 지정 (UTF-8) ALTER TABLE `test` ADD COLUMN `Col2` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL 코멘트 및 위치 지정 (코멘트 : 컬럼1, 위치 : Col1 컬럼 뒤) ALTER TABLE `test` ADD COLUMN `Col2` var..
-
CentOS mariadb slow query (슬로우쿼리) 설정Mysql, Maria DB 2019. 7. 5. 19:29
slow query는 기본적으로 OFF로 되어 있으며, 10초로 세팅되어 있다. > show variables like 'slow_query_%' > show global variables like 'long_query_time%'; > set global slow_query_log = 'ON'; > set global slow_query_log_file ='/var/log/mariadb/slow-query.log'; > set global long_query_time = 5 > flush logs; 재기동해도 설정을 유지하려면 아래와 같이 /etc/my.cnf.d/server.cnf에 [mysqld] 안에 세팅해준다
-
python을 이용한 maria DB 접속 로그 (1) - grafana 시각화 모니터링Mysql, Maria DB 2019. 6. 10. 12:36
grafana는 다양한 Data-Source를 사용할 수 있는 시각화 프로그램이다. 위와 같이 다양한 Data-Source를 연결할 수 있는데, 여기서는 mysql과 연동하여 간단한 대쉬보드를 만들겠다. 설치는 쉽기 때문에 패스하며, https://grafana.com/grafana/download URL을 참고하여 설치하면 된다. 1. grafana에 로그인을 하여 아래와 같이 data source를 클릭 2. mysql 선택 3. 기본적인 정보를 입력하고, Save & Test를 눌러 OK가 나오면 정상적으로 연결된다. 4. 다음으로 DashBoard를 선택하여, 그래프를 선택한다. 여러 그래프가 많지만 간단하게 'Table" 을 선택 5. 기본적으로 데이터가 없기 때문에 'Panel Title'에서..
-
[Python] maria DB 접속 로그 (1) - 설정 및 모니터링Mysql, Maria DB 2018. 5. 12. 17:33
1. maria DB 로깅설정 set global general_log = 1; set global log_output = 'TABLE'; show variables where Variable_name in ('version', 'log' , 'general_log') 2. 접속로그 확인 쿼리 select * from general_log where command_type = 'Connect' 3. 파이썬(python)을 이용한 접속로그 출력 import pymysql conn = pymysql.connect(host='ip', user='root', password='password',db='mysql', charset='utf-8') c = conn.cursor() c.execute('select *..
-
[Python] mysql lock monitoring. (실행 중인 스레드 모니터링)Mysql, Maria DB 2018. 5. 5. 22:01
파이썬 pymysql 모듈을 이용하여 실행 중인 스레드 모니터링을 할 수 있다. - mysql 명령어 : SHOW PROCESSLIST (DOCS : https://dev.mysql.com/doc/refman/5.5/en/show-processlist.html) import pymysql strFormat = '%-10s\t%-10s\t%-20s\t%-20s\t%-30s\t%-10s\t%-30s\t%-30s\t%-10s\n' strOut = strFormat % ('Id', 'User', 'Host', 'db', 'Command', 'Time', 'State','Info','Progress') strOut += '----------\t----------\t---------------------\t----..