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=
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.
The second way is recommended.

gearman with postgresql as persistent Queuing的更多相关文章

  1. gearman 简单试用

    服务启动 使用yum 的安装包 安装server yum install  -y gearmand 启动 systemctl restart  gearmand   启动worker gearman ...

  2. gearman mysql持久化

    gearman 创建Mysql持久化队列的方式如下: 启动gearman,命令如下: gearmand命令: -b, –backlog=BACKLOG 连接请求队列的最大值 -d, –daemon D ...

  3. PostgreSQL的OGG -- bucardo

    bucardo是PostgreSQL数据库中实现双向同步的软件,可以实现PostgreSQL数据库的双master的方案,不过bucardo中的同步都是异步的,它是通过触发器记录变化,程序是perl写 ...

  4. Streaming replication slots in PostgreSQL 9.4

    Streaming replication slots are a pending feature in PostgreSQL 9.4, as part of the logical changese ...

  5. gearman安装及初次使用

    官网:  http://gearman.org/ 一篇文章: 利用Gearman实现异步任务处理 一.问题分析 问题:在性能测试过程中,发现用户管理平台在进行图片上传时,性能不佳. 分析:经过代码分析 ...

  6. psycopg2.pool – Connections pooling / psycopg2.pool – 连接池 / postgresql 连接池

    创建新的PostgreSQL连接可以是一个昂贵的操作.这个模块提供了一些纯Python类直接在客户端应用程序实现简单的连接池.      class psycopg2.pool.AbstractCon ...

  7. 对PostgreSQL xmin的深入学习

    当PostgreSQL需要insert 一条记录的时候,它会把记录头放入xmin,xmax等字段. xmin的值,就是当前的Transaction的TransactionId.这是为了满足MVCC的需 ...

  8. PHP+lghttpd + postgresql 环境搭建

    PHP+lghttpd + postgresql 环境搭建 Linux 下PHP环境搭建 安装环境:PHP+lghttpd + postgresql 1:yum install lighttpd 红旗 ...

  9. gearman学习笔记1

    1.简介       gearman是一个分布式开发框架,适合处理一些必须处理但是不影响主流程的操作,比如保存日志.发送邮件.缩略图片等.最早是基于perl语言的,2008年发布的时候改为C++语言开 ...

随机推荐

  1. POJ 1182(食物链-另类做法【拆点】)[Template:并查集]

    食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 46039   Accepted: 13400 Description ...

  2. Python_生成測试数据

    本文出自:http://blog.csdn.net/svitter 生成1~10的随机数1000个: import random fp = open("test", 'w'); f ...

  3. sessionStorage、localStorage、cookie

    sessionStorage 和 localStorage 是HTML5 Web Storage API 提供的,可以方便的在web请求之间保存数据.有了本地数据,就可以避免数据在浏览器和服务器间不必 ...

  4. [推荐]ORACLE PL/SQL编程之四:把游标说透(不怕做不到,只怕想不到)

    原文:[推荐]ORACLE PL/SQL编程之四:把游标说透(不怕做不到,只怕想不到) [推荐]ORACLE PL/SQL编程之四: 把游标说透(不怕做不到,只怕想不到) 继上两篇:ORACLE PL ...

  5. ubuntu下Eclipse无法启动

    我的Ubuntu是12.04 LTS版的.jdk是官网下载后解压就可以用的.配置好PATH和CLASSPATH后,双击Eclipse弹出这个窗口: 但是如果通过终端,以命令行的方式执行 ./eclip ...

  6. JS中childNodes深入学习

    原文:JS中childNodes深入学习 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <ti ...

  7. Object.prototype.toString &amp; typeof

    Object.prototype.toString & typeof Object.prototype.toString 获取某个对象属于哪种内置类型 typeof  得到某个对象的类型 差别 ...

  8. [ext/iconv/iconv.lo] Error 1

    办法1: wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz tar -zxvf libiconv-1.13.1.tar.g ...

  9. 我的Android 4 学习系列之Intent 和 Broadcast Reciever

    目录 Intent 简介 使用隐式和显式Intent启动Activity.子Acitivity和Service 使用Linkify 使用Broadcast Intent 广播事件 使用 Pending ...

  10. 【工作笔记五】html5的placeholder属性(IE如何兼容placeholder属性)

    placeholder属性,IE对其的支持表示无奈,firefox.google chrome表示毫无压力. HTML5对Web Form做了许多增强,比如input新增的type类型.Form Va ...