gearman with postgresql as persistent Queuing

來源:互聯網
上載者:User

標籤:style   blog   io   color   os   ar   for   sp   div   

gearman is a good thing

 

gearman client --------------> gearman server <------------------------gearman worker

 

clients are requesting to handler something, 

gearman server is delivering jobs

gearman workers get some jobs and finish.

 

So different programming languages can work together.

 

Now we need to plant gearman persistent queues on postgresql.

So.

Now

Persistent Queue
  • Tools: gearman, postgresql, python, django model and other 3rd party libs
  • bash sudo pip install gearman && sudo apt-get install gearman -y
  • Database settings: [username] = gearman, [password] = ‘gearman_password_123‘, [database] = ‘chatservice‘, [port]=5432, [table_name] = queue123
  • sudo su - postgres# Then, psql# ThenCREATE DATABASE gearman;CREATE USER gearman with password gearman_password_123;GRANT ALL PRIVILEGES ON DATABASE gearman to gearman;

     

    On a server:
There are two ways to make gearman work with Postgresql serverFIRST WAY
  • Postgresql

To get Postgresql working you need to use the -q Postgeres command line option.

Below is a command line to get persistent queues working with Postgresql. This command line was run on Ubuntu 12.04 server, Postgresql version 9.1, and Gearman v 0.27.

gearmand -L 127.0.0.1 –libpq-conninfo ‘hostaddr=127.0.0.1 port=5432 dbname=gearman user=gearman password=gearman_password_123‘ –libpq-table=gearmanqueue1 –verbose DEBUG -q Postgres

 

  • Also note: gearmand will create the table if it does not already exist. In the case above, it will create a table named gearmanqueue1
  • You can see /var/log/gearman-job-server/gearman.log for log if error or somehow.
SECOND WAY
  • Edit the file /etc/default/gearman_job_server and make sure it would look like this:
export PGHOST=127.0.0.1export PGPORT=5432export PGUSER=gearmanexport PGPASSWORD=gearman_password_123export PGDATABASE=gearmanPARAMS="-q Postgres --libpq-table=gearmanqueue1 --verbose DEBUG"

 

  • Then try to start the service bash sudo service gearman-job-server start, gearman will auto-matically create a table ‘gearmanqueue1‘ there.
The second way is recommended.

 

gearman with postgresql as persistent Queuing

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.