Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MySQL ʼþµ÷¶ÈÆ÷(Event Scheduler)


Ò»¡¢¸ÅÊö
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊÇÔÚ MySQL 5.1 ÖÐÐÂÔöµÄÁíÒ»¸öÌØÉ«¹¦ÄÜ£¬¿ÉÒÔ×÷Ϊ¶¨Ê±ÈÎÎñµ÷¶ÈÆ÷£¬È¡´ú²¿·ÖÔ­ÏÈÖ»ÄÜÓòÙ×÷ϵͳÈÎÎñµ÷¶ÈÆ÷²ÅÄÜÍê³ÉµÄ¶¨Ê±¹¦>ÄÜ¡£ÀýÈ磬Linux ÖÐµÄ crontabe Ö»Äܾ«È·µ½Ã¿·ÖÖÓÖ´ÐÐÒ»´Î£¬¶ø MySQL µÄʼþµ÷¶ÈÆ÷Ôò¿ÉÒÔʵÏÖÿÃëÖÓÖ´ÐÐÒ»¸öÈÎÎñ£¬ÕâÔÚһЩ¶ÔʵʱÐÔÒª>Çó½Ï¸ßµÄ»·¾³Ï¾ͷdz£ÊµÓÃÁË¡£
¡¡¡¡Ê¼þµ÷¶ÈÆ÷ÊǶ¨Ê±´¥·¢Ö´Ðеģ¬ÔÚÕâ¸ö½Ç¶ÈÉÏÒ²¿ÉÒÔ³Æ×÷ÊÇ"ÁÙʱµÄ´¥·¢Æ÷"¡£´¥·¢Æ÷Ö»ÊÇÕë¶Ôij¸ö±í²úÉúµÄʼþÖ´ÐÐһЩÓï¾ä£¬¶øʼþµ÷¶ÈÆ÷ÔòÊÇÔÚijһ¸ö(¼ä¸ô)ʱ¼äÖ´ÐÐһЩÓï¾ä¡£Ê¼þÊÇÓÉÒ»¸öÌض¨µÄÏß³ÌÀ´¹ÜÀíµÄ£¬Ò²¾ÍÊÇËùνµÄ"ʼþµ÷¶ÈÆ÷"¡£ÆôÓÃʼþµ÷¶ÈÆ÷ºó£¬ÓµÓÐ SUPER ȨÏÞµÄÕË»§Ö´ÐÐ SHOW PROCESSLIST ¾Í¿ÉÒÔ¿´µ½Õâ¸öÏß³ÌÁË¡£Í¨¹ýÉ趨ȫ¾Ö±äÁ¿event_scheduler µÄÖµ¼´¿É¶¯Ì¬µÄ¿ØÖÆʼþµ÷¶ÈÆ÷ÊÇ·ñÆôÓá£
(root:localhost:)test> SET GLOBAL event_scheduler = ON;
(root:localhost:)test> show processlist\G
*************************** 4. row ***************************
     Id: 46147
   User: event_scheduler
   Host: localhost
     db: NULL
Command: Daemon
   Time: 1
  State: Waiting on empty queue
   Info: NULL
¡¡¡¡ÈçÉÏ£¬¸ÃÏ̵߳ÄËùÓÐÕßÊÇ event_scheduler¡£
¡¡¡¡¶þ¡¢Ó¦Óð¸Àý
¡¡¡¡±¾°¸ÀýÊÇÀûÓà event scheduler µÄÌØÐÔ£¬Ã¿ÃëÖÓµ÷ÓÃÒ»´Î´æ´¢¹ý³Ì£¬ÓÃÓÚÅÐ¶Ï SLAVE ÊÇ·ñÕý³£ÔËÐУ¬Èç¹û·¢ÏÖ SLAVE ¹Ø±ÕÁË£¬ºöÂÔ 0 ´Î´íÎó£¬È»ºóÖØÐÂÆô¶¯ SLAVE¡£
¡¡¡¡Ê×ÏÈ´´½¨´æ´¢¹ý³Ì
delimiter //
create procedure `Slave_Monitor`()
begin
SELECT VARIABLE_VALUE INTO @SLAVE_STATUS
from information_schema.GLOBAL_STATUS
WHERE VARIABLE_NAME='SLAVE_RUNNING';
IF ('ON' != @SLAVE_STATUS) THEN
 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=0;
 SLAVE START;
END IF;
end; //
delimiter ;
¡¡¡¡ÓÉÓÚ´æ´¢¹ý³ÌÖÐÎÞ·¨µ÷ÓÃÀàËÆ SHOW SLAVE STATUS ÕâÑùµÄÓï¾ä£¬Òò´ËÎÞ·¨µÃµ½È·Çеĸ´ÖÆ´íÎóÐÅÏ¢ºÍ´íÎó´úÂ룬²»ÄܽøÒ»²½µÄ´¦Àí SLAVE Í£Ö¹µÄ¸÷ÖÖÇé¿ö¡£
¡¡¡¡½Ó×Å£¬´´½¨ÈÎÎñ
CREATE EVENT IF NOT EXISTS `Slave_Monitor`
ON SCHEDULE EVERY 5 SECOND
ON COMPLETION PRESERVE
DO
CALL Slave_Monitor();
¡¡¡¡´´½¨ÁËÒ»¸öÈÎÎñ£¬Ã¿ 5ÃëÖÓ Ö´ÐÐÒ»´Î£¬ÈÎÎñ½áÊøºóÒÀ¾É±£Áô¸ÃÈÎÎñ£¬¶ø²»ÊÇɾ³ý¡


Ïà¹ØÎĵµ£º

MYSQL»ù´¡Ö®Á¬½ÓMYSQL¡¢ÐÞ¸ÄÃÜÂë¡¢Ìí¼ÓÓû§

Ò»¡¢Á¬½ÓMYSQL¡£
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £­pÓû§ÃÜÂë
1¡¢Àý1£ºÁ¬½Óµ½±¾»úÉϵÄMYSQL¡£
Ê×ÏÈÔÚ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼ mysqlbin£¬ÔÙ¼üÈëÃüÁîmysql -uroot -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂ룬Èç¹û¸Õ°²×°ºÃMYSQL£¬³¬¼¶Óû§rootÊÇûÓÐÃÜÂëµÄ£¬¹ÊÖ±½Ó»Ø³µ¼´¿É½øÈëµ½MYSQLÖÐÁË£¬MYSQLµÄÌáʾ·ûÊÇ£ºmysql>
2¡¢Àý2£ºÁ ......

tomcat6.0 + JSP + mysqlÊý¾Ý¿âÁ¬½Ó³ØÅäÖÃ


tomcat6.0 + JSP + mysqlÊý¾Ý¿âÁ¬½Ó³ØÅäÖÃ
»·¾³£ºtomcat6.0 £¬mySQL 5.021
°ÑmysqlÇý¶¯°ü·Ö±ð·Åµ½%TOMCAT_HOME%/lib ºÍÄãµÄÓ¦ÓõÄWEB-INF\libÎļþ¼ÐÏÂÃæ
1¡¢ÐÞ¸Ä%TOMCAT_HOME%/conf/server.xml,Ìí¼ÓÈçÏÂÄÚÈÝ£¨²¿·Ö²ÎÊýÇë±¾µØ»¯£©£º
      <Context path="/web" docBase="web" ......

MySQL¼Ü¹¹·½°¸(ת)

Scale Out£ººáÏòÀ©Õ¹£¬Ôö¼Ó´¦Àí½ÚµãÌá¸ßÕûÌå´¦ÀíÄÜÁ¦
Scale Up£º×ÝÏòÀ©Õ¹£¬Í¨¹ýÌáÉýµ¥¸ö½ÚµãµÄ´¦ÀíÄÜÁ¦´ïµ½ÌáÉýÕûÌå´¦ÀíÄÜÁ¦µÄÄ¿µÄ
Replication
MySQLµÄreplicationÊÇÒì²½µÄ£¬ÊÊÓÃÓÚ¶ÔÊý¾ÝʵʱÐÔÒªÇó²»ÊÇÌرð¹Ø¼üµÄ³¡¾°¡£slave¶ËµÄIOÏ̸߳ºÔð´Ómaster¶ÁÈ¡ÈÕÖ¾£¬SQLÏß ³ÌרߺÔðÔÚslave¶ËÓ¦ÓôÓmaster¶Á¹ýÀ´µÄÈÕÖ¾£¨ÔçÆÚ ......

MysqlµÄIP´¦Àíº¯Êýinet_aton()ºÍinet_ntoa()


INET_ATON(expr)
¸ø³öÒ»¸ö×÷Ϊ×Ö·û´®µÄÍøÂçµØÖ·µÄµãµØÖ·±íʾ£¬·µ»ØÒ»¸ö´ú±í¸ÃµØÖ·ÊýÖµµÄÕûÊý¡£µØÖ·¿ÉÒÔÊÇ4»ò8±ÈÌصØÖ·¡£
mysql> SELECT INET_ATON('209.207.224.40');
+-----------------------------+
| INET_ATON('209.207.224.40') |
+-----------------------------+
| 3520061480 |
+-------------------- ......

ubuntu MySQL°²×°Ö¸ÄÏ

Òª°²×° MySQL£¬¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÏÂÁÐÃüÁ
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install php5-mysql
// °²×°php5-mysql Êǽ«phpºÍmysqlÁ¬½ÓÆðÀ´
Ò»µ©°²×°Íê³É£¬MySQL ·þÎñÆ÷Ó¦¸Ã×Ô¶¯Æô¶¯¡£Äú¿ÉÒÔÔÚÖÕ¶ËÌáʾ·ûºóÔËÐÐÒÔÏÂÃüÁîÀ´¼ì²é MySQL ·þÎñÆ÷ÊÇ·ñÕýÔÚÔËÐУº ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ