坚信科学,分享技术

Tag Archives: nginx

nginx防hashdos模块使用帮助

经过上周一周朋友们帮忙测试和bug fix,nginx_http_hashdos_module已经达到可以线上使用的水平,下面是使用记录。 下载 #wget --no-check-certificate https://github.com/54chen/nginx-http-hashdos-module/zipball/master #mv master nginx_hashdos.zip #unzip nginx_hashdos.zip 编译安装 #tar zxvf nginx-1.0.xx.tar.gz #cd nginx-1.0.xx/ #./configure --prefix=/opt/soft/nginx --with-pcre --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../54chen-nginx-http-hashdos-module-f84d909 #make && make install 配置注意事项 在http段,增加如下: hashdos on; body_max_count 1000; 在各自的location段,要按照业务情况来加: client_body_buffer_size 2m; client_max_body_size 2m; …

Continue reading

Posted in linux, 架构研究 | Tagged , | Leave a comment

nginx防hashdos模块释出

2012.1.7 更新 编译的时候推荐使用nginx-1.0以上版本,不要加--with-debug参数编译,(感谢agentzh指出)。 hashdos这个事,严格意义上不是各种语言的错了(不过perl的确处理得很好),但是用nginx来擦屁股要干净些。 借鉴tomcat的作法,实现了下面这个nginx-http-hashdos-module,通过设置hashdos(默认on)的开关和body_max_count(默认值1000),对nginx后面的服务进行安全防护,相比对php或者java进行patch,这或许是最好的办法了。 nginx-http-hashdos-module项目地址 https://github.com/54chen/nginx-http-hashdos-module 如何使用 1.下载zip后保存到一个目录,如~/nginx-http-hashdos-module。 2.cd nginx-1.0.9/ 3.重新编译和安装nginx ./configure --prefix=/opt/soft/nginx --with-pcre --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=/path_to/nginx-http-hashdos-module/ && make && make install 4.配置打开: hashdos on; body_max_count

Continue reading

Posted in WEB相关, 架构研究 | Tagged , | 11 Comments

redmine极速安装手记

Redmine是用Ruby开发的基于基于web的项目管理软件,是用ROR框架开发的一套跨平台项目管理系统,系统通过“项目(Project)”的形式把成员、任务(问题)、文档、讨论以及各种形式的资源组织在一起,大家参与更新任务、文档等内容来推动项目的进度,同时系统利用时间线索和各种动态的报表形式来自动给成员汇报项目进度。 机器环境: ubuntu 10.04 dell optiplex 380 root权限下操作 1)apt-get install mysql-client mysqld-server 2)进mysql: create database redmine_default; GRANT all ON redmine_default.* TO root@'%' IDENTIFIED BY 'miliao'; FLUSH PRIVILEGES ; 3)apt-get install redmine redmine-mysql subversion libapache2-mod-passenger 4)ln -s /usr/share/redmine/public /var/www/redmine 5)a2enmod passenger …

Continue reading

Posted in linux, php, 资料文档 | Tagged , , | 1 Comment

硬件为王,软件为帝--记突增的访问

五一归来两周,精力都放在了因为服务器压力突增而来的各种鸡飞狗跳的事情上,今天总结一下,算是对过去两周的总结,希望对各创业团队有所借鉴。 1.访问突增,连锁反应 最先开始出现问题的,是在小负载下没有出现的问题,在大压力时,只要DB一堵,表像就会是循环锁死。 解决之道: 服务要有清晰的架构,开发规范里一定要有明确的架构层次规范,最好还有代码的层次规范。 2.mysql设计不合理,压力指数增加 mysql中存在大量的更新操作,特别是大字段或者变长字段的频繁更新,导致磁盘io居高不下,慢查询越来越多。 硬解决之道: raid卡加电,开启raid写缓存:一般服务器的raid卡都没有开启,开启是有一定用处的,但有一个前提,不是待续的高写入,否则这个写缓存是没有意义的。电池充电时无法缓存,一般三个月充一次电。 转微博:FusionioChina 回复 @YauzZ:多一个故障点。多一份丢数据的可能。而且目前有Raid卡的内存做到1GB。丢不起呀。(5月11日 23:29) 从raid分到多个盘、盘柜,都是从硬件上用多硬盘分担的好方案。 软解决之道: 写方案建立mysql隔离层,在写入前预先处理,类似软件缓存方案,效果明显,修改复杂。 3.后续可做 灵活的中间层数据层切换逻辑,让负载可以随时转移、分隔,基本可以达到“人傻钱多,万事不愁”。

Continue reading

Posted in java, linux, 架构研究 | Tagged , , | Leave a comment

利用sqoop将mysql数据同步到hive手记

1.下载 http://archive.cloudera.com/cdh/3/sqoop-1.2.0-CDH3B4.tar.gz 2.下载 http://archive.cloudera.com/cdh/3/hadoop-0.20.2-CDH3B4.tar.gz 3.解压 2 4.复制3里hadoop-core-0.20.2-CDH3B4.jar到sqoop的lib下 5.在某处复制mysql-connector-java-5.1.10.jar到sqoop的lib下 6.修改configure-sqoop 注释掉hbase zookeeper检查: #if [ ! -d "${HBASE_HOME}" ]; then # echo "Error: $HBASE_HOME does not exist!" # echo 'Please set $HBASE_HOME to the root of your HBase installation.' # exit 1 …

Continue reading

Posted in java | Tagged , , | 1 Comment

[nginx]如何在access log中记录post请求的参数

移动互联网行业开发过程中,服务端经常会需要检查是否收到请求,收到什么样的请求,最简单的办法就是看nginx的access log,常见的nginx配置中access log一般都只有GET请求的参数,而POST请求的参数却不行。 http://wiki.nginx.org/NginxHttpCoreModule#.24request_body $request_body This variable(0.7.58+) contains the body of the request. The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass. 正如上文件所示,只需要使用$request_body即可打出post的数据,在现存的server段加上下面的设置即可: log_format access '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $request_body "$http_referer" "$http_user_agent" $http_x_forwarded_for'; …

Continue reading

Posted in WEB相关 | Tagged , , | 2 Comments

ubuntu下Empathy十月起无法登录msn的解决办法

作为ubuntu深度用户,我(54chen)在几个星期前就有网友来问过,msn登录常常会挂掉,甚至到现在已经无法再登录,受影响的范围很广,最新的10.10也是一样的,原因可能是msn单方面更新了接口,下面提供一种解决办法(以10.04lts Empathy 2.30.1.1 为例): #vim /usr/share/pyshared/papyon/service/description/SingleSignOn/RequestMultipleSecurityTokens.py 找到第24行注释掉: #CONTACTS = ("contacts.msn.com", "?fs=1&id=24000&kv=7&rn=93S9SWWw&tw=0&ver=2.1.6000.1") 修改为: CONTACTS = ("contacts.msn.com", "MBI") (请勿复制,引号有转义) 然后重启,恭喜你msn高昂登录。 附: ubuntu下empathy的msn群显示昵称 点击下载我修改过的文件: http://www.54chen.com/RequestMultipleSecurityTokens.py.gz gunzip RequestMultipleSecurityTokens.py.gz sudo cp RequestMultipleSecurityTokens.py /usr/share/pyshared/papyon/service/description/SingleSignOn/

Continue reading

Posted in linux | Tagged , , | 1 Comment

nginx.conf控制指定的代理ip和ip访问的设置手记

工作中有一次用到利用nginx的配置来让只有公司ip的访问才能打开指定的后台url,于是有了下面的记录。 在nginx中if很弱,http://www.nginxcn.com/doc/standard/httprewrite.html,基本上不能写太复杂的条件或者是嵌套。 因为公司我(54chen)网络的设置,过去打到服务器的ip有可能是几个ip,同时也有可能是代理的ip,所以在if判断的时候,可能有多个条件。 location /administrator { #log_format www_54chen_com '$remote_addr - $remote_user [$time_local] $request ' # '"$status" $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; # access_log /data/www.log www_54chen_com; set $fuck 0; if ($remote_addr = '1.1.1.1'){ set $fuck 1; } if ($remote_addr = …

Continue reading

Posted in linux | Tagged , | 2 Comments

一条SQL引发的对order by的思考

==========尽职的安静的分隔线=========== 在实际工作中遇到下面一个问题: 有一个表,存有2000万数据。 主键为ID bigint(20) NOT NULL auto_increment 另有一字段time timestamp NOT NULL default CURRENT_TIMESTAMP 故事从这两个字段说起: sql1需要从这个表中检索出来时间为2010-05-26 11:55:00之前并且id号大于20000的前10条数据 sql2需要从这个表中检索出来时间为2010-05-26 11:55:00之后并且id号大于20000的前10条数据 两条sql写出来大概是这样子的: sql1:select * from table where time 20000 order by id limit 10; sql2:select * from table where time >'2010-05-26 11:55:00' …

Continue reading

Posted in 架构研究 | Tagged , | 19 Comments

ubuntu 10.04 LTS版本下的Empathy MSN群聊显示昵称方法

1.关系普及 Empathy是个托,python-papyon是个python实现的msn库,telepathy-butterfly是个完成msn功能的python客户端。 2.修改办法 sudo vim /usr/share/pyshared/papyon/conversation.py 查找 if message_type == 这个字符串 找到内容为: if message_type == 'text/plain': msg = ConversationMessage(unicode(message.body, message_encoding), TextFormat.parse(message_formatting), self.__last_received_msn_objects) try: display_name = message.get_header('P4-Context') 将if判断后try之前中间定义msg这一堆内容修改为如下: try: msg = ConversationMessage(unicode("["+message.get_header('P4-Context')+"]"+message.body, message_encoding), TextFormat.parse(message_formatt

Continue reading

Posted in linux | Tagged , | 6 Comments
Page 1 of 3123