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.
  • 相关阅读:
    CC DGCD:Dynamic GCD——题解
    BZOJ2243:[SDOI2011]染色——题解
    POJ1990:MooFest——题解
    POJ2299:Ultra-QuickSort——题解
    POJ2352:Stars——题解
    模板:树链剖分
    BZOJ1036:[ZJOI2008]树的统计——题解
    国务院正式“回应”马云:绝对不允许孩子们在30年后找不到工作!
    接口测试用例设计实践总结
    接口测试用例设计实践总结
  • 原文地址:https://www.cnblogs.com/hgj123/p/4284223.html
Copyright © 2011-2022 走看看