Archive | October, 2008
24. Oct, 2008

OPTIMIZE TABLE

Hôm nay biết thêm một điều . :)

OPTIMIZE [LOCAL | NO_WRITE_TO_BINLOG] TABLE tbl_name [, tbl_name] …

Example : OPTIMIZE TABLE `tablename`

OPTIMIZE TABLE should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have VARCHAR, VARBINARY, BLOB, or TEXT columns). Deleted rows are maintained in a linked list and subsequent INSERT operations reuse old row positions. You can use OPTIMIZE TABLE to reclaim the unused space and to defragment the data file.

This statement requires SELECT and INSERT privileges for the table.

In most setups, you need not run OPTIMIZE TABLE at all. Even if you do a lot of updates to variable-length rows, it is not likely that you need to do this more than once a week or month and only on certain tables.

OPTIMIZE TABLE works only for MyISAM, InnoDB, and (as of MySQL 5.0.16) ARCHIVE tables. It does not work for tables created using any other storage engine.

For MyISAM tables, OPTIMIZE TABLE works as follows:

  1. If the table has deleted or split rows, repair the table.
  2. If the index pages are not sorted, sort them.
  3. If the table’s statistics are not up to date (and the repair could not be accomplished by sorting the index), update them.
23. Oct, 2008

List of HTTP status

List of HTTP status

* 200: request completed (OK)
* 201: object created, reason = new URI
* 202: async completion (TBS)
* 203: partial completion
* 204: no info to return
* 205: request completed, but clear form
* 206: partial GET furfilled
* 300: server couldn’t decide what to return
* 301: object permanently moved
* 302: object temporarily moved
* 303: redirection w/ new access method
* 304: if-modified-since was not modified
* 305: redirection to proxy, location header specifies proxy to use
* 307: HTTP/1.1: keep same verb
* 400: invalid syntax
* 401: access denied
* 402: payment required
* 403: request forbidden
* 404: object not found
* 405: method is not allowed
* 406: no response acceptable to client found
* 407: proxy authentication required
* 408: server timed out waiting for request
* 409: user should resubmit with more info
* 410: the resource is no longer available
* 411: the server refused to accept request w/o a length
* 412: precondition given in request failed
* 413: request entity was too large
* 414: request URI too long
* 415: unsupported media type
* 500: internal server error
* 501: required not supported
* 502: error response received from gateway
* 503: temporarily overloaded
* 504: timed out waiting for gateway
* 505: HTTP version not supported

22. Oct, 2008

Convert latin1 to utf8 in MySQL

Dump DB nguyên bản skip charset

mysqldump -u root -p --opt --default-character-set=latin1 --skip-set-charset testdb > testdb.sql

Sử dụng Sed replate latin1 sang uft8

sed -e 's/latin1/utf8/g' -i ./testdb.sql

Tạo mới DB

mysql>DROP DATABASE testdb;
mysql>CREATE DATABASE testdb CHARACTER SET utf8 COLLATE utf8_general_ci;

Import dump file. Set default charset

mysql -u root -p --default-character-set=utf8 testdb < testdb.sql

13. Oct, 2008

disconnect tới SAN

Mấy con DB của mình store trên SAN. híc cứ thỉnh thoảng nó lại disconnect một phát. Lại phát mệt lên. Chán

Sáng sớm chạy ra ngoài vì ở nhà mất điện, chả kịp đánh răng rửa mặt. Ra đến nới lại mất session tới con 24.42. Híc.

Sau khi ssh qua 1 con trung gian để start lại mysql. Nhớ đến anh Sơn bảo reconnect lại session. search google 1 lúc ra cái này kq là dùng đc :
mstsc -v:222.255.24.42 -f /console
Híc. Giờ lại check lại replicate của mấy con DB. Chắc lại nghẻo rồi :(

10. Oct, 2008

Install Squid on CentOS / RHEL 5

Use yum command as follows:

# yum install squid

Squid Basic Configuration

Squid configuration file located at /etc/squid/squid.conf. Open file using a text editor:
# vi /etc/squid/squid.conf

At least you need to define ACL (access control list) to work with squid. The defaults port is TCP 3128. Following example ACL allowing access from your local networks 192.168.1.0/24 and 192.168.2.0/24. Make sure you adapt to list your internal IP networks from where browsing should be allowed:
acl our_networks src 192.168.1.0/24 192.168.2.0/24
http_access allow our_networks

Save and close the file. Start squid proxy server:
# chkconfig squid on
# /etc/init.d/squid start

Open TCP port 3128

/sbin/iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp --dport 3128 -j ACCEPT