2014年6月30日 星期一

ImportError: No module named gearman

# pip install gearman

Gearman 使用 MySQL 作爲 job queue

* 工作在執行完後會從資料庫刪除


安裝編譯相關套件:
# apt-get build-dep gearman-job-server
# apt-get install gperf libmysqlclient-dev libmysqld-dev

下載 Gearman :
https://launchpad.net/gearmand

$ wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
$ tar zxf gearmand-1.1.12.tar.gz
$ cd gearmand-1.1.12
$ ./configure --prefix=/opt/gearman
   ...
   ...
   ...
   * CPP Flags:                  -fvisibility=hidden
   * LIBS:                    
   * LDFLAGS Flags:           
   * Assertions enabled:        no
   * Debug enabled:             no
   * Warnings as failure:       no
   * Building with libsqlite3   yes
   * Building with libdrizzle   yes
   * Building with libmemcached yes
   * Building with libpq        yes
   * Building with tokyocabinet no
   * Building with libmysql     yes
   * SSL enabled:               no
   * cyassl found:              no
   * openssl found:             yes
   * make -j:                   2
   * VCS checkout:              no
   * sphinx-build:              :
$ make
# make install


新增資料庫:
CREATE DATABASE gearman;
CREATE TABLE gearman_queue ( 
    unique_key VARCHAR(255),
    function_name VARCHAR(255),
    priority INT,
    data LONGBLOB,
    when_to_run BIGINT,
    unique key (unique_key, function_name)
);

 
啓動:
# /opt/gearman/sbin/gearmand --log-file=/var/log/gearmand.log --queue-type=MySQL --mysql-host=127.0.0.1 --mysql-user=gearman --mysql-password=gearman --mysql-db=gearman --mysql-table=gearman_queue --mysql-port=3306 





References :
【CentOS】Gearman のジョブを MySQL に保存する - pospomeのプログラミング日記
生活在別處 : Gearman 安装及常见问题

舊:
Using Persistent Storage with Gearman | LornaJane

2014年6月28日 星期六

SNMP 概念

管理者 Manager (Server)
代理者 Agent (Client)


SNMP Version :
1, 2c, 3
3 : 確保 community 間通訊均爲加密
 
 
SNMP Community :
類似密碼
預設 "public" community 具有 read-only 功能
預設 "private" community 具有 read-write 以及讀取某些限制性數值的功能


管理者以 snmpget, snmpwalk 向代理者要求值
管理者以 snmpset 向代理者傳送值
代理者以 snmptrap 向管理者 snmptrapd 主動傳送值 (如:電池電量低訊息)