Press "Enter" to skip to content

作者: kiccleaf

Java MD5生成数据实现

常用的JAVA MD5实现方法。

调用 MD5(“123456”)
返回:e10adc3949ba59abbe56e057f20f883e

	/**
	 * 字符串数据进行MD5算法加密
	 */
	public static String MD5(String s) {
		String resultStr = null;

		try {
			byte[] source = s.getBytes("UTF-8");
			char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符
			'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c','d', 'e', 'f' };
			java.security.MessageDigest md = java.security.MessageDigest
					.getInstance("MD5");
			md.update(source);
			byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数,
										// 用字节表示就是 16 个字节
			char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符,
											// 所以表示成 16 进制需要 32 个字符
			int k = 0; // 表示转换结果中对应的字符位置
			for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节
											// 转换成 16 进制字符的转换
				byte byte0 = tmp[i]; // 取第 i 个字节
				str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换,
															// >>>
															// 为逻辑右移,将符号位一起右移
				str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换
			}
			resultStr = new String(str); // 换后的结果转换为字符串

		} catch (Exception e) {
			e.printStackTrace();
		}
		return resultStr;
	}
Leave a Comment

解决MacBook Pro视网膜屏下Office 2011更新后模糊解决办法

首选下载微软的最新更新补丁Offcie 2011 V14.2.4
更新完成后,在Terminal下分别输入以下四条命令

sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ Excel.app
sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ PowerPoint.app/
sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ Word.app/
sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ Outlook.app/

再次打开Office的Word及其它几个看看是否高清了。

以下是我的操作,需要输入管理员密码执行

kiccleafmatoMacBook-Pro:~ kiccleaf$ sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ Excel.app
Password:
kiccleafmatoMacBook-Pro:~ kiccleaf$ sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ PowerPoint.app/
kiccleafmatoMacBook-Pro:~ kiccleaf$ sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ Word.app/
kiccleafmatoMacBook-Pro:~ kiccleaf$ sudo touch /Applications/Microsoft\ Office\ 2011/Microsoft\ Outlook.app/

看看效果

Leave a Comment

配置Nginx多核CPU,worker_cpu_affinity方法

由于现今服务器的CPU基本是四核或是八核以上,Nginx默认是没有开启利用多核CPU,我们可以通过增加worker_cpu_affinity配置参数来充分利用多核CPU。实现高性能处理数据和利用CPU资源

1. 2核CPU,开启2个进程

worker_processes     2;
worker_cpu_affinity 01 10;

01表示启用第一个CPU内核,10表示启用第二个CPU内核
worker_cpu_affinity 01 10;表示开启两个进程,第一个进程对应着第一个CPU内核,第二个进程对应着第二个CPU内核。
2. 2核CPU,开启4个进程

worker_processes     4;
worker_cpu_affinity 01 10 01 10;

开启了四个进程,它们分别对应着开启2个CPU内核

3. 4核CPU,开户4个进程

worker_processes     4;
worker_cpu_affinity 0001 0010 0100 1000;

0001表示启用第一个CPU内核,0010表示启用第二个CPU内核,依此类推

4. 4核CPU,开启2个进程

worker_processes     2;
worker_cpu_affinity 0101 1010;

0101表示开启第一个和第三个内核,1010表示开启第二个和第四个内核

2个进程对应着四个内核

worker_cpu_affinity配置是写在/etc/nginx/nginx.conf里面的。

2核是 01,四核是0001,8核是00000001,有多少个核,就有几位数,1表示该内核开启,0表示该内核关闭。

5. 8核CPU,开户8个进程

worker_processes     8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

0001表示启用第一个CPU内核,0010表示启用第二个CPU内核,依此类推

worker_processes最多开启8个,8个以上性能提升不会再提升了,而且稳定性变得更低,所以8个进程够用了。

配置完毕后,重启nginx ,执行/etc/init.d/nginx restart 或是安装目录下:/nginx/sbin/nginx -s reload 重新加载

输入:top 命令后按 1 进行查看

Leave a Comment

Linux下c读取MysqL中文乱码解决方案

在编写接口API时,发现中文字utf8输入的在linux下采用c读取显示为”??”问号,这是由于编码造成的。很简单的两个地方做修改就搞定。
1.先找到mysql的my.cnf配置文件/etc/my.cnf编辑添加
[mysqld]
default-character-set=utf8

2.在程序中添加 mysql_set_character_set(&db,”utf8″); 语句
例子:kiccleaf.c 文件

#include <stdio.h>
//这里需要找到相应地址不知道可以用“ find / -name mysql.h ”查询
#include "/usr/include/mysql/mysql.h"
int main()
{
    MYSQL db;/*connector*/
    MYSQL_RES* result;/*result buffer*/
    MYSQL_ROW row;/*one row of the result*/
    int i;
    if(mysql_init(&db) ==NULL)
    {
      fprintf(stderr,"Fail to initialize the db.\n");
      return -1;
    }
    if(!mysql_real_connect(&db,"localhost","root","password","kiccleaf",3306,NULL,0))
    {
      fprintf(stderr,"Fail to connect to the server");
      return -1;
    }
    //添加字符集防止乱码
    mysql_set_character_set(&db,"utf8");
    if(mysql_query(&db,"SELECT * FROM user") != 0)
    {
      fprintf(stderr,"Fail to query the db for information.\n");
      return -1;
    }
    if ((result = mysql_store_result(&db)) == NULL)
    {
      fprintf(stderr,"Fail to get the result.\n");
      return -1;
    }

    while((row=mysql_fetch_row(result)) != NULL)/*fetching each row*/
    {
      puts("================================================");
      printf("id: %s\n",row[0]);
      printf("name: %s\n",row[1]);
      printf("pwd: %s\n",row[2]);
      printf("flag: %s\n",row[3]);
      puts("================================================");
    }

    mysql_free_result(result);
    mysql_close(&db);
    return 0;
}

编译时也会出现问题,可以添加参数 “-lz /usr/lib/mysql/libmysqlclient.so.15.0.0”

gcc -o kiccleaf -g kiccleaf.c -lz /usr/lib/mysql/libmysqlclient.so.15.0.0

原来乱码的情况

[root@kiccleaf c]# ./kiccleaf
================================================
id: 0000000001
name: ???
pwd: 123456
flag: 0
================================================
================================================
id: 0000000002
name: ???
pwd: 654123
flag: 0
================================================
================================================
id: 0000000003
name: ???
pwd: 789456
flag: 0
================================================
================================================
id: 0000000004
name: ???
pwd: 456321
flag: 0
================================================

添加字符集后输出结果:

[root@kiccleaf c]# ./kiccleaf
================================================
id: 0000000001
name: 测试1
pwd: 123456
flag: 0
================================================
================================================
id: 0000000002
name: 测试2
pwd: 654123
flag: 0
================================================
================================================
id: 0000000003
name: 测试3
pwd: 789456
flag: 0
================================================
================================================
id: 0000000004
name: 测试4
pwd: 456321
flag: 0
================================================
Leave a Comment

Linux X64下Nginx1.0.4无缝升级到新版本1.3.0版本操作方法[原创]

服务器近一年没有更新Nginx版本了,为了提高性能和稳定,采用了最新的Nginx版本。可以到http://nginx.org/en/download.html 进行下载。升级仅花了几分钟时间就搞定了。
注:以下代码是真实环境直接配置复制进来,可以根据代码从上至下进行操作配置。

[root@kiccleaf leaf]# wget http://nginx.org/download/nginx-1.3.0.tar.gz
[root@kiccleaf leaf]# tar -zxvf nginx-1.3.0.tar.gz
[root@kiccleaf leaf]# cd nginx-1.3.0
#如果需要服务器个性化名称可以修改
[root@kiccleaf nginx-1.3.0]# vi src/core/nginx.h
/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) Nginx, Inc.
 */


#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_


#define nginx_version      1003000
#define NGINX_VERSION      "1.3.0"  #可修改成自己需要的版本
#define NGINX_VER          "Nginx/" NGINX_VERSION #可修改成自己需要服务的名称

#define NGINX_VAR          "NGINX"  #可修改成自己需要服务的名称
#define NGX_OLDPID_EXT     ".oldbin"


#endif /* _NGINX_H_INCLUDED_ */

#进行配置操作,根据自己的实际配置来,以下是我简单的配置

[root@kiccleaf nginx-1.3.0]# ./configure --user=www --group=www --add-module=../ngx_cache_purge-1.3 --prefix=/usr/local/nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
checking for OS
 + Linux 2.6.18-274.12.1.el5 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.1.2 20080704 (Red Hat 4.1.2-51)
…………………………编译代码省略………………
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
[root@kiccleaf nginx-1.3.0]# make  #看清咯,只make,而不是make install,这里升级不需要install操作
make -f objs/Makefile
make[1]: Entering directory `/home/leaf/nginx-1.3.0'
…………………………编译代码省略………………
make[1]: Leaving directory `/home/leaf/nginx-1.3.0'
make -f objs/Makefile manpage
make[1]: Entering directory `/home/leaf/nginx-1.3.0'
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
		-e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
		-e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
		-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
		< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/home/leaf/nginx-1.3.0'

检查配置是否正确,这里出现了警告,因为从低版本升级至高版本产生了配置的问题

[root@kiccleaf nginx-1.3.0]# ./objs/nginx -t
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/nginx/conf/conf.d/www.kiccleaf.com.conf:22
nginx: [warn] the "log_format" directive may be used only on "http" level in /usr/local/nginx/conf/conf.d/www.qimutian.com.conf:22
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
#升级后出现配置文件conf有错误,如果有其的虚拟主机开启了日志,也按要求移出server段放在server段的前面即可。
[root@kiccleaf nginx-1.3.0]# vi /usr/local/nginx/conf/conf.d/www.kiccleaf.com.conf
#把server里面的log_format代码拿到上面来,保存退出
    log_format  www_kiccleaf_com  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';
server
{
    listen       80;
    server_name  www.kiccleaf.com;
    index index.html index.htm index.php;
    root  /data/kiccleaf;
    #limit_conn   crawler  20;    
                            
    location ~ .*\.(php|php5)?$
    {      
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }

#以下代码的问题,升级后需要把以下代码拿到server上面去。这里先注释掉
#    log_format  www_kiccleaf_com  '$remote_addr - $remote_user [$time_local] "$request" '
#             '$status $body_bytes_sent "$http_referer" '
#              '"$http_user_agent" $http_x_forwarded_for';
    access_log  /data/logs/www_kiccleaf_com.log www_kiccleaf_com;

}
[root@kiccleaf nginx-1.3.0]# /usr/local/nginx/sbin/nginx -t  #再检查,没有warn警告信息了
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

操作升级,出错误不管它

[root@kiccleaf nginx-1.3.0]# make upgrade #出现错误,就先不管它
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
cat: /usr/local/nginx/logs/nginx.pid: No such file or directory
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
make: *** [upgrade] Error 1

备份老的Nginx程序,复制新的过去

[root@kiccleaf nginx-1.3.0]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
mv: overwrite `/usr/local/nginx/sbin/nginx.old'? y
[root@kiccleaf nginx-1.3.0]# cp objs/nginx /usr/local/nginx/sbin/nginx
[root@kiccleaf nginx-1.3.0]# /usr/local/nginx/sbin/nginx -t #查看复制过去配置是否正确
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@kiccleaf nginx-1.3.0]# /usr/local/nginx/sbin/nginx -v  #再查看一下新版本,老的是1.0.4版本
nginx version: Nginx/1.3.0  #已经是新版本

无缝升级到新版本

[root@kiccleaf nginx-1.3.0]# kill -USR2 `cat /usr/local/nginx/nginx.pid` #
[root@kiccleaf nginx-1.3.0]# ps aux| grep nginx #查看一下进程
root      2169  0.0  0.0 248708  1788 ?        Ss    2011   0:00 nginx: master process /usr/local/nginx/sbin/nginx  #老的进程都是2011年开启的,嘿嘿
www       6891  0.0  0.3 274308 27796 ?        S    Apr20   0:13 nginx: worker process               
www       6892  0.0  0.3 274308 27616 ?        S    Apr20   0:13 nginx: worker process               
www       6893  0.0  0.3 274308 27596 ?        S    Apr20   0:13 nginx: worker process               
www       6894  0.0  0.3 274308 27612 ?        S    Apr20   0:13 nginx: worker process               
www       6895  0.0  0.3 274308 27608 ?        S    Apr20   0:15 nginx: worker process               
www       6896  0.0  0.3 274308 27796 ?        S    Apr20   0:15 nginx: worker process               
www       6897  0.0  0.3 274308 27700 ?        S    Apr20   0:15 nginx: worker process               
www       6898  0.0  0.3 274308 27600 ?        S    Apr20   0:12 nginx: worker process               
www       6899  0.0  0.3 274308 27592 ?        S    Apr20   0:13 nginx: worker process               
www       6900  0.0  0.3 274308 27620 ?        S    Apr20   0:13 nginx: worker process               
www       6901  0.0  0.3 274308 27616 ?        S    Apr20   0:14 nginx: worker process               
www       6902  0.0  0.3 274308 27652 ?        S    Apr20   0:11 nginx: worker process               
www       6903  0.0  0.3 274308 27856 ?        S    Apr20   0:13 nginx: worker process               
www       6904  0.0  0.3 274308 27608 ?        S    Apr20   0:15 nginx: worker process               
www       6905  0.0  0.3 274308 27644 ?        S    Apr20   0:12 nginx: worker process               
www       6906  0.0  0.3 274308 27612 ?        S    Apr20   0:16 nginx: worker process               
www       6907  0.0  0.0 248708  1500 ?        S    Apr20   0:00 nginx: cache manager process        
root     30293  0.0  0.0 248008  3764 ?        S    22:17   0:00 nginx: master process /usr/local/nginx/sbin/nginx
www      30294  0.0  0.3 273968 27524 ?        S    22:17   0:00 nginx: worker process               
www      30295  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30296  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30297  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30298  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30299  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30300  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30301  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30302  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30303  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30304  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30305  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30306  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30307  0.0  0.3 273936 27392 ?        S    22:17   0:00 nginx: worker process               
www      30308  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30309  0.0  0.3 273608 26784 ?        S    22:17   0:00 nginx: worker process               
www      30310  0.0  0.0 248188  1396 ?        S    22:17   0:00 nginx: cache manager process        
root     30316  0.0  0.0  61172   800 pts/1    S+   22:36   0:00 grep nginx

原来存放nginx.pid的目录下自动出现了nginx.pid.oldbin。现在新的和旧的一起在提供服务,我们执行一下命令把老的进程给Kill掉就可以了。

[root@kiccleaf nginx-1.3.0]# kill -QUIT `cat /usr/local/nginx/nginx.pid.oldbin` 
[root@kiccleaf nginx-1.3.0]# ps aux| grep nginx #现在查看进程只有新的了
root     30293  0.0  0.0 248720  3924 ?        S    22:17   0:00 nginx: master process /usr/local/nginx/sbin/nginx
www      30332  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30333  0.1  0.3 274320 27552 ?        S    22:43   0:00 nginx: worker process               
www      30334  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30335  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30336  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30337  0.1  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30338  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30339  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30340  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30341  0.1  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30342  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30343  0.1  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30344  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30345  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30346  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30347  0.0  0.3 274320 26944 ?        S    22:43   0:00 nginx: worker process               
www      30348  0.0  0.0 248720  1400 ?        S    22:43   0:00 nginx: cache manager process        
root     30418  0.0  0.0  61172   796 pts/1    S+   22:45   0:00 grep nginx

好了进行访问网站,是不是正常不间断切换至最新的Nginx版本了!

Leave a Comment

Win2003下安装Team Foundation Server 2010安装失败解决方案

Win2003下安装Team Foundation Server 2010 安装失败,找了好久网络上最多的是在win2003安装的时候就告诉你不要安装FrontPage 服务器扩展,但很不幸的事情,而且我服务器运行了三四年了,现在要安装TFS失败了。相信也有同样碰到这样的问题但找不到解决办法的人,就看看我是怎么安装成功的!!
土办法!有招可解!一步一步教你实现
1.首先安装好MSSQL2008数据库,当然你也可以安装SQL2005数据库。
2.去“控制面板”–“添加删除”中选择IIS中的FrontPage 服务器扩展,去掉并“下一步”。(光这样删除是不行的,安装TFS不是会提示你FrontPage 服务器扩展问题失败)



3.接下来需要手工操作了,找到C:\WINDOWS\system32\inetsrv下的MetaBase.xml配置文件

4.去服务里停止IIS,服务–找到“IIS Admin Service” 右击停止。

5.开始手动修改代码了,先备份一个MetaBase.xml,然后找到以下代码并删除:
删除 FrontPage Server Extensions;FPSE,ASP,IndexingService” 此行


<IIsWebService	Location ="/LM/W3SVC"
		AllowKeepAlive="TRUE"
		AnonymousUserName="IUSR_KICCLEAFSERVER"
		AnonymousUserPass="49634462700000002200000040000000475cbf110c40b876b7298c567297c5a6f2293855cecfef3ef15a5a7933a6e1f0fffb49004e004400ce9594fe9ea98168d799e40cafc23a53e28281b3d4e85da3a6801884dde6777b736af2f7a846d059b9ffc5eee95a11c19d4f4499ba36b8a4b15e1b152b174a5b"
		AppAllowClientDebug="FALSE"
		AppAllowDebugging="FALSE"
		AppPoolId="DefaultAppPool"
		ApplicationDependencies="Active Server Pages;ASP
			Internet 数据连接器;HTTPODBC
			在服务器端的包含文件;SSINC
			WebDAV;WEBDAV
			ASP.NET v1.1.4322;ASP.NET v1.1.4322
			ASP.NET v2.0.50727;ASP.NET v2.0.50727
			ASP.NET v4.0.30319;ASP.NET v4.0.30319
			FrontPage Server Extensions;FPSE,ASP,IndexingService"

删除以下几行


WebSvcExtRestrictionList="1,C:\WINDOWS\system32\inetsrv\gzip.dll,1,,gzip
			0,C:\WINDOWS\system32\inetsrv\httpodbc.dll,0,HTTPODBC,Internet 数据连接器
			0,C:\Program Files\Common Files\microsoft shared\web server extensions\50\isapi\_vti_adm\admin.dll,0,FPSE,FrontPage Server Extensions
			0,C:\WINDOWS\system32\inetsrv\ssinc.dll,0,SSINC,在服务器端的包含文件
			1,C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll,0,ASP.NET v4.0.30319,ASP.NET v4.0.30319
			1,C:\WINDOWS\system32\inetsrv\asp.dll,0,ASP,Active Server Pages
			0,C:\Program Files\Common Files\microsoft shared\web server extensions\50\isapi\shtml.dll,0,FPSE,FrontPage Server Extensions
			1,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,0,ASP.NET v2.0.50727,ASP.NET v2.0.50727
			0,C:\Program Files\Common Files\microsoft shared\web server extensions\50\isapi\_vti_adm\fpadmdll.dll,0,FPSE,FrontPage Server Extensions
			1,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,0,ASP.NET v1.1.4322,ASP.NET v1.1.4322
			1,C:\php\php5isapi.dll,1,,php
			0,C:\Program Files\Common Files\microsoft shared\web server extensions\50\isapi\_vti_aut\author.dll,0,FPSE,FrontPage Server Extensions
			0,*.exe
			0,C:\WINDOWS\system32\inetsrv\httpext.dll,0,WEBDAV,WebDAV
			0,*.dll
			0,C:\Program Files\Common Files\microsoft shared\web server extensions\50\isapi\fpcount.exe,0,FPSE,FrontPage Server Extensions"

修改后:


		WebSvcExtRestrictionList="1,C:\WINDOWS\system32\inetsrv\gzip.dll,1,,gzip
			0,C:\WINDOWS\system32\inetsrv\httpodbc.dll,0,HTTPODBC,Internet 数据连接器
			0,C:\WINDOWS\system32\inetsrv\ssinc.dll,0,SSINC,在服务器端的包含文件
			1,C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll,0,ASP.NET v4.0.30319,ASP.NET v4.0.30319
			1,C:\WINDOWS\system32\inetsrv\asp.dll,0,ASP,Active Server Pages
			1,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,0,ASP.NET v2.0.50727,ASP.NET v2.0.50727
			1,C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll,0,ASP.NET v1.1.4322,ASP.NET v1.1.4322
			1,C:\php\php5isapi.dll,1,,php
			0,*.exe
			0,C:\WINDOWS\system32\inetsrv\httpext.dll,0,WEBDAV,WebDAV
			0,*.dll"

删除代码以下全部


<IIsFilter	Location ="/LM/W3SVC/1/Filters/fpexedll.dll"
		FilterDescription="Microsoft FrontPage Server Extensions"
		FilterEnableCache="TRUE"
		FilterFlags="NotifySecurePort | NotifyNonSecurePort | NotifyPreProcHeaders | NotifyOrderLow"
		FilterPath="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\50\bin\fpexedll.dll"
		FilterState="1"
	>
</IIsFilter>

删除 FrontPageWeb=”TRUE” 此行


<IIsWebVirtualDir	Location ="/LM/W3SVC/1/ROOT"
		AccessFlags="AccessRead | AccessScript"
		AppFriendlyName="默认应用程序"
		AppIsolated="2"
		AppPoolId="vss"
		AppRoot="/LM/W3SVC/1/ROOT"
		AuthFlags="AuthAnonymous | AuthNTLM"
		DefaultDoc="index.asp,Default.htm,Default.asp,Default.html,Default.aspx,index.htm,index.html,index.aspx,index.php"
		FrontPageWeb="TRUE"
		HttpCustomHeaders="MicrosoftOfficeWebServer: 5.0_Pub

修改后


<IIsWebVirtualDir	Location ="/LM/W3SVC/1/ROOT"
		AccessFlags="AccessRead | AccessScript"
		AppFriendlyName="默认应用程序"
		AppIsolated="2"
		AppPoolId="vss"
		AppRoot="/LM/W3SVC/1/ROOT"
		AuthFlags="AuthAnonymous | AuthNTLM"
		DefaultDoc="index.asp,Default.htm,Default.asp,Default.html,Default.aspx,index.htm,index.html,index.aspx,index.php"
		HttpCustomHeaders="MicrosoftOfficeWebServer: 5.0_Pub

6.以上删除代码后,可以保存并重启IIS服务后,可以再次安装TFS软件了。我就是这么安装成功的!

Leave a Comment

TF31003: 您尚未输入必需的凭据,或您的用户帐户没有连接到 的 Team Foundation Server 的权限

错误提示:

TF31003: 您尚未输入必需的凭据,或您的用户帐户没有连接到 的 Team Foundation Server 的权限。
单击下面的“使用其他凭据”链接,或要求服务器管理员为您的帐户添加适当的权限。

TF31003: Your user account does not have permsision to connect to the team foundation server xxx. Contact your team foundation server administrator and request that the appropriate permission to be added to your account

解决方案:

我的情况是因为Windows7 或是window2008 无法访问Windows 2003共享的问题造成,所以解决方法为

首先确认一下控制面板-系统和安全-windows防火墙-允许的程序里打开了“文件和打印机共享”

开始=>运行–>管理工具—>本地计算机策略=>计算机配置=>Windows设置=>安全设置=>本地策略=>安全选项。找到:“网络安全:LAN管理器身份验证级别”项,默认值“没有定义”改为“发送LM & NTLM响应”

Leave a Comment

windows2008防火墙限制指定IP不能访问

只要服务器对公网,就有被攻击的可能。如果发现一些指定的IP绑定80端口进行攻击,那么我们可以配置windows2008自带的防火墙进行过滤,还别说,效果还真不假的。简单八步完成限制指定IP过滤。
实例:
从前一天开始两波的攻击流量上来看,占用了100M的带宽,配置了过滤指定的IP后,流量图最后面显示马上就下去了。如图所示:

系统进程可以看到网卡流量正常了,如图所示:

防火墙具体配置八个步骤完成。

第一步:点击“新建规则”

第二步:选择“自定义”

第三步:不用选择,默认“所有程序”

第四步:默认,下一步

第五步:自定义应用中添加指定的IP(需要过滤的IP)

第六步:选择“阻止链接”,下一步

第七步:选择需要生效的域,一般默认就好

第八步:填写规则名称及注释,完成生效配置

Leave a Comment

通过BAT实现统计Win2008下链接数的数据

最近访问服务器量有所增加,为排除一些功能行为,所以需要定时执行BAT进行数据统计。那么我的解决方案如下:
1.编写BAT文件实现自动创建目录和定时创建一个统计文本文件
2.配置windows2008计划任务并实现

第一步:
首先编写一个mkdirdate.bat文件进行每天凌晨00:00:00分执行创建一个目录,代码如下:

@echo off
set dat=%date:~0,4%%date:~5,2%%date:~8,2%
md %dat%

第二步:
由于时间的格式问题,如果是早上9点以前则取一位,如果是10点以后则取两位
这里的leq是判断是否时间小于9,而geq则是是否大于10
统计IP至当前时间的文本文件中
%time:~0,2% 这个是取系统时间的前两位
首先编写一个BAT脚本文件,本文以“ipcount.bat”为名称源码如下:


@echo off
set dat=%date:~0,4%%date:~5,2%%date:~8,2%
set tm=%time:~0,2%
if %tm% leq 9 set time0=%time:~1,1%%time:~3,2%%time:~6,2%%time:~9,2%
if %tm% geq 10 set time0=%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%
set dttm=%dat%%time0%

netstat -an >%dat%\IP%dttm%.txt

第三步:
统计服务器总链接数及其他的一些信息,创建文件“datacount.bat”代码如下:

@echo off
set dat=%date:~0,4%%date:~5,2%%date:~8,2%
set tm=%time:~0,2%
if %tm% leq 9 set time0=%time:~1,1%%time:~3,2%%time:~6,2%%time:~9,2%
if %tm% geq 10 set time0=%time:~0,2%%time:~3,2%%time:~6,2%%time:~9,2%

set dttm=%dat%%time0%

netstat -es >%dat%\Count%dttm%.txt

好了三个文件我们都已经创建好,接下去我们再讲一下配置计划任务时要注意的是分以下两步
第一步:

mkdirdate.bat 文件单独创建一个计划任务在每天00:00:00执行,每天执行一次就可以了。

第二步:
datacount.bat
ipcount.bat
两个文件添加到同一个计划任务里,并配置好每天重复执行,我这里配置是每分钟执行一次统计,每次会自动生成两个不同时间的文本文件,至于时间可以自己调整如果访问不高,可以5分钟统计一次,或是半小时,一小时都可以。

根据统计的文本,然后进行分析,流量大小,或是哪些IP比较可疑,如果有IP链接多达100以上的基本可以确定是属于非正常访问,当然就情况不同而决定
关于非法的IP链接数怎么进行过滤,我会在另一篇防火墙过滤指定IP的文章中进行说明。

看一下BAT任务执行后的效果图:

Leave a Comment

win2008 计划任务配置(任务计划程序)每分钟执行BAT

很多人在问我:
1、windows2008计划任务配置每分钟执行能配置吗?
2、windows2008计划任务在哪里配置?
3、windows2008可以配置每分钟或是每小时执行我的任务吗?

答案是:可以!
首先win2008不同于其他服务器操作系统和win2003有着很大的区别,计划任务的名称是“任务计划程序”不在控制面板里,而是在“管理工具”里。
由于服务器需要做些任务,定时执行,自己写程序吧,麻烦,所以采用BAT进行代替操作,网络上很多人都在说每分钟执行怎么配置,今天我们就配置一下。
打开“任务计划程序”–点击“任务计划程序库”在右则会看到操作项里有“创建基本任务”和“创建任务”如图所示:

点击“创建任务”后如图所示:填写好相应的名称和勾选好必要的条件

选择“触发器”选项,点击“新建”,创建任务执行时间,“重复任务间隔”这个选择后,后面有时间选择,是每小时,还是每分,可自己选择后再修改时间,再确定。

再来配置需要执行的“操作”,就是选择所写的程序或是BAT文件,这里很重要的配置是选择BAT文件后,在“起始于(可选)”这里一定要填写相应执行程序或是BAT文件的所在目录,要不然是执行不成功的。

添加后,列表栏中会出现添加的计划任务。

Leave a Comment