Use MySQL UDFs to call gearman distributed task distribution system

When inserting data into the table, triggering the execution of certain tasks to install gearman participate: http://www.ttlsa.com/html/663.html . A mounting gearman-mysql-udf # apt- get install libmysql ++ - dev # wget https://launchpad.net/gearman-mysql-udf/trunk/0.6/+download/gearman-mysql-udf-0.6.tar.gz CREATE AGGREGATE FUNCTION gman_sum RETURNS INTEGER SONAME "libgearman_mysql_udf.so"; mysql> CREATE FUNCTION gman_servers_set RETURNS STRING SONAME "libgearman_mysql_udf.so"; mysql> SELECT gman_servers_set ( "192.168.1.60:4730,192.168.1.60:4731") as gman_servers; / / set gearman server + ------------------------------------- + | gman_servers | + --- ---------------------------------- + | 192.168.1.60:4730,192.168.1.60:4731 | + - ------------------------------------ + mysql> create table udf_test (-> id int unsigned auto_increment primary key, -> val varchar (20) not null); // Create table mysql> create trigger sendmail before insert on udf_test for each row set @ return = gman_do_background ( 'MAIL', 'undef'); // create a trigger, when inserting data into a table udf_test time, perform the task. [/ Codesyntax] # perl -MCPAN -e shell cpan> '[email protected]' , Pass => '******',); Print "$ DATE \ n-"; My Status = $ $ mail-> Send (from => '[email protected]' , from_title => 'ttlsa', to => '[email protected]' , Subject => "$ DATE the MAIL the Test", MSG => "$ DATE", HTML => "<B> Test DATE $ </ B > ",); if ($ status) {print $ mail-> error;}!} [/ codesyntax] # perl WORKER_SENDMAIL.pl & # perl WORKER_SENDMAIL.pl & // two runs in the background test a two worker. udf_test insert data into mysql table> insert into udf_test value ( '' , 'a'); 2. to see if the message was received three .Gearman server information # telnet 192.168.1.60 4730 Trying 192.168.1.60 ... Connected to 192.168.1.60 . Escape character is '^]' .status MAIL 0 0 2 Note: The first column worker name; the second column the number of jobs performed; the third column the number of jobs queue; fourth column the number of available worker

Reproduced in: https: //my.oschina.net/766/blog/211040

Guess you like

Origin blog.csdn.net/weixin_34015566/article/details/91546861