forcemax's

MySQL Proxy

작업2010. 3. 29. 14:15
MySQL Proxy is a simple program that sits between your client and MySQL server(s) that can monitor, analyze or transform their communication.

https://launchpad.net/mysql-proxy

http://forge.mysql.com/wiki/MySQL_Proxy

MySQL에 fail-over와 load balancing(round-robin)을 하기 위한 가장 쉬운 도구.

MySQL에 MyISAM으로 DB를 운영중에 간혹 "Sending data" 상태에서 1분이상 시간이 소요되는 경우가 있다.

이 때문에 Table에 Lock이 걸려 다른 Query들이 다 대기상태가 된다.

MySQL의 Query Caching 시스템에 문제가 있을 수 있으니 query cache를 off해 보란다.

http://bugs.mysql.com/bug.php?id=45544

뭐.. 나아지기만 바란다 ㅠㅠ

PS. 그러나 제일 중요한건 Slow Query가 발생하는 원인이 되는 Query를 수정하는 것이지 않을까. ㅎㅎ

회사 서비스 서버중 DB 서버가 4GB의 메모리를 갖고 있는데 우리가 많이 사용하는 max_connections 계산식에 대입해보면 max_connections값으로 1333을 설정할 수 있다고 한다.

그런데 아무리 [mysqld] 섹션에 max_connections 값으로 1200을 설정해도 적용이 안되고 show variables 해보면 max_connections값이 886으로 되어 있다.

이러한 이유에서 찾아보니 다음의 두가지 설정이 중요하였다.

일단 /etc/mysql/my.cnf에는 다음의 설정을 넣어준다.

[mysqld]
max_connections = 1200
open-files-limit = 4096

그리고 한 process의 최대 open files 값을 변경하기 위해 /etc/security/limits.conf 에 다음 설정을 추가한다.

mysql           soft    nofile          4096
mysql           hard    nofile          4096

mysql 데몬을 재시작하자!



OpenID Provider를 만들기위해 PHP Standalone OpenID Server를 설치해보았다.

requirement는 기본적으로 모두 설치하여 맞추었다.

config.php를 설정하고 사용자가 잘 만들어지는 것까지 확인하였다.

그러나 OpenID 인증이 실패한다.

삽질끝에 알게된 것...

MySQL이 utf8로 동작하면서 PHP Standalone OpenID Server가 실행하면서 생성해야 하는 Table들이 정상적으로 생성되지 않은 것이다 ㅠㅠ

결국 Table들의 생성 SQL문을 수정하였다.

CREATE TABLE identities (id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
account VARCHAR(255) character set latin1 NOT NULL, url TEXT character set latin1 NOT NULL,
UNIQUE (account, url(255)));

CREATE TABLE sites (account VARCHAR(255) character set latin1 NOT NULL,
trust_root character set latin1 TEXT, trusted BOOLEAN,
UNIQUE (account, trust_root(255)));

어차피 영문만 들어갈 필드들... 결국 필드 character set을 latin1으로 바꿨다.

If you get an error message during install beginning something like this:

# SQL=Specified key was too long; max key length is 1000 bytes:

This is probably because of your MySQL servers default character set is UTF-8 and using this encoding, every character is 16bits while others are 8bits. So, every column will have a doubled length.

You can change default character set for your tables. Open installation/sql/mambo.sql file in your favorite editor and change the string

# TYPE=MyISAM;

with exactly this:

# TYPE=MyISAM, DEFAULT CHARACTER SET latin1;

[for latin1, you may use something else]

Save the file, start mambo install again.

(Source: Mambo Forums)