﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-空白-随笔分类-Linux/Unix</title><link>http://www.blogjava.net/niumd/category/32389.html</link><description>天行健、君子以自强不息 ；地势坤、君子以厚德载物……</description><language>zh-cn</language><lastBuildDate>Wed, 11 May 2011 02:52:49 GMT</lastBuildDate><pubDate>Wed, 11 May 2011 02:52:49 GMT</pubDate><ttl>60</ttl><item><title>Nginx+tomcat配置集群负载均衡</title><link>http://www.blogjava.net/niumd/archive/2011/05/10/349958.html</link><dc:creator>空白</dc:creator><author>空白</author><pubDate>Tue, 10 May 2011 12:56:00 GMT</pubDate><guid>http://www.blogjava.net/niumd/archive/2011/05/10/349958.html</guid><wfw:comment>http://www.blogjava.net/niumd/comments/349958.html</wfw:comment><comments>http://www.blogjava.net/niumd/archive/2011/05/10/349958.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/niumd/comments/commentRss/349958.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/niumd/services/trackbacks/349958.html</trackback:ping><description><![CDATA[<div style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; background-position: initial initial; background-repeat: initial initial; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; 作者：niumd&nbsp;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; Blog:http://ari.iteye.com</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; 转载请注明出处，谢谢</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp; 开发的应用采用F5负载均衡交换机，F5将请求转发给5台hp unix服务器，每台服务器有多个webserver实例，对外提供web服务和socket等接口服务。之初，曾有个小小的疑问为何不采用开源的apache、Nginx软件负载，F5设备动辄几十万，价格昂贵？自己一个比较幼稚的问题，后续明白：F5是操作于IOS网络模型的传输层，Nginx、apache是基于http反向代理方式，位于ISO模型的第七层应用层。直白些就是TCP UDP 和http协议的区别，Nginx不能为基于TCP协议的应用提供负载均衡。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 了解了二者之间的区别于应用场景，对Nginx产生浓厚的兴趣，阅读张宴的&lt;实战Nginx&gt;（这个85年的小伙子年轻有为羡慕+妒忌），搞明白了大致原理和配置，Ubuntu10.10，window下对Nginx+tomcat负载均衡做了配置尝试，将全部请求转发到tomcat，并未做静态，动态分开，图片防盗链等配置。<br />
<strong><span mce_style="font-size: small;" style="font-size: small; ">Nginx 介绍</span></strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp;&nbsp; Nginx （发音同 engine x）是一款轻量级的Web 服务器／反向代理服务器及电子邮件（IMAP/POP3）代理服务器，并在一个BSD-like 协议下发行。&nbsp; 其特点是占有内存少，并发能力强，事实上nginx的并发能力确实在同类型的网页伺服器中表现较好.目前中国大陆使用nginx网站用户有：新浪、网易、 腾讯,另外知名的微网志Plurk也使用nginx。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp; 上面的全是Nginx介绍基本上是废话，下面转入正题，图文结合展示基本配置，首先是window环境、其次是Ubuntu环境（Vbox虚拟）。本文主要基于Nginx下配置两台tomcat，结构如下图：<br />
<img src="http://dl.iteye.com/upload/attachment/360652/25338dc2-5d45-3bc7-b9f7-102eb25c4ce9.png" mce_src="http://dl.iteye.com/upload/attachment/360652/25338dc2-5d45-3bc7-b9f7-102eb25c4ce9.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><br />
<span mce_style="font-size: small;" style="font-size: small; "><strong>&nbsp;</strong></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span mce_style="font-size: medium;" style="font-size: medium; "><strong>Window xp环境：Nginx+Tomcat6</strong></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><strong>1、下载地址</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://nginx.org/en/download.html" mce_href="http://nginx.org/en/download.html">http://nginx.org/en/download.html</a>&nbsp;，这里我们推荐下载稳定版（stable versions），本文采用nginx-0.8.20。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
<strong>2、目录结构</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Nginx-</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; conf&nbsp;&nbsp; 配置目录</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; contrib</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; docs 文档目录</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; logs&nbsp; 日志目录</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; temp 临时文件目录</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; html 静态页面目录</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |_&nbsp; nginx.exe 主程序</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; window下安装Nginx极其简单，解压缩到一个无空格的英文目录即可（个人习惯，担心中文出问题），双击nginx启动，这里我安装到：D:\server目录，下面涉及到的tomcat也安装在此目录。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360565/40f0081a-c121-32e5-9157-07ee4fb800d1.jpg" mce_src="http://dl.iteye.com/upload/attachment/360565/40f0081a-c121-32e5-9157-07ee4fb800d1.jpg" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">DOS环境启动</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360567/baf0cca2-abbf-30aa-ad04-735fa82834b8.jpg" mce_src="http://dl.iteye.com/upload/attachment/360567/baf0cca2-abbf-30aa-ad04-735fa82834b8.jpg" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">若果想停止nginx，dos环境运行命令：nginx -s stop</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
<strong>3、nginx.conf配置</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp; Nginx配置文件默认在conf目录，主要配置文件为nginx.conf，我们安装在D:\server\nginx-0.8.20、默认主配置文件为D:\server\nginx-0.8.20\nginx.conf。下面是nginx作为前端反向代理服务器的配置。</p>
<pre name="code" class="nginx.conf" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#Nginx所用用户和组，window下不指定
#user  niumd niumd;
#工作的子进程数量（通常等于CPU数量或者2倍于CPU）
worker_processes  2;
#错误日志存放路径
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;
#指定pid存放文件
pid        logs/nginx.pid;
events {
#使用网络IO模型linux建议epoll，FreeBSD建议采用kqueue，window下不指定。
#use epoll;
#允许最大连接数
worker_connections  2048;
}
http {
include       mime.types;
default_type  application/octet-stream;
#定义日志格式
#log_format  main  '$remote_addr - $remote_user [$time_local] $request '
#                  '"$status" $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';
#access_log  off;
access_log  logs/access.log;
client_header_timeout  3m;
client_body_timeout    3m;
send_timeout           3m;
client_header_buffer_size    1k;
large_client_header_buffers  4 4k;
sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;
#keepalive_timeout  75 20;
include    gzip.conf;
upstream localhost {
#根据ip计算将请求分配各那个后端tomcat，许多人误认为可以解决session问题，其实并不能。
#同一机器在多网情况下，路由切换，ip可能不同
#ip_hash;
server localhost:18081;
server localhost:18080;
}
server {
listen       80;
server_name  localhost;
location / {
proxy_connect_timeout   3;
proxy_send_timeout      30;
proxy_read_timeout      30;
proxy_pass http://localhost;
}
}
}</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
&nbsp;&nbsp; 代理设置如下：</p>
<pre name="code" class="proxy.conf" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">proxy_redirect          off;
proxy_set_header        Host $host;
proxy_set_header        X-Real-IP $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
proxy_connect_timeout   300;
proxy_send_timeout      300;
proxy_read_timeout      300;
proxy_buffer_size       4k;
proxy_buffers           4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp; gzip压缩相关配置如下：</p>
<pre name="code" class="gzip.conf" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">gzip              on;
gzip_min_length      1000;
gzip_types         text/plain text/css application/x-javascript;
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<strong>&nbsp; 4、Tomcat配置</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp; 对于tomcat大家都很熟悉，只需要修改server.xml配置文件即可，这里我们以apache-tomcat-6.0.14为例，分别在server目录，解压缩并命名为：apache-tomcat-6.0.14_1、apache-tomcat-6.0.14_2。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp; 第一处端口修改：</p>
<pre name="code" class="xml" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">&lt;!--  修改port端口：18006 俩个tomcat不能重复，端口随意，别太小--&gt;
&lt;Server port="18006" shutdown="SHUTDOWN"&gt;
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
&nbsp;&nbsp; 第二处端口修改：</p>
<pre name="code" class="xml" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">&lt;!-- port="18081" tomcat监听端口，随意设置，别太小 --&gt;
&lt;Connector port="18081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" /&gt;
&nbsp;</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp; 第三处端口修改：</p>
<pre name="code" class="java" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">&lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt;
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp; Engine元素增加jvmRoute属性：</p>
<pre name="code" class="xml" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">&lt;Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1"&gt;
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
&nbsp;&nbsp;&nbsp; 两个tomcat的端口别重复，保证能启动起来，另一个tomcat配置希捷省略，监听端口为18080，附件中我们将上传所有的配置信息。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
<strong>5、验证配置与测试负载均衡</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp; 首先测试nginx配置是否正确，测试命令：nginx -t&nbsp; (默认验证:conf\nginx.conf),也可以指定配置文件路径。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;此例nginx安装目录：D:\server\nginx-0.8.20，dos环境下图画面成功示例：<br />
<img src="http://dl.iteye.com/upload/attachment/360606/488826c2-d5a6-3a5a-8b6b-ea55c33ab01b.jpg" mce_src="http://dl.iteye.com/upload/attachment/360606/488826c2-d5a6-3a5a-8b6b-ea55c33ab01b.jpg" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;其次验证tomcat，启动两个tomcat，不出现端口冲突即为成功（tomcat依赖的java等搞&#8220;挨踢&#8221;的就废话不说了）；</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360608/53ac9d08-9c6e-3ea4-a7fa-8c0bb1f3e2fd.jpg" mce_src="http://dl.iteye.com/upload/attachment/360608/53ac9d08-9c6e-3ea4-a7fa-8c0bb1f3e2fd.jpg" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 最后验证配置负载均衡设置，<a href="http://localhost/" mce_href="http://localhost/">http://localhost/</a>&nbsp;或<a href="http://localhost/index.jsp" mce_href="http://localhost/index.jsp">http://localhost/index.jsp</a>&nbsp;。我修改了index.jsp页面，增加日志输出信息，便于观察。注意：左上角小猫头上的：access tomcat2、access tomcat1。说明访问了不同的tomcat。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360614/ae669075-5a52-3116-b2a1-c455e0c7d2f3.jpg" mce_src="http://dl.iteye.com/upload/attachment/360614/ae669075-5a52-3116-b2a1-c455e0c7d2f3.jpg" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp; 至此window下nginx+tomcat负载均衡配置结束，关于tomcat Session的问题通常是采用memcached，或者采用nginx_upstream_jvm_route ，他是一个 Nginx 的扩展模块，用来实现基于 Cookie 的 Session Sticky 的功能。如果tomcat过多不建议session同步，server间相互同步session很耗资源，高并发环境容易引起Session风暴。请根据自己应用情况合理采纳session解决方案。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;作者：niumd&nbsp;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; Blog:http://ari.iteye.com</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span mce_style="font-size: medium;" style="font-size: medium; "><strong>Ubuntu10.10环境：Nginx+Tomcat6</strong></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
我们下面简单说下ubuntu10.10下如何安装配置，主要以图片为主，简单解释。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><strong></strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><strong><span mce_style="color: #000000;" style="color: #000000; ">1、下载Nginx</span></strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 地址：<a href="http://nginx.org/en/download.html" mce_href="http://nginx.org/en/download.html">http://nginx.org/en/download.html</a>&nbsp;，linux版本：nginx-0.8.20.tar.。解压缩命令：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
tar -zxvf nginx-0.8.20.tar.gz</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
<strong>2、编译安装Nginx</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp;&nbsp; Nginx依赖一些其他PCRE、openssl（依赖libssl-dev），本人笔记本Ubuntu环境已经安装PCRE，仅需安装依赖的openssl，下面我们简单说下如何安装PCRE和openssl等</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
&nbsp;&nbsp;&nbsp;&nbsp; PCRE下载地址：<a href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/" mce_href="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/">ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/</a></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<pre name="code" class="shell" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">tar zxvf  pcre-8.01.tar.gz
cd pcre-8.01
sudo ./configure
sodu make
sodu make install
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;openssl通过apt-get install安装，命令、截图如下：</p>
<pre name="code" class="shell" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">sudo apt-get install openssl
sudo apt-get install libssl-dev
//如缺少其他包，请采用此方法安装，ubuntu有依赖提示
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360643/8a26cf32-8136-3583-956a-4d86f233f644.png" mce_src="http://dl.iteye.com/upload/attachment/360643/8a26cf32-8136-3583-956a-4d86f233f644.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><br />
&nbsp;<br />
&nbsp;依赖的软件包安装完毕，下面来编译Nginx：</p>
<pre name="code" class="shell" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#将window共享目录软件拷贝到当前工作目录
cp /mnt/fileshare/nginx-0.8.20.tar.gz ./
#解压缩软件包
tar zxvf nginx-0.8.20.tar.gz
cd nginx-0.8.20
//编译源码,默认使用nobody，指定本机已存在的用户，组，启用nginx-status功能，监控nginx状态。启动debug
sudo ./configure  --user=niumd --group=niumd --with-debug --with-http_stub_status_module
sudo make
sudo make install
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
&nbsp;&nbsp; 截图 如下：<br />
<img src="http://dl.iteye.com/upload/attachment/360645/95a8c78c-9bab-36f8-aaf8-fa2c77917d44.png" mce_src="http://dl.iteye.com/upload/attachment/360645/95a8c78c-9bab-36f8-aaf8-fa2c77917d44.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">安装结果截图如下：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360647/9a4db10e-d6d0-3131-b652-3040a9a575ae.png" mce_src="http://dl.iteye.com/upload/attachment/360647/9a4db10e-d6d0-3131-b652-3040a9a575ae.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">编译安装正确结束，按照上述window下方法检查默认配置，然后在默认配置下启动nginx，访问<a href="http://127.0.0.1/" mce_href="http://127.0.0.1">http://127.0.0.1</a>&nbsp;，如下图说明成功</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360649/83cb2060-085a-3cc6-9fe7-3703b46ab745.png" mce_src="http://dl.iteye.com/upload/attachment/360649/83cb2060-085a-3cc6-9fe7-3703b46ab745.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Nginx配置成功后我们对window下nginx.conf少做修改，如下：</p>
<pre name="code" class="ubuntu Nginx.conf" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#Nginx所用用户和组
user  niumd niumd;
#工作的子进程数量（通常等于CPU数量或者2倍于CPU）
worker_processes  2;
#错误日志存放路径
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;
#指定pid存放文件
pid        logs/nginx.pid;
events {
#使用网络IO模型linux建议epoll，FreeBSD建议采用kqueue
use epoll;
#允许最大连接数
worker_connections  2048;
}
http {
include       mime.types;
default_type  application/octet-stream;
#定义日志格式
#log_format  main  '$remote_addr - $remote_user [$time_local] $request '
#                  '"$status" $body_bytes_sent "$http_referer" '
#                  '"$http_user_agent" "$http_x_forwarded_for"';
#access_log  off;
access_log  logs/access.log;
client_header_timeout  3m;
client_body_timeout    3m;
send_timeout           3m;
client_header_buffer_size    1k;
large_client_header_buffers  4 4k;
sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;
#keepalive_timeout  75 20;
include    gzip.conf;
upstream localhost {
#ip_hash
#ip_hash;
server localhost:18081;
server localhost:18080;
}
server {
listen       80;
server_name  localhost;
location / {
proxy_connect_timeout   3;
proxy_send_timeout      30;
proxy_read_timeout      30;
proxy_pass http://localhost;
}
}
}
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;对于上面关于ubuntu下Nginx配置和window下基本相同，区别在使用的IO网络模型，linux下建议使用epoll，另外就是运行所用的用户和组；</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><strong>3、配置tomcat</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 请参考window下配置，完全相同。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span mce_style="color: #000000;" style="color: #000000; "><strong>4、启动停止nginx</strong></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><strong>&nbsp;&nbsp;&nbsp;&nbsp;</strong>ubuntu下启动nginx与window稍有不同，大致启动停止方法如下。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<pre name="code" class="java" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#nginx目录执行
sbin/nginx
或通过-c 指定配置文件
sbin/nginx -c usr/local/nginx8.20/conf/nginx/conf</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<pre name="code" class="shell" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">niumd@niumd-laptop:/usr/local/nginx$ pwd
/usr/local/nginx
niumd@niumd-laptop:/usr/local/nginx$ sudo sbin/nginx -t
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
niumd@niumd-laptop:/usr/local/nginx$ sudo sbin/nginx -v
nginx version: nginx/0.8.20
niumd@niumd-laptop:/usr/local/nginx$ sudo sbin/nginx -V
nginx version: nginx/0.8.20
built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
configure arguments: --user=niumd --group=niumd --with-debug --with-http_sub_module
niumd@niumd-laptop:/usr/local/nginx$ sudo sbin/nginx
niumd@niumd-laptop:/usr/local/nginx$ ps -ef|grep nginx
root      5158     1  0 22:32 ?        00:00:00 nginx: master process sbin/nginx
niumd     5159  5158  0 22:32 ?        00:00:00 nginx: worker process
niumd     5161  1577  0 22:32 pts/0    00:00:00 grep --color=auto nginx
niumd@niumd-laptop:/usr/local/nginx$ </pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; &nbsp;&nbsp; 我们通过ps&nbsp; -ef|grep nginx,看到如下结果:</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/360672/64e32e0c-10a4-3cb6-a1d4-87045140b37a.png" mce_src="http://dl.iteye.com/upload/attachment/360672/64e32e0c-10a4-3cb6-a1d4-87045140b37a.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">注意：在启动时linux提示一句警告【warn】&#8230;&#8230;，是因为我们设置的 #允许最大连接数 worker_connections&nbsp; 2048，超过linux默认1024的限制。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 停止：kill -信号类型 pid</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nginx/logs目录下有个nginx。pid的文件，此文件记录了每次运行的pid，也可以通过ps命令查询。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">信号类型如下：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<table mce_style="height: 40px;" border="0" width="400" class="mceItemTable" height="40" style="height: 40px; ">
    <caption style="border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; border-left-style: dashed; border-top-color: #bbbbbb; border-right-color: #bbbbbb; border-bottom-color: #bbbbbb; border-left-color: #bbbbbb; "><strong>信号控制</strong></caption>
    <tbody>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; "><strong>信号类型</strong></td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; "><strong>描述</strong></td>
        </tr>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">RERM.INT</td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">快速关闭</td>
        </tr>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">HUP</td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">平滑重启，加载配置</td>
        </tr>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">USR1</td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">重新加载日志</td>
        </tr>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">USER2</td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">平滑升级执行程序</td>
        </tr>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">WINCH</td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">从容关闭工作进程</td>
        </tr>
        <tr>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">QUIT</td>
            <td style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; ">从容关闭</td>
        </tr>
    </tbody>
</table>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">参考资料：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://www.oschina.net/bbs/thread/9301" mce_href="http://www.oschina.net/bbs/thread/9301">http://www.oschina.net/bbs/thread/9301</a></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">oschina.net 生产配置，此网站采用java语言，nginx，tomcat服务器。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="http://nginx.org/" mce_href="http://nginx.org/">http://nginx.org/</a></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">张宴：&lt;&lt;实战Nginx&gt;&gt;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
</div>
<img src ="http://www.blogjava.net/niumd/aggbug/349958.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/niumd/" target="_blank">空白</a> 2011-05-10 20:56 <a href="http://www.blogjava.net/niumd/archive/2011/05/10/349958.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu11 Unity 2D桌面</title><link>http://www.blogjava.net/niumd/archive/2011/05/10/349955.html</link><dc:creator>空白</dc:creator><author>空白</author><pubDate>Tue, 10 May 2011 12:54:00 GMT</pubDate><guid>http://www.blogjava.net/niumd/archive/2011/05/10/349955.html</guid><wfw:comment>http://www.blogjava.net/niumd/comments/349955.html</wfw:comment><comments>http://www.blogjava.net/niumd/archive/2011/05/10/349955.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/niumd/comments/commentRss/349955.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/niumd/services/trackbacks/349955.html</trackback:ping><description><![CDATA[<div style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; background-position: initial initial; background-repeat: initial initial; ">
<h5 mce_style="text-align: center;" style="font-size: 0.83em; text-align: center; "><span mce_style="font-size: 18px;" style="font-size: 18px; ">Ubuntu11.04如何设置2D Unity桌面</span></h5>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; &nbsp; Ubuntu11.04一发布就迫不及待的尝鲜，虚拟机环境不支持Unity 3D,尝试了下Unity 2D，效果很炫。安装很简单，给大家分享下。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span mce_style="white-space: pre;" style="white-space: pre; ">	</span><span mce_style="font-family: Arial, serif; font-size: 14px; line-height: 22px;" style="font-family: Arial, serif; font-size: 14px; line-height: 22px; ">Terminal 键入如下命令：</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<pre name="code" class="java" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">sudo add-apt-repository ppa:unity-2d-team/unity-2d-daily
sudo apt-get update
sudo apt-get install unity-2d</pre>
&nbsp;
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; &nbsp;这三行命令就不解释，Ubuntu新手老手都应该清楚，经过10-20分钟的等待（取决你的网速和选择更新源），Ubuntu安装Unity-2d和依赖包，安装完毕，log out，这点比windows强，xp都是提示重启的。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;上图：登陆界面选择Unity 2D。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><img src="http://dl.iteye.com/upload/attachment/475018/0cb6e7d0-37f4-3a6a-b393-c060f316d86a.jpg" mce_src="http://dl.iteye.com/upload/attachment/475018/0cb6e7d0-37f4-3a6a-b393-c060f316d86a.jpg" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><span mce_style="font-family: Arial, serif;" style="font-family: Arial, serif; "><span mce_style="font-size: 14px; line-height: 22px;" style="font-size: 14px; line-height: 22px; ">&nbsp;上图秀桌面：</span></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
<img src="http://dl.iteye.com/upload/attachment/475016/8b87cf08-2d68-38a9-ae33-174151f3e743.png" mce_src="http://dl.iteye.com/upload/attachment/475016/8b87cf08-2d68-38a9-ae33-174151f3e743.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
</div>
<img src ="http://www.blogjava.net/niumd/aggbug/349955.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/niumd/" target="_blank">空白</a> 2011-05-10 20:54 <a href="http://www.blogjava.net/niumd/archive/2011/05/10/349955.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>crontab命令用法</title><link>http://www.blogjava.net/niumd/archive/2011/05/10/349957.html</link><dc:creator>空白</dc:creator><author>空白</author><pubDate>Tue, 10 May 2011 12:54:00 GMT</pubDate><guid>http://www.blogjava.net/niumd/archive/2011/05/10/349957.html</guid><wfw:comment>http://www.blogjava.net/niumd/comments/349957.html</wfw:comment><comments>http://www.blogjava.net/niumd/archive/2011/05/10/349957.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/niumd/comments/commentRss/349957.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/niumd/services/trackbacks/349957.html</trackback:ping><description><![CDATA[<div style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 8px; margin-right: 8px; margin-bottom: 8px; margin-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; background-position: initial initial; background-repeat: initial initial; ">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp; &nbsp;Linux提供了用户控制例行任务的命令crontab，常用于每间隔一定时间循环执行一些脚本，此处我们暂时称为：Linux定时任务。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<pre name="code" class="shell" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#问下男人crontab的用法
man crontab
crontab [ -u user ] { -l | -r [ -i ] | -e }
参数：
-u：只有root才可以执行此任务
-l ：查看crontab工作内容
-e：编辑crontab工作内容
-r ：删除crontab工作内容
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><strong>&nbsp;&nbsp;&nbsp;crontab应用场景举例：定时采集远程服务器文件</strong></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp; 手机发送短信，短信回以文本形式记录在交换机上形成短信话单，短信话单通常是达到5M，如果不满5m则每五分钟形成一个话单（不同的交换机可能存在差异）。如果对话单计费，当然需要对短信话单进行采集，然后进行后续计费工作。我们假设采用shell或者python脚本采集，暂且用shell举例，假设采集shell为acquisition.sh ，每间隔1分钟采集一次。</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 命令终端执行：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<pre name="code" class="java" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#标示编辑例行任务
crontab -e</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 然后我们将会看到如下画面：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;<br />
<img src="http://dl.iteye.com/upload/attachment/384214/873a6227-c863-39cd-af72-ebfbdee15b96.png" mce_src="http://dl.iteye.com/upload/attachment/384214/873a6227-c863-39cd-af72-ebfbdee15b96.png" alt="" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " /><br />
&nbsp;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp; 已经进入VI 编辑模式，在里面输入下面这行，按下ESC-&gt;：-&gt;wq就保存了</p>
<pre name="code" class="python" style="color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin-top: 0px; margin-right: 5px; margin-bottom: 5px; margin-left: 15px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #fafafa; background-position: initial initial; background-repeat: initial initial; ">#每间隔一分钟执行一次采集脚本
*/1 * * * * crontab  /路径/acquisition.sh
</pre>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; crontab的格式为：</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 分钟&nbsp; 小时 日&nbsp; 月 周 crontab&nbsp;&nbsp; 待执行命令或者脚本&nbsp;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; 其中：* 代表任何时间都接受，如上例小时、日期、月份、周都为*</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;，代表分割时间段，如分钟修改为：0,1,2,3,4,5 即任何小时地1,2，&#8230;&#8230;6分钟都执行</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - 代表时间段上面的每间隔一分钟可以标示为0-59；</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /n&nbsp;代表每间隔，分钟位置：*/5标示每间隔五分钟</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;注意：*和*之间只有一个空格；</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><br />
</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">EOF</p>
</div>
<img src ="http://www.blogjava.net/niumd/aggbug/349957.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/niumd/" target="_blank">空白</a> 2011-05-10 20:54 <a href="http://www.blogjava.net/niumd/archive/2011/05/10/349957.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>转载：Solaris/Linux 命令行 简单手册</title><link>http://www.blogjava.net/niumd/archive/2008/06/20/209450.html</link><dc:creator>空白</dc:creator><author>空白</author><pubDate>Fri, 20 Jun 2008 06:45:00 GMT</pubDate><guid>http://www.blogjava.net/niumd/archive/2008/06/20/209450.html</guid><wfw:comment>http://www.blogjava.net/niumd/comments/209450.html</wfw:comment><comments>http://www.blogjava.net/niumd/archive/2008/06/20/209450.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/niumd/comments/commentRss/209450.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/niumd/services/trackbacks/209450.html</trackback:ping><description><![CDATA[1. 系统<br />
# passwd：修改口令<br />
# exit：退出系统<br />
<br />
2. 文件<br />
# cp：复制文件或目录，参数：-a递归目录，-i覆盖确认<br />
# mv：改名移动<br />
# rm：删除，参数：-r递归删除<br />
<br />
3. 目录<br />
# mkdir：创建目录<br />
# rmdir：删除空目录<br />
# cd：改变工作目录<br />
# pwd：查看当前路径<br />
# ls：列目录，参数：-a所有文件，-c按时间排序，-l详细信息<br />
<br />
4. 文本<br />
# sort：排序<br />
# uniq：删除重复行<br />
<br />
5. 备份压缩<br />
# tar：档案，参数：-c创建新档案，-r追加到末尾，-t列出档案内容，-u更新文件，-x释放文件，-f使用档案文件或设备，-M多卷，-v详细报告，-w每步确认。例tar cvf text.tar *.txt<br />
# gzip：压缩解压缩，参数：-d解压，-r递归压缩<br />
# unzip：解压缩，参数：-d目录，-x解压缩<br />
<br />
6. 权限<br />
# chmod：改变权限，r可读，w可写，x可执行。0表示没有权限，1表示可执行权限，2表示可写权限，4表示可读权限，然后将其相加。例如，如果想让某个文件的属主有&#8220;读/写&#8221;二种权限，需要把4（可读）+2（可写）＝6（读/写）。<br />
# chgrp：改变所属用户组<br />
# chown：改变属主<br />
<br />
7. 管理<br />
# wall：发送信息到全部登录用户<br />
# write：向某个用户发送信息<br />
# mesg y：设定允许别人给自己发送信息<br />
# sync：缓存同步校验<br />
# shutdown：关机，参数：-r重启，-h关机不重启，-f快速关机，-c取消关机<br />
# free：查看内存<br />
# uptime：显示系统运行时间<br />
# df：磁盘占用空间，参数：-a显示所有文件系统<br />
# du：磁盘使用情况<br />
# dd：拷贝并格式转换<br />
# fdformat：低格软盘<br />
# echo：显示文字<br />
# cal：日历<br />
# date：系统日期和时间<br />
# clear：清屏<br />
<br />
8. 我的回忆 by tom2sun<br />
# who：查看当前用户<br />
# finger：查看其他用户信息<br />
# rlogin：远程登录<br />
# rcp：远程复制<br />
# netstat：网络状态<br />
# cat：一次完全显示<br />
# more：分屏显示<br />
# file：列出文件类型<br />
# grep：查找内容<br />
# find：查找文件<br />
# ps：当前运行程序，参数-a显示所有进程<br />
# at：时间，命令，Ctrl+D结束<br />
# lp：打印<br />
# nice：指定优先级<br />
# renice：调整优先级<br />
# kill：终止进程<br />
# man：获取命令帮助<br />
# touch：改变时间记录<br />
# ln：链接<br />
# mount -t vfat /dev/hda1 /mnt/dos：挂载Dos分区(不适用于Unix-Center)<br />
<br />
9. FTP<br />
# ftp：启动FTP程序<br />
ftp&gt;<br />
open：打开<br />
close：关闭<br />
bye：离开<br />
get：下载<br />
put：上传<br />
mget/mput：多个文件下载/上传<br />
reget：恢复下载<br />
binary：二进制传送文件<br />
ascii：ASCII码传送<br />
cd：改变远程目录<br />
lcd：改变本地目录<br />
mkdir：建目录<br />
rmdir：删除目录<br />
delete：删除文件<br />
mdelete：一次删除多个<br />
rename：重命名<br />
status：显示状态<br />
prompt：交互式<br />
hash：每传送1024字节显示#（hash）<br />
size：显示文件大小<br />
reset：重置<br />
<br />
10. vi<br />
a,i：进入输入状态<br />
ESC：返回命令状态<br />
:命令模式<br />
Q!：退出<br />
<br />
11. 快键及其他<br />
Alt+F1~F6：访问多个虚拟控制台(不适用于Unix-Center)<br />
Tab：命令补全<br />
末尾&amp;：后台进程<br />
<br />
----------------------------------------<br />
<br />
硬件系统：<br />
<br />
1、如何查看cpu的状态？&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
# psrinfo -v<br />
# mpstat&nbsp; &nbsp;&nbsp;&nbsp;可以列出多cpu负载的状态<br />
<br />
2、如何查看内存？&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
# prtconf | grep 'Memory' 可以查看内存的多少.<br />
# /usr/platform/sun4u/sbin/prtdiag<br />
<br />
3、如何动态添加swap分区？ # $su － root&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; -----&nbsp;&nbsp;成为超级用户 <br />
# mkfile 100m /home/swapfile&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-----&nbsp;&nbsp;创建100m的Swap文件 <br />
# /usr/sbin/swap －a /path/filename&nbsp;&nbsp;-----&nbsp;&nbsp;激活Swap文件 <br />
# /usr/sbin/swap －l&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-----&nbsp;&nbsp;验证swap文件<br />
# /usr/sbin/swap －d /path/filename&nbsp;&nbsp;-----&nbsp;&nbsp;取消swap文件<br />
# rm -rf /home/swapfile&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-----&nbsp;&nbsp;删除swap文件<br />
<br />
4、如何查看当前网卡是以何种速率起来的？&nbsp; &nbsp;&nbsp;&nbsp;<br />
# dmesg |grep Link<br />
<br />
5、如何调整x-window的分辨率和刷新频率？<br />
&nbsp;&nbsp;字符界面登陆，运行：#/kdmconfig<br />
<br />
6、如何使用光、软驱？<br />
一般情况下用：<br />
# /etc/init.d/volmgt start<br />
# volcheck<br />
以上方法不行，用：<br />
# /etc/init.d/volmgt stop<br />
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom --挂接光驱<br />
# mount -F pcfs /dev/diskette0 /floppy&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;--挂接软驱<br />
solaris定义系统磁盘文件系统说明：<br />
ufs &#8211; UNIX文件系统。是Solaris缺省的文件系统。 <br />
hsfs &#8211; 高密度CD-ROM文件系统，是只读文件系统。 <br />
pcfs &#8211; PC文件系统，支持DOS格式化的软盘<br />
<br />
7、SCSI设备的命名规则是什么？<br />
带有总线控制器的硬盘的使用，下面列出了总线控制器的硬盘命名习惯： <br />
cWtXdYsZ<br />
c Logical controller number<br />
t Physical bus target number <br />
d Drive number <br />
s Slice (or partition) number (0 to 7) <br />
例如：<br />
/dev/rdsk/c0t0d0s0 该原始接口对应第一个控制器的第一个SCSI目标地址的第一个硬盘的第一片(根) <br />
/dev/rdsk/c0t0d0s2 该原始接口对应第一个控制器的第一个SCSI目标地址上的第一个硬盘的第三片(表示整上硬盘) <br />
<br />
8、如何查看硬盘的使用情况？&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
# df -k&nbsp; &nbsp;&nbsp; &nbsp;可以看到已安装的文件系统的空间大小及剩余空间大小。<br />
# quota -v&nbsp; &nbsp;&nbsp; &nbsp; 查看用户的磁盘空间信息,如果你用quota限制了用户空间大小的话。<br />
# du -sk *&nbsp; &nbsp;查看目录的使用情况<br />
# du -k | sort -n&nbsp;&nbsp;可以迅速发现那个目录是最大的。 <br />
<br />
9、如何查看硬盘物理信息？<br />
# format&nbsp; &nbsp;&nbsp; &nbsp; 这个命令也可以查看硬盘的类型和分区的详细情况<br />
# iostat -E看硬盘的大小和型号<br />
# prtvtoc /dev/rdsk/c0t0d0s0&nbsp; &nbsp;显示某个磁盘的分区状况<br />
<br />
10、查看系统内核命令。&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
&nbsp;&nbsp;# isainfo&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;看内核的bit, <br />
&nbsp;&nbsp;# isainfo -kv&nbsp; &nbsp;&nbsp; &nbsp;调整内核<br />
# modinfo&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 显示可载入的模组<br />
# prtconf&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 显示系统硬件配置（周边设备）<br />
#sysdef&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;显示可载入的模组，硬件配置与一些可以调整的核心参考值<br />
#ulimit -a<br />
<br />
11、打印当前的OBP版本号&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br />
# prtconf &#8211;V <br />
OBP 3.20.0 2000/10/24 10:47 <br />
# /usr/platform/sun4u/sbin/prtdiag &#8211;v | grep OBP <br />
OBP 3.20.0 2000/10/24 10:47 POST 6.1.0 2000/10/24 10:49 <br />
ok. .version <br />
Release 3.20 Version 0 created 2000/10/24 10:47 <br />
OBP 3.20.0 2000/10/24 10:47 <br />
POST 6.1.0 2000/10/24 10:49 <br />
OBDIAG 4.5.1 2000/10/24 10:48 <br />
<br />
12、查看及启动系统的32位或64位内核模式&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
64位模式 <br />
# isalist &#8211;v <br />
sparcv9+vis sparcv9 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc <br />
# isainfo &#8211;v <br />
64-bit sparcv9 applications <br />
32-bit sparc applications <br />
# isainfo &#8211;b <br />
64 <br />
启动64位内核模式 <br />
ok. boot kernel/sparcv9/unix <br />
<br />
32位模式 <br />
# isalist &#8211;v <br />
sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc <br />
# isainfo &#8211;v <br />
32-bit sparc applications <br />
# isainfo &#8211;b <br />
32 <br />
启动32位模式 <br />
ok. boot kernel/unix <br />
<br />
13、测定当前的显示器刷新频率 <br />
# /usr/sbin/fbconfig &#8211;rev \? <br />
<br />
14、如何配置网卡ip？<br />
# ifconfig -a&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; --查看网卡,例如是hme0<br />
# ifconfig hme0&nbsp;&nbsp;unplumb&nbsp;&nbsp;--停止网卡<br />
# ifconfig hme0&nbsp;&nbsp;plumb&nbsp; &nbsp; --起用网卡<br />
# ifconfig hme0 inet 192.168.2.3 netmask 255.255.255.0 up&nbsp;&nbsp;--添加ip、子网掩码<br />
# vi /etc/defaultrouter&nbsp; &nbsp;添加默认路由的ip<br />
# vi /etc/hostname.hme0&nbsp; &nbsp;添加主机名<br />
# vi /etc/nodename&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;添加主机名<br />
# vi /etc/resolv.conf&nbsp; &nbsp;&nbsp;&nbsp;<br />
&nbsp; &nbsp;domain china.com&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 你的域名<br />
&nbsp; &nbsp;nameserver 202.106.0.20&nbsp; &nbsp;你使用的nds ip<br />
# vi /etc/nsswitch.conf&nbsp; &nbsp;&nbsp;&nbsp;更改 hosts：file dns<br />
<br />
15、 PROM状态命令与参数<br />
格式：&nbsp;&nbsp;OK&gt;; 指令<br />
&nbsp; &nbsp;&nbsp; &nbsp; 命令&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;说明<br />
banner&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;显示当前机器配置状况，CPU,内存,hostid,EtherNet<br />
probe-scsi&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;显示内部SCSI通道所挂接设备<br />
probe-scsi-all&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 显示所有SCSI通道及所挂接设备<br />
probe-ide&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;显示所有IDE通道及所挂接设备(针对U10,U5)<br />
devalias&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 显示设备别名，如 cdrom,disk,disk0,disk1等<br />
printenv&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 无参数，显示环境变量或<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;参数为环境变量名 如： printenv auto-boot?<br />
setenv&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;设置环境变量，如： setenv auto-boot? false<br />
set-default&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 恢复环境变量预定值&nbsp;&nbsp;如：set-default auto-boot?<br />
set-defaults&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;恢复所有环境变量预定值<br />
boot device option&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;启动主机<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;设备别名:&nbsp;&nbsp;cdrom 或 disk<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;设备名:&nbsp; &nbsp;/pci@1f,4000/scsi@3,1/disk@6,0:f<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;option&nbsp;&nbsp;-r&nbsp;&nbsp;设备配置&nbsp;&nbsp;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-s&nbsp;&nbsp;单用户<br />
eject cdrom|floppy&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;弹出cdrom或floppy<br />
reset&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 复位<br />
test net&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
watch-net-all&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
show-devs&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
<br />
16、查找网卡名称及接口个数&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
# grep network /etc/path_to_inst <br />
<br />
17、如何一块网卡帮定三个ip,并且子网掩码不同？<br />
举例说明，网卡名hme0：<br />
# vi /etc/hosts <br />
127.0.0.1 localhost <br />
192.168.2.1 dbs loghost <br />
192.168.9.15 dd <br />
192.168.9.65 aa <br />
# vi /etc/netmasks <br />
192.168.2.0 255.255.255.0 <br />
192.168.9.0 255.255.255.192 <br />
192.168.9.64 255.255.255.252 <br />
<br />
#vi /etc/hostname.hme0 <br />
dbs <br />
#vi /etc/hostname.hme0:1 <br />
dd <br />
#vi /etc/hostname.hme0:2 <br />
aa <br />
# ipconfig hme0 inet 192.168.2..1 netmask 255.255.255.0 up&nbsp;&nbsp;<br />
# ipconfig hme0:1inet 192.168.9.15 netmask 255.255.255.192 up <br />
# ipconfig hme0 inet 192.168.9.65 netmask 255.255.255.252 up <br />
# init 6<br />
#ipconfig -a<br />
<br />
18、如何在prom状态下查看光纤硬盘 ？&nbsp; &nbsp;<br />
stop +a进入ok状态：<br />
ok&gt;; select 光纤卡设备名（可用show-devs查看到） <br />
ok&gt;; show-children<br />
<br />
19、主机双屏幕设置。&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
1.Confirm there are two Video Cards。 <br />
2.Confirm driver installed and patches installed if need。 <br />
3.vi /usr/dt/config/Xservers. <br />
comment the last line. <br />
and uncomment the nearest line like this. <br />
4.reboot.<br />
<br />
20、查看硬盘参数及其物理地址： <br />
#format &lt;/dev/null <br />
<br />
21、显示磁盘的分区情况： <br />
#prtvtoc /dev/rdsk/c0t0d0s2 <br />
<br />
<br />
系统应用：<br />
<br />
1、、查看系统运行级别<br />
# who -r 看运行级别<br />
<br />
2、进程工具&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
pstop pid　 停止进程 <br />
prun　pid　 重新启动进程 <br />
ptime pid　 使用微状态计算进程时间 <br />
pwait pid　 等待指定的进程终止 <br />
pcred pid　显示可信度　　　 * <br />
pfiles pid 显示已打开文件的fstat和fcntl信息　　 * <br />
pflags pid 显示每个lwp的/proc跟踪标志，等待和待有信号量以及其他状态信息　 * <br />
pldd　 pid 显示链接到每个进程的动态链接库　　 * <br />
pmap　pid　 显示地址映射空间　　 * <br />
psig　pid　显示信号操作　　　 * <br />
pstack pid 显示每个lwp的十六进制与符号堆跟踪　　 * <br />
ptree　pid　显示包含指定PID的进程树 <br />
pwdx　 pid 显示当前工作目录　　　* <br />
后面加*的必须是超级用户执行。 <br />
这些工具在/usr/proc/bin/里面。<br />
<br />
3、patch软件包的安装<br />
每个补丁都有编号。例如补丁号为101945，版本是34的话，这个补丁的目录名就是101945-34. <br />
# patchadd 105160-01&nbsp; &nbsp;&nbsp;&nbsp;安装补丁<br />
# patchrm&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 删除补丁<br />
# patchadd -p&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;检查系统的补丁情况 <br />
# showrev -p&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 查看所有已经安装的patch<br />
<br />
4、如何容许root用户远程登录？<br />
&nbsp;&nbsp;# vi /etc/default/login&nbsp;&nbsp;<br />
&nbsp;&nbsp;CONSOLE=/dev/console&nbsp;&nbsp;---用#注释掉这一行。<br />
<br />
5、如何限定telnet登陆数？solaris pts的数量缺省为47, 修改/etc/system文件， 增加如下内容: <br />
set maxusers=数量 <br />
set pt_cnt=数量 <br />
<br />
6、显示已经使用和未使用的i-node数目&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
# df &#8211;F ufs &#8211;o i <br />
<br />
7、显示cpu使用率最高的进程&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
# ps &#8211;eo pid,pcpu,args | sort +1n <br />
该命令输出当前系统进程的pid, CPU占用率及命令描述，并以pcpu来排序&nbsp;&nbsp;<br />
<br />
8、查看当前的OpenWindows版本&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
# showrev &#8211;w <br />
OpenWindows version: <br />
X11 Version 6.4.1 5 November 2001 <br />
<br />
9、查看当前CDE的版本&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
# /usr/ccs/bin/what /usr/dt/bin/dtmail <br />
/usr/dt/bin/dtmail: <br />
CDE Version 1.4.6_06 <br />
CDEVersion1.4.6_06 <br />
<br />
10、文消掉本中的^M <br />
# cat test.dat | tr -d '\015' &gt;; test.out <br />
这样可以将 test.dat 内 ^M(\015) 这个字元去掉, 产生 test.out <br />
<br />
11、关机命令。<br />
关闭系统的方式根据关闭的原因而不同.执行关闭有的是为了转至执行等级S，有的是要停止操作系统并关闭设备的电源. <br />
(1) /usr/sbin/shutdown &#8211;gtime &#8211;ilevel -y <br />
(2) init 0 <br />
(3) halt <br />
(4) STOP+A ; sync <br />
(5) 关闭电源 <br />
紧急情况，按Stop_A , 如Stop_A不起作用，则将设备电源关闭再打开.这是 <br />
极端情况.这两种方法不是干净的关闭，是突然关闭的，仅在紧急情况使用.<br />
<br />
12、Solaris下怎么发送即时消息？<br />
用wirte命令到单个用户的终端。 <br />
$ wirte username <br />
输入消息正文，结束按ctrl-d,消息就会出现在用户终端。 <br />
用户可以用mesg n[y]来决定是否启动接受消息。 <br />
<br />
用wall，是发给所有系统用户。 <br />
$ wall <br />
hello ,i love you ...... 结束用ctrl-D. <br />
<br />
rwall -n netgroup 给网络上所有用户。 <br />
$ rwall -n workgroup --------发给组workgroup下的每一个用户 <br />
hi ! no smoking ...... 结束用ctrl -d <br />
<br />
$ rwall sune450 ------或者主机名为sune450。用法如上。。。<br />
<br />
13、系统是sunos5.8， 不知何种原因现在唯一的普通用户起不了Terminal, vi等，但是超级用户可以，如何补救？&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br />
&nbsp; &nbsp;用/etc/skel/local.cshrc 替换掉登陆路径下的 .cshrc, 重新登陆， 就OK了！ <br />
$cp /etc/skel/local.cshrc ./ <br />
<br />
14、关机时这个题是什么意思？&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
/usr/sbin/vold[724]: [ID 244572 daemon.error] 卸载 /vol 时发生问题；中断系统调用 <br />
uxwdog[481]: [ID 248799 daemon.error] error communicating with server (Broken pipe)<br />
<br />
你还没卸下来/VOL就启动，才出问题，运行：<br />
# umount -f /vol后再做。<br />
<br />
15、find常用的例子：<br />
命令格式: find dir -name filename command<br />
例子:<br />
# find . -name hello -print&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;寻找目前目录及所有的子目录内叫hello的文档。<br />
# find . -ctime +7 -print&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;找出七天内未被更动的文档<br />
# find . -size +2000m -print&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;找出大小超过2000 bytes的文档<br />
# find /tmp -user b1234567 -print&nbsp; &nbsp; 在/tmp下属於b1234567的文档<br />
# find . -name '*.c' -exec rm {}&nbsp; &nbsp;&nbsp;&nbsp;删除所有的.c档<br />
# find . -name test\* -print&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;显示当前目录及其子目录文件名前4位为test的文件名<br />
<br />
16、忘记solarsi的root口令怎么办？&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
方法一:<br />
1.别怕 ,跟我来.<br />
2.把你的solaris光盘放进cdrom<br />
3.键入stop+a <br />
4.当出现'ok'字样时,键入boot cdrom -s <br />
5.cd /tmp <br />
6.mkdir /tmp/xxx (xxx是什么鬼东西就无关紧要了) <br />
7.mount /dev/dsk/c0t0d0s0 /tmp/xxx (在这里c0t0d0s0是你的root盘)<br />
8.运行csh <br />
9.TERM=sun;export TERM或者<br />
setenv TERM vt220 <br />
10.cp /tmp/root/xxx/shadow /tmp/root/xxx/shadow/shadow.backup<br />
11.vi /tmp/root/xxx/shadow并且将password里root项删除。<br />
12.重启动，你就可以以无密码的root登陆了，这时更改你的密码。<br />
要是没有shadow,就把/etc/passwd里root用户名后面的X删掉,就可以了<br />
方法二:<br />
找一台有系统的solaris机器,把忘记密码的系统放进去mount上来,重复方法一10以后的步骤.<br />
<br />
solaris for x86的机器：<br />
用光盘启动到要你安装的时候退出去就成单用户，剩下的操作如上。<br />
<br />
17、常见文件的解压&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
一般而言,在solaris下,会有这么几种格式的软件:<br />
1) .gz结尾的文件,我们用gunzip或者gzip -d来解压,再用tar来解压. <br />
2) .tar结尾的文件,我们肯定知道用tar xvf的格式来解压.<br />
3) .zip结尾的文件,我们用unzip,注意,这个只有在高版本的solaris下,才有.而且该文件格式以solaris的patch比较多.<br />
4) .Z结尾的文件,我们一般用uncompress来解压(当然,每个人的习惯不一样.) <br />
上面讲的是解压,一般解压后,会生成这么几种方式: <br />
1)生成.local的文件,这个时候,我们用: pkgadd -d xxx.local来安装. <br />
2) 生成一个目录,而且该目录下会有一些pkg信息,我们用: pkgadd -d . ;指在当前目录下,安装,并且按照缺省的路径来安装. <br />
3) 生成一个数字的目录,一般是指solaris的patch,这个时候我们用patchadd来安装.<br />
<br />
18、如何在命令行界面替换一个文件中的字符段？<br />
# vi file 在命令模式中输入：<br />
：1， $s/diag/peng/g 全文件查找diag并替换为peng <br />
<br />
19、请问TERM=VT100和TERM=dtterm都在什么情况下设置？&nbsp; &nbsp; <br />
一般情况下如果你在机器的显示器上登陆或者通过XMANAGER等登陆，就默认是dtterm，telnet 一般是ansi，当你通过telnet修改文件的时候，需要设置成 TERM = VT100 ; export <br />
<br />
TERM<br />
<br />
20、如何查看系统的版本？<br />
$ uname -X <br />
$ more /etc/release<br />
<br />
21、命令行进入CDE： <br />
#/usr/dt/bin/dtlogin -daemon;exit <br />
or <br />
#/etc/rc2.d/S92dtlogin start;exit; <br />
<br />
22、查看patch安装过程中返回错误代码的含义：<br />
#more /usr/sbin/patchadd <br />
<br />
23、如何从一台SOL8的机器登录到另外一台SOL8的CDE桌面上去。<br />
登陆CDE的时候点击一下菜单：选择--登陆远程主机-- <br />
<br />
24、如何查看你的默认语言环境？&nbsp; &nbsp; C.Arthur <br />
# more /etc/default/init<br />
<br />
25、如何更改/home的权限？&nbsp; &nbsp; <br />
停掉autofs服务，或者将/etc/auto_master的home注释掉： <br />
#vi /etc/auto_master&nbsp; &nbsp;<br />
------------内容如下---------- <br />
# Master map for automounter <br />
# <br />
+auto_master <br />
/net -hosts -nosuid,nobrowse <br />
#/home auto_home -nobrowse <br />
/xfn -xfn<br />
<br />
<br />
第三方软件应用或技巧：<br />
<br />
1、查看当前的bind版本信息&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br />
# nslookup &#8211;class=chaos &#8211;q=txt version.bind <br />
<br />
2、在登录时显示系统指定的消息？<br />
#vi /etc/motd&nbsp; &nbsp; ----删除所有过时的消息,输入新消息<br />
注意：对于已经登录且正在使用系统的用户不显示该消息，超过一屏的消息无法显示。每次修改该文件后，该文件的时间戳随之更新。<br />
<br />
3、去掉文本中^M<br />
# dos2unix aaa.txt bbb.txt,会去掉aaa.txt中的^M，生成bbb.txt文件。<br />
<br />
4、将系统中7天前的txt文件查找并打包。<br />
# find / -mtime -7 &gt;;aaa.txt&nbsp;&nbsp;<br />
# tar cvf bbb.tar -I aaa.txt<br />
---查找出文件记录在aaa.txt文件中，在作成bbb.tar文件包。<br />
<br />
5、查找并删除比某一天更老的文件： <br />
#find . ! -mtime -&lt;days&gt;; | /usr/bin/xarys rn -rf <br />
<br />
6、solaris9普通用户下无法正确输入中文的解决方法： <br />
在用户目录在#vi .profile 修改如下： <br />
stty cs8 -istrip<br />
<br />
7、请问如何防止telnet登陆发呆时间过长被踢呢？ <br />
这里，vi /etc/default/login <br />
# TIMEOUT sets the number of seconds (between 0 and 900) to wait before <br />
# abandoning a login session. <br />
# <br />
#TIMEOUT=300 <br />
修改之后不是立即生效，在这之后所又的login session都符合这个要求，但是在修改之前已经建立的连接不受影响。<br />
<br />
8、如何安装gcc。<br />
去sunfreeware.com上下载相应平台的pkg包的gcc版本。<br />
#pkgadd -d gcc* <br />
设置环境变量：<br />
bash 和sh 的shell:<br />
vi $home/.profiel<br />
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/etc:/usr/local/bin:/usr/ccs/bin;export PATH <br />
CC=gcc;export CC <br />
csh的shell：<br />
vi $home/.cshrc<br />
set path=( /bin /usr/bin /usr/ucb /etc /usr/local/bin /usr/local/sbin .)<br />
setenv CC gcc&nbsp;&nbsp;<br />
<br />
9、列出当前目录下的目录。&nbsp; &nbsp;<br />
ls -al | grep '^d'<br />
<br />
10、用命令行来打开一个新的terminal。&nbsp;&nbsp;<br />
/usr/dt/bin/dtterm<br />
<br />
<br />
X86或者Vmware：<br />
<br />
1、在Solaris10 x86上挂接window98分区的方法。&nbsp; &nbsp;&nbsp; &nbsp;<br />
#mount -F pcfs /dev/dsk/c0d1p0:e /mnt <br />
总结一下： <br />
偶的硬盘是接在IDE1的slaver盘上，用上述命令可将E：盘挂在/mnt <br />
目录下。如果你的电脑只有一个硬盘，并且是接在主板的IDE1槽，设为 <br />
Master盘（通常这种情况较多），现在想挂WIN98下的D：盘，可输入 <br />
#mount -F pcfs /dev/dsk/c0d0p0:d /mnt <br />
注意，/mnt可以改为任意的其它空目录，如/data(我在文件管理器中自己 <br />
新建的一个目录），可改为 <br />
#mount -F pcfs /dev/dsk/c0d0p0:d /data <br />
按回车后如没有任何出错提示，则表示挂接成功，你就可以进入挂接的文件夹（此处为/data）找到你所挂接的win98的D：分区上的文件了。 <br />
本方法经过偶N次实验，是确实可行的。为后来者不再偶走过的弯路，偶特在此总结一下，哪位初学者不会在Solaris10 x86（Solaris9也应该行） <br />
挂win98分区的话，可参考本方法。 <br />
<img src ="http://www.blogjava.net/niumd/aggbug/209450.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/niumd/" target="_blank">空白</a> 2008-06-20 14:45 <a href="http://www.blogjava.net/niumd/archive/2008/06/20/209450.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>