zoukankan      html  css  js  c++  java
  • 018 nginx与第三模块整合[一致性哈希模块整合]

    nginx第三方模块官网:http://wiki.nginx.org/HttpUpstreamConsistentHash
    
    nginx第三方模块下载地址:https://github.com/replay/ngx_http_consistent_hash/archive/master.zip
    
    下载模块   wget https://github.com/replay/ngx_http_consistent_hash/archive/master.zip
    
    解压:unzip   master.zip
    
    nginx整合第三方模块 [nginx-1.4.2]  ./configure --prefix=/usr/local/nginx/  --add-module=/ngx_http_consistent_hash-master/
    
    #杀掉nginx进程
    pkill
    -9 nginx #重新编译 make && make install cd /usr/local/nginx/ [root@localhost nginx]# ./sbin/nginx [root@localhost nginx]# ls sbin/ 出现:nginx nginx.old 编写conf文件: vim conf/nginx.conf #配置服务器 upstream mcserver{ consistent_hash $request_uri; server 127.0.0.1:11214; server 127.0.0.1:11212; server 127.0.0.1:11213; } location / { #设置key set $memcached_key "$uri"; #根据key查找对应的服务器 memcached_pass mcserver; #出错的时候回调php,查找数据库中的数据 error_page 404 /callback.php; } #开启memcached ./usr/local/memcached/bin/memcached -m 64 -p 11211 -vvv 【注意不能是root用户开启】 ./usr/local/memcached/bin/memcached -u nobody -vv -p 11211 开启telnet telnet 127.0.0.1 11211 回车 ctrl+] 打开回显回车。 #修改callback.php $memc->addServer('127.0.0.1',11212); $memc->addServer('127.0.0.1',11213); $memc->addServer('127.0.0.1',11214); #在php.ini中添加 memcache.hash_strategy=consistent 杀掉PHP进程 pkill -9 php 重新启动php-fpm /usr/sbin/php-fpm 【注意】upstream 做负载均衡时要用IP或者 远程主机名,不能用localhost.
  • 相关阅读:
    Codeforces Round #279 (Div. 2) C. Hacking Cypher 机智的前缀和处理
    Codeforces Round #279 (Div. 2) A. Team Olympiad 水题
    Codeforces Round #279 (Div. 2) B
    利用Hog特征和SVM分类器进行行人检测
    opencv 支持向量机SVM分类器
    opencv hog算子
    NOIP 2008 传纸条 NOIP 2000 方块取数 多线程DP
    POJ 1654 Area 计算几何
    hihocoder #1015 KMP
    HDU 1722 Cake 数学题
  • 原文地址:https://www.cnblogs.com/hgj123/p/4284223.html
Copyright © 2011-2022 走看看