Nginx之读写分离

1.实验拓扑

Nginx之读写分离_第1张图片

       需求分析,前端一台nginx做负载均衡反向代理,后面两台httpd服务器。整个架构是提供BBS(论坛)服务,有一需求得实现读写分离,就是上传附件的功能,我们上传的附件只能上传到Web1,然后在Web1上利用rsync+inotify实现附件同步,大家都知道rsync+inotify只能是主向从同步,不能双向同步。所以Web1可进行写操作,而Web2只能进行读操作,这就带来读写分离的需求,下面我们就来说一下,读写分离怎么实现。

2.WebDAV功能说明

       WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通信协议。它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法,使应用程序可直接对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制。这样我们就能配置读写分离功能了,下面我们来具体配置一下。

3.修改配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@nginx nginx] # vim /etc/nginx/nginx.conf
server {
         listen       80;
         server_name  localhost;
         #charset koi8-r;
         #access_log  logs/host.access.log  main;
         location / {
                 proxy_pass http: //192 .168.18.202;
                 if  ($request_method =  "PUT" ){
                         proxy_pass http: //192 .168.18.201;
                 }
         }
}

4.重新加载一下配置文件

1
2
3
4
[root@nginx ~] # service nginx reload
nginx: the configuration  file  /etc/nginx/nginx .conf syntax is ok
nginx: configuration  file  /etc/nginx/nginx .conf  test  is successful
重新载入 nginx:                                           [确定]

5.配置httpd的WebDAV功能

1
[root@web1 ~] # vim /etc/httpd/conf/httpd.conf


注,在下启用就行。

6.重新启动一下httpd

1
2
3
[root@web1 ~] # service httpd restart
停止 httpd:                                               [确定]
正在启动 httpd:                                           [确定]

7.测试一下

1
2
3
4
[root@nginx ~] # curl http://192.168.18.201

web1. test .com< /h1 >

[root@nginx ~] # curl http://192.168.18.202

web2. test .com< /h1 >

注,web1与web2访问都没问题。

1
2
3
4
5
6
7
8
9
10
[root@nginx ~] # curl -T /etc/issue  http://192.168.18.202
"-//IETF//DTD HTML 2.0//EN" >
< head >
405 Method Not Allowed<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/title</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number5 index4 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/head</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">><body></code> </div> <div class="line number6 index5 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><h1>Method Not Allowed<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/h1</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number7 index6 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">The requested method PUT is not allowed </code> <code class="bash keyword" style="font-family:'microsoft yahei', arial, simsun;">for</code>  <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">the URL </code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/issue</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">.</code> </div> <div class="line number8 index7 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><hr></code> </div> <div class="line number9 index8 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><address>Apache</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/2</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">.2.15 (CentOS) Server at 192.168.18.202 Port 80<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/address</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number10 index9 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/body</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/html</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> </div> </td> </tr> </tbody> </table> </div> </div> <p style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <span style="font-family:'微软雅黑', 'microsoft yahei';">注,我们上传文件到,web2上时,因为web2只人读功能,所以没有开户WebDAV功能,所以显示是405 Method Not Allowed。  <br style="font-family:'microsoft yahei', arial, simsun;"></span></p> <div style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <div class="syntaxhighlighter bash ie" id="highlighter_869682"> <table border="0"> <tbody> <tr> <td class="gutter" style="font-family:'microsoft yahei', arial, simsun;"> <div class="line number1 index0 alt2"> 1 </div> <div class="line number2 index1 alt1"> 2 </div> <div class="line number3 index2 alt2"> 3 </div> <div class="line number4 index3 alt1"> 4 </div> <div class="line number5 index4 alt2"> 5 </div> <div class="line number6 index5 alt1"> 6 </div> <div class="line number7 index6 alt2"> 7 </div> <div class="line number8 index7 alt1"> 8 </div> <div class="line number9 index8 alt2"> 9 </div> <div class="line number10 index9 alt1"> 10 </div> <div class="line number11 index10 alt2"> 11 </div> </td> <td class="code" style="font-family:'microsoft yahei', arial, simsun;"> <div> <div class="line number1 index0 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">[root@nginx ~]</code> <code class="bash comments" style="font-family:'microsoft yahei', arial, simsun;"># curl -T /etc/issue  http://192.168.18.201</code> </div> <div class="line number2 index1 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><!DOCTYPE HTML PUBLIC </code> <code class="bash string" style="font-family:'microsoft yahei', arial, simsun;">"-//IETF//DTD HTML 2.0//EN"</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number3 index2 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><html><</code> <code class="bash functions" style="font-family:'microsoft yahei', arial, simsun;">head</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number4 index3 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><title>403 Forbidden<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/title</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number5 index4 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/head</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">><body></code> </div> <div class="line number6 index5 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><h1>Forbidden<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/h1</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number7 index6 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">You don't have permission to access </code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/issue</code> </div> <div class="line number8 index7 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">on this server.</code> </div> <div class="line number9 index8 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><hr></code> </div> <div class="line number10 index9 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><address>Apache</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/2</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">.2.15 (CentOS) Server at 192.168.18.201 Port 80<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/address</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number11 index10 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/body</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/html</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> </div> </td> </tr> </tbody> </table> </div> </div> <p style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <span style="font-family:'微软雅黑', 'microsoft yahei';">注,我们在Web1开启了WebDAV功能,但我们目录是root目录是不允许apache用户上传的,所以显示的是403 Forbidden。下面我们给apache授权,允许上传。</span><br></p> <div style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <div class="syntaxhighlighter bash ie" id="highlighter_46104"> <table border="0"> <tbody> <tr> <td class="gutter" style="font-family:'microsoft yahei', arial, simsun;"> <div class="line number1 index0 alt2"> 1 </div> </td> <td class="code" style="font-family:'microsoft yahei', arial, simsun;"> <div> <div class="line number1 index0 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">[root@web1 ~]</code> <code class="bash comments" style="font-family:'microsoft yahei', arial, simsun;"># setfacl -m u:apache:rwx /var/www/html/</code> </div> </div> </td> </tr> </tbody> </table> </div> </div> <p style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <span style="font-family:'微软雅黑', 'microsoft yahei';">下面我们再来测试一下,</span></p> <div style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <div class="syntaxhighlighter bash ie" id="highlighter_144788"> <table border="0"> <tbody> <tr> <td class="gutter" style="font-family:'microsoft yahei', arial, simsun;"> <div class="line number1 index0 alt2"> 1 </div> <div class="line number2 index1 alt1"> 2 </div> <div class="line number3 index2 alt2"> 3 </div> <div class="line number4 index3 alt1"> 4 </div> <div class="line number5 index4 alt2"> 5 </div> <div class="line number6 index5 alt1"> 6 </div> <div class="line number7 index6 alt2"> 7 </div> <div class="line number8 index7 alt1"> 8 </div> <div class="line number9 index8 alt2"> 9 </div> <div class="line number10 index9 alt1"> 10 </div> </td> <td class="code" style="font-family:'microsoft yahei', arial, simsun;"> <div> <div class="line number1 index0 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">[root@nginx ~]</code> <code class="bash comments" style="font-family:'microsoft yahei', arial, simsun;"># curl -T /etc/issue  http://192.168.18.201</code> </div> <div class="line number2 index1 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><!DOCTYPE HTML PUBLIC </code> <code class="bash string" style="font-family:'microsoft yahei', arial, simsun;">"-//IETF//DTD HTML 2.0//EN"</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number3 index2 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><html><</code> <code class="bash functions" style="font-family:'microsoft yahei', arial, simsun;">head</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number4 index3 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><title>201 Created<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/title</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number5 index4 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/head</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">><body></code> </div> <div class="line number6 index5 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><h1>Created<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/h1</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number7 index6 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">Resource </code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/issue</code>  <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">has been created.</code> </div> <div class="line number8 index7 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><hr /></code> </div> <div class="line number9 index8 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><address>Apache</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/2</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">.2.15 (CentOS) Server at 192.168.18.201 Port 80<</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/address</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> <div class="line number10 index9 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;"><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/body</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">><</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">/html</code> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">></code> </div> </div> </td> </tr> </tbody> </table> </div> </div> <p style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <span style="font-family:'微软雅黑', 'microsoft yahei';">注,大家可以看到我们成功的上传了文件,说明nginx读写分离功能配置完成。最后,我们来查看一下上传的文件。</span></p> <div style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <div class="syntaxhighlighter bash ie" id="highlighter_69653"> <table border="0"> <tbody> <tr> <td class="gutter" style="font-family:'microsoft yahei', arial, simsun;"> <div class="line number1 index0 alt2"> 1 </div> <div class="line number2 index1 alt1"> 2 </div> <div class="line number3 index2 alt2"> 3 </div> <div class="line number4 index3 alt1"> 4 </div> <div class="line number5 index4 alt2"> 5 </div> <div class="line number6 index5 alt1"> 6 </div> </td> <td class="code" style="font-family:'microsoft yahei', arial, simsun;"> <div> <div class="line number1 index0 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">[root@web1 ~]</code> <code class="bash comments" style="font-family:'microsoft yahei', arial, simsun;"># cd /var/www/html/</code> </div> <div class="line number2 index1 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">[root@web1 html]</code> <code class="bash comments" style="font-family:'microsoft yahei', arial, simsun;"># ll</code> </div> <div class="line number3 index2 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">总用量 12</code> </div> <div class="line number4 index3 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">drwxr-xr-x 2 root   root   4096 9月   4 13:16 forum</code> </div> <div class="line number5 index4 alt2"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">-rw-r--r-- 1 root   root     23 9月   3 23:37 index.html</code> </div> <div class="line number6 index5 alt1"> <code class="bash plain" style="font-family:'microsoft yahei', arial, simsun;">-rw-r--r-- 1 apache apache   47 9月   4 14:06 issue</code> </div> </div> </td> </tr> </tbody> </table> </div> </div> <p style="font-family:'microsoft yahei', arial, simsun;color:rgb(46,46,46);font-size:16px;line-height:24px;"> <span style="font-family:'微软雅黑', 'microsoft yahei';">好了,到这里nginx的反向代理、负载均衡、页面缓存、URL重写及读写分离就全部讲解完成。希望大家有所收获,^_^……</span></p> </div> </div> </div> </div> </div> <!--PC和WAP自适应版--> <div id="SOHUCS" sid="1276421244832464896"></div> <script type="text/javascript" src="/views/front/js/chanyan.js"></script> <!-- 文章页-底部 动态广告位 --> <div class="youdao-fixed-ad" id="detail_ad_bottom"></div> </div> <div class="col-md-3"> <div class="row" id="ad"> <!-- 文章页-右侧1 动态广告位 --> <div id="right-1" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_1"> </div> </div> <!-- 文章页-右侧2 动态广告位 --> <div id="right-2" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_2"></div> </div> <!-- 文章页-右侧3 动态广告位 --> <div id="right-3" class="col-lg-12 col-md-12 col-sm-4 col-xs-4 ad"> <div class="youdao-fixed-ad" id="detail_ad_3"></div> </div> </div> </div> </div> </div> </div> <div class="container"> <h4 class="pt20 mb15 mt0 border-top">你可能感兴趣的:(Nginx,漫漫编程路)</h4> <div id="paradigm-article-related"> <div class="recommend-post mb30"> <ul class="widget-links"> <li><a href="/article/1835434126874865664.htm" title="ubuntu安装wordpress" target="_blank">ubuntu安装wordpress</a> <span class="text-muted">lissettecarlr</span> <div>1安装nginx网上安装方式很多,这就就直接用apt-get了apt-getinstallnginx不用启动啥,然后直接在浏览器里面输入IP:80就能看到nginx的主页了。如果修改了一些配置可以使用下列命令重启一下systemctlrestartnginx.service2安装mysql输入安装前也可以更新一下软件源,在安装过程中将会让你输入数据库的密码。sudoapt-getinstallmy</div> </li> <li><a href="/article/1835432358141063168.htm" title="深入浅出 -- 系统架构之负载均衡Nginx的性能优化" target="_blank">深入浅出 -- 系统架构之负载均衡Nginx的性能优化</a> <span class="text-muted">xiaoli8748_软件开发</span> <a class="tag" taget="_blank" href="/search/%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84/1.htm">系统架构</a><a class="tag" taget="_blank" href="/search/%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84/1.htm">系统架构</a><a class="tag" taget="_blank" href="/search/%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1/1.htm">负载均衡</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a> <div>一、Nginx性能优化到这里文章的篇幅较长了,最后再来聊一下关于Nginx的性能优化,主要就简单说说收益最高的几个优化项,在这块就不再展开叙述了,毕竟影响性能都有多方面原因导致的,比如网络、服务器硬件、操作系统、后端服务、程序自身、数据库服务等,对于性能调优比较感兴趣的可以参考之前《JVM性能调优》中的调优思想。优化一:打开长连接配置通常Nginx作为代理服务,负责分发客户端的请求,那么建议开启H</div> </li> <li><a href="/article/1835428317084348416.htm" title="最简单将静态网页挂载到服务器上(不用nginx)" target="_blank">最简单将静态网页挂载到服务器上(不用nginx)</a> <span class="text-muted">全能全知者</span> <a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/html/1.htm">html</a><a class="tag" taget="_blank" href="/search/%E7%AC%94%E8%AE%B0/1.htm">笔记</a> <div>最简单将静态网页挂载到服务器上(不用nginx)如果随便弄个静态网页挂在服务器都要用nignx就太麻烦了,所以直接使用Apache来搭建一些简单前端静态网页会相对方便很多检查Web服务器服务状态:sudosystemctlstatushttpd#ApacheWeb服务器如果发现没有安装web服务器:安装Apache:sudoyuminstallhttpd启动Apache:sudosystemctl</div> </li> <li><a href="/article/1835382307679203328.htm" title="鲲鹏 ARM 架构 麒麟 Lylin v10 安装 Nginx (离线)" target="_blank">鲲鹏 ARM 架构 麒麟 Lylin v10 安装 Nginx (离线)</a> <span class="text-muted">焚木灵</span> <a class="tag" taget="_blank" href="/search/arm%E5%BC%80%E5%8F%91/1.htm">arm开发</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>最近做一个银行的项目,银行的服务器是鲲鹏ARM架构的服务器,并且是麒麟v10的系统,这里记录一下在无法访问外网安装Nginx的方法。其他文章:鲲鹏ARM架构麒麟Lylinv10安装Mysql8.3(离线)-CSDN博客鲲鹏ARM架构麒麟Lylinv10安装Node和NVM(离线)-CSDN博客鲲鹏ARM架构麒麟Lylinv10安装Pm2(离线)-CSDN博客鲲鹏ARM架构麒麟Lylinv10安装P</div> </li> <li><a href="/article/1835381929642389504.htm" title="shell脚本中sed命令如何使用变量" target="_blank">shell脚本中sed命令如何使用变量</a> <span class="text-muted">歪歪的酒壶</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a> <div>在shell脚本中我们常常需要使用sed命令进行配置文件的更新,但是更新的内容又往往根据环境相关。值并不是固定的。这里我们介绍一种在sed命令中使用变量的方法。比如,在nginx的配置中,我们需要根据环境来更新/etc/nginx/sites-available/default中的目录配置。通常我们采用一个变量,来记录当前环境需要配置的目录比如:dist_dir=/home/dev/code/ui</div> </li> <li><a href="/article/1835376000981102592.htm" title="Nginx之代理模块 ngx_http_proxy_module" target="_blank">Nginx之代理模块 ngx_http_proxy_module</a> <span class="text-muted">途径日暮不赏丶</span> <a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a> <div>正向代理正向代理是指位于客户机(A)和站点服务器(B)之间的代理服务器(C),为了从站点服务器(B)获取资源,客户机(A)向代理服务器(C)发送请求并指定站点服务器(B),然后代理服务器(C)向站点服务器(B)转交请求并将获取的资源返回给客户机(A)。上述这样的代理模式称为正向代理,正向代理最大的特点:客户端非常明确要访问的服务器地址;服务器只清楚请求来自哪个代理服务器,而不清楚来自哪个具体的客户</div> </li> <li><a href="/article/1835372974182592512.htm" title="网关gateway学习总结" target="_blank">网关gateway学习总结</a> <span class="text-muted">猪猪365</span> <a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/1.htm">学习总结</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0%E6%80%BB%E7%BB%93/1.htm">学习总结</a> <div>一微服务概述:微服务网关就是一个系统!通过暴露该微服务的网关系统,方便我们进行相关的鉴权,安全控制,日志的统一处理,易于监控的相关功能!实现微服务网关技术都有哪些呢?1nginx:nginx是一个高性能的http和反向代理web的服务器,同事也提供了IMAP/POP3/SMTP服务.他可以支撑5万并发链接,并且cpu,内存等资源消耗非常的低,运行非常的稳定!2Zuul:Zuul是Netflix公司</div> </li> <li><a href="/article/1835371585679224832.htm" title="Nginx之ngx_http_proxy_connect_module模块" target="_blank">Nginx之ngx_http_proxy_connect_module模块</a> <span class="text-muted">小米bb</span> <a class="tag" taget="_blank" href="/search/Nginx/1.htm">Nginx</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/http/1.htm">http</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>近期由于项目需要使用到https正向代理,而nginx官方模块仅支持做http正向代理,一番百度学习后发现了该模块,故今日记录下此笔记供大家一起学习交流ngx_http_proxy_connect_module模块主要用于隧道SSL请求的代理服务器GitHub地址:http://www.github.com/chobits/ngx_http_proxy_connect_modulenginx配置:</div> </li> <li><a href="/article/1835370955510214656.htm" title="Nginx:高性能的Web服务器与反向代理" target="_blank">Nginx:高性能的Web服务器与反向代理</a> <span class="text-muted">张某布响丸辣</span> <a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/SpringBoot/1.htm">SpringBoot</a> <div>在当今的互联网世界中,Web服务器的选择对于网站的性能、稳定性和安全性至关重要。Nginx(发音为“engineX”)凭借其卓越的性能、丰富的功能集和灵活的配置选项,成为了众多网站和应用程序的首选Web服务器和反向代理。本文将深入探讨Nginx的特点、应用场景、基本配置以及它如何助力你的Web项目。Nginx简介Nginx是一个开源的、高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/</div> </li> <li><a href="/article/1835361883645898752.htm" title="编译Windows平台的Nginx+ngx_http_proxy_connect_module" target="_blank">编译Windows平台的Nginx+ngx_http_proxy_connect_module</a> <span class="text-muted">Grovvy_Deng</span> <a class="tag" taget="_blank" href="/search/windows/1.htm">windows</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/http/1.htm">http</a> <div>编译Windows平台的Nginx+ngx_http_proxy_connect_module背景:由于公司的正向出局代理是windows机器。机器上的Squid不稳定,打算替换成nginx+ngx_http_proxy_connect_module实现。通过几天痛苦的尝试,最后参考了github大神项目通过在线CICD工具编译window平台可用的ng。步骤:获取git可识别的patch由于CI</div> </li> <li><a href="/article/1835359727924637696.htm" title="Nginx从入门到实践(三)" target="_blank">Nginx从入门到实践(三)</a> <span class="text-muted">听你讲故事啊</span> <div>动静分离动静分离是将网站静态资源(JavaScript,CSS,img等文件)与后台应用分开部署,提高用户访问静态代码的速度,降低对后台应用访问。动静分离的一种做法是将静态资源部署在nginx上,后台项目部署到应用服务器上,根据一定规则静态资源的请求全部请求nginx服务器,达到动静分离的目标。rewrite规则Rewrite规则常见正则表达式Rewrite主要的功能就是实现URL的重写,Ngin</div> </li> <li><a href="/article/1835354700392787968.htm" title="Nginx的使用场景:构建高效、可扩展的Web架构" target="_blank">Nginx的使用场景:构建高效、可扩展的Web架构</a> <span class="text-muted">张某布响丸辣</span> <a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a> <div>Nginx,作为当今最流行的Web服务器和反向代理软件之一,凭借其高性能、稳定性和灵活性,在众多Web项目中扮演着核心角色。无论是个人博客、中小型网站,还是大型企业级应用,Nginx都能提供强大的支持。本文将探讨Nginx的几个主要使用场景,帮助读者理解如何在实际项目中充分利用Nginx的优势。1.静态文件服务对于包含大量静态文件(如HTML、CSS、JavaScript、图片等)的网站,Ngin</div> </li> <li><a href="/article/1835353690366636032.htm" title="【nginx】ngx_http_proxy_connect_module 正向代理" target="_blank">【nginx】ngx_http_proxy_connect_module 正向代理</a> <span class="text-muted">等风来不如迎风去</span> <a class="tag" taget="_blank" href="/search/%E7%BD%91%E7%BB%9C%E6%9C%8D%E5%8A%A1%E5%85%A5%E9%97%A8%E4%B8%8E%E5%AE%9E%E6%88%98/1.htm">网络服务入门与实战</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/http/1.htm">http</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>50.65无法访问服务器,(403错误)50.196可以访问服务器。那么,配置65通过196访问。需要一个nginx作为代理【nginx】搭配okhttp配置反向代理发送原生的nginx是不支持okhttp的CONNECT请求的。大神竟然给出了一个java工程GINX编译ngx_http_proxy_connect_module及做正向代理是linux构建的。是windows构建的:编译Windo</div> </li> <li><a href="/article/1835337301350248448.htm" title="Kubernetes Ingress 控制器(Nginx)安装与使用教程" target="_blank">Kubernetes Ingress 控制器(Nginx)安装与使用教程</a> <span class="text-muted">农优影</span> <div>KubernetesIngress控制器(Nginx)安装与使用教程kubernetes-ingressNGINXandNGINXPlusIngressControllersforKubernetes项目地址:https://gitcode.com/gh_mirrors/ku/kubernetes-ingress1.项目目录结构及介绍在nginxinc/kubernetes-ingress仓库中,</div> </li> <li><a href="/article/1835321042592165888.htm" title="浅谈openresty" target="_blank">浅谈openresty</a> <span class="text-muted">爱编码的钓鱼佬</span> <a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/openresty/1.htm">openresty</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>熟悉了nginx后再来看openresty,不得不说openresty是比较优秀的。对nginx和openresty的历史等在这此就不介绍了。首先对标nginx,自然有优劣一、开发难度nginx:毫无疑问nginx的开发难度比较高,需要扎实的c/c++基础,而且还需要对nginx源码比较熟悉,开发效率慢,比如实现一个类似echo的功能,至少要上百行代码。而openresty只需要一句ngx.say</div> </li> <li><a href="/article/1835243836679483392.htm" title="页面报错 POST 413错误 (Request Entity Too Large)" target="_blank">页面报错 POST 413错误 (Request Entity Too Large)</a> <span class="text-muted">小黑屋说YYDS</span> <a class="tag" taget="_blank" href="/search/%E8%B8%A9%E5%9D%91/1.htm">踩坑</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>一般来说是服务器使用nginx作为反向代理出现的问题,post请求长度超过了nginx默认的缓存大小和最大客户端最大请求大小。解决方式如下,更该nginx代理配置:在nginx.conf配置文件中,找到http{}代码块,添加如下配置client_max_body_size20m;重启nginx即可。</div> </li> <li><a href="/article/1835199093819928576.htm" title="docker 安装、运行nginx shell脚本" target="_blank">docker 安装、运行nginx shell脚本</a> <span class="text-muted">三希</span> <a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a> <div>以下是一个简单的用于安装和运行DockerNginx的shell脚本:bash#!/bin/bash#安装Docker(如果还未安装)#请根据实际情况调整安装命令#拉取Nginx镜像dockerpullnginx#运行Nginx容器dockerrun-d--namemynginx-p80:80nginx</div> </li> <li><a href="/article/1835198462149357568.htm" title="老生常谈:MySQL高可用架构" target="_blank">老生常谈:MySQL高可用架构</a> <span class="text-muted">我有一头小花驴</span> <a class="tag" taget="_blank" href="/search/mysql/1.htm">mysql</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a> <div>引言“高可用”是互联网一个永恒的话题,先避开MySQL不谈,为了保证各种服务的高可用有几种常用的解决方案。服务冗余:把服务部署多份,当某个节点不可用时,切换到其他节点。服务冗余对于无状态的服务是相对容易的。服务备份:有些服务是无法同时存在多个运行时的,比如说:Nginx的反向代理,一些集群的leader节点。这时可以存在一个备份服务,处于随时待命状态。自动切换:服务冗余之后,当某个节点不可用时,要</div> </li> <li><a href="/article/1835189633021997056.htm" title="docker项目切换(nginx)、重启shell 脚本" target="_blank">docker项目切换(nginx)、重启shell 脚本</a> <span class="text-muted">懒惰的小蜗牛</span> <a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a> <div>docker项目切换、重启脚本背景具体操作nginx配置配置文件1配置文件2编写nginx替换脚本(用来执行端口替换)编写启动脚本dockerfile文件正常编写给脚本授权执行./start脚本背景项目部署docker中,更新项目时,需要将原原来的容器停止,再启动新的容器,这样会有一个空窗期,导致不可用解决方案:映射不同的端口并启动新的容器,将nginx转发到新容器,停止旧容器具体操作说明ngin</div> </li> <li><a href="/article/1835187991388188672.htm" title="FastCGI结合docker下的Nginx执行shell脚本" target="_blank">FastCGI结合docker下的Nginx执行shell脚本</a> <span class="text-muted">南波波</span> <a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a> <div>1使用docker下载Nginx下面展示一些内联代码片。a.#dockerpullnginx#dockerrun--namerunoob-php-nginx-p8088:80-d\-v~/nginx/www:/usr/share/nginx/html:ro\-v~/nginx/conf/conf.d:/etc/nginx/conf.d:ro\nginxb.在~/nginx/conf/conf.d创</div> </li> <li><a href="/article/1835130592988065792.htm" title="主流行架构" target="_blank">主流行架构</a> <span class="text-muted">rainbowcheng</span> <a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a><a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a> <div>nexus,gitlab,svn,jenkins,sonar,docker,apollo,catteambition,axure,蓝湖,禅道,WCP;redis,kafka,es,zookeeper,dubbo,shardingjdbc,mysql,InfluxDB,Telegraf,Grafana,Nginx,xxl-job,Neo4j,NebulaGraph是一个高性能的,NOSQL图形数据库</div> </li> <li><a href="/article/1835124784199987200.htm" title="面试题篇: 跨域问题如何处理(Java和Nginx处理方式)" target="_blank">面试题篇: 跨域问题如何处理(Java和Nginx处理方式)</a> <span class="text-muted">guicai_guojia</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E8%AF%AD%E8%A8%80/1.htm">开发语言</a> <div>1.服务器端解决方案最常见的解决方案是在服务器端配置CORS头。服务器需要在响应中添加适当的Access-Control-Allow-头来允许跨域请求。1.1NGINX配置在NGINX配置中,你可以通过add_header指令来设置CORS头。配置示例:server{  listen80;  server_nameapi.example.com;  location/{    proxy_pass</div> </li> <li><a href="/article/1835093403788996608.htm" title="Nginx Hard模式" target="_blank">Nginx Hard模式</a> <span class="text-muted">西木风落</span> <a class="tag" taget="_blank" href="/search/%E4%B8%AD%E9%97%B4%E7%BB%84%E4%BB%B6/1.htm">中间组件</a><a class="tag" taget="_blank" href="/search/Nginx/1.htm">Nginx</a><a class="tag" taget="_blank" href="/search/Nginx%E9%85%8D%E7%BD%AE%E8%AF%A6%E8%A7%A3/1.htm">Nginx配置详解</a><a class="tag" taget="_blank" href="/search/Nginx%E9%85%8D%E7%BD%AE%E4%BC%98%E5%8C%96/1.htm">Nginx配置优化</a><a class="tag" taget="_blank" href="/search/Nginx%E9%9D%A2%E8%AF%95hard/1.htm">Nginx面试hard</a> <div>一、Nginx简介1.Nginx概述Nginx是一个免费、开源、高性能、轻量级的HTTP和反向代理服务器,也是一个电子邮件(IMAP/POP3)代理服务器。其特点是能支持高并发请求处理,并且占用较少的内存资源,提供稳定的、丰富的模块库,有很高的配置灵活性。目前,几乎所有的web项目,都配有Nginx。Nginx由内核和一系列模块组成,内核提供Web服务的基本功能,启用网路协议、提供运行环境、创建连</div> </li> <li><a href="/article/1835057978672246784.htm" title="nginx部署前端项目的一些配置【刚入门】" target="_blank">nginx部署前端项目的一些配置【刚入门】</a> <span class="text-muted">weixin_30847271</span> <a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/ViewUI/1.htm">ViewUI</a> <div>前期准备:在linux上安装nginx,我用的是腾讯云centos7服务器,具体的安装过程可以到腾讯云的开发者实验室里体验,自己先试试水。修改nginx.conf配置文件,我用到的修改只是以下的部分。1.端口号2.项目的存放位置server{listen8088default_server;#访问的端口号。listen[::]:8088default_server;server_name_;#ro</div> </li> <li><a href="/article/1834997709858238464.htm" title="定制优化Nextcloud镜像" target="_blank">定制优化Nextcloud镜像</a> <span class="text-muted">攻城狮_正</span> <div>Nextcloud是一款开源免费的私有云存储网盘项目,可以让你快速便捷地搭建一套属于自己或团队的云同步网盘,从而实现跨平台跨设备文件同步、共享、版本控制、团队协作等功能。它的客户端覆盖了Windows、Mac、Android、iOS、Linux等各种平台,也提供了网页端以及WebDAV接口,所以你几乎可以在各种设备上方便地访问你的云盘。Nextcloud基于PHP语言开发,可以使用Nginx+PH</div> </li> <li><a href="/article/1834963034653683712.htm" title="React 前端应用结合 Nginx 部署指南及常见错误排查" target="_blank">React 前端应用结合 Nginx 部署指南及常见错误排查</a> <span class="text-muted">蜗牛去旅行吧</span> <a class="tag" taget="_blank" href="/search/%E5%89%8D%E7%AB%AF/1.htm">前端</a><a class="tag" taget="_blank" href="/search/react.js/1.htm">react.js</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a> <div>在现代Web开发中,React已成为构建用户界面的流行选择,而Nginx则是一个高性能的Web服务器,广泛用于静态文件的托管和负载均衡。在本篇博客中,我们将详细介绍如何将一个React应用部署到Nginx上,并探讨在部署过程中可能遇到的常见错误及其解决方案。部署步骤1.准备React应用首先,确保你已经创建了一个React应用。如果还没有,可以使用CreateReactApp快速生成一个基础项目:</div> </li> <li><a href="/article/1834918400317550592.htm" title="docker-compose部署minio分布式集群" target="_blank">docker-compose部署minio分布式集群</a> <span class="text-muted">伏案惊涛</span> <a class="tag" taget="_blank" href="/search/docker/1.htm">docker</a><a class="tag" taget="_blank" href="/search/%E5%88%86%E5%B8%83%E5%BC%8F/1.htm">分布式</a><a class="tag" taget="_blank" href="/search/%E5%AE%B9%E5%99%A8/1.htm">容器</a> <div>1、节点情况建议:minio节点数最好4节点以上,nginx独立部署在其他服务器。主机IP操作系统部署情况minio1192.168.16.34centos7miniominio2192.168.16.35centos7miniominio3192.168.16.36centos7miniominio4192.168.16.40centos7minio、nginx2、安装docker、docker</div> </li> <li><a href="/article/1834896221005770752.htm" title="多级缓存架构设计" target="_blank">多级缓存架构设计</a> <span class="text-muted">白鸽呀</span> <a class="tag" taget="_blank" href="/search/%E6%9E%B6%E6%9E%84/1.htm">架构</a><a class="tag" taget="_blank" href="/search/%E7%BC%93%E5%AD%98/1.htm">缓存</a><a class="tag" taget="_blank" href="/search/redis/1.htm">redis</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E6%8D%AE%E5%BA%93/1.htm">数据库</a> <div>缓存是提升性能最直接的方法多级缓存分为:客户端,应用层,业务层,数据层1、客户端缓存:主要对浏览器的静态资源进行缓存通过在响应头设置Expires,cache-control,将文件保存在本地,减少多次请求静态资源带来的带宽损耗(解决并发手段)2、应用层缓存:浏览器只负责读取Expires,Expires在CDN内容分发网络和Nginx进行设置CDN内容分发网络是静态资源分发的主要技术手段,有效解</div> </li> <li><a href="/article/1834895337622433792.htm" title="统计/nginx/access.log中每个ip的访问次数,按高到低排列" target="_blank">统计/nginx/access.log中每个ip的访问次数,按高到低排列</a> <span class="text-muted">年薪丰厚</span> <a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a> <div>/nginx/access.log具体内容长这样:第一个元素就是ip。awk'{print$1}'/nginx/access.log|sort|uniq-c|sort-r首先,awk'{print$1}'/nginx/access.log从/nginx/access.log文件的每行中提取出第一个字段。然后,sort对提取出的第一个字段进行排序。接着,uniq-c统计每个唯一的字段出现的次数。最后</div> </li> <li><a href="/article/1834722635074859008.htm" title="Linux+Nginx+Asp.net Core及守护进程部署" target="_blank">Linux+Nginx+Asp.net Core及守护进程部署</a> <span class="text-muted">念童</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/nginx/1.htm">nginx</a><a class="tag" taget="_blank" href="/search/asp.net/1.htm">asp.net</a><a class="tag" taget="_blank" href="/search/%E8%BF%90%E7%BB%B4/1.htm">运维</a><a class="tag" taget="_blank" href="/search/%E6%9C%8D%E5%8A%A1%E5%99%A8/1.htm">服务器</a> <div>上篇《Docker基础入门及示例》文章介绍了Docker部署,以及相关.netcore的打包示例。这篇文章我将以oss.offical.site站点为例,主要介绍下在linux机器下完整的部署流程,.netcore在docker容器中的运行已经介绍,这里.netcore运行环境我会介绍直接在linux运行的场景,内容主要包含以下几个部分:1.基础工具和Linux环境准备2..NetCore环境安装</div> </li> <li><a href="/article/58.htm" title="多线程编程之理财" target="_blank">多线程编程之理财</a> <span class="text-muted">周凡杨</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/%E5%A4%9A%E7%BA%BF%E7%A8%8B/1.htm">多线程</a><a class="tag" taget="_blank" href="/search/%E7%94%9F%E4%BA%A7%E8%80%85/1.htm">生产者</a><a class="tag" taget="_blank" href="/search/%E6%B6%88%E8%B4%B9%E8%80%85/1.htm">消费者</a><a class="tag" taget="_blank" href="/search/%E7%90%86%E8%B4%A2/1.htm">理财</a> <div>      现实生活中,我们一边工作,一边消费,正常情况下会把多余的钱存起来,比如存到余额宝,还可以多挣点钱,现在就有这个情况:我每月可以发工资20000万元 (暂定每月的1号),每月消费5000(租房+生活费)元(暂定每月的1号),其中租金是大头占90%,交房租的方式可以选择(一月一交,两月一交、三月一交),理财:1万元存余额宝一天可以赚1元钱,</div> </li> <li><a href="/article/185.htm" title="[Zookeeper学习笔记之三]Zookeeper会话超时机制" target="_blank">[Zookeeper学习笔记之三]Zookeeper会话超时机制</a> <span class="text-muted">bit1129</span> <a class="tag" taget="_blank" href="/search/zookeeper/1.htm">zookeeper</a> <div>首先,会话超时是由Zookeeper服务端通知客户端会话已经超时,客户端不能自行决定会话已经超时,不过客户端可以通过调用Zookeeper.close()主动的发起会话结束请求,如下的代码输出内容 Created /zoo-739160015 CONNECTEDCONNECTED .............CONNECTEDCONNECTED CONNECTEDCLOSEDCLOSED </div> </li> <li><a href="/article/312.htm" title="SecureCRT快捷键" target="_blank">SecureCRT快捷键</a> <span class="text-muted">daizj</span> <a class="tag" taget="_blank" href="/search/secureCRT/1.htm">secureCRT</a><a class="tag" taget="_blank" href="/search/%E5%BF%AB%E6%8D%B7%E9%94%AE/1.htm">快捷键</a> <div>ctrl + a : 移动光标到行首ctrl + e :移动光标到行尾crtl + b: 光标前移1个字符crtl + f: 光标后移1个字符crtl + h : 删除光标之前的一个字符ctrl + d :删除光标之后的一个字符crtl + k :删除光标到行尾所有字符crtl + u : 删除光标至行首所有字符crtl + w:  删除光标至行首</div> </li> <li><a href="/article/439.htm" title="Java 子类与父类这间的转换" target="_blank">Java 子类与父类这间的转换</a> <span class="text-muted">周凡杨</span> <a class="tag" taget="_blank" href="/search/java+%E7%88%B6%E7%B1%BB%E4%B8%8E%E5%AD%90%E7%B1%BB%E7%9A%84%E8%BD%AC%E6%8D%A2/1.htm">java 父类与子类的转换</a> <div>    最近同事调的一个服务报错,查看后是日期之间转换出的问题。代码里是把 java.sql.Date 类型的对象 强制转换为 java.sql.Timestamp 类型的对象。报java.lang.ClassCastException。       代码:             </div> </li> <li><a href="/article/566.htm" title="可视化swing界面编辑" target="_blank">可视化swing界面编辑</a> <span class="text-muted">朱辉辉33</span> <a class="tag" taget="_blank" href="/search/eclipse/1.htm">eclipse</a><a class="tag" taget="_blank" href="/search/swing/1.htm">swing</a> <div>      今天发现了一个WindowBuilder插件,功能好强大,啊哈哈,从此告别手动编辑swing界面代码,直接像VB那样编辑界面,代码会自动生成。       首先在Eclipse中点击help,选择Install New Software,然后在Work with中输入WindowBui</div> </li> <li><a href="/article/693.htm" title="web报表工具FineReport常用函数的用法总结(文本函数)" target="_blank">web报表工具FineReport常用函数的用法总结(文本函数)</a> <span class="text-muted">老A不折腾</span> <a class="tag" taget="_blank" href="/search/finereport/1.htm">finereport</a><a class="tag" taget="_blank" href="/search/web%E6%8A%A5%E8%A1%A8%E5%B7%A5%E5%85%B7/1.htm">web报表工具</a><a class="tag" taget="_blank" href="/search/%E6%8A%A5%E8%A1%A8%E8%BD%AF%E4%BB%B6/1.htm">报表软件</a><a class="tag" taget="_blank" href="/search/java%E6%8A%A5%E8%A1%A8/1.htm">java报表</a> <div>文本函数 CHAR CHAR(number):根据指定数字返回对应的字符。CHAR函数可将计算机其他类型的数字代码转换为字符。 Number:用于指定字符的数字,介于1Number:用于指定字符的数字,介于165535之间(包括1和65535)。 示例: CHAR(88)等于“X”。 CHAR(45)等于“-”。   CODE CODE(text):计算文本串中第一个字</div> </li> <li><a href="/article/820.htm" title="mysql安装出错" target="_blank">mysql安装出错</a> <span class="text-muted">林鹤霄</span> <a class="tag" taget="_blank" href="/search/mysql%E5%AE%89%E8%A3%85/1.htm">mysql安装</a> <div>[root@localhost ~]# rpm -ivh MySQL-server-5.5.24-1.linux2.6.x86_64.rpm Preparing...                #####################</div> </li> <li><a href="/article/947.htm" title="linux下编译libuv" target="_blank">linux下编译libuv</a> <span class="text-muted">aigo</span> <a class="tag" taget="_blank" href="/search/libuv/1.htm">libuv</a> <div>下载最新版本的libuv源码,解压后执行: ./autogen.sh   这时会提醒找不到automake命令,通过一下命令执行安装(redhat系用yum,Debian系用apt-get): # yum -y install automake # yum -y install libtool     如果提示错误:make: *** No targe</div> </li> <li><a href="/article/1074.htm" title="中国行政区数据及三级联动菜单" target="_blank">中国行政区数据及三级联动菜单</a> <span class="text-muted">alxw4616</span> <div>近期做项目需要三级联动菜单,上网查了半天竟然没有发现一个能直接用的! 呵呵,都要自己填数据....我了个去这东西麻烦就麻烦的数据上. 哎,自己没办法动手写吧. 现将这些数据共享出了,以方便大家.嗯,代码也可以直接使用   文件说明 lib\area.sql -- 县及县以上行政区划分代码(截止2013年8月31日)来源:国家统计局 发布时间:2014-01-17 15:0</div> </li> <li><a href="/article/1201.htm" title="哈夫曼加密文件" target="_blank">哈夫曼加密文件</a> <span class="text-muted">百合不是茶</span> <a class="tag" taget="_blank" href="/search/%E5%93%88%E5%A4%AB%E6%9B%BC%E5%8E%8B%E7%BC%A9/1.htm">哈夫曼压缩</a><a class="tag" taget="_blank" href="/search/%E5%93%88%E5%A4%AB%E6%9B%BC%E5%8A%A0%E5%AF%86/1.htm">哈夫曼加密</a><a class="tag" taget="_blank" href="/search/%E4%BA%8C%E5%8F%89%E6%A0%91/1.htm">二叉树</a> <div> 在上一篇介绍过哈夫曼编码的基础知识,下面就直接介绍使用哈夫曼编码怎么来做文件加密或者压缩与解压的软件,对于新手来是有点难度的,主要还是要理清楚步骤;   加密步骤:  1,统计文件中字节出现的次数,作为权值   2,创建节点和哈夫曼树   3,得到每个子节点01串   4,使用哈夫曼编码表示每个字节   </div> </li> <li><a href="/article/1328.htm" title="JDK1.5 Cyclicbarrier实例" target="_blank">JDK1.5 Cyclicbarrier实例</a> <span class="text-muted">bijian1013</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/thread/1.htm">thread</a><a class="tag" taget="_blank" href="/search/java%E5%A4%9A%E7%BA%BF%E7%A8%8B/1.htm">java多线程</a><a class="tag" taget="_blank" href="/search/Cyclicbarrier/1.htm">Cyclicbarrier</a> <div>CyclicBarrier类 一个同步辅助类,它允许一组线程互相等待,直到到达某个公共屏障点 (common barrier point)。在涉及一组固定大小的线程的程序中,这些线程必须不时地互相等待,此时 CyclicBarrier 很有用。因为该 barrier 在释放等待线程后可以重用,所以称它为循环的 barrier。 CyclicBarrier支持一个可选的 Runnable 命令,</div> </li> <li><a href="/article/1455.htm" title="九项重要的职业规划" target="_blank">九项重要的职业规划</a> <span class="text-muted">bijian1013</span> <a class="tag" taget="_blank" href="/search/%E5%B7%A5%E4%BD%9C/1.htm">工作</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0/1.htm">学习</a> <div>一. 学习的步伐不停止        古人说,活到老,学到老。终身学习应该是您的座右铭。        世界在不断变化,每个人都在寻找各自的事业途径。        您只有保证了足够的技能储</div> </li> <li><a href="/article/1582.htm" title="【Java范型四】范型方法" target="_blank">【Java范型四】范型方法</a> <span class="text-muted">bit1129</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div>范型参数不仅仅可以用于类型的声明上,例如   package com.tom.lang.generics; import java.util.List; public class Generics<T> { private T value; public Generics(T value) { this.value = </div> </li> <li><a href="/article/1709.htm" title="【Hadoop十三】HDFS Java API基本操作" target="_blank">【Hadoop十三】HDFS Java API基本操作</a> <span class="text-muted">bit1129</span> <a class="tag" taget="_blank" href="/search/hadoop/1.htm">hadoop</a> <div>  package com.examples.hadoop; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoo</div> </li> <li><a href="/article/1836.htm" title="ua实现split字符串分隔" target="_blank">ua实现split字符串分隔</a> <span class="text-muted">ronin47</span> <a class="tag" taget="_blank" href="/search/lua+split/1.htm">lua split</a> <div>LUA并不象其它许多"大而全"的语言那样,包括很多功能,比如网络通讯、图形界面等。但是LUA可以很容易地被扩展:由宿主语言(通常是C或 C++)提供这些功能,LUA可以使用它们,就像是本来就内置的功能一样。LUA只包括一个精简的核心和最基本的库。这使得LUA体积小、启动速度快,从 而适合嵌入在别的程序里。因此在lua中并没有其他语言那样多的系统函数。习惯了其他语言的字符串分割函</div> </li> <li><a href="/article/1963.htm" title="java-从先序遍历和中序遍历重建二叉树" target="_blank">java-从先序遍历和中序遍历重建二叉树</a> <span class="text-muted">bylijinnan</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a> <div> public class BuildTreePreOrderInOrder { /** * Build Binary Tree from PreOrder and InOrder * _______7______ / \ __10__ ___2 / \ / 4</div> </li> <li><a href="/article/2090.htm" title="openfire开发指南《连接和登陆》" target="_blank">openfire开发指南《连接和登陆》</a> <span class="text-muted">开窍的石头</span> <a class="tag" taget="_blank" href="/search/openfire/1.htm">openfire</a><a class="tag" taget="_blank" href="/search/%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97/1.htm">开发指南</a><a class="tag" taget="_blank" href="/search/smack/1.htm">smack</a> <div>第一步     官网下载smack.jar包     下载地址:http://www.igniterealtime.org/downloads/index.jsp#smack 第二步     把smack里边的jar导入你新建的java项目中 开始编写smack连接openfire代码 p</div> </li> <li><a href="/article/2217.htm" title="[移动通讯]手机后盖应该按需要能够随时开启" target="_blank">[移动通讯]手机后盖应该按需要能够随时开启</a> <span class="text-muted">comsci</span> <a class="tag" taget="_blank" href="/search/%E7%A7%BB%E5%8A%A8/1.htm">移动</a> <div>    看到新的手机,很多由金属材质做的外壳,内存和闪存容量越来越大,CPU速度越来越快,对于这些改进,我们非常高兴,也非常欢迎      但是,对于手机的新设计,有几点我们也要注意      第一:手机的后盖应该能够被用户自行取下来,手机的电池的可更换性应该是必须保留的设计,</div> </li> <li><a href="/article/2344.htm" title="20款国外知名的php开源cms系统" target="_blank">20款国外知名的php开源cms系统</a> <span class="text-muted">cuiyadll</span> <a class="tag" taget="_blank" href="/search/cms/1.htm">cms</a> <div>内容管理系统,简称CMS,是一种简易的发布和管理新闻的程序。用户可以在后端管理系统中发布,编辑和删除文章,即使您不需要懂得HTML和其他脚本语言,这就是CMS的优点。 在这里我决定介绍20款目前国外市面上最流行的开源的PHP内容管理系统,以便没有PHP知识的读者也可以通过国外内容管理系统建立自己的网站。 1. Wordpress WordPress的是一个功能强大且易于使用的内容管</div> </li> <li><a href="/article/2471.htm" title="Java生成全局唯一标识符" target="_blank">Java生成全局唯一标识符</a> <span class="text-muted">darrenzhu</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/uuid/1.htm">uuid</a><a class="tag" taget="_blank" href="/search/unique/1.htm">unique</a><a class="tag" taget="_blank" href="/search/identifier/1.htm">identifier</a><a class="tag" taget="_blank" href="/search/id/1.htm">id</a> <div>How to generate a globally unique identifier in Java http://stackoverflow.com/questions/21536572/generate-unique-id-in-java-to-label-groups-of-related-entries-in-a-log http://stackoverflow</div> </li> <li><a href="/article/2598.htm" title="php安装模块检测是否已安装过, 使用的SQL语句" target="_blank">php安装模块检测是否已安装过, 使用的SQL语句</a> <span class="text-muted">dcj3sjt126com</span> <a class="tag" taget="_blank" href="/search/sql/1.htm">sql</a> <div> SHOW [FULL] TABLES [FROM db_name] [LIKE 'pattern'] SHOW TABLES列举了给定数据库中的非TEMPORARY表。您也可以使用mysqlshow db_name命令得到此清单。 本命令也列举数据库中的其它视图。支持FULL修改符,这样SHOW FULL TABLES就可以显示第二个输出列。对于一个表,第二列的值为BASE T</div> </li> <li><a href="/article/2725.htm" title="5天学会一种 web 开发框架" target="_blank">5天学会一种 web 开发框架</a> <span class="text-muted">dcj3sjt126com</span> <a class="tag" taget="_blank" href="/search/Web/1.htm">Web</a><a class="tag" taget="_blank" href="/search/%E6%A1%86%E6%9E%B6/1.htm">框架</a><a class="tag" taget="_blank" href="/search/framework/1.htm">framework</a> <div>web framework层出不穷,特别是ruby/python,各有10+个,php/java也是一大堆 根据我自己的经验写了一个to do list,按照这个清单,一条一条的学习,事半功倍,很快就能掌握 一共25条,即便很磨蹭,2小时也能搞定一条,25*2=50。只需要50小时就能掌握任意一种web框架 各类web框架大同小异:现代web开发框架的6大元素,把握主线,就不会迷路 建议把本文</div> </li> <li><a href="/article/2852.htm" title="Gson使用三(Map集合的处理,一对多处理)" target="_blank">Gson使用三(Map集合的处理,一对多处理)</a> <span class="text-muted">eksliang</span> <a class="tag" taget="_blank" href="/search/json/1.htm">json</a><a class="tag" taget="_blank" href="/search/gson/1.htm">gson</a><a class="tag" taget="_blank" href="/search/Gson+map/1.htm">Gson map</a><a class="tag" taget="_blank" href="/search/Gson+%E9%9B%86%E5%90%88%E5%A4%84%E7%90%86/1.htm">Gson 集合处理</a> <div>转载请出自出处:http://eksliang.iteye.com/blog/2175532 一、概述        Map保存的是键值对的形式,Json的格式也是键值对的,所以正常情况下,map跟json之间的转换应当是理所当然的事情。 二、Map参考实例 package com.ickes.json; import java.lang.refl</div> </li> <li><a href="/article/2979.htm" title="cordova实现“再点击一次退出”效果" target="_blank">cordova实现“再点击一次退出”效果</a> <span class="text-muted">gundumw100</span> <a class="tag" taget="_blank" href="/search/android/1.htm">android</a> <div>基本的写法如下: document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { //navigator.splashscreen.hide(); document.addEventListener("b</div> </li> <li><a href="/article/3106.htm" title="openldap configuration leaning note" target="_blank">openldap configuration leaning note</a> <span class="text-muted">iwindyforest</span> <a class="tag" taget="_blank" href="/search/configuration/1.htm">configuration</a> <div>hostname // to display the computer name hostname <changed name> // to change go to: /etc/sysconfig/network, add/modify HOSTNAME=NEWNAME to change permenately dont forget to change /etc/hosts</div> </li> <li><a href="/article/3233.htm" title="Nullability and Objective-C" target="_blank">Nullability and Objective-C</a> <span class="text-muted">啸笑天</span> <a class="tag" taget="_blank" href="/search/Objective-C/1.htm">Objective-C</a> <div>https://developer.apple.com/swift/blog/?id=25   http://www.cocoachina.com/ios/20150601/11989.html   http://blog.csdn.net/zhangao0086/article/details/44409913   http://blog.sunnyxx</div> </li> <li><a href="/article/3360.htm" title="jsp中实现参数隐藏的两种方法" target="_blank">jsp中实现参数隐藏的两种方法</a> <span class="text-muted">macroli</span> <a class="tag" taget="_blank" href="/search/JavaScript/1.htm">JavaScript</a><a class="tag" taget="_blank" href="/search/jsp/1.htm">jsp</a> <div>在一个JSP页面有一个链接,//确定是一个链接?点击弹出一个页面,需要传给这个页面一些参数。//正常的方法是设置弹出页面的src="***.do?p1=aaa&p2=bbb&p3=ccc"//确定目标URL是Action来处理?但是这样会在页面上看到传过来的参数,可能会不安全。要求实现src="***.do",参数通过其他方法传!//////</div> </li> <li><a href="/article/3487.htm" title="Bootstrap A标签关闭modal并打开新的链接解决方案" target="_blank">Bootstrap A标签关闭modal并打开新的链接解决方案</a> <span class="text-muted">qiaolevip</span> <a class="tag" taget="_blank" href="/search/%E6%AF%8F%E5%A4%A9%E8%BF%9B%E6%AD%A5%E4%B8%80%E7%82%B9%E7%82%B9/1.htm">每天进步一点点</a><a class="tag" taget="_blank" href="/search/%E5%AD%A6%E4%B9%A0%E6%B0%B8%E6%97%A0%E6%AD%A2%E5%A2%83/1.htm">学习永无止境</a><a class="tag" taget="_blank" href="/search/bootstrap/1.htm">bootstrap</a><a class="tag" taget="_blank" href="/search/%E7%BA%B5%E8%A7%82%E5%8D%83%E8%B1%A1/1.htm">纵观千象</a> <div>Bootstrap里面的js modal控件使用起来很方便,关闭也很简单。只需添加标签 data-dismiss="modal" 即可。 可是偏偏有时候需要a标签既要关闭modal,有要打开新的链接,尝试多种方法未果。只好使用原始js来控制。   <a href="#/group-buy" class="btn bt</div> </li> <li><a href="/article/3614.htm" title="二维数组在Java和C中的区别" target="_blank">二维数组在Java和C中的区别</a> <span class="text-muted">流淚的芥末</span> <a class="tag" taget="_blank" href="/search/java/1.htm">java</a><a class="tag" taget="_blank" href="/search/c/1.htm">c</a><a class="tag" taget="_blank" href="/search/%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84/1.htm">二维数组</a><a class="tag" taget="_blank" href="/search/%E6%95%B0%E7%BB%84/1.htm">数组</a> <div>Java代码:   public class test03 { public static void main(String[] args) { int[][] a = {{1},{2,3},{4,5,6}}; System.out.println(a[0][1]); } }  运行结果: Exception in thread "mai</div> </li> <li><a href="/article/3741.htm" title="systemctl命令用法" target="_blank">systemctl命令用法</a> <span class="text-muted">wmlJava</span> <a class="tag" taget="_blank" href="/search/linux/1.htm">linux</a><a class="tag" taget="_blank" href="/search/systemctl/1.htm">systemctl</a> <div>对比表,以 apache / httpd 为例 任务 旧指令 新指令 使某服务自动启动 chkconfig --level 3 httpd on systemctl enable httpd.service 使某服务不自动启动 chkconfig --level 3 httpd off systemctl disable httpd.service 检查服务状态 service h</div> </li> </ul> </div> </div> </div> <div> <div class="container"> <div class="indexes"> <strong>按字母分类:</strong> <a href="/tags/A/1.htm" target="_blank">A</a><a href="/tags/B/1.htm" target="_blank">B</a><a href="/tags/C/1.htm" target="_blank">C</a><a href="/tags/D/1.htm" target="_blank">D</a><a href="/tags/E/1.htm" target="_blank">E</a><a href="/tags/F/1.htm" target="_blank">F</a><a href="/tags/G/1.htm" target="_blank">G</a><a href="/tags/H/1.htm" target="_blank">H</a><a href="/tags/I/1.htm" target="_blank">I</a><a href="/tags/J/1.htm" target="_blank">J</a><a href="/tags/K/1.htm" target="_blank">K</a><a href="/tags/L/1.htm" target="_blank">L</a><a href="/tags/M/1.htm" target="_blank">M</a><a href="/tags/N/1.htm" target="_blank">N</a><a href="/tags/O/1.htm" target="_blank">O</a><a href="/tags/P/1.htm" target="_blank">P</a><a href="/tags/Q/1.htm" target="_blank">Q</a><a href="/tags/R/1.htm" target="_blank">R</a><a href="/tags/S/1.htm" target="_blank">S</a><a href="/tags/T/1.htm" target="_blank">T</a><a href="/tags/U/1.htm" target="_blank">U</a><a href="/tags/V/1.htm" target="_blank">V</a><a href="/tags/W/1.htm" target="_blank">W</a><a href="/tags/X/1.htm" target="_blank">X</a><a href="/tags/Y/1.htm" target="_blank">Y</a><a href="/tags/Z/1.htm" target="_blank">Z</a><a href="/tags/0/1.htm" target="_blank">其他</a> </div> </div> </div> <footer id="footer" class="mb30 mt30"> <div class="container"> <div class="footBglm"> <a target="_blank" href="/">首页</a> - <a target="_blank" href="/custom/about.htm">关于我们</a> - <a target="_blank" href="/search/Java/1.htm">站内搜索</a> - <a target="_blank" href="/sitemap.txt">Sitemap</a> - <a target="_blank" href="/custom/delete.htm">侵权投诉</a> </div> <div class="copyright">版权所有 IT知识库 CopyRight © 2000-2050 E-COM-NET.COM , All Rights Reserved. <!-- <a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">京ICP备09083238号</a><br>--> </div> </div> </footer> <!-- 代码高亮 --> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shCore.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shLegacy.js"></script> <script type="text/javascript" src="/static/syntaxhighlighter/scripts/shAutoloader.js"></script> <link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/styles/shCoreDefault.css"/> <script type="text/javascript" src="/static/syntaxhighlighter/src/my_start_1.js"></script> </body> </html>