• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            xiaoguozi's Blog
            Pay it forword - 我并不覺的自豪,我所嘗試的事情都失敗了······習慣原本生活的人不容易改變,就算現狀很糟,他們也很難改變,在過程中,他們還是放棄了······他們一放棄,大家就都是輸家······讓愛傳出去,很困難,也無法預料,人們需要更細心的觀察別人,要隨時注意才能保護別人,因為他們未必知道自己要什么·····
            官網:http://gearman.org/

            跨多種環境部署 Gearman
            http://www.ibm.com/developerworks/cn/opensource/os-gearman/index.html
            利用開源的Gearman框架構建分布式圖片處理平臺-張宴
            http://blog.s135.com/dips/
            監控:
            https://github.com/yugene/Gearman-Monitor

            一、簡介
            Gearman是一個分發任務的程序架構,由三部分組成:
            Gearman client:提供gearman client API給應用程序調用。API可以使用C,PHP,PERL,MYSQL UDF等待呢個語言,它是請求的發起者。
            Gearman job server:將客戶端的請求分發到各個gearman worker的調度者,相當于中央控制器,但它不處理具體業務邏輯。
            Gearman worker:提供gearman worker API給應用程序調用,具體負責客戶端的請求,并將處理結果返回給客戶端。
            Mogilefs的分布式文件系統的核心就是用gearman實現的。
            這個軟件的應用場景很多,比如視頻網站的視頻處理,分布式日志處理,電子郵件處理,文件同步處理,圖片處理等等,只要是可以放開,不影響體驗和響應的場 景,需要并行進行大量計算和處理的程序都是可以的。Yahoo在60或更多的服務器上使用gearman每天處理600萬個作業。新聞聚合器digg構建 了一個相同規模的gearman網絡,每天可處理400000個作業。
            Gearman不但可以做為任務分發,還可以做為應用方面的負載均衡??梢宰寃orker放在不同的一堆服務器上,也可以啟動放在同一個cpu的多個核 上。比如,應用視頻轉換程序,不希望web服務器來處理視頻格式轉換,這時,可以在這一堆服務器上進行任務分發,在上面加載worker處理視頻格式,對 外的web服務器就不會被視頻轉換過程影響。而且擴展方便,加一臺服務器到任務調度中心,注冊成worker即可,這時job server會在請求到來的時候,將請求發送給空閑的worker。還可以運行多個job server,組成ha架構,如果一個job server當掉了,client和worker會自動遷移到另一臺job server上。

            二、安裝
            [Job Server (gearmand) -- 172.16.1.183]
            1.首先安裝libdrizzle
                #yum install libdrizzle libdrizzle-devel
            2.安裝gearman(兩種方法1.yum2.源碼包)。(c版的server)
                1)yum安裝
                #rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm
                #yum install -y gearmand
                2)源碼包安裝
                #cd /opt/build/
                #wget https://launchpad.net/gearmand/trunk/0.34/+download/gearmand-0.34.tar.gz
                #tar zxf gearmand-0.34.tar.gz
                #cd gearmand-0.34
                #./configure
                #make && make install
            3.啟動gearman服務
                1)yum安裝方式
                #/etc/init.d/gearmand start
                2)源碼包安裝方式
                #/opt/build/gearmand-0.34/sbin/gearmand -d

                #gearmand -vvv -u root
                INFO Starting up
                INFO Listening on :::4730 (6)
                INFO Creating wakeup pipe
                INFO Creating IO thread wakeup pipe
                INFO Adding event for listening socket (6)
                INFO Adding event for wakeup pipe
                INFO Entering main event loop

            worker&&client以php方式
            [worker --  172.16.1.180]
            安裝gearmand如上所示

            安裝 Gearman PHP extension
            1.下載gearman-0.8.0.tgz并安裝
                #cd /opt/build/
                #wget http://pecl.php.net/get/gearman-0.8.0.tgz
                # yum install -y libgearman-devel.x86_64
                # yum install -y re2c
                #tar zxf gearman-0.8.0.tgz
                #cd gearman-0.8.0.tgz
                #phpize
                # ./configure
                # make && make install
            2.編輯php.ini配置文件加載相應模塊并使之生效
                # vim /etc/php.ini
                extension = "gearman.so"
            3.查看gearman.so模塊是否加載
                # php --info | grep gearman
                gearman
                gearman support => enabled
                libgearman version => 0.14
                PWD => /opt/build/gearman-0.8.0
                _SERVER["PWD"] => /opt/build/gearman-0.8.0
                # php -m | grep gearman
                gearman
            4.啟動job
            gearmand -d
            如果當前用戶是 root 的話,則需要這樣操作:
            gearmand -d -u root
            缺省會使用 4730 端口,下面會用到。
                注意:如果找不到 gearmand 命令的路徑,別忘了用 whereis gearmand 確認

            [client -- 172.16.1.181]
                安裝如work同。如上所示。

            三、測試:
            [Job Server (gearmand) -- 172.16.1.183]
            啟動gearmand

            以命令行工具來驗證gearman的功能
            啟動 Worker:gearman -h 172.16.1.183 -w -f wc -- wc -l &
            運行Client:gearman -h 172.16.1.183 -f wc < /etc/passwd
            42
            可以看到驗證成功。

            以php驗證gearman的功能
            編寫 Worker
            worker.php 文件內容如下:
            <?php
            $worker= new GearmanWorker();
            $worker->addServer('172.16.1.183', 4730);
            $worker->addFunction('reverse', 'my_reverse_function');
            while ($worker->work());
            function my_reverse_function($job) {
            return strrev($job->workload());
            }
            ?>
            設置后臺運行 work
            php worker.php &
            編寫 Client
            client.php 文件內容如下:
            <?php
            $client= new GearmanClient();
            $client->addServer('172.16.1.183', 4730);
            echo $client->do('reverse', 'Hello World!'), "\n";
            ?>
            運行 client
            php client.php
            輸出:!dlroW olleH

            Q:

            I've been trying to get Gearman compiled on CentOS 5.8 all afternoon. Unfortunately I am restricted to this version of CentOS by my CTO and how he has our entire network configured. I think it's simply because we don't have enough resources to upgrade our network... But anyways, the problem at hand.

            I have searched through Server Fault, Stack Overflow, Google, and am unable to locate a working solution. What I have below is stuff I have pieced together from my searching.

            Searches have told said to install the following via yum:

            yum -y install --enablerepo=remi boost141-devel libgearman-devel e2fsprogs-devel e2fsprogs gcc44 gcc-c++ 

            To get the Boost headers working correctly I did this:

            cp -f /usr/lib/boost141/* /usr/lib/ cp -f /usr/lib64/boost141/* /usr/lib64/ rm -f /usr/include/boost ln -s /usr/include/boost141/boost /usr/include/boost 

            With all of the dependancies installed and paths setup I then download and compile gearmand-1.1.2 just fine.

            wget -O /tmp/gearmand-1.1.2.tar.gz https://launchpad.net/gearmand/1.2/1.1.2/+download/gearmand-1.1.2.tar.gz cd /tmp && tar zxvf gearmand-1.1.2.tar.gz ./configure && make -j8 && make install 

            That works correctly. So now I need to install the Gearman library for PHP. I have attempted through PECL and downloading the source directly, both result in the same error:

            checking whether to enable gearman support... yes, shared not found configure: error: Please install libgearman 

            What I don't understand is I installed the libgearman-devel package which also installed the core libgearman. The installation installs libgearman-devel-0.14-3.el5.x86_64, libgearman-devel-0.14-3.el5.i386, libgearman-0.14-3.el5.x86_64, and libgearman-0.14-3.el5.i386.

            Is it possible the package version is lower than what is required? I'm still poking around with this, but figured I'd throw this up to see if anyone has a solution while I continue to research a fix.

            Thanks!


            A:

            This should do the trick:

            export GEARMAN_LIB_DIR=/usr/include/libgearman 
            export GEARMAN_INC_DIR=/usr/include/libgearman

            That should work, if not you'll have to do some minor edits to config.m4.


            other:

            http://gearman.org/gearman_php_extension
            http://blog.csdn.net/aidenliu/article/details/7406390
            http://www.php.net/manual/en/gearmanclient.dobackground.php
            http://www.wenzizone.com/2012/09/27/how_to_fix_rpm_filedigests_payloadisxz_is_needed.html
            http://www.2cto.com/os/201206/136785.html
            http://blog.s135.com/dips
            http://blog.csdn.net/hfahe/article/details/5519582
            http://hi.baidu.com/sunjiujiu/item/4406281c952cf47a7b5f2594

            posted on 2013-01-07 16:39 小果子 閱讀(7887) 評論(0)  編輯 收藏 引用 所屬分類: 學習筆記 、Linux 、框架
            亚洲AV无码久久| 久久人人爽人人爽人人AV东京热| 国产欧美久久一区二区| 久久久无码精品亚洲日韩按摩 | 日本精品一区二区久久久| 日产久久强奸免费的看| 精品久久久一二三区| 久久国产精品成人影院| 一本大道加勒比久久综合| 亚洲国产精品无码久久98| 久久av无码专区亚洲av桃花岛| 久久国产精品久久精品国产| 国产精品伊人久久伊人电影| 99精品国产99久久久久久97 | 久久青青色综合| 国产91色综合久久免费分享| 亚洲国产成人乱码精品女人久久久不卡 | 亚洲va久久久噜噜噜久久男同| 久久久久无码精品国产| 亚洲а∨天堂久久精品9966| 99久久精品毛片免费播放| 久久国产欧美日韩精品免费| 99国内精品久久久久久久 | 99国产欧美久久久精品蜜芽| 思思久久99热只有频精品66| 久久综合九色综合久99| 国内精品久久久久影院优| 91精品国产91久久| 久久久精品一区二区三区| 欧美777精品久久久久网| 久久国产色AV免费观看| 久久精品www人人爽人人| 国内精品久久久久影院一蜜桃| 亚洲精品国产字幕久久不卡| 久久福利资源国产精品999| 亚洲а∨天堂久久精品| 久久乐国产精品亚洲综合| 久久综合狠狠综合久久激情 | 2021精品国产综合久久| 99精品国产在热久久无毒不卡| 欧美久久一级内射wwwwww.|