gearman with postgresql as persistent Queuing

本文详细介绍了如何将Gearman持久队列整合到PostgreSQL数据库中,包括使用命令行工具和编辑配置文件的方法,确保不同编程语言能够协同工作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
    # Then
    CREATE 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 server

FIRST 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.1
export PGPORT=5432
export PGUSER=gearman
export PGPASSWORD=gearman_password_123
export PGDATABASE=gearman
PARAMS="-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.

 

转载于:https://www.cnblogs.com/spaceship9/p/4058204.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值