Rootop 服务器运维与web架构

2011-04-12
发表者 Venus
暂无评论

apache 开启 .htaccess

       修改httpd.conf配置文件,开启加载mod_rewrite.so 模块

LoadModule rewrite_module modules/mod_rewrite.so

    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#

# AllowOverride None

    AllowOverride All

将.htaccess文件放置于网站根目录即可。重启apache服务生效。

参考文档:https://www.rootop.org/ApacheManual/Apache2.2_zh_CN/howto/htaccess.html

常见配置语法:

 在linux下,可以手动创建一个.htaccess文件   //touch .htaccess

自定义错误页
       .htaccess的一个应用是自定义错误页面,这将使你可以拥有自己的、个性化的错误页面

可以通过在.htaccess文件里加入下面的文字将其变成自定义页面:
ErrorDocument {ErrorNumber} /file.html
比如根目录下有一个notfound.html文件,我想使用它作为404 error的页面:
ErrorDocument 404 /notfound.html
如果文件不在网站的根目录下,你只需要把路径设置为:
ErrorDocument 404 /errorpages/404.html
以下是一些最常用的错误:
401 – Authorization Required 需要验证
400 – Bad request 错误请求
403 – Forbidden 禁止
500 – Internal Server Error 内部服务器错误
404 – Wrong page 找不到页面

如果想更加具体的了解.htaccess的使用,那可以参照Appache的doc中相关的文档及其它网站资料。

2011-04-11
发表者 Venus
暂无评论

Office 2007 excel 输入中文时崩溃

Office 2007 excel 输入中文时崩溃

检查日志如下:

ID: 1, Application Name: Microsoft Office Excel, Application Version: 12.0.4518.1014, Microsoft Office Version: 12.0.4518.1014. This session lasted 8 seconds with 0 seconds of active time.  This session ended with a crash.

Google之:

* Suggestion 1: Repair Office
===========

Sometimes corrupted core Office files may cause this issue. To repair
Office, see the steps below.

1. Click Start>Control Panel
2. Double click Add and Remove Programs
3. Select Office 2007 and click Change.
4. Select Repair and click Continue              //搞定

Now start Excel and exit. Does it crash again?

* Suggestion 2: Excel Safe Mode
===========

1. Click Start>Run.
2. Type “excel /s” (without the quotation marks) and press Enter.
3. Click File>Exit to exit Excel.

Do you still get a crash? If this scenario does not occur when you use the
/s switch, please try the following suggestions to see if this problem can
be fixed.

#1 Check Excel startup folders
#2 Check Excel toolbar file and Quick Access Toolbar file

To view the detailed troubleshooting steps, please refer to the following
KB article:

919196 How to troubleshoot Excel 2007 startup problems
http://support.microsoft.com/default…b;EN-US;919196

If this issue persists in Excel Safe Mode, please try to run Windows in
Safe Mode to narrow down the issue:

* Run Windows in Safe Mode
==========

1. Restart your Windows.
2. Long press F8 key when Windows is preparing to launch.
3. Choose Safe Mode to start Windows in Safe Mode.
4. After Windows Starts in Safe Mode, determine if this issue still
persists.

Please also help us collect more information for further research:

* Information Collection
================

1. Does this only occur on the laptop or it also occurs on the other
desktops?
2. Does this also occur on any other Office applications such as Word?
3. Does this also occur on every user account on this laptop? Please
create a new one to test.
4. Please send me a screenshot on the exact error message.
** To take a screenshot
———————
1. When this error message appears, press PrScrn key on your keyboard.
2. Type ¡°mspaint¡± (without the quotation marks) in Start>Run box and
click OK.
3. Click Edit>Paste to paste the screenshot.
4. Save it as JPEG file type and send it as Email attachment.
———————
5. Please send me the application event log.
** Collect Application Event log
——————————-
1. Click Start>Run
2. Type ¡°eventvwr¡± (without the quotation marks) and click OK.
3. Right click on the Application, and click Save Log File As¡*
4. Save it as TXT file format and send it as e-mail attachment.
——————————
6. Please also provide MPS_REPORT so that we can do further research.
** Obtain MPS_REPORT
———————
1. Go to the following web page:

http://www.microsoft.com/downloads/d…C7C-7CA5-408F-
88B7-F9C79B7306C0&displaylang=en
2. Click to download MPSRPT_SETUPPerf.EXE
3. Double click to run this EXE file.
4. After a few minutes, a CAB file will be generated. Please send the CAB
file directly to my mail box.
Here is the detailed information about MPS_REPORT:
818742 Overview of the Microsoft Configuration Capture Utility
(MPS_REPORTS)
http://support.microsoft.com/default…b;EN-US;818742
———————-

Here is my Email address: <v-lehao@microsoft.com>

Please try my suggestions and provide results and information.

Regards,

Leon Hao

Microsoft Online Partner Support
Get Secure! – www.microsoft.com/security
====================================================
When responding to posts, please “Reply to Group” via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided “AS IS” with no warranties, and confers no rights.

2011-04-07
发表者 Venus
暂无评论

SQL Server 无法生成 FRunCM 线程。请查看 SQL Server 错误日志和 Windows 事件日志

     启动MSSQLSERVER服务时报错:

     本地计算机上的MSSQLSERVER服务启动后又停止了。一些服务自动停止,如果它们没有什么可做的,例如“性能日志和警报”服务。

打开日志查看器开始看日志:

       SQL Server 无法生成 FRunCM 线程。请查看 SQL Server 错误日志和 Windows 事件日志,获取有关可能发生的相关问题的信息。

       由于网络库中存在内部错误,所以无法启动网络库。要确定原因,请查看错误日志中紧位于此错误之前的那些错误。

        TDSSNIClient 初始化失败,出现错误 0x7e,状态代码 0x1。

接着查看SQL日志 (MSSQL.1\MSSQL\LOG)

2011-04-07 10:35:39.15 Server      Microsoft SQL Server 2005 – 9.00.1399.06 (Intel X86)
 Oct 14 2005 00:33:37
 Copyright (c) 1988-2005 Microsoft Corporation
 Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 2)

2011-04-07 10:35:39.15 Server      (c) 2005 Microsoft Corporation.
2011-04-07 10:35:39.15 Server      All rights reserved.
2011-04-07 10:35:39.15 Server      Server process ID is 5400.
2011-04-07 10:35:39.15 Server      Logging SQL Server messages in file ‘D:\sql\MSSQL.1\MSSQL\LOG\ERRORLOG’.
2011-04-07 10:35:39.15 Server      This instance of SQL Server last reported using a process ID of 6068 at 2011-4-7 10:34:02 (local) 2011-4-7 2:34:02 (UTC). This is an informational message only; no user action is required.
2011-04-07 10:35:39.15 Server      Registry startup parameters:
2011-04-07 10:35:39.15 Server        -d D:\sql\MSSQL.1\MSSQL\DATA\master.mdf
2011-04-07 10:35:39.15 Server        -e D:\sql\MSSQL.1\MSSQL\LOG\ERRORLOG
2011-04-07 10:35:39.15 Server        -l D:\sql\MSSQL.1\MSSQL\DATA\mastlog.ldf
2011-04-07 10:35:39.17 服务器         SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2011-04-07 10:35:39.17 服务器         Detected 2 CPUs. This is an informational message; no user action is required.
2011-04-07 10:35:39.37 服务器         Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2011-04-07 10:35:39.39 服务器         Attempting to initialize Microsoft Distributed Transaction Coordinator (MS DTC). This is an informational message only. No user action is required.
2011-04-07 10:35:39.39 服务器         The Microsoft Distributed Transaction Coordinator (MS DTC) service could not be contacted.  If you would like distributed transaction functionality, please start this service.
2011-04-07 10:35:39.39 服务器         Database Mirroring Transport is disabled in the endpoint configuration.
2011-04-07 10:35:39.40 spid5s      Starting up database ‘master’.
2011-04-07 10:35:39.59 spid5s      SQL Trace ID 1 was started by login “sa”.
2011-04-07 10:35:39.60 spid5s      Starting up database ‘mssqlsystemresource’.
2011-04-07 10:35:39.76 spid5s      Server name is ‘NQ’. This is an informational message only. No user action is required.
2011-04-07 10:35:39.76 spid9s      Starting up database ‘model’.
2011-04-07 10:35:39.81 服务器         The certificate was successfully loaded for encryption.
2011-04-07 10:35:39.81 服务器         错误: 17182,严重性: 16,状态: 1。
2011-04-07 10:35:39.81 服务器         TDSSNIClient initialization failed with error 0x7e, status code 0x60.
2011-04-07 10:35:39.81 服务器         错误: 17182,严重性: 16,状态: 1。
2011-04-07 10:35:39.81 服务器         TDSSNIClient initialization failed with error 0x7e, status code 0x1.
2011-04-07 10:35:39.81 服务器         错误: 17826,严重性: 18,状态: 3。
2011-04-07 10:35:39.81 服务器         Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2011-04-07 10:35:39.81 服务器         错误: 17120,严重性: 16,状态: 1。
2011-04-07 10:35:39.81 服务器         SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.

可以判定,可能是以下几个问题:

1、IP地址配置不正确:

打开 \Microsoft SQL Server 2005\配置工具\下的SQL Server Configuration Manager,选择MSSQLSERVER协议, 然后双击右边窗口的TCP/IP,在弹出窗口中检查IP配置。

一般默认的IP2是:127.0.0.1,如果第一个IP地址的端口1433端口telnet不通的话,服务无法启动。您可以将127.0.0.1放在IP1上,那么不管IP2的端口是否能telnet通,服务都能够正常启动。您也可以将IP1设置为当前机器的IP地址,并保证该IP地址的端口能够ping通。

2、可能是因为VIA协议启用造成的。解决方法如下:

打开 \Microsoft SQL Server 2005\配置工具\下的SQL Server Configuration Manager,选择mssqlserver协议, 然后右边窗口有个VIA,点击右键禁用它,点击“确定”即可。这时候再启动sqlserver服务即可!

另外,管理员密码修改也会造成sqlserver服务无法启动。解决方法如下:

打开 \Microsoft SQL Server 2005\配置工具\下的SQL Server Configuration Manager,在MSSQLSERVER服务属性中,修改以哪个账号来启动服务。

我机器启动不了服务的原因就是启用了 “VIA”服务,禁用后,OK了。

(VIA: 是SQL Server的一个连接协议,全名Virtual Interface Architecture,中文名是虚拟接口架构。搜索相关资料后说,via协议最好不要启动,类似于虚拟设备,特像vpn原理,不知道这样说对不对,总之排错的时候注意下这些)

2011-04-07
发表者 Venus
暂无评论

关于sql2008企业版中的编辑前200行“打开表”

现在数据库更换为sql2008,其中的“打开表”没有了,替而代之是“编辑前200行”。

操作数据库,修改表中的内容时,有时候觉得还真不方便,那么我们可以手动修改一下,完全打开整张表。(微软改为前200行也是有道理的,万一表中的数据庞大,那么很容易造成机器变慢)

点击 “工具”-“选项”-SQL Server 资源对象管理器-命令-表和试图选项-“编辑前<n>行”命令的值,改为0即可。

出现“编辑所有行”,相当于sql2005中的“打开表”

2011-04-06
发表者 Venus
暂无评论

Linux dd命令

dd 的主要选项:

指定数字的地方若以下列字符结尾乘以相应的数字:

b=512, c=1, k=1024, w=2, xm=number m

if=file

输入文件名,缺省为标准输入。

of=file

输出文件名,缺省为标准输出。

ibs=bytes

一次读入 bytes 个字节(即一个块大小为 bytes 个字节)。

obs=bytes

一次写 bytes 个字节(即一个块大小为 bytes 个字节)。

bs=bytes

同时设置读写块的大小为 bytes ,可代替 ibs 和 obs 。

cbs=bytes

一次转换 bytes 个字节,即转换缓冲区大小。

skip=blocks

从输入文件开头跳过 blocks 个块后再开始复制。

seek=blocks

从输出文件开头跳过 blocks 个块后再开始复制。(通常只有当输出文件是磁盘或磁带时才有效)。

count=blocks

仅拷贝 blocks 个块,块大小等于 ibs 指定的字节数。

conv=conversion[,conversion…]

用指定的参数转换文件。

转换参数:

ascii 转换 EBCDIC 为 ASCII。

ebcdic 转换 ASCII 为 EBCDIC。

ibm 转换 ASCII 为 alternate EBCDIC.

block 把每一行转换为长度为 cbs 的记录,不足部分用空格填充。

unblock 使每一行的长度都为 cbs ,不足部分用空格填充。

lcase 把大写字符转换为小写字符。

ucase 把小写字符转换为大写字符。

swab 交换输入的每对字节。

noerror 出错时不停止。

notrunc 不截短输出文件。

sync 把每个输入块填充到ibs个字节,不足部分用空(NUL)字符补齐。

2.实例分析

2.1.数据备份与恢复

2.1.1整盘数据备份与恢复
备份:

dd if=/dev/hdx of=/dev/hdy
将本地的/dev/hdx整盘备份到/dev/hdy
dd if=/dev/hdx of=/path/to/image
将/dev/hdx全盘数据备份到指定路径的image文件
dd if=/dev/hdx | gzip >/path/to/image.gz
备份/dev/hdx全盘数据,并利用gzip工具进行压缩,保存到指定路径
恢复:
dd if=/path/to/image of=/dev/hdx
将备份文件恢复到指定盘
gzip -dc /path/to/image.gz | dd of=/dev/hdx
将压缩的备份文件恢复到指定盘

2.1.2.利用netcat远程备份
dd if=/dev/hda bs=16065b | netcat < targethost-IP > 1234
在源主机上执行此命令备份/dev/hda
netcat -l -p 1234 | dd of=/dev/hdc bs=16065b
在目的主机上执行此命令来接收数据并写入/dev/hdc
netcat -l -p 1234 | bzip2 > partition.img
                netcat -l -p 1234 | gzip > partition.img
以上两条指令是目的主机指令的变化分别采用bzip2  gzip对数据进行压缩,并将备份文件保存在当前目录。

2.1.3.备份MBR
备份:

dd if=/dev/hdx of=/path/to/image count=1 bs=512
备份磁盘开始的512Byte大小的MBR信息到指定文件
恢复:

dd if=/path/to/image of=/dev/hdx
将备份的MBR信息写到磁盘开始部分

2.1.4.备份软盘

dd if=/dev/fd0 of=disk.img count=1 bs=1440k
将软驱数据备份到当前目录的disk.img文件

2.1.5.拷贝内存资料到硬盘

dd if=/dev/mem of=/root/mem.bin bs=1024
将内存里的数据拷贝到root目录下的mem.bin文件

2.1.6.从光盘拷贝iso镜像

dd if=/dev/cdrom of=/root/cd.iso
拷贝光盘数据到root文件夹下,并保存为cd.iso文件     

2.2.增加Swap分区文件大小

dd if=/dev/zero of=/swapfile bs=1024 count=262144
创建一个足够大的文件(此处为256M)
mkswap /swapfile
把这个文件变成swap文件
swapon /swapfile
启用这个swap文件
/swapfile swap swap defaults 0 0
在每次开机的时候自动加载swap文件, 需要在 /etc/fstab 文件中增加一行

2.3.销毁磁盘数据

dd if=/dev/urandom of=/dev/hda1
利用随机的数据填充硬盘,在某些必要的场合可以用来销毁数据。执行此操作以后,/dev/hda1将无法挂载,创建和拷贝操作无法执行。
2.4磁盘管理

2.4.1.得到最恰当的block size

dd if=/dev/zero bs=1024 count=1000000 of=/root/1Gb.file
                dd if=/dev/zero bs=2048 count=500000 of=/root/1Gb.file
                dd if=/dev/zero bs=4096 count=250000 of=/root/1Gb.file     
                dd if=/dev/zero bs=8192 count=125000 of=/root/1Gb.file
通过比较dd指令输出中所显示的命令执行时间,即可确定系统最佳的block size大小

              
2.4.2测试硬盘读写速度

dd if=/root/1Gb.file bs=64k | dd of=/dev/null
                dd if=/dev/zero of=/root/1Gb.file bs=1024 count=1000000
通过上两个命令输出的执行时间,可以计算出测试硬盘的读/写速度     
2.4.3.修复硬盘

dd if=/dev/sda of=/dev/sda
当硬盘较长时间(比如1,2年)放置不使用后,磁盘上会产生magnetic fluxpoint。当磁头读到这些区域时会遇到困难,并可能导致I/O错误。当这种情况影响到硬盘的第一个扇区时,可能导致硬盘报废。上边的命令有可能使这些数据起死回生。且这个过程是安全,高效的。

今天一群里朋友说用了这个命令,将一块硬盘中的数据找回来了,太神奇了,想不通呐。请大牛们详解。