<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?641</link>
<title><![CDATA[我的亲测体验：打卡卡免单电商凭啥让我疯狂“剁手”？——一个普通用户的自白]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[媒体报导]]></category>
<pubDate>Thu, 06 Nov 2025 09:53:57 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?641</guid> 
<description>
<![CDATA[ 
	自从同事安利我用打卡卡，我的购物习惯彻底被颠覆了。作为一个资深网购用户，我本以为各大平台的满减、津贴已经榨干了最后一滴羊毛，直到遇见这个藏在微信小程序里的“免单黑马”。今天就跟你们唠唠，我眼里真实的打卡卡到底有多香。<br/><br/>1. 免单这事，居然真的靠谱？<br/><br/>刚开始我也觉得“免单”俩字儿像营销噱头，直到自己中了三次免单。比如那瓶原价99的面霜，系统提示“您已获得免单资格”——当时手都在抖，反复确认订单状态后才敢相信。后来发现，这玩法其实挺科学：商家把原本分散给10个人的折扣集中给我一个人，数学好的朋友算过，相当于直接砍掉100%的价格——免单了。最绝的是，买得越多中奖机会越大，上次囤了20包抽纸愣是抽中两单免单，直接白嫖了一箱纸！<br/><br/>2. 微信生态=安全感MAX<br/><br/>说出来你们可能不信，我现在买东西前第一反应是打开打卡卡搜一搜。为啥？因为微信小程序不用下载APP，点进去就是打卡卡小程序界面，关键还能直接用微信支付，省去了跳转链接的麻烦。最安心的是，能看到平台资质认证，什么《增值电信业务许可证》《商标注册证》排成一溜，比某些野鸡平台强百倍。朋友之前在某宝买到假货找客服扯皮半个月，而我用打卡卡以来，还没遇到过货不对板的情况。<br/><br/>3. 省钱这件事，可以很快乐<br/><br/>现在我的购物车里永远塞满了“待免单品”。比如超市里15块钱的抽纸，打卡卡显示免单率25%，算下来买4包必中一单；就连我家猫粮这种大件，商家都敢标6免1，相当于6袋白送1袋。最骚的操作是，我发现把零碎需求攒一起买更划算——上周一口气囤了5支口红，就妥妥的1支免单，相当于用4支的钱拿下全套色号。现在闺蜜聚会，我掏出手机展示刚中的免单记录，妥妥的话题中心。<br/><br/>4. 操作丝滑到让人上瘾<br/><br/>对比某宝某东的复杂流程，打卡卡简直像开了挂。没有烦人的弹窗广告，没有逼你充会员的套路，连注册都不用输手机号——直接微信授权就行。最人性化的设计是“一键退款”，上次买的运动鞋尺码选错了，从申请到退款到账全程不到3分钟，比客服回复还快。最近发现他们还搞了个“免单排行榜”，看着自己的ID霸占榜首，那种“薅到羊毛”的成就感，属实上头。<br/><br/>5. 躺赚的快乐，谁懂啊？<br/><br/>说到最绝的，还得是“拉人头”机制。我妈平时连拼多多都不爱逛，结果我教她在打卡卡拼单免单后，现在天天催我“快看看今天有啥便宜货”。原来她跟着邻居拼单抽中了两箱牛奶，转头就在小区广场嘚瑟，硬是拉了十几个人一起玩。现在我们家阿姨生活用品都改在打卡卡下单了，毕竟生活费能省一半，搁谁谁不香？<br/><br/>6. 隐藏彩蛋：这里藏着未来购物的样子<br/><br/>用了打卡卡，我越来越觉得这可能是电商的未来方向。你看啊，商家不用烧钱打广告，用户不用当冤大头，双赢的局面下还能刺激消费。最近发现他们上线了很多大牌美妆的免单率直逼33%，连我妈都开始问我“打卡卡是不是正品”。这种既能省钱又能保质量的模式，说不定真能改变我们的消费习惯。<br/><br/>结语：别问，问就是真香警告 &nbsp;<br/>现在我的手机里躺着三个打卡卡订单提醒：一单是免单的蓝牙耳机，一单是半价的投影仪幕布，还有一单是抽中的免费咖啡机。说实在的，现在的我有点理解为什么身边人都在讨论打卡卡了——毕竟谁不想用别人的羊毛，织一件属于自己的毛衣呢？<br/>Tags - <a href="tag.php?tag=%E6%89%93%E5%8D%A1%E5%8D%A1" rel="tag">打卡卡</a> , <a href="tag.php?tag=dakaka" rel="tag">dakaka</a> , <a href="tag.php?tag=%E5%85%8D%E5%8D%95%E7%94%B5%E5%95%86" rel="tag">免单电商</a> , <a href="tag.php?tag=%E5%85%8D%E5%8D%95%E5%B0%8F%E7%A8%8B%E5%BA%8F" rel="tag">免单小程序</a> , <a href="tag.php?tag=%E7%94%B5%E5%95%86%E5%B0%8F%E7%A8%8B%E5%BA%8F" rel="tag">电商小程序</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?640</link>
<title><![CDATA[失业6个月，打卡卡免单电商平台拯救了我，做好这3件事更踏实]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[媒体报导]]></category>
<pubDate>Thu, 06 Nov 2025 09:51:50 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?640</guid> 
<description>
<![CDATA[ 
	失业像场漫长的暴雨，手机里不断弹出的面试拒绝信，父母询问近况时欲言又止的眼神，就连楼下咖啡店飘来的焦糖玛奇朵香气，都成了刺痛神经的催化剂。<br/><br/>失业最开始我像只无头苍蝇，听说短视频博主好变现，砸钱报班学剪辑，一个月后对着剪辑软件骂娘；又跟风考会计证，看到"借贷记账法"就犯困。想省钱自己折腾炒菜，煎糊的鸡蛋比点的外卖菜还多。这些慌不择路的努力，像往漏水的桶里倒水，越折腾越心慌。<br/><br/>直有一天看到我同学的朋友圈我才醒悟：失业期不用到处去抓救命稻草，做好下面3件事才重要。<br/><br/>一、省钱：用打卡卡免单电商小程序，把钱花在刀刃上<br/><br/>过去总忍不住冲动消费，直到某天刷朋友圈，看到老同学晒出打卡卡的"免单"截图，向他询问后证实打卡卡在没要他退货的情况下，确实将他购物的钱一分不少的退回来了。天啊！这不就是真正的免单吗？我都不可置信，还有这样好的平台，希望这样的好平台别亏倒闭了。我向同学问了打卡卡怎么进入，原来打卡卡免单电商平台是一个微信小程序，在微信小程序里搜“打卡卡”，那个牛哦网络公司运营的就是。<br/><br/>我深入了解后，发现了打卡卡平台的免单玄学：商家将原本分散的让利集中回馈给单个用户。例如，一件标价10元的商品，商家原本可能分别让利1元给10位消费者（即9折），而打卡卡将这10元的让利全部集中给一位幸运消费者（还是9折），实现真正意义上的免单。 而且中奖概率很高，基本上是10%到50%之间，每个商品都有免单机会，购买越多，免单机会越大。商家并不会因为免单而亏本，只是给了消费者一个优惠折扣，所以打卡卡免单电商平台不像那些返利电商平台，搞到最后资金断裂而倒闭。我现在日常消费都在打卡卡电商平台上下单了，一个月累计免单金额可达数百元至数千元，长期下来显著降低生活成本。积少成多的免单收益堪比一份额外收入。<br/><br/>二、薅“小羊毛”：玩转打卡卡免单电商小程序赚钱活动，小羊毛也能滚成大雪球<br/><br/>失业后经常刷一些极速版，在极速版我看了N多的广告，做了N多个任务后，快则半个月挣的金币能换15块，慢的一个月才能换到15块，还要在N多个极速版之间不停地切换，不仅伤眼还耗时，对我的生活和学习完全没有任何益处。打卡卡电商平台的赚钱活动，就简单明了多了，打卡卡有邀新赚钱活动、浏览赚钱活动和免单兜底活动：<br/><br/>邀新赚钱活动就是邀请新用户加入打卡卡平台，3个新用户领15元，10个新用户领100元，20个新用户能领200元，而现在打卡卡是发展初期，基本上邀请的人都是新人，感觉跟送钱似的；<br/><br/>浏览赚钱活动就是按照打卡卡活动的规定，每天浏览商品详情达到规定的次数，不间断持续3天可以领7元，7天领25元，15天可以领60元；<br/><br/>免单兜底活动就是在活动期间，用户完成订单总数中没有获得免单的订单数超过20个的，在活动到期后，打卡卡平台会将从这些没有获得免单的订单中选出最低金额的订单，免单返还给用户。<br/><br/>虽然这些活动，在期限之内只能报名参加一次，不过打卡卡的活动挺频繁的，1个星期或者半个月就会有一次新的活动推出。我现在基本上每月都能薅到几百块，虽然这些钱不足以解决我的生活开支，但是也弥补了我一部分的生活开支，让我的生活有了一些改善。<br/><br/>三、创业：打卡卡免单电商小程序上卖货，轻资产创业<br/><br/>上面说的两点，只是让我有了生存的底气，却没有真正改变我的生存现状，如果你也和我一样，觉得确实做不了铁人三项（外卖、快递、网约车）和吉祥三保（保安、保洁、保姆），那么你最好仔细听听我下面要说的话，我在打卡卡免单电商平台购物过程中，我发现了打卡卡平台上有很多像我一样，奔着免单来的消费者，用我妈的话说：“在哪买不是买，在打卡卡上买，中了免单我高兴，没中免单我也要买的，换个地方买而已”，既然在打卡卡上有销量，而打卡卡又是按成交效果收费的，也就是只有成交了才从成交额里抽取8%作为服务费，其他没有任何支出，并且打卡卡的流量是共享的，中小商家不用像其他电商平台那样碰到“投流没钱、不投没单”的窘境，在打卡卡上都会有单，只是根据商品特性，单多单少而已。<br/><br/>既然在打卡卡能做到了真正的无成本创业了，那我就抱着试试看的想法，在打卡卡平台上开了一个个人店，将我们家里自种的柿子，做成柿饼后挂在我打卡卡的店里销售，结果你别说，生意还特别的好，我上个月就卖了几千单，虽然我承担了免单的费用，其实就相当于打折促销了，我现在卖货挣的钱，已经超过我之前上班的工资了，我妈甭提有多高兴了，即解决了家里自种产品的销路问题，又让我解决生存问题。我妈现在是逢人就夸我多能干，其实我自己心里明白，真正要感谢的是打卡卡免单电商平台，给了我这样的零成本创业机会。<br/><br/>虽然我现在还在找工作，基本面试失败，但心里不慌了。我已经有了自己最可靠的副业，在打卡卡免单电商平台上，商品没卖出去，又没成本，卖出去了，我就挣钱，何乐而不为，当然我并没有放弃我的专业，我还是会找专业对口的工作，只是我现在底气足了很多，不像刚失业的时候，患得患失，我由衷的感谢打卡卡免单电商平台，我希望我这篇心得能够解救更多像我一样中年失业的人们，失业只是生活的中场休息，不用急着证明自己，管好钱、攒足底气、找对方向，撸起袖子加油干就行了！<br/><br/><br/>Tags - <a href="tag.php?tag=%E6%89%93%E5%8D%A1%E5%8D%A1" rel="tag">打卡卡</a> , <a href="tag.php?tag=dakaka" rel="tag">dakaka</a> , <a href="tag.php?tag=%E5%85%8D%E5%8D%95%E7%94%B5%E5%95%86" rel="tag">免单电商</a> , <a href="tag.php?tag=%E7%94%B5%E5%95%86%E5%B0%8F%E7%A8%8B%E5%BA%8F" rel="tag">电商小程序</a> , <a href="tag.php?tag=%E5%85%8D%E5%8D%95%E5%B0%8F%E7%A8%8B%E5%BA%8F" rel="tag">免单小程序</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?639</link>
<title><![CDATA[打卡卡免单电商平台测试有感]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[业界点评]]></category>
<pubDate>Thu, 06 Nov 2025 09:49:07 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?639</guid> 
<description>
<![CDATA[ 
	近期受邀参与一个极其有特色的电商平台“打卡卡免单电商平台”的测试，感触颇深。<br/><br/>首先一般人听到“免单”都觉得天下没有免费的午餐，这免单肯定有套路，是的，确实有套路，只是这套路合理合法，打卡卡的所有商品免单都是由商家让利，只是让利不像其他平台那样分散人人都有，而是集中给了一个买家，例如10元的商品，商家之前是让利1元给10个买家（相当于打9折），现在是将让利的10个1元集中起来给1个买家让利10元，这个买家就实现了免单，至于让利给哪个买家，就看谁能抽到打卡卡平台送出的免单红包奖励了，中奖者即可免单，当然如果这个买家很豪横，一口气买下了10件商品，那么免单必中，这就是打卡卡免单的套路。<br/><br/>有人又会问，这套路是否违法？其实这套路早就存在，只是打卡卡演变成了互联网化，之前很多人在冰棒批发的店铺，都见过买十送一的促销活动吧，商家甚至只要价位相同，并不要求一定买同款的冰棒，而买家必须一个人完成买十送一的活动，很多时候买家一次性买不了那么多根冰棒，比如你买了五支冰棒就离开了，那你就无法参加买十送一的活动了。而打卡卡将这个活动互联网化了，打卡卡将十个只买了一支冰棒的买家组团在一起，发出一个专属免单红包，由这十个买家抽取，谁抽中了，就可以将买货的钱一分不少的拿回来，从而实现了免单。这种套路既不是拉人头充值购物的传销，也不是消费换积分再换奖励的套路营销，比的只是谁运气好。<br/><br/><br/><br/>还有人质疑，打卡卡这种免单电商会不会崩盘，类似庞氏骗局，免单免到最后，平台关闭跑路了。其实用户完全不用有这种担心，打卡卡平台上的商品免单率是由商家自己控制的，是商家根据商品的利润率自行设定的，由2免1到20免1，例如A商品有20%的利润率，商家可以设定10免1，相当于让利了10%，商家还有10%的利润，所以商家是不会亏本的。打卡卡平台为商家带去流量和买家，买家得到了商家提供的真实的免单实惠，商家得到了除免单外其他订单的利润，此模式为三赢模式，完全不可能崩盘跑路的！<br/><br/><br/><br/>有人问打卡卡免单电商从来没听过，在手机应用市场里也搜不到，那怎么访问打卡卡平台的呢？这一点打卡卡的团队设想就很贴心周到了，打卡卡免单电商平台是微信小程序，无需下载安装，只要在微信里搜索打卡卡，就会看到一个名为“打卡卡Dakaka”的小程序，直接点击进入即可。这样用户就不用担心安装到乱七八糟的不知名的APP会盗取你手机里的资金或者信息。可以放心的大胆使用打卡卡平台，打卡卡的相关资质都通过了微信的审核，打卡卡的小程序才能得以上线的。<br/><br/><br/><br/>经我对打卡卡的测试，我个人感觉打卡卡将会成为电商界里的一匹黑马，目前打卡卡免单电商平台还在外测中，商家推出了很多2免1,3免1的商品，祝大家在打卡卡平台上好运连连，免单多多！<br/>Tags - <a href="tag.php?tag=%E6%89%93%E5%8D%A1%E5%8D%A1" rel="tag">打卡卡</a> , <a href="tag.php?tag=%E5%85%8D%E5%8D%95%E7%94%B5%E5%95%86" rel="tag">免单电商</a> , <a href="tag.php?tag=dakaka" rel="tag">dakaka</a> , <a href="tag.php?tag=%E5%B0%8F%E7%A8%8B%E5%BA%8F" rel="tag">小程序</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?638</link>
<title><![CDATA[Error Domain=IDEFoundationErrorDomain Code=1 Symbols tool failed UserInfo={NSLocalizedDescription=Symbols tool failed}错误的解决方法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[APIcloud]]></category>
<pubDate>Mon, 23 Sep 2019 07:54:03 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?638</guid> 
<description>
<![CDATA[ 
	之前一直打包正常的APP，今天要重新打包一个IOS正式版，一打包就报错，提示如下：<br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>error: exportArchive: Symbols tool failed<br/>Error Domain=IDEFoundationErrorDomain Code=1 "Symbols tool failed" UserInfo={NSLocalizedDescription=Symbols tool failed}<br/></div></div><br/><br/>经百度查询，说是WWDR中间证书过期了，不过就我的印象中，好像从来就没使用过这个证书，百度里也说的不清不楚，什么到哪里下载然后安装，到链文件去找过期，可是我是windows系统，下载了AppleWWDRCA.cer，也安装了，装到哪里去也不知道，重新编译，报错依旧。<br/><br/>只能先放弃这个思路，先看看IOS的发布证书和描述文件是否过期，查看了证书没有过期啊，先不管那么多了，死马当活马医，生成新的IOS证书提交编译，报错信息变了，说描述文件关联证书不匹配，心中窃喜，以为就要成功了，马上生成了新的描述文件，提交编译。<br/><br/>结果错误信息依旧如上，看来根本就不是证书和描述文件的问题，仔细看了错误提示，是在不知道如何产生的。<br/><br/>把模块检查一遍，发现之前百度模块没有使用最新版的，重新最新版之后重新编译，一切正常！<br/><br/>在这里给大家提个醒，编译不通过，不一定全是我们自己证书的问题，还有可能调用第三方SDK的模块产生的错误，最好全部使用最新版的，当然之前也发送过最新版模块有bug的问题，记住不使用第三方SDK的就可以不使用最新版模块，如果使用第三方SDK模块的，建议全部使用最新版模块进行编译打包！<br/>Tags - <a href="tag.php?tag=apicloud" rel="tag">apicloud</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?637</link>
<title><![CDATA[413 Request Entity Too Large报错]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[centos]]></category>
<pubDate>Tue, 04 Jun 2019 02:42:20 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?637</guid> 
<description>
<![CDATA[ 
	今天调试中，发现上传图片一会成功，一会不成功，最后服务器反馈的错误是413 Request Entity Too Large。我记得我已经把php.ini中上传文件的配置开到了80M了，为啥还有会报错呢，经查原来是nignx的限制了。<br/><br/>修改 Nginx 的配置文件<br/><br/>server { &nbsp;<br/> &nbsp; &nbsp;... &nbsp;<br/> &nbsp; &nbsp;client_max_body_size 20m; &nbsp;<br/> &nbsp; &nbsp;... &nbsp;<br/>}<br/>重启 Nginx 服务和 php-fpm 服务即可。
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?636</link>
<title><![CDATA[CentOS7下解决SSH自动断开办法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[centos]]></category>
<pubDate>Wed, 19 Sep 2018 04:00:40 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?636</guid> 
<description>
<![CDATA[ 
	vim /etc/ssh/sshd_config<br/>找到下面两行<br/><br/>ClientAliveInterval 0<br/>ClientAliveCountMax 3<br/>去掉注释，改成<br/><br/>ClientAliveInterval 30 <br/>ClientAliveCountMax 86400<br/><br/>这两行的意思分别是<br/><br/>1、客户端每隔多少秒向服务发送一个心跳数据<br/><br/>2、客户端多少秒没有相应，服务器自动断掉连接<br/><br/>重启sshd服务<br/><br/>service sshd restart<br/>Tags - <a href="tag.php?tag=centos" rel="tag">centos</a> , <a href="tag.php?tag=ssh" rel="tag">ssh</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?635</link>
<title><![CDATA[Centos 7 SSH连接超时自动断开的解决方案]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[centos]]></category>
<pubDate>Thu, 13 Sep 2018 08:45:49 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?635</guid> 
<description>
<![CDATA[ 
	最近在Centos 7 上安装软件，一会不看就自动断开，很是讨厌，故调整下面的设置，让其长时间保持连线。<br/>1.编辑sshd配置文件<br/><br/> &nbsp; &nbsp;<div class="code"># vi /etc/ssh/sshd_config <br/>找到 #ClientAliveInterval 0 #ClientAliveCountMax 3 <br/>修改为 ClientAliveInterval 60 ClientAliveCountMax 3</div><br/><br/>2.重启sshd服务<br/><br/> &nbsp; &nbsp;<div class="code"># systemctl restart sshd</div><br/><br/>这样连接centos7长时间不操作也不会连接超时中断了。<br/>Tags - <a href="tag.php?tag=centos7" rel="tag">centos7</a> , <a href="tag.php?tag=ssh" rel="tag">ssh</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?634</link>
<title><![CDATA[centos查找大文件]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[centos]]></category>
<pubDate>Thu, 30 Aug 2018 08:26:04 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?634</guid> 
<description>
<![CDATA[ 
	查找大于200M的文件<br/><div class="code">find / -type f -size +200M</div><br/><br/>查看当前目录占磁盘空间<br/><div class="code">du -h --max-depth=1</div><br/><br/>目录按照占用空间大小排序<br/><div class="code">du -h --max-depth=2 &#124; sort -n</div><br/>Tags - <a href="tag.php?tag=%E6%9F%A5%E6%89%BE%E5%A4%A7%E6%96%87%E4%BB%B6" rel="tag">查找大文件</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?633</link>
<title><![CDATA[centos6.5 用yum安装Nginx+PHP7.1+MySQL]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[centos]]></category>
<pubDate>Mon, 03 Apr 2017 11:07:31 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?633</guid> 
<description>
<![CDATA[ 
	准备篇：<br/><br/>1、开启端口（以80端口为例）<br/> /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT &nbsp; 写入修改<br/> /etc/init.d/iptables save &nbsp; 保存修改<br/> service iptables restart &nbsp; &nbsp;重启防火墙，修改生效<br/><br/>2、关闭SELINUX<br/>vi /etc/selinux/config<br/>#SELINUX=enforcing &nbsp; &nbsp; &nbsp; #注释掉<br/>#SELINUXTYPE=targeted &nbsp; &nbsp;#注释掉<br/>SELINUX=disabled &nbsp; &nbsp; &nbsp; &nbsp; #增加<br/><br/>:wq &nbsp;保存，关闭<br/>shutdown -r now &nbsp; #重启系统<br/><br/>3、配置CentOS 6.2第三方yum源（CentOS默认的标准源里没有nginx软件包）<br/>yum install wget &nbsp; &nbsp;#安装下载工具wget<br/>wget http://www.atomicorp.com/installers/atomic &nbsp;#下载atomic yum源<br/>sh ./atomic &nbsp; #安装<br/>yum check-update &nbsp;#更新yum软件包<br/>##########################################################################<br/><br/>安装篇<br/><br/>1、安装开发包和库文件<br/># yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel<br/><br/>一、安装nginx<br/>yum install nginx &nbsp; &nbsp; &nbsp;#安装nginx，根据提示，输入Y安装即可成功安装<br/>service nginx start &nbsp; &nbsp;#启动<br/>chkconfig nginx on &nbsp; &nbsp;#设为开机启动<br/>/etc/init.d/nginx &nbsp;restart &nbsp;#重启<br/>rm -rf /usr/share/nginx/html/* &nbsp;#删除ngin默认测试页<br/><br/>二、安装MySQL<br/>1、安装mysql<br/><br/> yum install mysql mysql-server &nbsp; #询问是否要安装，输入Y即可自动安装,直到安装完成<br/>/etc/init.d/mysqld start &nbsp; #启动MySQL<br/>chkconfig mysqld on &nbsp; #设为开机启动<br/>cp /usr/share/mysql/my-medium.cnf &nbsp; /etc/my.cnf &nbsp;#拷贝配置文件（注意：如果/etc目录下面默认有一个my.cnf，直接覆盖即可）<br/>shutdown -r now &nbsp;#重启系统<br/><br/>2、为root账户设置密码<br/>mysql_secure_installation<br/><br/>回车，根据提示输入Y<br/><br/>输入2次密码，回车<br/><br/>根据提示一路输入Y<br/><br/>最后出现：Thanks for using MySQL!<br/><br/>MySql密码设置完成，重新启动 MySQL：<br/>/etc/init.d/mysqld stop &nbsp; #停止<br/>/etc/init.d/mysqld start &nbsp;#启动<br/>service mysqld restart &nbsp; &nbsp;#重启<br/><br/>2、安装PHP<br/>#yum install php71w lighttpd-fastcgi php71w-cli php71w-MySQL php71w-gd php71w-imap php71w-ldap php71w-odbc php71w-pear php71w-xml php71w-xmlrpc php71w-mbstring php71w-mcrypt php71w-mssql php71w-snmp php71w-soap php71w-openssl openssl<br/><br/>3、安装php和所需组件使PHP支持MySQL、FastCGI模式<br/># yum install php71w-tidy php71w-common php71w-devel php71w-fpm php71w-mysql<br/># service php-fpm start<br/># chkconfig --levels 235 php-fpm on<br/><br/>/etc/init.d/mysqld restart &nbsp;#重启MySql<br/>/etc/init.d/nginx &nbsp;restart &nbsp;#重启nginx<br/>/etc/rc.d/init.d/php-fpm start &nbsp;#启动php-fpm<br/>chkconfig php-fpm on &nbsp;#设置开机启动<br/><br/>配置篇<br/><br/>一、配置nginx支持php<br/>cp /etc/nginx/nginx.conf &nbsp;/etc/nginx/nginx.confbak &nbsp; &nbsp;#备份原有配置文件<br/>vi /etc/nginx/nginx.conf &nbsp;#编辑<br/>user &nbsp;nginx &nbsp;nginx; &nbsp;#修改nginx运行账号为：nginx组的nginx用户<br/><br/>:wq! &nbsp; &nbsp;#保存退出<br/><br/>cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak &nbsp; #备份原有配置文件<br/>vi /etc/nginx/conf.d/default.conf &nbsp; #编辑<br/><br/>index index.php index.html index.htm; &nbsp; #增加index.php<br/><br/> # pass the PHPscripts to FastCGI server listening on 127.0.0.1:9000<br/> #<br/> location ~ &#92;.php$ {<br/> &nbsp; root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;html;<br/> &nbsp; fastcgi_pass &nbsp; 127.0.0.1:9000;<br/> &nbsp; fastcgi_index &nbsp;index.php;<br/> &nbsp; fastcgi_param &nbsp;SCRIPT_FILENAME &nbsp;$document_root$fastcgi_script_name;<br/> &nbsp; include &nbsp; &nbsp; &nbsp; fastcgi_params;<br/> }<br/>#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径<br/><br/>二、配置php<br/><br/>vi /etc/php.ini &nbsp; #编辑<br/><br/>date.timezone= PRC &nbsp; &nbsp; #在946行 把前面的分号去掉，改为date.timezone = PRC<br/><br/>disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec<br/><br/>,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink<br/><br/>,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen<br/><br/>,disk_free_space,checkdnsrr,getservbyname,getservbyport,disk_total_space<br/><br/>,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid<br/><br/>,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp<br/><br/>,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid<br/><br/>,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid<br/><br/>,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname<br/>#在386行 列出PHP可以禁用的函数，如果某些程序需要用到这个函数，可以删除，取消禁用。<br/>expose_php = Off &nbsp; &nbsp; &nbsp; &nbsp;#在432行 禁止显示php版本的信息<br/>magic_quotes_gpc = On &nbsp; #在745行 打开magic_quotes_gpc来防止SQL注入<br/>open_basedir = .:/tmp/ &nbsp;#在380行，设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站，如果改了之后安装程序有问题，可注销此行，或者直接写上程序目录路径/var/www/html/www.osyunwei.com/:/tmp/<br/><br/>:wq! #保存退出<br/><br/>(转载者语:magic_quotes_gpc我的配置中是不存在的,open_basedir没有看懂也就跳过了,这两条并没有影响我配置成功,隐患...暂时还没找到或者还没理解)<br/><br/>三、配置php-fpm<br/>cp /etc/php-fpm.d/www.conf &nbsp; /etc/php-fpm.d/www.confbak &nbsp; #备份原有配置文件<br/>vi /etc/php-fpm.d/www.conf &nbsp; #编辑<br/>user = nginx &nbsp; #修改用户为nginx<br/>group = nginx &nbsp; #修改组为nginx<br/><br/>/etc/init.d/mysqld restart &nbsp;#重启MySql<br/>/etc/init.d/nginx &nbsp;restart &nbsp;#重启nginx<br/>/etc/rc.d/init.d/php-fpm &nbsp;restart &nbsp;#重启php-fpm<br/>#############################################################################<br/>测试篇<br/>cd /usr/share/nginx/html/ &nbsp; #进入nginx默认网站根目录<br/>vi &nbsp;index.php &nbsp; #新建index.php文件<br/><br/><?php<br/> &nbsp; &nbsp; phpinfo();<br/><br/>?><br/><br/>:wq! #保存<br/><br/>chown nginx.nginx /usr/share/nginx/html/ -R &nbsp;#设置目录所有者<br/><br/>chmod 700 &nbsp;/usr/share/nginx/html/ -R &nbsp; #设置目录权限<br/><br/>在客户端浏览器输入服务器IP地址，可以看到相关的配置信息！<br/>##########################################################################<br/><br/>备注<br/><br/>nginx默认站点目录是：/usr/share/nginx/html/<br/>Mysql配置文件my.cnf路径：/etc/my.cnf <br/>Nginx配置文件nginx.conf路径：/etc/nginx/nginx.conf <br/>PHP配置文件php.ini路径： /etc/php.ini <br/>php-fpm配置文件php-fpm.conf路径：/etc/php-fpm.conf<br/>Tags - <a href="tag.php?tag=centos" rel="tag">centos</a> , <a href="tag.php?tag=php7.1" rel="tag">php7.1</a> , <a href="tag.php?tag=nginx" rel="tag">nginx</a> , <a href="tag.php?tag=mysql" rel="tag">mysql</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?632</link>
<title><![CDATA[centos FreeBSD 查看CPU核数使用率 系统 位 内存大小 硬盘 HBA光纤卡号 常用命令]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Fri, 08 Apr 2016 04:08:11 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?632</guid> 
<description>
<![CDATA[ 
	一：使用CentOS常用命令查看cpu<br/><br/>more /proc/cpuinfo &#124; grep "model name" &nbsp; <br/>grep "model name" /proc/cpuinfo &nbsp; <br/>[root@localhost /]# grep "CPU" /proc/cpuinfo &nbsp; <br/>model name &nbsp; &nbsp; &nbsp;: Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz &nbsp; <br/>model name &nbsp; &nbsp; &nbsp;: Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz &nbsp; <br/>如果觉得需要看的更加舒服<br/>grep "model name" /proc/cpuinfo &#124; cut -f2 -d:<br/><br/> <br/><br/> <br/><br/>查看linux系统是多少位<br/><br/> &nbsp; &nbsp;使用命令如下：<br/><br/> &nbsp; &nbsp;uname -a<br/>如果结果类似于这样：<br/>[root@localhost ~]# uname -a<br/>Linux localhost.localdomain 2.6.18-92.el5xen #1 SMP Tue Apr 29 13:45:57 EDT 2008 i686 i686 i386 GNU/Linux<br/>表明是32位<br/>如果显示结果是x86_64，表明是64位<br/><br/> <br/><br/> <br/><br/>二：使用CentOS常用命令查看内存<br/><br/>grep MemTotal /proc/meminfo &nbsp;grep MemTotal /proc/meminfo &#124; cut -f2 -d: &nbsp;free -m &#124;grep "Mem" &#124; awk '{print $2}'<br/><br/>三：使用CentOS常用命令查看cpu是32位还是64位<br/><br/>查看CPU位数(32 or 64)<br/>getconf LONG_BIT<br/><br/>四：使用CentOS常用命令查看当前linux的版本<br/><br/>more /etc/redhat-release<br/>cat /etc/redhat-release<br/><br/>五：使用CentOS常用命令查看内核版本<br/><br/>uname -r<br/>uname -a<br/><br/>六：使用CentOS常用命令查看当前时间<br/><br/>date上面已经介绍如何同步时间了<br/><br/>七：使用CentOS常用命令查看硬盘和分区<br/><br/>df -h<br/>fdisk -l<br/>也可以查看分区<br/>du -sh<br/>可以看到全部占用的空间<br/>du /etc -sh<br/>可以看到这个目录的大小<br/><br/>八：使用CentOS常用命令查看安装的软件包<br/><br/>查看系统安装的时候装的软件包<br/>cat -n /root/install.log<br/>more /root/install.log &#124; wc -l<br/>查看现在已经安装了那些软件包<br/>rpm -qa<br/>rpm -qa &#124; wc -l<br/>yum list installed &#124; wc -l<br/>不过很奇怪，我通过rpm，和yum这两种方式查询的安装软件包，数量并不一样。没有找到原因。<br/><br/>九：使用CentOS常用命令查看键盘布局<br/><br/>cat /etc/sysconfig/keyboard<br/>cat /etc/sysconfig/keyboard &#124; grep KEYTABLE &#124; cut -f2 -d=<br/><br/>十：使用CentOS常用命令查看selinux情况<br/><br/>sestatus<br/>sestatus &#124; cut -f2 -d:<br/>cat /etc/sysconfig/selinux<br/><br/>十一：使用CentOS常用命令查看ip，mac地址<br/><br/>在ifcfg-eth0 文件里你可以看到mac，网关等信息。 &nbsp;ifconfig &nbsp;cat /etc/sysconfig/network-scripts/ifcfg-eth0 &#124; grep IPADDR &nbsp;cat /etc/sysconfig/network-scripts/ifcfg-eth0 &#124; grep IPADDR &#124; cut -f2 -d= &nbsp;ifconfig eth0 &#124;grep "inet addr:" &#124;awk '{print $2}'&#124;cut -c 6- &nbsp;ifconfig &nbsp; &#124; grep 'inet addr:'&#124; grep -v '127.0.0.1' &#124; cut -d: -f2 &#124; awk '{ print $1}' &nbsp;查看网关 &nbsp;cat /etc/sysconfig/network &nbsp;查看dns &nbsp;cat /etc/resolv.conf &nbsp;十二：使用CentOS常用命令查看默认语言<br/>echo $LANG $LANGUAGE<br/>cat /etc/sysconfig/i18n<br/><br/>十二：使用CentOS常用命令查看所属时区和是否使用UTC时间<br/><br/>cat /etc/sysconfig/clock<br/><br/>十三：使用CentOS常用命令查看主机名<br/><br/>hostname<br/>cat /etc/sysconfig/network<br/>修改主机名就是修改这个文件，同时最好也把host文件也修改。<br/><br/>十四：使用CentOS常用命令查看开机运行时间<br/><br/>uptime<br/>09:44:45 up 67 days, 23:32, ...<br/>看来刚才确实是网段的问题，我的机器还是67天前开机的。<br/>#系统资源使用情况<br/><br/>2. 注销系统 请在 # 号后，输入 logout 或 exit 表示离开。 当你完成注销，系统会显示出 login 的画面。<br/><br/>1、freebsd下如何查看程序所占用的端口？<br/><br/>#sockstat<br/><br/>#netstat -na<br/><br/> <br/><br/>2 、route相关命令<br/><br/>查询 routing table<br/>#netstat -rn<br/><br/> <br/><br/>查询网络接口流量统计<br/>#netstat -I<br/><br/> <br/><br/>查询 TCP网络联机情形<br/>#netstat -t<br/><br/> <br/><br/>查询所有网络联机情形<br/>#netstat -a<br/><br/> <br/><br/>netstat 查看端口状态，如：<br/>#netstat -an &#124; grep tcp &nbsp; 查看开放的tcp端口<br/><br/> <br/><br/>3、如何查看系统所有进程/用户进程<br/><br/>#ps -A<br/><br/>#ps auxww （查看系统所有进程）<br/><br/>#ps或ps -ef 查看用户进程<br/><br/> <br/><br/>4、FreeBSD下怎么查看内存大小<br/><br/>#top （可以查看，但不直观）<br/><br/>#dmesg -a &#124; grep memory （这个很直内存大小)<br/><br/> <br/><br/>5、查看网络流量<br/><br/>#systat -if 1 (1表示1s刷新屏幕一次)<br/><br/>#netstat 1<br/><br/>#Traffic 表示当前流量 &nbsp;#peak表示流量峰值<br/><br/> <br/><br/>6、查看硬盘信息<br/><br/>#diskinfo -vt /dev/ad0 (整个硬盘信息)<br/><br/>#disklabel /dev/ad0 &nbsp;(分区信息）<br/><br/>#disklabel /dev/ad0s1 <br/><br/> <br/><br/>7、查看硬盘详细分区及读写状况<br/><br/> &nbsp;#gstat<br/><br/> <br/><br/>8、freebsd如何挂载光驱<br/><br/>1)普通挂载<br/><br/>#mount -t cd9660 &nbsp;/dev/acd0 /mnt<br/><br/>或 #mount_cd9660 -e /dev/cd0 /cdrom<br/><br/>2)挂载显示中文<br/><br/>#mount_cd9660 -C GB2312 &nbsp;-e &nbsp;/dev/cd0 &nbsp;/cdrom <br/><br/> <br/><br/>9、freebsd如何挂载USB、移动硬盘<br/><br/>1）普通挂载<br/><br/>#mount -t msdosfs /dev/da0s1 /data <br/><br/>或#mount_msdosfs /dev/da0s1 /data &nbsp;(注:挂载usb移动硬盘至/data目录) <br/><br/> <br/><br/>2）如何显示中文<br/><br/> #mount_msdos -L zh_CN.GB2312 -D cp936 /dev/ad0s1 /data<br/><br/> <br/><br/>3)访问NTFS<br/><br/>mount_ntfs -C eucCN /dev/ad0s5 /media/winD<br/><br/> <br/><br/> <br/><br/>10、Freebsd 下如何查看CPU个数<br/><br/>方法1：dmesg&#124;grep cpu<br/><br/>方法2:sysctl -a&#124;grep cpu<br/><br/> <br/><br/>11、Freebsd下如果CPU是多核，如何查看各颗CPU的运行状态:<br/><br/>方法1：top命令(在输出中，有一列的名字叫C,在STATE列后面，如下图:)<br/><br/>PID USERNAME &nbsp; &nbsp; THR PRI NICE &nbsp; SIZE &nbsp; &nbsp;RES STATE &nbsp;C &nbsp; TIME &nbsp; WCPU COMMAND<br/>35871 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;48 &nbsp; &nbsp;0 &nbsp;4520K &nbsp;2864K CPU1 &nbsp; 1 &nbsp; 0:00 &nbsp;0.49% top<br/>35867 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;20 &nbsp; &nbsp;0 &nbsp;4504K &nbsp;2312K pause &nbsp;2 &nbsp; 0:00 &nbsp;0.10% csh<br/> 1186 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;5768K &nbsp;4312K select 3 &nbsp; 0:57 &nbsp;0.00% httpd<br/>29884 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;9320K &nbsp;5232K select 1 &nbsp; 0:47 &nbsp;0.00% snmpd<br/>12482 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;8428K &nbsp;2792K select 3 &nbsp; 0:05 &nbsp;0.00% sshd<br/> &nbsp;768 root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;5876K &nbsp;2456K select 0 &nbsp; 0:01 &nbsp;0.00% sendmail<br/>34691 www &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp;44 &nbsp; &nbsp;0 &nbsp;5768K &nbsp;4372K select 2 &nbsp; 0:01 &nbsp;0.00% httpd<br/>34748 www &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp; 4 &nbsp; &nbsp;0 &nbsp;5768K &nbsp;4376K accept 0 &nbsp; 0:01 &nbsp;0.00% httpd<br/><br/>从上面的结果，可以知道，这是一颗四核的CPU<br/><br/> <br/><br/>AIX:<br/> &nbsp; &nbsp;1,获得AIX主机连接的光纤设备:<br/> &nbsp; &nbsp; &nbsp; # lsdev -Cc adapter -S a &#124; grep fcs<br/> &nbsp; &nbsp; &nbsp; &nbsp;fcs0 &nbsp; &nbsp; &nbsp;Available 09-08 FC Adapter<br/> &nbsp; &nbsp; &nbsp; &nbsp;fcs1 &nbsp; &nbsp; &nbsp;Available 09-09 FC Adapter<br/> &nbsp; &nbsp;其中,显示有两块光纤卡.fcs0和fcs1<br/> &nbsp; &nbsp;2,查看光纤卡的WWN号<br/> &nbsp; &nbsp; &nbsp; # lscfg -vpl fcs0<br/> &nbsp;fcs0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; U787B.001.DNWG664-P1-C1-T1 &nbsp;FC Adapter<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;Part Number.................10N8620<br/> &nbsp; &nbsp; &nbsp; &nbsp;Serial Number...............1B74404468<br/> &nbsp; &nbsp; &nbsp; &nbsp;Manufacturer................001B<br/> &nbsp; &nbsp; &nbsp; &nbsp;EC Level....................A<br/> &nbsp; &nbsp; &nbsp; &nbsp;Customer Card ID Number.....5759<br/> &nbsp; &nbsp; &nbsp; &nbsp;FRU Number.................. 10N8620<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZM)........3<br/> &nbsp; &nbsp; &nbsp; &nbsp;Network Address.............10000000C96E2898<br/> &nbsp; &nbsp; &nbsp; &nbsp;ROS Level and ID............02C82138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z0)........1036406D<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z1)........00000000<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z2)........00000000<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z3)........03000909<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z4)........FFC01159<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z5)........02C82138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z6)........06C12138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z7)........07C12138<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z8)........20000000C96E2898<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(Z9)........BS2.10X8<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZA)........B1F2.10X8<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZB)........B2F2.10X8<br/> &nbsp; &nbsp; &nbsp; &nbsp;Device Specific.(ZC)........00000000<br/> &nbsp; &nbsp; &nbsp; &nbsp;Hardware Location Code......U787B.001.DNWG664-P1-C1-T1<br/> &nbsp; &nbsp;其中标红的部分就是光纤卡的WWN号<br/> &nbsp; &nbsp;<br/><br/>HP-Unix:<br/> &nbsp; &nbsp;1,列出HP机上连接的光纤卡设备:<br/> &nbsp; &nbsp; &nbsp; &nbsp;# ioscan -fnC fc<br/>Class &nbsp; &nbsp; I &nbsp;H/W Path &nbsp;Driver S/W State &nbsp; H/W Type &nbsp; &nbsp; Description<br/>=================================================================<br/>fc &nbsp; &nbsp; &nbsp; &nbsp;0 &nbsp;0/3/1/0 &nbsp; fcd &nbsp;CLAIMED &nbsp; &nbsp; INTERFACE &nbsp; &nbsp;HP A6826-60001 2Gb Dual Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/dev/fcd0<br/>fc &nbsp; &nbsp; &nbsp; &nbsp;1 &nbsp;0/3/1/1 &nbsp; fcd &nbsp;CLAIMED &nbsp; &nbsp; INTERFACE &nbsp; &nbsp;HP A6826-60001 2Gb Dual Port PCI/PCI-X Fibre Channel Adapter (FC Port 2)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/dev/fcd1<br/> &nbsp; &nbsp;由此图可以看到,/dev/fcd0和/dev/fcd1是两个光纤卡<br/> &nbsp; &nbsp;2, 查看光纤卡的WWN号<br/> &nbsp; &nbsp; &nbsp; # fcmsutil /dev/fcd0<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vendor ID is = 0x001077<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Device ID is = 0x002312<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PCI Sub-system Vendor ID is = 0x00103c<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PCI Sub-system ID is = 0x0012ba<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PCI Mode = PCI-X 133 MHz<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ISP Code version = 3.3.18<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ISP Chip version = 3<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Topology = PTTOPT_FABRIC<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Link Speed = 2Gb<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Local N_Port_id is = 0xa10500<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Previous N_Port_id is = None<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;N_Port Node World Wide Name = 0x50060b00001db241<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;N_Port Port World Wide Name = 0x50060b00001db240<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Switch Port World Wide Name = 0x205e000dec0e2e00<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Switch Node World Wide Name = 0x2001000dec0e2e01<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Driver state = ONLINE<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hardware Path is = 0/3/1/0<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Maximum Frame Size = 2048<br/> &nbsp; &nbsp; &nbsp; &nbsp; Driver-Firmware Dump Available = NO<br/> &nbsp; &nbsp; &nbsp; &nbsp; Driver-Firmware Dump Timestamp = N/A<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Driver Version = @(#) libfcd.a HP Fibre Channel ISP 23xx & 24xx Driver B.11.23.04 /ux/core/isu/FCD/kern/src/common/wsio/fcd_init.c:Oct 18 2005,08:21:11<br/> &nbsp; &nbsp;其中红色部分显示了HBA卡的WWNN和WWPN号,另外还能看到该HBA卡连接的光纤交换机端口的WWN号<br/><br/><br/>Solaris:<br/> &nbsp; &nbsp;solaris上用luxadm命令来管理存储设备以及光纤相关设备.<br/> &nbsp; &nbsp;1, 查询现有存储设备和光纤设备,可以读到包括磁盘设备的WWN号<br/> &nbsp; &nbsp; &nbsp; &nbsp;# luxadm probe<br/> &nbsp; &nbsp;2, 查看HBA的prot,可以得到HBA卡的port值以及连接属性:<br/> &nbsp; &nbsp; &nbsp; # luxadm -e port<br/> &nbsp; &nbsp; &nbsp; &nbsp;/devices/pci@0,0/pci1022,7450@2/pci1077,101@1/fp@0,0:devctl &nbsp; &nbsp; &nbsp; &nbsp;NOT CONNECTED<br/> &nbsp; &nbsp; &nbsp; &nbsp;/devices/pci@0,0/pci1022,7450@2/pci1077,101@1,1/fp@0,0:devctl &nbsp; &nbsp; &nbsp;CONNECTED<br/> &nbsp; &nbsp;从中可以看到仅有一块光纤卡连接到存储设备<br/> &nbsp; &nbsp;3, 选择那个已经连接的HBA卡,查看其WWN号<br/> &nbsp; &nbsp; &nbsp; 格式: # luxadm -e dump_map 设备port.其中port值可从步骤2得到.如下图啊所示:<br/> &nbsp; &nbsp; &nbsp; # luxadm -e dump_map /devices/pci@0,0/pci1022,7450@2/pci1077,101@1/fp@0,0:devctl<br/>Pos &nbsp;Port_ID Hard_Addr Port WWN &nbsp; &nbsp; &nbsp; &nbsp; Node WWN &nbsp; &nbsp; &nbsp; &nbsp; Type<br/>0 &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; &nbsp; &nbsp;210000e08b19827a 200000e08b19827a 0x1f (Unknown Type,Host Bus Adapter)<br/><br/><br/>Redhat:<br/> &nbsp; &nbsp;在Redhat中,设备管理的相关信息都保存在内核中,即/proc目录.所以我们一般查询CPU,内存,磁盘等信息,也是在该目录下. 其中HBA卡相关信息保存在/proc/scsi/qla2300/目录下,不同设备对应不同的文件名,例如<br/> &nbsp; &nbsp;# grep scsi /proc/scsi/qla2300/1<br/> &nbsp; &nbsp;Number of reqs in pending_q= 0, retry_q= 0, done_q= 0, scsi_retry_q= 0<br/> &nbsp; &nbsp;scsi-qla0-adapter-node=200000e08b9cf661;<br/> &nbsp; &nbsp;scsi-qla0-adapter-port=210000e08b9cf661;<br/> &nbsp; &nbsp;就可以查到系统第一块HBA卡的WWNN和WWPN号.<br/>Tags - <a href="tag.php?tag=cpu" rel="tag">cpu</a> , <a href="tag.php?tag=%E5%86%85%E5%AD%98" rel="tag">内存</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?631</link>
<title><![CDATA[FreeBSD常用的110条命令]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Sat, 31 Jan 2015 02:30:01 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?631</guid> 
<description>
<![CDATA[ 
	01.查看网络流量<br/> a.systat -if 1 （1表示1s刷新屏幕一次）<br/> b.netstat 1<br/> # Traffic 流量 peak 峰值 average 平均值<br/> 02.查看硬盘信息<br/> diskinfo -vt /dev/ad0<br/> disklable /dev/ad0 (分区信息)<br/> disklable /dev/ad0s2<br/> 03.查看核心信息<br/> vmstat 1<br/> 04.查看进程<br/> top ps auxww &nbsp; ps -ef &#124;grep xxx<br/> 05.查看硬盘详细分区信息＆读写状况<br/> gstat<br/> 06.sysctl sysctl -a 查看所有变量（/etc/sysctl.conf）<br/> sysctl kern.maxproc 查看特定变量<br/> sysctl kern.maxfiles=5000 设置变量<br/> 07.查看磁盘空间使用情形 df 和 du<br/> 指令df用来查看整个档案系统的使用情形，<br/> 如果您需要知道某个目录的使用情形用指令du。<br/> df -h<br/> du -h /etc<br/> du -sh /etc<br/> -s 参数来省略指定目录下的子目录<br/> -h 表示使用GB、MB等易读的格式<br/> 08.断电后系统无法启动<br/> a.启动到sing user模式<br/> b.fsck<br/> c.reboot<br/> 09.升级内核后无法启动<br/> a.重启机器到10秒读秒时按enter以外的任意键(新版bsd按6)<br/> b.unload<br/> c.boot kernel.old 或其他可以启动的内核<br/> 另外一种方法<br/> a.使用cd1启动，选择Fixit-->CDROM/DVD<br/> b.Fixit#mount /dev/ad0s2a /mnt mount硬盘上的文件系统<br/> c.cd /mnt/boot<br/> d.rm -rf kernel<br/> e.cp -R kernel.old kernel<br/> f.reboot<br/> 修改了/boot/loader.conf以后不能正常引导系统了，当机器开始加载<br/> /boot/defaults/loader.conf的时候(未加载完)机器停止响应，我应该怎么办？<br/> a.使用cd1启动，选择Fixit-->CDROM/DVD<br/> b.Fixit#mount /dev/ad0s2a /mnt mount硬盘上的文件系统<br/> c.cd /mnt/boot<br/> d.vi loader.conf 去掉错误的加载项<br/> e.reboot<br/> 10.丢失root密码<br/> 启动到单用户模式,执行/sbin/mount -a, 然后用passwd更改密码<br/> /sbin/mount -a=挂接/etc/fstab里所有列出的文件系统<br/> 如果单用户登录也需要密码<br/> a.使用cd1启动，选择Fixit-->CDROM/DVD<br/> b.Fixit#mount /dev/ad0s2a /mnt mount硬盘上的文件系统<br/> c.cd /mnt/etc<br/> d.vi /ttys 找到when going to single-user mode,更改<br/> console none unknow off insecure为secure<br/> e.reboot,启动到单用户模式/sbin/mount -a,passwd<br/> 启动到单用户模式后，ctrl+d进入多用户模式<br/> ####让单用户登录也需要密码<br/> a.cd /etc<br/> b.vi /ttys 找到when going to single-user mode,更改<br/> console none unknow off secure为insecure<br/> 11.用win2000的引导器启动FreeBSD<br/> 我在笔记本上装了双系统，win2000 和freebsd，装完 freebsd后 系统自动设置如下：<br/> f1 dos<br/> f2 freebsd<br/> 先起动到dos下，fdisk /mbr，再把FreeBSD光盘上的boot&#92;boot1复制到c:&#92;,<br/> 再编辑c:&#92;boot.ini 加一行c:&#92;boot1="FreeBsd"<br/> 12.硬盘分区时shift+F -->NO可以使用全部空间<br/> 13.ctrl+alt+backspace 杀掉xwindows<br/> 14.alt+F1...F8 或 printscreensysr循环切换控制台<br/> 15.shutdown now 切换到单用户模式<br/> shutdown -p now shutdown -hp now 关闭电源<br/> shutdown -r now reboot 重新启动机器<br/> shutdown -p +90 (90分钟后关机)<br/> shutdown 0203122359(0203122359表示2002年3月12日23:59，格式是yymmddhhmm)<br/> 16.挂载ntfs,fat32分区和u盘<br/> ntfs: mount_ntfs -C eucCN /dev/ad0s5 /mnt/d<br/> fat32:mount_msdos -L zh_CN.eucCN /dev/ad0s6 /mnt/e<br/> u盘(scsi盘): &nbsp; mount_msdos -L zh_CN.eucCN /dev/da0s1 /mnt/u<br/> cdrom: #mount_cd9660 /dev/acd0 /mnt/cdrom<br/> NTFS在FreeBSD中只能只读而无法写入<br/> 17.卸载分区<br/> umount /dev/ad0s5<br/> umount -f /dev/ad0s5 (强制卸载)<br/> 18.在/etc/fstab中挂载fat32分区<br/> /dev/ad0s5 &nbsp; /mnt/d &nbsp; msdos &nbsp; rw,-L=zh_CN.eucCN 2 2<br/> 19.如何在FreeBSD5.X以上加载,卸载ISO文件<br/> mount iso文件：<br/> mdconfig -a -t vnode -f myisofile.iso (屏幕输出md0或者类似的设备名)<br/> mount -t cd9660 /dev/md0 /cdrom<br/> umount：<br/> umount /cdrom<br/> mdconfig -d -u 0 (上面的-u后面的数字和前面的md?中的数字一致)<br/> mdconfig -l 命令可以列出关于配置 md(4) 设备的信息<br/> 20.声卡<br/> vi /boot/defaults/loader.conf<br/> 更改snd_ich_load="NO"->"YES" #intel ich<br/> 检测声卡 kldstat 或 dmesg &#124;grep pcm<br/> 21.ls 命令详解<br/> ls 显示本目录下的文件及目录<br/> ls -a显示本目录下的所有文件及目录（包括隐藏目录和文件）<br/> ls -l 显示本目录下所有文件的属性<br/> ls -l &#124; grep ^d 只显示目录<br/> ls -l &#124; grep ^- 只显示文件<br/> ls -l &#124; grep ^d &#124; wc –l &nbsp; 统计当能目录下的子目录数<br/> ls -l &#124; grep ^- &#124; wc –l &nbsp; 统计当能目录下的文件数<br/> ls -G &nbsp; 以颜色显示目录名和文件名<br/> 22.查找程序或文件<br/> which 程序名<br/> whereis 程序名<br/> find 文件名<br/> locate 文件名<br/> locate: database too small: /var/db/locate.database的一种解决方法<br/> a.这个仅仅是因为你开机时间不够长，看看/etc/periodic/weekly/310.locate<br/> b.试试运行/usr/libexec/locate.updatedb看<br/> whatis xxx 要找东西但不知道它是什么<br/> grep bpf /usr/src/sys/i386/conf/GENERIC 在文件中找指定文本<br/> #只能对文本进行grep,如是命令,则<br/> command &#124;grep text<br/> grep text filename<br/> 23.xmms乱码问题 (要拷贝simsun.ttf和taboma.ttf到/usr/X11R6/lib/X11/fonts/TrueType/)<br/> 在用户目录下建立 .gtkrc.mine 文件.代码如下<br/> style "gtk-default-zh-cn" {<br/> fontset = "-*-tahoma-medium-r-normal-*-12-0-0-0-p-0-iso8859-1,<br/> -misc-simsun-medium-r-normal-*-*-120-*-*-p-*-gbk-0,*-r-*" }<br/> class "GtkWidget" style "gtk-default-zh-cn"<br/> 修改xmms中的字体设置，将播放清单及主窗口的字体修改为下面的设置<br/> -*-tahoma-medium-r-normal-*-12-0-0-0-p-0-iso8859-1,<br/> -misc-simsun-medium-r-normal-*-*-120-*-*-p-*-gbk-0,*-r-*<br/> xorg6.9+xfce4+xmms<br/> cd /usr/ports/chineses/xmms make install clean<br/> 拷贝simsun.ttf到/usr/X11R6/lib/X11/fonts/TTF/,无需要建立.gtkrc.mine<br/> 只要修改xmms中的字体设置,字体simsun,size 12就好了。<br/> 24.停止sendmail<br/> vi /etc/rc.conf 加入<br/> sendmail_enable="NONE"<br/> 25.you have mail<br/> mail 回车,输入1看第一封邮件...输入?看帮助<br/> mail 古老的 UNIX 邮件处理程序<br/> 如果我们要寄信给非本机的使用者，可以使用的收件人格式如下：<br/> mail -s"hi, my friend"<br/> jack@mymail.com<br/> mail -s "hi, my friend"<br/> jack@mymail.com<br/> zh_CN.eucCN<br/> 28.远程连接windows终端<br/> rdesktop [-a 16 -f] server'IP[:port]<br/> -a 16表示16位色,-f表示全屏<br/> gui，grdesktop (/usr/ports/net/grdesktop)<br/> 29.播放APE格式音乐<br/> /usr/ports/chinese/xmms/ /usr/ports/audio/xmms-mac(ape插件)xmms-wma(wma插件)<br/> 30.看图<br/> /usr/ports/graphics/xnview<br/> 31.apache22+php5+mysql+postgresql+ZendOptimizer<br/> a,apache22:<br/> cd /usr/ports/www/apache22<br/> make install clean<br/> b,php5:<br/> cd /usr/ports/lang/php5<br/> make install clean<br/> 选中APACHE，就可以联编出用于与Apache web服务器配合使用的可动态加载的mod_php5模块.<br/> 勿选debug,否则不能装ZendOptimizer<br/> c,php5扩展:<br/> cd /usr/ports/lang/php5-extesions<br/> make install [FORCE_PKG_REGISTER=yes] 强迫安装<br/> make clean<br/> (除预设项目还应选中CTYPE,EXIF,GD,ICONV,IMAP,PCRE,SESSION,ZLIB)<br/> FreeBSD中的PHP支持是高度模块化的，因此基本安装的功能十分有限。增加其他功能非常简单，只需通过lang/php5-extensions即可完成。这个port提供了一个菜单驱动的界面来帮助完成PHP扩展的安装。另外也可以通过对应的port来单独安装扩展。例如要将对于MySQL数据库服务器的支持加入PHP5，只需简单地安装databases/php5-mysql.<br/> d,cp /usr/local/etc/php.ini.recommended /usr/local/etc/php.ini<br/> e,ZendOptimizer<br/> cd /usr/ports/devel/ZendOptimizer<br/> make install clean<br/> f,mysql:<br/> cd /usr/ports/databases/mysql41-server<br/> make WITH_OPENSSL=yes BUILD_OPTIMIZED=yes WITH_CHARSET=gbk WITH_XCHARSET=all SKIP_DNS_CHECK=yes install<br/> ./work/mysql-5.0.24/scripts/mysql_install_db<br/> cd /usr/ports/databases/php5-mysql<br/> make install clean<br/> g,postgresql<br/> cd /usr/ports/databases/postgresql81-server<br/> make install clean<br/> /usr/local/etc/rc.d/postgresql initdb<br/> echo 'postgresql_enable="YES"' >> /etc/rc.conf<br/> cd /usr/ports/databases/php5-pgsql<br/> make install clean<br/> <br/>32.怎样刷新环境变量值，而不用退出再登陆？<br/> a,比如要重新设置环境变量ABC的值为abcdef<br/> bash$ export ABC=abcdef<br/> csh% setenv ABC abcdef<br/> b,更新了PATH变量指定目录里可执行命令<br/> rehash<br/> c,更新配置文件<br/> 比如你编辑了.cshrc等文件，就需要用source命令<br/> source .cshrc<br/> 33.检视软件间的关联<br/> cd /usr/ports/sysutils/pkg_tree<br/> make install clean<br/> 之后我们就可以使用 pkg_tree &#124; more 来看各个软件之间的关系了<br/> 34.使用 portupgrade 更新软件<br/> cd /usr/ports/sysutils/portupgrade<br/> make install clean<br/> 配置文件:/usr/local/etc/pkgtools.conf<br/> 如果您只想要升级某一个软件本身，而非所有相依的软件，只要使用portupgrade "pkgname" 即可。如果您要升级所有和该软件相依的其它软件，则可以加上参数 -r。如果您要更新包含相依软件的相依软件，则可以使用参数 -R。另外，您可以使用参数 -m 来要求编译 (make) ports 时多传入一些参数，还可以使用参数 -f 要求就算版本一样也强制更新。portupgrade在更新软件时，会保留您原本的设定档。例如，在更新 Apache 时，它会保留httpd.conf的设定。假设我们更新软件perl-5.8，我们可以用下列指令更新：<br/> # portupgrade -rRf "perl-5.8.*" -m "ENABLE_SUIDPERL=yes"<br/> 35.ports安装失败提示<br/> stop in /usr/ports/lang/ruby18/work<br/> 删除work目录下所有文件＆文件夹再次安装即可.(make clean)<br/> 36.ntop--网络监控软件<br/> cd /usr/ports/net/ntop<br/> make install clean<br/> vi /etc/rc.conf 加入<br/> ntop_enable="YES"<br/> 在地址栏中输入<br/> http://x.x.x.x:3000<br/> 即出来管理界面.<br/> 37.修改/etc/rc.conf不重启生效<br/> a.sh /etc/rc<br/> b./etc/netstart<br/> 38.freebsd启动的时候停到blanktime的解决办法<br/> 可以试试 这个参数:blanktime="NO"<br/> etc/rc.conf 中把 default_router 注释掉<br/> #未验证!!!<br/> 39.Bsd 下的QQ<br/> eva不错，运行速度飞快。<br/> /usr/ports/net-im/eva<br/> gaim-openq<br/> /usr/ports/net-im/gaim-openq<br/> 40.一次性把所有安装的ports删除掉<br/> a.pkg_delete -a<br/> 以下步骤去掉配置文件，解决一些疑难问题<br/> rm -fr /usr/local/<br/> rm -fr /var/db/ports/<br/> cd /usr/ports && make NOCLEANDEPENDS=yes clean<br/> portsnap fetch update<br/> b.安装pkg_cutleaves它会告诉你，哪些package没有人依赖，并让你决定要不要删除<br/> c.make deinstall与pkg_delete有什麽不同？<br/> 简单来说，make deinstall会移除该port，并且不会叁照其相依相关的ports。pkg_delete在移除该port前，会叁照其相依相关的ports，并且pkg_delete<br/> 有支援 wild card，如要移除所有p开头的 ports，则：<br/> cd /var/db/pkg/<br/> pkg_delete p*<br/> 要注意的是，如果使用 `make deinstall'，则最好确定系统目前所安装的版本，与 ports collection 中显示的版本符合，否则有可能会出现非预期性错误；而pkg_delete是因为直接删除系统中所安装的版本，所以没有此问题。<br/> 因此，换句话说，当系统所安装的版本符合ports collections中的版本，则可以使用make deinstall或pkg_delete，否则的话最好用pkg_delete。<br/> 41.pure-ftp安装<br/> cd /usr/ports/ftp/pure-ftpd/<br/> make WITH_LANG=simplified-chinese install clean<br/> [X] BANNER Show pure-ftpd welcome upon session start<br/> cd /usr/local/etc/<br/> cp pure-ftpd.conf.sample pure-ftpd.conf<br/> vi /etc/rc.conf -->加入pureftpd_enable="YES"<br/> 关于pureftpd的编码问题<br/> 在win下登陆ftp然后建立中文文件夹,传中文文件然后用FlashFXP登陆看到这些中文文件和文件夹名字全部是乱码.pure-ftpd.conf中强制用gbk就可以了.<br/> FileSystemCharset &nbsp; &nbsp;gbk<br/> ClientCharset &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gbk<br/> 42.开机自动校准时间<br/> vi /etc/rc.conf--->加入<br/> ntpdate_enable="YES" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Run ntpdate to sync time on boot (or NO).<br/> ntpdate_flags="218.75.4.130" &nbsp; &nbsp; # cn.pool.ntp.org<br/> 43.将/usr/ports/distfiles/目录放到/data/disktfiles<br/> cd /usr/ports<br/> mv distfiles /data/distfiles [移动]<br/> ln -s /data/distfiles distfiles [链接][要在/usr/ports目录下做]<br/> ln -s source_file[_dir] target_file[_dir]<br/> 44.FreeBSD下面通过串口连接到路由器<br/> 使用cu -s speed -l line，就可以连接到COM口或者家猫的线路上，我用的是COM1口，<br/> 连接Cisco2924XL，使用cu -s 9600 -l ttyd0，即可连接上交换机配置界面。<br/> 45.电子书：CHM、PDF的查看<br/> chmsee,kchmviewer,xpdf,xchm,Acrobat Reader...chmsee对中文支持比较好<br/> /usr/ports/print/acroread7<br/> 46.使用axel或者prozilla加速你的port下载<br/> a.axel(据说能搞定文件夹钳套,不错!推荐使用 )<br/> cd /usr/ports/ftp/axel<br/> make install clean<br/> vi /etc/make.conf 加入<br/> FETCH_CMD=axel -a<br/> DISABLE_SIZE=yes<br/> vi /usr/local/etc/axelrc 修改代码<br/> #num_connections = 4<br/> num_connections = 10<br/> 4改为10,num_connections前面不留空格,否则出错.<br/> (-a 交互的进步指示器,num_connections = 10 10线程下载)<br/> SIZE参数用来在取得文件之前检查文件的大小.而DISABLE_SIZE则是是否开启这项功能<br/> b.prozilla(速度快,遇到欠套的文件夹会出问题)<br/> cd /port/ftp/prozilla<br/> make install clean<br/> vi /etc/make.conf 加入<br/> FETCH_CMD=proz -s -k=10 -r --no-curses<br/> DISABLE_SIZE=yes<br/> (-s 查找最快的境像,-k=10 10个线程下载,-r 重新开始一个被打断的下载)<br/> c.wget(未测试)<br/> cd /usr/ports/ftp/wget/<br/> make install clean<br/> vi /etc/make.conf 加入<br/> FETCH_CMD=wget -c -t 1<br/> DISABLE_SIZE=yes #这行是必要的<br/> d.在其它机器上fetch<br/> make fetch-recursive (fetch:取得recursive:递归的)<br/> 然后将/usr/ports/distfiles拿走。<br/> ###make install设置是/etc/make.conf<br/> ###pkg_add是在~/.cshrc或~/.profile<br/> e.vi /etc/csh.cshrc<br/> 加上以下一行可以在让pkg_add先从更快的站点下载<br/> setenv PACKAGEROOT<br/> ftp://ftp.cn.freebsd.org<br/> 你可以先设定 PACKAGEROOT，这是用来抓取套件的位置,笔者通常设定<br/> setenv PACKAGEROOT<br/> ftp://ftp.tw.freebsd.org<br/> 因为这是我认为最稳定的机器，然后就可以透过pkg_add -r 套件名来安装套件，他会自动的到pub/FreeBSD/ports/i386/packages-4.9-release/Latest/底下寻找套件，而且你不需要知道版本，只要知道套件名称即可，他会自动安装当时的最新版，中文的部分只要加上 zh-，像是 zh-xcin。<br/> 你也可以直接指定 PACKAGESITE 来指向特定的位置。像是你希望安装的套件是最新的，而不是 release 时的版本。<br/> setenv PACKAGESITE<br/> ftp://ftp.tw.freebsd.org/pub/Fre<br/> ... ages-stable/Latest/<br/> f.vi /etc/make.conf<br/> 加上以下一行可以在让make先从更快的站点下载ports Distfiles<br/> MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/<br/> ####http://ports.cn.freebsd.org/<br/> Welcome to use FreeBSD Ports Distfiles Mirror.<br/> This mirror is running on China Telecom 100Mbit network.<br/> How to use? Set your /etc/make.conf like this:<br/> MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/<br/> or like this:<br/> MASTER_SITE_OVERRIDE?=http://ports.hshh.org/${DIST_SUBDIR}/<br/> 47.星际译王<br/> 辞典程序： /usr/ports/textproc/stardict2/<br/> 简体中文辞典：/usr/ports/chinese/stardict2-dict-zh_CN/<br/> 48.控制台调音量<br/> mixer<br/> 49.How to build openoffice<br/> cd /usr/ports/editors/openoffice.org-2.0<br/> Building/installing/packaging a localized language package (Japanese version for example)<br/> make LOCALIZED_LANG=ja install<br/> 去这里<br/> ftp://ooopackages.good-day.net/pub/OpenOffice.org/FreeBSD/<br/> 里面的tbz文件，<br/> 可以直接pkg_add<br/> 50.OPERA，支持Flash浏览器<br/> cd /usr/ports/www/linux-opera<br/> （注意是www/linux-opera，www/opera是不支持Flash的。）<br/> cd /usr/ports/www/opera<br/> make config<br/> 选中[X]SHARED Use a shared Qt library(instead of static)[解决在opera中输入汉字的问题]<br/> make install clean<br/> 安装后的美化:<br/> A.Tools->Preference->Advanced->Fonts，把所有的字体都改成Simsun，字体大小设成12。<br/> B.最小字体大小（像素）改为12.[解决一些网站看不清楚的问题]<br/> 51.bt客户端<br/> /usr/ports/net-p2p/py-bittorrent 安装完成后执行bittorrent<br/> /usr/ports/net-p2p/rtorrent 功能多，速度快，还完美支持中文编码！<br/> 52.emule客户端<br/> /usr/ports/net-p2p/amule2<br/> 53.ipguard解决arp攻击<br/> ipguard->Tool designed to protect LAN IP adress space by ARP spoofing<br/> /usr/ports/security/ipguard<br/> make install (不要clean参数,否则无ethers.sample文件)<br/> 补充：<br/> A.以/usr/ports/security/ipguard/work/ipguard-0.04/doc/ethers.sample<br/> 文件为实例，建立/etc/ethers文件。<br/> B.And then start ipguard:<br/> cd /usr/local/etc/rc.d<br/> mv ipguard.sh.sample ipguard.sh<br/> /usr/local/etc/rc.d/ipguard.sh start<br/> ipguard.sh启动脚本里默认有iface=fxp0，这里应该替换为你做NAT的内网网卡名称。<br/> 54.一些安装参数<br/> make fetch 只抓取tarball<br/> make fetch-recursive 抓取安装ports所有须要的其他ports的tarball<br/> make fetch-list 列出port所需的文件<br/> make clean Ports里面make clean,会附带着make clean依赖的软件的<br/> make -DBATCH install不需要用户输入任何东西<br/> make -DINTERACTIVE install 继续上一步<br/> make configure<br/> make distclean，删除不想要的distfiles<br/> 55.pkg_info<br/> pkg_info &#124;grep zh-fcitx (查软件版本)<br/> #ls /var/db/pkg也可以查软件版本<br/> pkg_info -L zh-fcitx-3.4 (查看软件安装目录和安装的文件)<br/> pkg_info -xL zh-fcitx (加x了不需要加软件版本号)<br/> pkg_info -r zh-fcitx-3.4 (查看软件依赖情况)<br/> pkg_info -W fcitx (查看fcitx属于哪个软件)<br/> 56.Ports如何清除安装参数<br/> cd /usr/ports/www/opera<br/> make distclean移除不是port collections所期望下载的文件<br/> make rmconfig清除用户配置的参数<br/> make showconfig查看当前配置的参数<br/> make config更改参数<br/> 57.一款好用的网络性能测试工具iperf<br/> /usr/ports/benchmarks/iperf<br/> 58.FreeBSD用户帐户锁定<br/> a.用vipw把他的shell修改成/sbin/nologin就可以了.<br/> b.pw lock useri 解锁用pw unlock userid 59.中文locale<br/> zh_CN.eucCN zh_CN.GBK zh_CN.GB18030 zh_CN.euc zh_CN.UTF-8<br/> #语言代码_国家代码.字符编码<br/> #查看环境变量：locale<br/> #目前还是zh_CN.eucCN(使用GB2312编码)locale最为正式，也最为成熟。<br/> 60.本地化设置,以系统默认的csh为例<br/> vi /etc/csh.cshrc 加入<br/> setenv LANG zh_CN.eucCN (语言设为中文)<br/> setenv LC_ALL zh_CN.eucCN (所有本地子集设为中文)<br/> setenv XMODIFIERS @im=fcitx (X下的中文输入法)<br/> set prompt = "%B%m"(个性化控制台%B颜色%m主机%/目录)<br/> set autolist &nbsp; (自动补齐扩展)<br/> set nobeep (告诉应用程式避免发出哔哔声)<br/> set filec &nbsp; &nbsp; (使档案名称在命令列被完成)<br/> alias ls &nbsp; &nbsp; &nbsp; &nbsp;ls -FG (彩色化ls)61.fcitx小企鹅输入法(有关步骤见60)<br/> /usr/ports/chineses/fcitx<br/> vi /root/.xinitrc 添加<br/> exec fcitx& 到最前一行<br/> 62.安装X Server xorg-6.9.0<br/> 1.cp freebsddisk1 disk2 PKG to /data/pkg61目录<br/> 2.cd /data/pkg61<br/> 3.pkg_add xorg-6.9.0.tbz<br/> 4.rehash<br/> 5.X[Xorg] -configure (生成/root/xorg.conf.new)<br/> 6.X[Xorg] -config /root/xorg.conf.new (测试xorg.conf.new配置是否正确)<br/> 7.cp /root/xorg.conf.new /etc/x11/xorg.conf<br/> 63.安装桌面环境gnome2 and xfce4 and kde3.5.1<br/> gnome2-2.12.3<br/> 1.cd /data/pkg61<br/> 2.pkg_add gnome2-2.12.3.tbz<br/> 3.rehash<br/> 4.vi /root/.xinitrc 加入 exec gnome-session<br/> #gnome2提示vi /etc/sysctl.conf,加入<br/> kern.ipc.shmmax=67108864<br/> kern.ipc.shmall=32768<br/> kern.maxfiles=25000<br/> xfce4<br/> 1.cd /usr/ports/x11-wm/xfce4<br/> 2.make install clean<br/> 3.rehash<br/> 4.vi /root/.xinitrc 加入 exec xfce4-session<br/> kde-3.5.1<br/> 1.cd /data/pkg61<br/> 2.pkg_add kde-3.5.1.tbz<br/> 3.rehash<br/> 4.cd /usr/ports/chineses/kde3-i18n-zh_CN<br/> 5.make install clean (kde3汉化)<br/> 6.vi /root/.xinitrc 加入 exec startkde<br/> pkg_add -r kde<br/> pkg_add -r zh_CN-kde-i18n<br/> pkg_add -r zh_CN-koffice-i18n<br/> ###more /root/.xinitrc<br/> exec fcitx&<br/> exec gnome-session<br/> #exec xfce4-session<br/> #exec startkde<br/> #exec /usr/X11R6/bin/gnome-session<br/> #exec /usr/local/bin/xfce4-session<br/> #exec /usr/local/bin/startkde<br/> 64.在Xwindow中使用TrueType字体(simsun宋体,msyh雅黑,tahoma)<br/> 1.cp simsun.ttc /usr/X11R6/lib/X11/fonts/TTF/simsun.ttf<br/> 2.cp msyh.ttf tahoma.ttf /usr/X11R6/lib/X11/fonts/TTF/<br/> 3.cd /usr/X11R6/lib/X11/fonts/TTF<br/> #下面4,5步骤更新字体信息,6重建字体缓存.<br/> 4.mkfontscale (生成fonts.scale)否则xorg报错如下:<br/> Could not init font path element/usr/X11R6/lib/X11/fonts/TTF/,removing from list!<br/> 5.mkfontdir (生成fonts.dir)否则xorg报错如下:<br/> (WW) `fonts.dir' not found (or not valid) in "/usr/X11R6/lib/X11/fonts/TTF/".<br/> Entry deleted from font path.<br/> (Run 'mkfontdir' on "/usr/X11R6/lib/X11/fonts/TTF/".<br/> 6.fc-cache -f -v (生成fonts.cache-1)<br/> 7.vi /etc/X11/xorg.conf 确认8<br/> 8.Load "freetype" (启用支持TrueType字体)<br/> #现在X应用程序已经记住已安装的TrueType字体.<br/> 9.在gnome和其他X程序中把字体设置为宋体或雅黑.<br/> 65.xlsfonts显示系统中安装的字体<br/> 66.FreeBSD中3D加速功能的启用<br/> a.DRI。<br/> 这是实现3D功能最重要的部分。DRI是Direct Rendering Infrastructure,可以简单的把它理解为X和硬件间的接口.但它包含很多独立的模块，负责从X到硬件的各个环节，包括内核。它最主要的工作就是将Mesa或OpenGL的函数调用转换为硬件的指令，从而指挥硬件进行渲染等工作。<br/> b.测试你的显卡是不是能实现3D功能，可以采取以下办法：<br/> 1.dmesg &#124; grep agp，如果出现:<br/> agp0: &nbsp;mem<br/> 0xe0000000-0xe3ffffff at device 0.0 on pci0<br/> 的字样，那么你的显卡就有可能实现3D功能.如果什么也没有的话，那么恭喜你，你再也不用为3D功能而费心了.<br/> 2.kldload drm，如果没报错的话，那么你的显卡基本上就可以实现3D功能了。<br/> c.3D功能的确认<br/> 运行：glxinfo。在第二行或第三行，如果出现”Direct Rendering: YES“字样，那就说明已经启用3D加速了。<br/> more /var/log/Xorg.0.log &#124; grep "direct rendering"如果出现下面的字样，(II) I810(0): direct rendering: Enabled那么你的3D就启用的。如果没有，<br/> 那么你要仔细读/var/log/Xorg.0.log。它会在某一行告诉你没启用的原因的。<br/> d.nvidia显卡驱动安装 cd /usr/ports/x11/nvidia-driver/<br/> 67.刷新率的问题，<br/> 将xorg.conf里的Modes行改成:Modes "1024x768"(小写的X)<br/> 选择默认的分辨率和色深。 这是在 "Screen" 小节中定义的：<br/> Section "Screen"<br/> Identifier "Screen0"<br/> Device &nbsp; &nbsp; "Card0"<br/> Monitor "Monitor0"<br/> DefaultDepth 24<br/> SubSection "Display"<br/> Viewport &nbsp; 0 0<br/> Depth &nbsp; &nbsp; 24<br/> Modes &nbsp; &nbsp; "1024x768"<br/> EndSubSection<br/> EndSection<br/> 68.make world<br/> cvsup -g -L 2 -h cvsup.freebsdchina.org standard-supfile &nbsp; (升级源码树)<br/> cp /usr/share/examples/etc/make.conf /etc/make.conf<br/> vi /etc/make.conf,保留如下内容<br/> CFLAGS= -O -pipe<br/> COPTFLAGS= -O -pipe<br/> cd /usr/src/sys/i386/conf &nbsp; (更改内核配置文件)<br/> cp GENERIC TDS<br/> vi TDS (按需要修改其内容)<br/> shutdown now &nbsp; (重启到单用户模式)<br/> adjkerntz -i &nbsp; (确定本地时间设置)<br/> cd /usr/src<br/> make -j4 buildworld &nbsp; (编译基本系统)<br/> make buildkernel KERNCONF=TDS &nbsp; (编译新内核)<br/> make installkernel KERNCONF=TDS &nbsp; (安装新内核)<br/> reboot &nbsp; (重新启动)<br/> shutdown now &nbsp; (重启到单用户模式)<br/> cd /usr/src<br/> mergemaster -p &nbsp; (更新/etc目录里的文件,-p预建模式)<br/> make installworld &nbsp; (安装新的二进制)<br/> mergemaster -Ui (更新makeinstallworld不更新的文件,-U進了6-STABLE了,這功能很讚，<br/> 就是他會看哪些/etc 的檔案，你沒有改過的，就會自動 merge，這樣子可以省下很多時間跟力氣。<br/> shutdown -r now &nbsp; (重新启动)<br/> uname -a &nbsp; (查看系统信息)<br/> cd /usr/src<br/> make cleanworld &nbsp; (清除升级过程产生的临时文件)<br/> #############################################<br/> 中断的 build 可以被恢复吗<br/> cd /usr/src<br/> make -DNOCLEAN all<br/> 这样就不会取消先前的 make buildworld 所做的工作。<br/> ##############################################<br/> 如果出现了错误我该怎么办？<br/> 删除以往的系统更新树<br/> cd /usr/obj<br/> chflags -R noschg *<br/> rm -rf *<br/> cd /usr/src<br/> make cleandir<br/> make cleandir<br/> 不错，make cleandir 真的要执行两次。<br/> 然后重新开始整个过程，使用 make buildworld 开始。<br/> mergemaster -p的说明<br/> mergemaster -p的作用是建立一个临时的根环境，把新的配置文件映射到这个环境当中，然后和系统的配置文件进行比较和处理，目的是保证系统配置文件的更新，这一点很重要！<br/> 在执行"mergemaster -p"的过程中，主要是进行以下处理：<br/> 检测系统是否存在临时的根环境，如果存在，让用户选择是利用现有的还是删除它，然后新建！<br/> *** The directory specified for the temporary root environment,<br/> /var/tmp/temproot, exists. This can be a security risk if untrusted<br/> users have access to the system.<br/> Use 'd' to delete the old /var/tmp/temproot and continue 删除旧的/var/tmp/temproot<br/> Use 't' to select a new temporary root directory 为temproot选择新的目录<br/> Use 'e' to exit mergemaster 退出mergemaster<br/> Default is to use /var/tmp/temproot as is<br/> How should I deal with this? [Use the existing /var/tmp/temproot]<br/> 一般的处理是选 "d" ，删除原有的目录，系统开始重新建立这个临时的根环境。<br/> 只要进行的不是大跨度的 FreeBSD 版本升级,可以简单地跳过这一步.<br/> mergemaster的说明<br/> 重新编译整个系统不会使用新的或改过的配置文件更新某些目录(尤其像 /etc,/var和/usr)更新这些文件最简单的方式就是使用 mergemaster，手工去做也是可以的，只要您愿意。<br/> 不管您选择哪一种，一定记得备份/etc 以防出错。<br/> mergemaster操作中可能会遇到以下操作提示:<br/> Use 'd' to delete the temporary 删除文件,不更新相应的系统配置文件<br/> Use 'i' to install the temporary 安装文件,使用新的配置文件覆盖旧文件<br/> Use 'm' to merge the temporary and installed versions 对旧的配置文件进行合并处理,并安装<br/> Use 'v' to view the diff results again 察看新文件与旧文件的差异<br/> ###跟踪多台机器,以A.B2个机器为例。A要启动nfs_server,B要启动nfs_client<br/> A:/etc/rc.conf<br/> rpcbind_enable="YES"<br/> nfs_server_enable="YES"<br/> /etc/exports<br/> /usr/src /usr/obj /usr/ports &nbsp; -maproot=0 &nbsp; 192.168.0.61(B-ip)<br/> B:/etc/rc.conf<br/> nfs_client_enable="YES"<br/> A.cd /usr/src<br/> make -j4 buildworld &nbsp; (编译基本系统)<br/> make buildkernel KERNCONF=TDS &nbsp; (编译新内核)<br/> B。mount b-ip:/usr/src /usr/src<br/> mount b-ip:/usr/obj /usr/obj<br/> cd /usr/src<br/> make installkernel KERNCONF=TDS &nbsp; (安装新内核)<br/> reboot &nbsp; (重新启动)<br/> shutdown now &nbsp; (重启到单用户模式)<br/> cd /usr/src<br/> mergemaster -p &nbsp; (更新/etc目录里的文件,-p预建模式)<br/> make installworld &nbsp; (安装新的二进制)<br/> mergemaster -U &nbsp; (更新makeinstallworld不更新的文件,-U進了6-STABLE了,這功能很讚，<br/> 69.freebsd上下的jdk的安装方法(FreeBSD基金会提供的diablo-jdk)<br/> cd /usr/ports/java/diablo-jdk15<br/> 最好是通过port的diablo-jdk安装，而不是直接pkg_add，因为后者可能会出现依赖关系不对的问题。<br/> JDK与JRE的关系<br/> JAVA DEVELOPMENT KIT 与JAVA RUNTIME ENVIROMENT之间是什么关系？<br/> JRE只是Java的运行环境，而JDK是Java的开发、运行和调试一体的环境。<br/> JAVA环境变量的设置<br/> csh 就在/etc/csh.cshrc<br/> setenv JAVA_HOME /usr/local/diablo-jdk1.5.0<br/> setenv CLASS_PATH .:/usr/local/diablo-jdk1.5.0/lib/dt.jar<br/> bash就在/etc/profile<br/> export JAVA_HOME=/usr/local/diablo-jdk1.5.0<br/> #export CATALINA_HOME=/usr/local/jakarta-tomcat5<br/> export CLASSPATH=.JAVA_HOME/jre/lib/rt.jarJAVA_HOME/lib/dt.jarJAVA_HOME/lib/tools.jar<br/> 70.查找最快的cvsup站点<br/> cd /usr/ports/sysutils/fastest-cvsup<br/> make install clean<br/> fastest-cvsup -c jp,cn,hk,us<br/> 71.chmod 命令概解：chmod命令用于改变文件的运行级别(读=4写=2执行=1)<br/> chmod 400 files 给某文件以只读权限<br/> chmod 600 files 给某文件以只读、写权限<br/> chmod 700 files 给某文件以只读、写、执行权限<br/> chmod -R 400 directory 改变某目录下所有文件的运行权限为只读权限<br/> chmod -R 600 directory 改变某目录下所有文件的运行权限为以只读、写权限<br/> chmod -R 700 directory 改变某目录下所有文件的运行权限为只读、写、执行权限<br/> 72.chown概解：改变文件及文件夹的用户所属<br/> chown root:wheel files 改变文件的用户为root用户组为wheel组<br/> chown -R root:wheel directory 改变目录的用户为root用户组为wheel组<br/> 73.crontab 指令語法<br/> crontab [ -u user ] file<br/> crontab [ -u user ] { -l &#124; -r &#124; -e }<br/> crontab 提供我们在固定的间隔时间执行自订的程序、系统指令或 shell secrip。时间间隔的单位可以是分钟、<br/> 小时、日、周、月及以上的任意组合。允许使用者离线执行，并且可以将执行结果以 email 通知使用者。因此，<br/> 非常设合对周期性的管理分析或数据备份等工作。<br/> 基本上，crontab 的指令格式分为六个部分，前五个为时间间隔，最后则是执行的指令。每一个部分用空格来区隔。<br/> crontab -e : 执行文字编辑器来设定时程表，内定的文字编辑器是 VI，如果你想用别的文字编辑器，则请先设定<br/> VISUAL 环境变数来指定使用那个文字编辑器(比如说 setenv VISUAL joe)<br/> crontab -r : 删除目前的时程表<br/> crontab -l : 列出目前的时程表<br/> crontab file [-u user]-用指定的文件替代目前的crontab。<br/> 时程表的格式如下:<br/> f1 f2 f3 f4 f5 &nbsp; &nbsp; program<br/> 分 时 天 月 星期几 要执行的程序<br/> 当 f1 为 * 时表示每分钟都要执行 program，f2 为 * 时表示每小时都要执行程序，其馀类推<br/> 当 f1 为 a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行，f2 为 a-b 时表示从第 a 到第 b 小时都要执行，其馀类推<br/> 当 f1 为 */n 时表示每 n 分钟个时间间隔执行一次，f2 为 */n 表示每 n 小时个时间间隔执行一次，其馀类推<br/> 当 f1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行，f2 为 a, b, c,... 时表示第 a, b, c...个小时要执行，其馀类推<br/> 使用者也可以将所有的设定先存放在档案 file 中，用 crontab file 的方式来设定时程表。<br/> 先前曾提到，crontab 的格式分成六个部分，前五个是时间参数。在上例中你会发现除了数字与英文名称，<br/> 有使用到符号"*"，这个符号代表每一单位的意思，譬如30 3 * * *既代表30分3点每日每月星期的每天。<br/> 时间的指定，可以是单一的数字，或几个数字用逗号来连接。看下例<br/> 30 3,12 * * * /root/fbin/bak-web<br/> 其中的第二项为 3,12，这代表 3 以及 12 小时的意思。再来看下例<br/> 30 */6 * * * /root/fbin/bak-web<br/> 我把第二项改成 */6 这代表每 6 小时，也相当于 6,12,18,24 的作用。此外还有一个区段的做法<br/> 30 8-18/2 * * * /root/fbin/bak-web<br/> 我把第二项改成 8-18/2 这代表在 8 小时到 18 小时之间每 2 小时，也相当于 8,10,12,14,16,18 的作用<br/> 74.使用portsnap更新系统ports<br/> portsnap从6.0开始引进系统，给与用户方便的更新系统ports，portsnap的命令比较少,fetch 获取数据,extract 释放全部ports,update 更新ports<br/> 第一次使用可以portsnap fetch extract,以后使用可以portsnap fetch update国内镜像站<br/> portsnap.hshh.org<br/> portsnap2.hshh.org<br/> portsnap3.hshh.org (网通)<br/> 使用方法:<br/> /etc/portsnap.conf 里面更改<br/> SERVERNAME=portsnap.hshh.org<br/> 使用portupgrade 更新已安装的软件<br/> 75.清屏<br/> clear或ctrl+L<br/> 76.freebsd 怎么安装GF4 MX 440的显卡<br/> 首先更新ports和src，到/usr/ports/x11/nvidia-driver下make install clean，要選中linux的支持。<br/> 然后到/usr/ports/x11/nvidia-xconfig下make install clean，還可以到/usr/ports/x11/nvidia-settings下安裝控制面板。<br/> 運行nvidia-xconfig會自動生成xorg.conf文件，然后根据需要自行更改。<br/> 77.如何知道一个文件属于哪个port，比如libplds4.so.1<br/> pkg_info -W filename<br/> 78.mplayer<br/> cd /usr/ports/multimedia/mplayer<br/> make install clean<br/> 问题：如何让mplayer支持srt格式的字幕？<br/> 解答：首先复制一个中文ttf字体文件到 ~/.mplayer/ 目录下，并改名为 subfont.ttf ；然后在gmplayer的选项<br/> (Preferences)->Subtitle & OSD 中将 Encoding 项选为“Simplified Chinese charset (CP936)”。如果你还使用命令行播放电影，还需要在 ~/.mplayer/config 文件中加上这么一行：subcp=cp936 。如果仍然不能显示字幕，请看看字幕文件名和电影文件名是否相配：如果avi文件是movie.avi的话，字幕文件名应该是movie.srt。<br/> 问题：怎么mplayer不能显示.idx+.rar格式的字幕？<br/> 解答：先将rar文件中的sub文件解压出来 。<br/> 问题：如何让mplayer的播放窗口保持在最前面？<br/> 解答：修改 ~/.mplayer/config 文件，加上这么一行：ontop=yes 。<br/> 问题：如何让mplayer的画面随窗口大小自动缩放呢？<br/> 解答：修改 ~/.mplayer/config 文件，加上这么一行：zoom=yes。<br/> 测试通过by tds 061119。fb61+xorg6.9+xfce4+gmplayer<br/> 79.设置控制台高分辩率<br/> 1.在内核配制文件里加入下面的编译内核<br/> options &nbsp; &nbsp;VESA<br/> options &nbsp; &nbsp;SC_PIXEL_MODE<br/> 第一行选项让內核支持VESA 2，第二行让内核支持控制台图形模式。<br/> 2.vidcontrol -i mode 查询出所有模式<br/> ......<br/> 279 (0x117) 0x0000000f G 1024x768x16 1 8x16 &nbsp; 0xa0000 64k 64k 0xd8000000 65536k<br/> 280 (0x11 0x0000000f G 1024x768x32 1 8x16 &nbsp; 0xa0000 64k 64k 0xd8000000 65536k<br/> ......<br/> 3.测试模式<br/> vidcontrol MODE_280<br/> 4.vi /etc/rc.conf加入下面这条<br/> allscreens_flags="MODE_280"<br/> 5.把console改成黑底绿字的<br/> vidcontrol green<br/> 80.设置FreeBSD console下的字体大小<br/> vidcontrol -f ...<br/> 81.锁住终端<br/> lock -np<br/> -n 永不超时,-p 使用系统密码作为开启终端的密匙<br/> 82.刻录CD ISO映像文件<br/> burncd -f /dev/acd0 -s max data imagefile.iso fixate<br/> 刻录一个文件到CD上而不创建ISO9660文件系统<br/> burncd -f /dev/acd1 -s 12 data archive.tar.gz fixate<br/> 生成ISO文件<br/> mkisofs -o imagefile.iso /path/to/tree<br/> 把数据CD复制成一个与之等价的镜像文件<br/> dd if=/dev/acd0 of=file.iso bs=2048<br/> 83.类似flashget的东东download for X，d4x<br/> /usr/ports/ftp/downloader<br/> 84.使用watch监视终端<br/> 1.编辑核心加入pseudo-device snp或者kldload snp<br/> 2.cd /dev &nbsp; ./MAKEDEV snp0 snp1<br/> 3.watch ttyp1<br/> 去换终端ctrl-x<br/> 退出watch ctrl-g<br/> 85.kldload xxx 加载xxx模块<br/> kldstat 查看已加载的模块<br/> kldunload xxx 从核心中移除<br/> 86.让程序读取新的配置文件<br/> kill -HUP 199 &nbsp; &nbsp; &nbsp; &nbsp;(进称号)<br/> killall -HUP sshd (进程名)<br/> 上述指令中的参数 -HUP 也可以使用 -1 来取代<br/> 87.登入后的讯息Message Of The Day(motd)<br/> 编辑 /etc/motd 来制作自己的画面<br/> 登入前的讯息<br/> 修改 /etc/gettytab 及 /etc/issue<br/> 编辑 /etc/gettytab，找到 default的地方。<br/> default:&#92;:cb:ce:ck:lc:fd#1000:im=&#92;r&#92;n%s/%m (%h) (%t)&#92;r&#92;n&#92;r&#92;n:sp#1200:&#92;<br/> :if=/etc/issue:<br/> 其中的%s %m %h %t分别对应到FreeBSD i386 example.com ttyp0，如果你不想显示FreeBSD，<br/> 就把%s拿掉。最后一行if=/etc/issue就是表如果没有issue这个档的话，就执行default。<br/> 88.变更自己所使用的Shell<br/> chsh -s /bin/tcsh<br/> 上述指令将Shell变更成/bin/tcsh。注意!输入的shell名称一定要存在于/etc/shells中<br/> 89.Shell 的环境变量<br/> tcsh可以使用setenv看目前所有的环境变量，也可以使用setenv来改变一个环境变量的值<br/> setenv EDITOR ee<br/> 如果您使用的是 Bourne Shell：<br/> export EDITOR="ee"<br/> 90./etc/master.passwd 介绍<br/> FreeBSD使用shadow password的方式来保护密码文件，只有root才可以读取编码后的密码文件/etc/master.passwd。但是这并不是系统用来验证的档案，为了加快速度，FreeBSD将该文件做成数据库/etc/spwd.db及/etc/pwd.db，因此在修改完master.passwd后，必须使用指令pwd_mkdb来将master.passwd做成数据库档案。不过一般而言，我会使用vipw这个指令来修改master.passwd，vipw会先将master.passwd以预设的文书编辑软件打开，修改完存盘后，它会视需要自动更新数据库。<br/> pwd_mkdb -p -d /etc /etc/master.passwd<br/> master.passwd这个档案内容中，每个使用者都是独立的一行，每个字段使用冒号分开，格式是：<br/> name:password:UID:GID:class:change:expire:fullname:home:shell<br/> pwd_mkdb介绍<br/> 如果我们直接以文书编辑软件来修改/etc/master.passwd，在修改完后，必须执行pwd_mkdb来将更新的数据做成系统可以读取的数据库文件。pwd_mkdb还会自动建立/etc/passwd。<br/> 91.将使用者目录拥有者更改为所属的使用者<br/> chown -R user:group /home/user<br/> 使用参数-R将目录user及其下所有档案及子目录的拥有人改变成user<br/> 92.记录使用者指令<br/> 修改 /etc/rc.conf，加上下列一行设定：<br/> accounting_enable="YES"<br/> 系统会将使用者的历程记录在/var/account/acct*中，最新的记录是acct<br/> 当下达指令lastcomm时，则系统会以/var/account/acct为参考，印出所记录的数据。<br/> 也可以使用lastcomm -f acct1来查看前一天的资料。<br/> 93.sudo<br/> 如果你希望它能将执行sudo的log记下来的话，必须先编辑/usr/ports/security/sudo/Makefile，<br/> 将CONFIGURE_ARGS中的参数 --disable-log-wrap 拿掉。<br/> cd /usr/ports/security/sudo<br/> make install clean<br/> 安装完后，我们要先执行/usr/local/sbin/visudo以设定sudo的设定档(/usr/loca/etc/sudoers)。设定完后，使用者即可执行sudo ，使用者只要输入自己的密码即可，不必知道root密码，而且5分钟内再次执行sudo时不需再输入密码。如果你有打开log记录功能，sudo执行成功或失败的log都将被记录到/var/log/sudo.log中。<br/> 94./usr/ports/dns/ddclient动态dns更新软件<br/> 95.SCSI工具camcontrol<br/> camcontrol devlist 查看目前所有USB装置<br/> ATA工具<br/> atacontrol list 查看目前所有ATA装置<br/> 96.如果我们只知道一个关键词，却不知要使用哪一个指令，我们可以使用参数k来查询。<br/> 例如我们要查询 firewall 相关的指令：man -k firewall<br/> 97.bg<br/> 将指定的程序放入背景中执行。当我们下达一个指令后，必须要等待该程序结束后才能输入下一个命令。<br/> 如果该程序必须执行一段很长的时间，我们不想等程序结束，可以把它放到背景中执行。在下达指令后，按 Ctrl+Z 来暂停程序，接着再执行 bg 即可将程序放到背景中执行。<br/> $ sleep 1000<br/> ^Z<br/> Suspended<br/> $ bg<br/> [1] sleep 1000 &<br/> 我们也可以在所要执行的指令后面加上符号 "&"，就可以将该程序放到背景执行：<br/> $ sleep 1000 &<br/> [2] 46461<br/> 98.jobs<br/> jobs 指令可以让我们查询目前有哪些程序在背景执行。如果加入参数 -l 可以得到 PID 的信息。<br/> jobs -l<br/> [1] + 46459 Running sleep 1000<br/> [2] - 46461 Running sleep 1500<br/> 99.fg<br/> 将指定的程序放到前景中执行。我们使用jobs看到目前在背景执行的程序之后，可以使用fg把它叫回前景。<br/> 例如要叫回第一个在背景中执行的程序：<br/> fg %1<br/> sleep 1000<br/> 100.sync<br/> 让系统暂存的数据强制存回硬盘<br/> 101.cp -Rp sourdir tardir<br/> -R完成递归复制(即可以复制目录以下的所有内容)，-p保留文件的时间、所属等等<br/> 102.ssh<br/> [email=username@hostname]username@hostname[/email]<br/> 从远程拷贝 scp<br/> [email=user@host:/path/to/files]user@host:/path/to/files[/email]<br/> local_file_name<br/> 拷贝到远程 scp local_file_name<br/> [email=user@host:/path/to/files]user@host:/path/to/files[/email]<br/> <br/>103.使用Portaudit监视第三方安全问题<br/> cd /usr/ports/security/portaudit && make install clean<br/> 安装完成之后更新数据库<br/> portaudit -Fda<br/> 使用下面的命令对通过Ports Collection安装的第三方软件工具进行审计<br/> portaudit -a<br/> 104.我要怎么从 X 切换到 virtual consoles？<br/> 请用Ctrl+Alt+Fn以切回至console。Ctrl+Alt+F1可以切回至第一个console。<br/> 当你切回至文字console后，你就可以使用一般的Alt+Fn组合键在各console之间切换了。<br/> 要回到X的话，你就可以使用Alt+F9以返回至X中。<br/> 105.FB下Free的杀毒软件<br/> clamav (security/clamav)<br/> man clamscan 扫描<br/> man freshclam 更新病毒库<br/> man clamd<br/> man clamdscan<br/> man sigtool<br/> 配置文件<br/> /use/local/etc/freshclam.conf<br/> /usr/local/etc/clamd.conf<br/> 把conf里的#Example去掉<br/> # Comment or remove the line below.<br/> #Example<br/> /etc/rc.conf加入<br/> clamav_clamd_enable="YES"<br/> clamav_freshclam_enable="YES"<br/> 106.软件默认配置示例文件的一般存放位置<br/> /usr/share/examples<br/> /usr/local/share/examples<br/> 107.安装文泉驿字体<br/> cd /usr/ports/x11-fonts/wqy/<br/> make install clean<br/> 108.把/data/tftp打包成pxeinstfb62.tgz<br/> cd /data/<br/> tar zcvf pxeinstfb62.tgz tftp<br/> 解压<br/> tar zxvf pxeinstfb62.tgz<br/> 109.ports下有没有xxx这个软件？在哪个目录下？<br/> 回答：有两种办法来查找，一是通过软件名：<br/> make fetchindex<br/> cd /usr/ports<br/> make search name=xxx &#124; grep ^Path<br/> 另一种是通过关键字，也就是在软件名和说明中只要包括这个单词的都会查找出来：<br/> cd /usr/ports<br/> make search key=xxx &#124; grep ^Path<br/> 110.FreeBSD如何获得硬件信息?<br/> sysctl -a &#124; grep "^dev&#92;."<br/> pciconf -lv<br/>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?630</link>
<title><![CDATA[freebsd10下安装xvfb]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[媒体报导]]></category>
<pubDate>Wed, 28 Jan 2015 10:38:37 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?630</guid> 
<description>
<![CDATA[ 
	网上大把的资料都是说在linux下如何安装xvfb，就是没有说在freebsd下如何安装。<br/>经本人多时研究，总算得到了答案，现分享给大家。<br/>freebsd下xvfb不是这个名字了。<br/>可以用下面的命令进行安装。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">pkg install xorg-vfbserver<br/>or<br/><br/>cd /usr/ports/x11-servers/xorg-vfbserver<br/>make install<br/><br/>安装了以后就会有Xvfb这个命令了，注意X要大写哦</div></div>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?629</link>
<title><![CDATA[freebsd10 更新ports]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Wed, 28 Jan 2015 09:48:17 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?629</guid> 
<description>
<![CDATA[ 
	使用最新的ports可以保证软件的互相依赖，升级的命令也比以前的版本简单了很多。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#portsnap fetch extract</div></div><br/>会下载一个70M的包，解压后就升级好了。
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?628</link>
<title><![CDATA[freebsd10下安装Nginx+php56+mysql56]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Wed, 28 Jan 2015 09:42:43 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?628</guid> 
<description>
<![CDATA[ 
	freebsd10下安装Nginx+php56+mysql56其实很简单，只是很多PHP组件怎么装？网上少有提及，我来给大家一个比较全的安装命令吧。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">pkg install nginx php56 php56-extensions php56-mysql php56-mysqli php56-mbstring php56-soap php56-gd php56-curl php56-bz2 php56-mcrypt php56-xsl php56-ftp php56-pdo_mysql php56-sockets php56-tidy mysql56-server</div></div><br/><br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">pkg install nginx php70 php70-extensions php70-mysqli php70-mbstring php70-soap php70-gd php70-curl php70-bz2 php70-mcrypt php70-xsl php70-ftp php70-pdo_mysql php70-sockets php70-tidy mysql57-server</div></div><br/>这样一句命令就把这些都装完了。剩下的就是配置了。<br/>首先在启动中加入开启服务命名。<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># ee /etc/rc.conf<br/>在最后加入下面三句<br/>nginx_enable="YES"<br/>php_fpm_enable="YES"<br/>mysql_enable="YES"</div></div><br/>完成下面的步骤，才可以重启服务器啊，否则会有rc.conf报错<br/>配置mysql<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># ee /usr/local/etc/my.cnf<br/>[mysqld]<br/>socket = /tmp/mysql.sock<br/><br/>skip-networking<br/>skip-name-resolve<br/>然后启动mysql<br/># service mysql-server start<br/>修改root的密码<br/># /usr/local/bin/mysqladmin -u root password '你的密码'</div></div><br/>配置 PHP <br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini<br/># ee php.ini<br/>修改post_max_size = 200M<br/>upload_max_filesize = 200M<br/>max_file_uploads = 100<br/>display_errors = On</div></div><br/>配置php-fpm<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/># ee /usr/local/etc/php-fpm.conf<br/>修改<br/>pm.max_children = 300<br/>pm.start_servers = 20<br/>pm.min_spare_servers = 5<br/>pm.max_spare_servers = 35<br/>pm.max_requests = 10240<br/>启动php-fpm<br/># service php-fpm start</div></div><br/>配置Nginx<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>建立日志目录<br/># mkdir /var/log/nginx/<br/>编辑nginx配置文件<br/># ee /usr/local/etc/nginx/nginx.conf<br/>写入下面内容<br/>user &nbsp;www www;<br/>worker_processes 8;<br/>worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;<br/>worker_rlimit_nofile 204800;<br/><br/>#error_log &nbsp;logs/error.log;<br/>#error_log &nbsp;logs/error.log &nbsp;notice;<br/>#error_log &nbsp;logs/error.log &nbsp;info;<br/><br/>pid &nbsp; &nbsp; &nbsp; &nbsp;/var/run/nginx.pid;<br/><br/><br/>events {<br/> &nbsp; &nbsp;use kqueue;<br/> &nbsp; &nbsp;multi_accept on;<br/> &nbsp; &nbsp;worker_connections &nbsp;204800;<br/>}<br/><br/><br/>http {<br/> &nbsp; &nbsp;server_tokens off;<br/> &nbsp; &nbsp;sendfile on;<br/> &nbsp; &nbsp;tcp_nopush on;<br/> &nbsp; &nbsp;tcp_nodelay on;<br/><br/> &nbsp; &nbsp;access_log off;<br/> &nbsp; &nbsp;error_log /var/log/nginx/error.log crit;<br/><br/> &nbsp; &nbsp;keepalive_timeout 60;<br/> &nbsp; &nbsp;client_header_timeout 10;<br/> &nbsp; &nbsp;client_body_timeout 10;<br/> &nbsp; &nbsp;reset_timedout_connection on;<br/> &nbsp; &nbsp;send_timeout 10;<br/><br/> &nbsp; &nbsp;limit_conn_zone $binary_remote_addr zone=addr:5m;<br/> &nbsp; &nbsp;limit_conn addr 100;<br/><br/> &nbsp; &nbsp;include mime.types;<br/> &nbsp; &nbsp;default_type application/octet-stream;<br/> &nbsp; &nbsp;charset UTF-8;<br/><br/> &nbsp; &nbsp;gzip on;<br/> &nbsp; &nbsp;gzip_disable "msie6";<br/> &nbsp; &nbsp;gzip_proxied any;<br/> &nbsp; &nbsp;gzip_min_length 1k;<br/> &nbsp; &nbsp;gzip_buffers 4 16k;<br/> &nbsp; &nbsp;gzip_comp_level 6;<br/> &nbsp; &nbsp;gzip_vary on;<br/> &nbsp; &nbsp;gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;<br/><br/> &nbsp; &nbsp;open_file_cache max=204800 inactive=20s;<br/> &nbsp; &nbsp;open_file_cache_valid 30s;<br/> &nbsp; &nbsp;open_file_cache_min_uses 2;<br/> &nbsp; &nbsp;open_file_cache_errors on;<br/> &nbsp; &nbsp;server_names_hash_bucket_size 128;<br/> &nbsp; &nbsp;client_header_buffer_size 2k;<br/> &nbsp; &nbsp;large_client_header_buffers 4 4k;<br/> &nbsp; &nbsp;client_max_body_size 8m;<br/> &nbsp; &nbsp;fastcgi_connect_timeout 300;<br/> &nbsp; &nbsp;fastcgi_send_timeout 300;<br/> &nbsp; &nbsp;fastcgi_read_timeout 300;<br/> &nbsp; &nbsp;fastcgi_buffer_size 4k;<br/> &nbsp; &nbsp;fastcgi_buffers 8 4k;<br/> &nbsp; &nbsp;fastcgi_busy_buffers_size 8k;<br/> &nbsp; &nbsp;fastcgi_temp_file_write_size 8k;<br/> &nbsp; &nbsp;fastcgi_cache_valid 200 302 1h;<br/> &nbsp; &nbsp;fastcgi_cache_valid 301 1d;<br/> &nbsp; &nbsp;fastcgi_cache_valid any 1m;<br/> &nbsp; &nbsp;fastcgi_cache_min_uses 1;<br/> &nbsp; &nbsp;upstream fastcgi_backend {<br/> &nbsp; &nbsp; &nbsp; &nbsp;server 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; &nbsp;keepalive 60;<br/> &nbsp; &nbsp;}<br/> &nbsp; &nbsp;#include &nbsp; &nbsp; &nbsp; mime.types;<br/> &nbsp; &nbsp;#default_type &nbsp;application/octet-stream;<br/><br/> &nbsp; &nbsp;#log_format &nbsp;main &nbsp;'$remote_addr - $remote_user [$time_local] "$request" '<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'$status $body_bytes_sent "$http_referer" '<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'"$http_user_agent" "$http_x_forwarded_for"';<br/><br/> &nbsp; &nbsp;#access_log &nbsp;logs/access.log &nbsp;main;<br/><br/> &nbsp; &nbsp;#sendfile &nbsp; &nbsp; &nbsp; &nbsp;on;<br/> &nbsp; &nbsp;#tcp_nopush &nbsp; &nbsp; on;<br/><br/> &nbsp; &nbsp;#keepalive_timeout &nbsp;0;<br/> &nbsp; &nbsp;#keepalive_timeout &nbsp;65;<br/><br/> &nbsp; &nbsp;#gzip &nbsp;on;<br/><br/> &nbsp; &nbsp;server {<br/> &nbsp; &nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 80;<br/> &nbsp; &nbsp; &nbsp; &nbsp;server_name &nbsp;localhost;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;#charset koi8-r;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;#access_log &nbsp;logs/host.access.log &nbsp;main;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;location / {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; /usr/local/www/nginx;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm index.php;<br/> &nbsp; &nbsp; &nbsp;#try_files $uri $uri/ /index.php$uri?$args;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;#error_page &nbsp;404 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/404.html;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;# redirect server error pages to the static page /50x.html<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;error_page &nbsp; 500 502 503 504 &nbsp;/50x.html;<br/> &nbsp; &nbsp; &nbsp; &nbsp;location = /50x.html {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; /usr/local/www/nginx-dist;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp;location ~ ^/(status)$ {<br/> &nbsp; &nbsp; &nbsp; access_log off;<br/> &nbsp; &nbsp; &nbsp; include fastcgi_params;<br/> &nbsp; &nbsp; &nbsp; fastcgi_pass 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; fastcgi_param SCRIPT_FILENAME /usr/loca/www/nginx$fastcgi_script_name;<br/> &nbsp;}<br/><br/> &nbsp;location /myadmin {<br/> &nbsp; &nbsp; &nbsp; alias /usr/local/www/phpMyAdmin;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index index.php;<br/> &nbsp;}<br/> &nbsp;location ~ /myadmin/.+&#92;.php$ {<br/> &nbsp; &nbsp; &nbsp; if ($fastcgi_script_name ~ /myadmin/(.+&#92;.php.*)$) {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; set $valid_fastcgi_script_name $1;<br/> &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; include fastcgi_params;<br/> &nbsp; &nbsp; &nbsp; fastcgi_pass &nbsp; 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; fastcgi_index &nbsp;index.php;<br/> &nbsp; &nbsp; &nbsp; fastcgi_param SCRIPT_FILENAME /usr/local/www/phpMyAdmin/$valid_fastcgi_script_name;<br/> &nbsp;}<br/> &nbsp; &nbsp; &nbsp; &nbsp;# proxy the PHP scripts to Apache listening on 127.0.0.1:80<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;#location ~ &#92;.php$ {<br/> &nbsp; &nbsp; &nbsp; &nbsp;# &nbsp; &nbsp;proxy_pass &nbsp; http://127.0.0.1;<br/> &nbsp; &nbsp; &nbsp; &nbsp;#}<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;location ~ &#92;.php$ {<br/> &nbsp; &nbsp; &nbsp;fastcgi_pass 127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp;fastcgi_index index.php;<br/> &nbsp; &nbsp; &nbsp;include fastcgi_params;<br/> &nbsp; &nbsp; &nbsp;fastcgi_split_path_info ^(.+&#92;.php)(/?.*)$;<br/> &nbsp; &nbsp; &nbsp;fastcgi_param PATH_INFO $fastcgi_path_info; &nbsp; &nbsp; &nbsp; &nbsp;<br/> &nbsp; &nbsp; &nbsp;fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#root &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html;<br/> &nbsp; &nbsp; &nbsp;#fastcgi_pass fastcgi_backend;<br/> &nbsp; &nbsp; &nbsp;#fastcgi_keep_conn on;<br/> &nbsp; &nbsp; &nbsp; &nbsp;}<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp;# deny access to .htaccess files, if Apache's document root<br/> &nbsp; &nbsp; &nbsp; &nbsp;# concurs with nginx's one<br/> &nbsp; &nbsp; &nbsp; &nbsp;#<br/> &nbsp; &nbsp; &nbsp; &nbsp;#location ~ /&#92;.ht {<br/> &nbsp; &nbsp; &nbsp; &nbsp;# &nbsp; &nbsp;deny &nbsp;all;<br/> &nbsp; &nbsp; &nbsp; &nbsp;#}<br/> &nbsp; &nbsp;}<br/><br/><br/> &nbsp; &nbsp;# another virtual host using mix of IP-, name-, and port-based configuration<br/> &nbsp; &nbsp;#<br/> &nbsp; &nbsp;#server {<br/> &nbsp; &nbsp;# &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 8000;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; somename:8080;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;server_name &nbsp;somename &nbsp;alias &nbsp;another.alias;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;location / {<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; html;<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;}<br/> &nbsp; &nbsp;#}<br/><br/><br/> &nbsp; &nbsp;# HTTPS server<br/> &nbsp; &nbsp;#<br/> &nbsp; &nbsp;#server {<br/> &nbsp; &nbsp;# &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; 443 ssl;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;server_name &nbsp;localhost;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_certificate &nbsp; &nbsp; &nbsp;cert.pem;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_certificate_key &nbsp;cert.key;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_session_cache &nbsp; &nbsp;shared:SSL:1m;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_session_timeout &nbsp;5m;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_ciphers &nbsp;HIGH:!aNULL:!MD5;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;ssl_prefer_server_ciphers &nbsp;on;<br/><br/> &nbsp; &nbsp;# &nbsp; &nbsp;location / {<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;root &nbsp; html;<br/> &nbsp; &nbsp;# &nbsp; &nbsp; &nbsp; &nbsp;index &nbsp;index.html index.htm;<br/> &nbsp; &nbsp;# &nbsp; &nbsp;}<br/> &nbsp; &nbsp;#}<br/><br/>}<br/>启动nginx<br/># service nginx start</div></div><br/>测试是否工作正常<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"># ee /usr/local/www/nginx/info.php<br/>写入下面的内容<br/><div class="code">&lt;?php phpinfo(); ?&gt;</div><br/>用浏览器访问http://IP/info.php，如果能看到就说明工作正常了。</div></div><br/>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?627</link>
<title><![CDATA[JS得到窗口高度和屏幕高度]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[Javascript]]></category>
<pubDate>Tue, 14 Jan 2014 05:40:24 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?627</guid> 
<description>
<![CDATA[ 
	<br/><div class="code">&lt;SCRIPT &nbsp; LANGUAGE=&quot;JavaScript&quot;&gt; &nbsp;<br/>var s = &quot;网页可见区域宽 ：&quot;+ document.body.clientWidth; &nbsp;<br/>s += &quot;&#92;r&#92;n网页可见区域高：&quot;+ document.body.clientHeight; &nbsp; <br/>s += &quot;&#92;r&#92;n网页可见区域高：&quot;+ document.body.offsetHeight +&quot; (包括边线的宽)&quot;; &nbsp;<br/>s += &quot;&#92;r&#92;n网页正文全文宽：&quot;+ document.body.scrollWidth; &nbsp;<br/>s += &quot;&#92;r&#92;n网页正文全文高：&quot;+ document.body.scrollHeight; &nbsp;<br/>s += &quot;&#92;r&#92;n网页被卷去的高：&quot;+ document.body.scrollTop; &nbsp;<br/>s += &quot;&#92;r&#92;n网页被卷去的左：&quot;+ document.body.scrollLeft; &nbsp;<br/>s += &quot;&#92;r&#92;n网页正文部分上：&quot;+ window.screenTop; &nbsp;<br/>s += &quot;&#92;r&#92;n网页正文部分左：&quot;+ window.screenLeft; &nbsp;<br/>s += &quot;&#92;r&#92;n屏幕分辨率的高：&quot;+ window.screen.height; &nbsp;<br/>s += &quot;&#92;r&#92;n屏幕分辨率的宽：&quot;+ window.screen.width; &nbsp;<br/>s += &quot;&#92;r&#92;n屏幕可用工作区高度：&quot;+ window.screen.availHeight; &nbsp;<br/>s += &quot;&#92;r&#92;n屏幕可用工作区宽度：&quot;+ window.screen.availWidth; &nbsp;<br/>alert(s); <br/>&lt;/SCRIPT&gt; </div><br/>Tags - <a href="tag.php?tag=javascript" rel="tag">javascript</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?626</link>
<title><![CDATA[MySQL笔记之视图的使用详解]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[MySQL]]></category>
<pubDate>Mon, 30 Dec 2013 17:41:31 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?626</guid> 
<description>
<![CDATA[ 
	使用视图的大部分情况是为了保障数据安全性，提高查询效率 <br/>什么是视图 <br/><br/>视图是从一个或多个表中导出来的表，是一种虚拟存在的表。<br/><br/>视图就像一个窗口，通过这个窗口可以看到系统专门提供的数据。<br/><br/>这样，用户可以不用看到整个数据库中的数据，而之关心对自己有用的数据。<br/><br/>数据库中只存放了视图的定义，而没有存放视图中的数据，这些数据存放在原来的表中。<br/><br/>使用视图查询数据时，数据库系统会从原来的表中取出对应的数据。<br/><br/>视图中的数据依赖于原来表中的数据，一旦表中数据发生改变，显示在视图中的数据也会发生改变。<br/><br/> <br/><br/>视图的作用 <br/><br/>1.使操作简单化，可以对经常使用的查询定义一个视图，使用户不必为同样的查询操作指定条件<br/><br/>2.增加数据的安全性，通过视图，用户只能查询和修改指定的数据。<br/><br/>3.提高表的逻辑独立性，视图可以屏蔽原有表结构变化带来的影响。<br/><br/> <br/><br/>总而言之，使用视图的大部分情况是为了保障数据安全性，提高查询效率<br/><br/> <br/><br/>参考表：<br/><br/><br/><br/><br/><br/>创建视图的语法<br/><br/><br/>复制代码 代码如下:<br/>CREATE [ALGORITHM]={UNDEFINED&#124;MERGE&#124;TEMPTABLE}]<br/> &nbsp; &nbsp; &nbsp; VIEW 视图名 [(属性清单)]<br/> &nbsp; &nbsp; &nbsp; AS SELECT 语句<br/> &nbsp; &nbsp; &nbsp; [WITH [CASCADED&#124;LOCAL] CHECK OPTION];<br/><br/>ALGORITHM表示视图选择的算法（可选参数）<br/><br/> &nbsp; &nbsp;　　UNDEFINED：MySQL将自动选择所要使用的算法<br/> &nbsp; &nbsp;　　MERGE：将视图的语句与视图定义合并起来，使得视图定义的某一部分取代语句的对应部分<br/> &nbsp; &nbsp;　　TEMPTABLE：将视图的结果存入临时表，然后使用临时表执行语句<br/><br/>视图名表示要创建的视图的名称<br/><br/>属性清单表示视图中的列名，默认与SELECT查询结果中的列名相同（可选参数）<br/><br/>WITH CHECK OPTION表示更新视图时要保证在该试图的权限范围之内（可选参数）<br/><br/> &nbsp; &nbsp;　　CASCADED：更新视图时要满足所有相关视图和表的条件<br/> &nbsp; &nbsp;　　LOCAL：更新视图时，要满足该视图本身定义的条件即可<br/><br/> <br/><br/>tips：创建试图时最好加上WITH CASCADED CHECK OPTION参数，这种方式比较严格<br/><br/>　　 &nbsp; 可以保证数据的安全性<br/><br/><br/>视图操作<br/>在单表上创建视图<br/><br/><br/>复制代码 代码如下:<br/>mysql> CREATE VIEW work_view(ID,NAME,ADDR) AS SELECT id,name,address FROM work; &nbsp;<br/>Query OK, 0 rows affected (0.05 sec)<br/><br/>此处work_view为视图名，后面括号内的参数代表视图中的列<br/><br/>AS表示将后面SELECT 语句中的查询结果赋给前面的视图中<br/><br/>在多表上创建视图<br/><br/><br/>复制代码 代码如下:<br/>mysql> CREATE ALGORITHM=MERGE VIEW work_view2(ID,NAME,SALARY)<br/> &nbsp; &nbsp;-> AS SELECT work.id,name,salary FROM work,salary<br/> &nbsp; &nbsp;-> WHERE work.id=salary.id<br/> &nbsp; &nbsp;-> WITH LOCAL CHECK OPTION;<br/>Query OK, 0 rows affected (0.02 sec)<br/><br/>在多表中创建视图需要两表有指定联系，如上面的work.id=salary.id<br/><br/><br/>SELECT查询视图<br/><br/><br/>复制代码 代码如下:<br/>mysql> SELECT * FROM work_view;<br/>+----+--------+--------+<br/>&#124; ID &#124; NAME &nbsp; &#124; ADDR &nbsp; &#124;<br/>+----+--------+--------+<br/>&#124; &nbsp;1 &#124; 张三 &nbsp; &#124; 北京 &nbsp; &#124;<br/>&#124; &nbsp;2 &#124; 李四 &nbsp; &#124; 上海 &nbsp; &#124;<br/>&#124; &nbsp;3 &#124; 王五 &nbsp; &#124; 湖南 &nbsp; &#124;<br/>&#124; &nbsp;4 &#124; 赵六 &nbsp; &#124; 重庆 &nbsp; &#124;<br/>+----+--------+--------+<br/> rows in set (0.00 sec)<br/><br/>此处的SELECT语句用法和其他表中的用法一样<br/><br/>别忘了，视图也是一张表，只不过它是虚拟的<br/><br/><br/>DESCRIBE查看视图基本信息<br/><br/><br/>复制代码 代码如下:<br/>mysql> DESCRIBE work_view;<br/>+-------+-------------+------+-----+---------+-------+<br/>&#124; Field &#124; Type &nbsp; &nbsp; &nbsp; &nbsp;&#124; Null &#124; Key &#124; Default &#124; Extra &#124;<br/>+-------+-------------+------+-----+---------+-------+<br/>&#124; ID &nbsp; &nbsp;&#124; int(10) &nbsp; &nbsp; &#124; NO &nbsp; &#124; &nbsp; &nbsp; &#124; NULL &nbsp; &nbsp;&#124; &nbsp; &nbsp; &nbsp; &#124;<br/>&#124; NAME &nbsp;&#124; varchar(20) &#124; NO &nbsp; &#124; &nbsp; &nbsp; &#124; NULL &nbsp; &nbsp;&#124; &nbsp; &nbsp; &nbsp; &#124;<br/>&#124; ADDR &nbsp;&#124; varchar(50) &#124; YES &nbsp;&#124; &nbsp; &nbsp; &#124; NULL &nbsp; &nbsp;&#124; &nbsp; &nbsp; &nbsp; &#124;<br/>+-------+-------------+------+-----+---------+-------+<br/> rows in set (0.00 sec)<br/><br/>与以往一样，此处的DESCRIBE可以简写为DESC<br/><br/><br/>SHOW TABLE STATUS查看视图基本信息<br/><br/><br/>复制代码 代码如下:<br/>mysql> SHOW TABLE STATUS LIKE 'work_view'&#92;G<br/>*************************** 1. row ***************************<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Name: work_view<br/> &nbsp; &nbsp; &nbsp; &nbsp; Engine: NULL<br/> &nbsp; &nbsp; &nbsp; &nbsp;Version: NULL<br/> &nbsp; &nbsp; Row_format: NULL<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Rows: NULL<br/> Avg_row_length: NULL<br/> &nbsp; &nbsp;Data_length: NULL<br/>Max_data_length: NULL<br/> &nbsp; Index_length: NULL<br/> &nbsp; &nbsp; &nbsp;Data_free: NULL<br/> Auto_increment: NULL<br/> &nbsp; &nbsp;Create_time: NULL<br/> &nbsp; &nbsp;Update_time: NULL<br/> &nbsp; &nbsp; Check_time: NULL<br/> &nbsp; &nbsp; &nbsp;Collation: NULL<br/> &nbsp; &nbsp; &nbsp; Checksum: NULL<br/> Create_options: NULL<br/> &nbsp; &nbsp; &nbsp; &nbsp;Comment: VIEW<br/> row in set (0.00 sec)<br/><br/>此处大部分信息显示为NULL，更加说明了视图只是一张虚拟表<br/><br/>如果使用SHOW TABLE STATUS查看一张真实表，结果就不会如此<br/><br/>SHOW CREATE VIEW查看视图详细信息<br/><br/><br/>复制代码 代码如下:<br/>mysql> SHOW CREATE VIEW work_view&#92;G<br/>*************************** 1. row ***************************<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;View: work_view<br/> &nbsp; &nbsp; &nbsp; &nbsp; Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `work_view` AS select `work`.`id` AS `ID`,`work`.`name` AS `NAME`,`work`.`address` AS `ADDR` from `work`<br/>character_set_client: utf8<br/>collation_connection: utf8_general_ci<br/> row in set (0.00 sec)<br/><br/>尼玛好复杂，这里包含了视图的各个属性<br/><br/>在views表中查看视图详细信息<br/>复制代码 代码如下:<br/>mysql> SELECT * FROM information_schema.views&#92;G<br/>*************************** 1. row ***************************<br/> &nbsp; &nbsp; &nbsp; TABLE_CATALOG: def<br/> &nbsp; &nbsp; &nbsp; &nbsp;TABLE_SCHEMA: person<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TABLE_NAME: work_view<br/> &nbsp; &nbsp; VIEW_DEFINITION: select `person`.`work`.`id` AS `ID`,`person`.`work`.`name` AS `NAME`,`person`.`work`.`address` AS `ADDR` from `person`.`work`<br/> &nbsp; &nbsp; &nbsp; &nbsp;CHECK_OPTION: NONE<br/> &nbsp; &nbsp; &nbsp; &nbsp;IS_UPDATABLE: YES<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DEFINER: root@localhost<br/> &nbsp; &nbsp; &nbsp; SECURITY_TYPE: DEFINER<br/>CHARACTER_SET_CLIENT: utf8<br/>COLLATION_CONNECTION: utf8_general_ci<br/>*************************** 2. row ***************************<br/> &nbsp; &nbsp; &nbsp; TABLE_CATALOG: def<br/> &nbsp; &nbsp; &nbsp; &nbsp;TABLE_SCHEMA: person<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TABLE_NAME: work_view2<br/><br/>information_schema.views表内包含了所有的视图定义信息<br/><br/>不过，通常使用SHOW CREATE VIEW 更加方便<br/><br/>这里信息太长，没有完全列举……<br/><br/><br/>修改视图<br/><br/>修改视图是指修改数据库中已存在的表的定义，当基本表的某些字段发生改变时，可以通过修改视图来保持视图和基本表之间一致<br/>CREATE OR REPLACE VIEW语句修改视图<br/><br/><br/>复制代码 代码如下:<br/>mysql> CREATE OR REPLACE ALGORITHM=TEMPTABLE<br/> &nbsp; &nbsp;-> VIEW work_view(ID,NAME) <br/> &nbsp; &nbsp;-> AS SELECT id,name FROM work;<br/>Query OK, 0 rows affected (0.03 sec)<br/><br/>话说，CREATE OR REPLACE语句非常灵活<br/><br/>在视图存在的情况下可对视图进行修改，视图不在的情况下可创建视图<br/><br/>其基本用法和CREATE VIEW 几乎一致<br/><br/><br/>ALTER语句修改视图<br/><br/><br/>复制代码 代码如下:<br/>mysql> ALTER VIEW work_view2(NAME,SALARY,ADDR)<br/> &nbsp; &nbsp;-> AS SELECT name,salary,address FROM work,salary<br/> &nbsp; &nbsp;-> WHERE work.id=salary.id;<br/>Query OK, 0 rows affected (0.03 sec)<br/><br/>我这把名字、工资和地址当做字段修改了视图<br/><br/>如果是真实的话，对小偷来说极为方便<br/><br/>更新视图<br/><br/>更新视图是指通过视图来插入、更新和删除表中的数据，以为视图是一个虚拟表，其中木有数据<br/><br/>通过视图更新时，都是转换到基本表来更新<br/><br/><br/>复制代码 代码如下:<br/>mysql> UPDATE work_view2 SET SALARY=5899.00 WHERE NAME='张三';<br/>Query OK, 1 row affected (0.03 sec)<br/>Rows matched: 1 &nbsp;Changed: 1 &nbsp;Warnings: 0<br/><br/>此处语句等价于<br/>复制代码 代码如下:<br/>mysql> UPDATE salary SET salary=5899.00 WHERE id=1;<br/><br/>tips:视图中虽然可以更新数据，但是有很多限制<br/><br/>　　 一般情况下，最好将视图作为查询数据的虚拟表，而不要通过视图更新数据<br/><br/><br/>删除视图<br/><br/>删除视图是指删除数据库中已存在的视图，删除视图时，只能删除视图的定义，不会删除数据<br/><br/><br/>复制代码 代码如下:<br/>mysql> DROP VIEW IF EXISTS work_view;<br/>Query OK, 0 rows affected (0.00 sec)<br/><br/>mysql> DROP VIEW work_view2;<br/>Query OK, 0 rows affected (0.01 sec)<br/><br/><br/>这里的IF EXIST参数用来判断视图是否存在，也可以不写<br/><br/>Tags - <a href="tag.php?tag=mysql" rel="tag">mysql</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?625</link>
<title><![CDATA[MySQL笔记之触发器的应用]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[MySQL]]></category>
<pubDate>Mon, 30 Dec 2013 17:40:28 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?625</guid> 
<description>
<![CDATA[ 
	触发器是由事件来触发某个操作，这些事件包括INSERT语句，UPDATE语句和DELETE语句 <br/>创建触发器<br/><br/>创建只有一个执行语句的触发器<br/><br/><br/>复制代码 代码如下:<br/>CREATE TRIGGER 触发器名 BEFORE&#124;AFTER 触发事件<br/>ON 表名 FOR EACH ROW 执行语句<br/><br/>其中，触发器名参数指要创建的触发器的名字<br/><br/>BEFORE和AFTER参数指定了触发执行的时间，在事件之前或是之后<br/><br/>FOR EACH ROW表示任何一条记录上的操作满足触发事件都会触发该触发器<br/><br/><br/>复制代码 代码如下:<br/>mysql> CREATE TRIGGER trig1 AFTER INSERT<br/> &nbsp; &nbsp;-> ON work FOR EACH ROW<br/> &nbsp; &nbsp;-> INSERT INTO time VALUES(NOW());<br/>Query OK, 0 rows affected (0.09 sec)<br/><br/>上面创建了一个名为trig1的触发器，一旦在work中有插入动作，就会自动往time表里插入当前时间<br/><br/><br/>创建有多个执行语句的触发器<br/><br/><br/>复制代码 代码如下:<br/>CREATE TRIGGER 触发器名 BEFORE&#124;AFTER 触发事件<br/>ON 表名 FOR EACH ROW<br/>BEGIN<br/> &nbsp; &nbsp;执行语句列表<br/>END<br/><br/>其中，BEGIN与END之间的执行语句列表参数表示需要执行的多个语句，不同语句用分号隔开<br/><br/>tips：一般情况下，mysql默认是以 ; 作为结束执行语句，与触发器中需要的分行起冲突<br/><br/>　　 &nbsp; 为解决此问题可用DELIMITER，如：DELIMITER &#124;&#124;，可以将结束符号变成&#124;&#124;<br/><br/>　　 &nbsp; 当触发器创建完成后，可以用DELIMITER ;来将结束符号变成;<br/><br/><br/>复制代码 代码如下:<br/>mysql> DELIMITER &#124;&#124;<br/>mysql> CREATE TRIGGER trig2 BEFORE DELETE<br/> &nbsp; &nbsp;-> ON work FOR EACH ROW<br/> &nbsp; &nbsp;-> BEGIN<br/> &nbsp; &nbsp;-> INSERT INTO time VALUES(NOW());<br/> &nbsp; &nbsp;-> INSERT INTO time VALUES(NOW());<br/> &nbsp; &nbsp;-> END<br/> &nbsp; &nbsp;-> &#124;&#124;<br/>Query OK, 0 rows affected (0.06 sec)<br/><br/>mysql> DELIMITER ;<br/><br/><br/>上面的语句中，开头将结束符号定义为&#124;&#124;，中间定义一个触发器，一旦有满足条件的删除操作<br/><br/>就会执行BEGIN和END中的语句，接着使用&#124;&#124;结束<br/><br/>最后使用DELIMITER ; 将结束符号还原<br/><br/><br/>查看触发器<br/>SHOW TRIGGERS语句查看触发器信息<br/><br/><br/>复制代码 代码如下:<br/>mysql> SHOW TRIGGERS&#92;G;<br/>*************************** 1. row ***************************<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Trigger: trig1<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Event: INSERT<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Table: work<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Statement: INSERT INTO time VALUES(NOW())<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Timing: AFTER<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Created: NULL<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sql_mode: <br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Definer: root@localhost<br/>character_set_client: utf8<br/>collation_connection: utf8_general_ci<br/> &nbsp;Database Collation: latin1_swedish_ci<br/><br/>结果会显示所有触发器的基本信息<br/><br/>tips：SHOW TRIGGERS语句无法查询指定的触发器<br/><br/><br/>在triggers表中查看触发器信息<br/><br/><br/>复制代码 代码如下:<br/>mysql> SELECT * FROM information_schema.triggers&#92;G<br/>*************************** 1. row ***************************<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TRIGGER_CATALOG: def<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRIGGER_SCHEMA: person<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRIGGER_NAME: trig1<br/> &nbsp; &nbsp; &nbsp; &nbsp;EVENT_MANIPULATION: INSERT<br/> &nbsp; &nbsp; &nbsp;EVENT_OBJECT_CATALOG: def<br/> &nbsp; &nbsp; &nbsp; EVENT_OBJECT_SCHEMA: person<br/> &nbsp; &nbsp; &nbsp; &nbsp;EVENT_OBJECT_TABLE: work<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ACTION_ORDER: 0<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ACTION_CONDITION: NULL<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ACTION_STATEMENT: INSERT INTO time VALUES(NOW())<br/><br/>结果显示了所有触发器的详细信息，同时，该方法可以查询制定触发器的详细信息<br/>复制代码 代码如下:<br/>mysql> SELECT * FROM information_schema.triggers WHERE TRIGGER_NAME='trig1'&#92;G<br/>*************************** 1. row ***************************<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TRIGGER_CATALOG: def<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRIGGER_SCHEMA: person<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TRIGGER_NAME: trig1<br/> &nbsp; &nbsp; &nbsp; &nbsp;EVENT_MANIPULATION: INSERT<br/> &nbsp; &nbsp; &nbsp;EVENT_OBJECT_CATALOG: def<br/> &nbsp; &nbsp; &nbsp; EVENT_OBJECT_SCHEMA: person<br/> &nbsp; &nbsp; &nbsp; &nbsp;EVENT_OBJECT_TABLE: work<br/><br/>tips：所有触发器信息都存储在information_schema数据库下的triggers表中<br/><br/>　　 &nbsp; 可以使用SELECT语句查询，如果触发器信息过多，最好通过TRIGGER_NAME字段指定查询<br/><br/><br/>删除触发器<br/><br/><br/>复制代码 代码如下:<br/>mysql> DROP TRIGGER trig1;<br/>Query OK, 0 rows affected (0.04 sec)<br/><br/>删除触发器之后最好使用上面的方法查看一遍<br/><br/>同时，也可以使用database.trig来指定某个数据库中的触发器<br/><br/>tips：如果不需要某个触发器时一定要将这个触发器删除，以免造成意外操作<br/><br/>Tags - <a href="tag.php?tag=mysql" rel="tag">mysql</a> , <a href="tag.php?tag=%E8%A7%A6%E5%8F%91%E5%99%A8" rel="tag">触发器</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?624</link>
<title><![CDATA[上海网务公司在桂林建立实训基地]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[ArthurXF介绍]]></category>
<pubDate>Mon, 21 Oct 2013 22:52:39 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?624</guid> 
<description>
<![CDATA[ 
	上海网务网络信息有限公司，2004年6月成立于上海，是上海市科委认证的高新技术企业。上海网务网络信息有限公司有着非凡的技术设计能力，自主研发了 ArthurXF &nbsp;PHP开发框架，并在ArthurXF开发框架之上研发了BIWEB商务智能网站系统，BIWEB是经过不断的在各种大型项目中实践、总结、开发设计出来 的一个快速开发、简单易用的面向对象的企业应用级PHP MVC建站系统。BIWEB自2005年开源推出后，BIWEB网站系统在经历了多次重大版本升级之后，至2013年8月BIWEB推出webapp版 本，标志着BIWEB从电脑网站系统正式步入移动端应用系统时代。<br/> <br/>上海网务公司在行业中发展多年，发现目前行业人才奇缺，招聘来的人员都需要再培训不能直接上岗，遂在上海、桂林、东莞等多地设立实习训练基地，为本公司及行业培养大量直接跟行业接轨的人才。上海网务公司设置的实训课程，直接按照工作岗位设立，完成实训课程即可就业。上海网务公司在行业内积累了大量人脉和口 碑，同行前来招聘络绎不绝，实训人员供不应求。如您有朋友想加入IT行业，请推荐来上海网务公司实训，上海网务公司对实训完成的学生可以解决上海就业。<br/> <br/><br/><br/><br/><br/>BIWEB上海实训基地<br/> 1.上海市徐汇区漕溪路165号华谊党校1203室<br/> 2.上海黄浦区打浦路8号海华商厦2楼225室<br/> <br/>BIWEB东莞实训基地<br/> 东莞市南城区西平二路弥珍道3栋306室<br/> 电话：0769-23889935<br/> <br/>BIWEB桂林实训基地<br/> 桂林市雁山区果园村委旁二楼<br/> 电话：13367735767<br/> <br/>实训基地加盟联系方式<br/> 联系人：肖飞<br/> 电话：13124812420 <br/><br/>Tags - <a href="tag.php?tag=%E5%AE%9E%E8%AE%AD" rel="tag">实训</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?623</link>
<title><![CDATA[mysql分表，分区的区别和关系]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[MySQL]]></category>
<pubDate>Sat, 27 Jul 2013 09:40:16 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?623</guid> 
<description>
<![CDATA[ 
	一，什么是mysql分表，分区<br/><br/>什么是分表，从表面意思上看呢，就是把一张表分成N多个小表，具体请看mysql分表的3种方法<br/><br/>什么是分区，分区呢就是把一张表的数据分成N多个区块，这些区块可以在同一个磁盘上，也可以在不同的磁盘上，具体请参考mysql分区功能详细介绍，以及实例<br/><br/>二，mysql分表和分区有什么区别呢<br/><br/>1，实现方式上<br/><br/>a），mysql的分表是真正的分表，一张表分成很多表后，每一个小表都是完正的一张表，都对应三个文件，一个.MYD数据文件，.MYI索引文件，.frm表结构文件。<br/><br/>view sourceprint?1 [root@BlackGhost test]# ls &#124;grep user &nbsp; &nbsp;<br/><br/>2 alluser.MRG &nbsp; &nbsp;<br/><br/>3 alluser.frm &nbsp; &nbsp;<br/><br/>4 user1.MYD &nbsp; &nbsp;<br/><br/>5 user1.MYI &nbsp; &nbsp;<br/><br/>6 user1.frm &nbsp; &nbsp;<br/><br/>7 user2.MYD &nbsp; &nbsp;<br/><br/>8 user2.MYI &nbsp; &nbsp;<br/><br/>9 user2.frm <br/><br/>简单说明一下，上面的分表呢是利用了merge存储引擎（分表的一种），alluser是总表，下面有二个分表，user1，user2。他们二个都是独立的表，取数据的时候，我们可以通过总表来取。这里总表是没有.MYD,.MYI这二个文件的，也就是说，总表他不是一张表，没有数据，数据都放在分表里面。我们来看看.MRG到底是什么东西<br/><br/>view sourceprint?1 [root@BlackGhost test]# cat alluser.MRG &#124;more &nbsp; &nbsp;<br/><br/>2 user1 &nbsp; &nbsp;<br/><br/>3 user2 &nbsp; &nbsp;<br/><br/>4 #INSERT_METHOD=LAST <br/><br/>从上面我们可以看出，alluser.MRG里面就存了一些分表的关系，以及插入数据的方式。可以把总表理解成一个外壳，或者是联接池。<br/><br/>b），分区不一样，一张大表进行分区后，他还是一张表，不会变成二张表，但是他存放数据的区块变多了。<br/><br/>view sourceprint?1 [root@BlackGhost test]# ls &#124;grep aa &nbsp; &nbsp;<br/><br/>2 aa#P#p1.MYD &nbsp; &nbsp;<br/><br/>3 aa#P#p1.MYI &nbsp; &nbsp;<br/><br/>4 aa#P#p3.MYD &nbsp; &nbsp;<br/><br/>5 aa#P#p3.MYI &nbsp; &nbsp;<br/><br/>6 aa.frm &nbsp; &nbsp;<br/><br/>7 aa.par <br/><br/>从上面我们可以看出，aa这张表，分为二个区，p1和p3，本来是三个区，被我删了一个区。我们都知道一张表对应三个文件.MYD,.MYI,.frm。分区呢根据一定的规则把数据文件和索引文件进行了分割，还多出了一个.par文件，打开.par文件后你可以看出他记录了，这张表的分区信息，根分表中的.MRG有点像。分区后，还是一张，而不是多张表。<br/><br/>2，数据处理上<br/><br/>a），分表后，数据都是存放在分表里，总表只是一个外壳，存取数据发生在一个一个的分表里面。看下面的例子：<br/><br/>select * from alluser where id=’12′表面上看，是对表alluser进行操作的，其实不是的。是对alluser里面的分表进行了操作。<br/><br/>b），分区呢，不存在分表的概念，分区只不过把存放数据的文件分成了许多小块，分区后的表呢，还是一张表。数据处理还是由自己来完成。<br/><br/>3，提高性能上<br/><br/>a），分表后，单表的并发能力提高了，磁盘I/O性能也提高了。并发能力为什么提高了呢，因为查寻一次所花的时间变短了，如果出现高并发的话，总表可以根据不同的查询，将并发压力分到不同的小表里面。磁盘I/O性能怎么搞高了呢，本来一个非常大的.MYD文件现在也分摊到各个小表的.MYD中去了。<br/><br/>b），mysql提出了分区的概念，我觉得就想突破磁盘I/O瓶颈，想提高磁盘的读写能力，来增加mysql性能。<br/><br/>在这一点上，分区和分表的测重点不同，分表重点是存取数据时，如何提高mysql并发能力上；而分区呢，如何突破磁盘的读写能力，从而达到提高mysql性能的目的。<br/><br/>4），实现的难易度上<br/><br/>a），分表的方法有很多，用merge来分表，是最简单的一种方式。这种方式根分区难易度差不多，并且对程序代码来说可以做到透明的。如果是用其他分表方式就比分区麻烦了。<br/><br/>b），分区实现是比较简单的，建立分区表，根建平常的表没什么区别，并且对开代码端来说是透明的。<br/><br/>三，mysql分表和分区有什么联系呢<br/><br/>1，都能提高mysql的性高，在高并发状态下都有一个良好的表面。<br/><br/>2，分表和分区不矛盾，可以相互配合的，对于那些大访问量，并且表数据比较多的表，我们可以采取分表和分区结合的方式（如果merge这种分表方式，不能和分区配合的话，可以用其他的分表试），访问量不大，但是表数据很多的表，我们可以采取分区的方式等。<br/><br/>另附一段评价：<br/>在以前，一种解决方案就是使用 MERGE<br/><br/>类型，这是一个非常方便的做饭。架构和程序基本上不用做改动，不过，它的缺点是显见的：<br/><br/>只能在相同结构的 MyISAM 表上使用 <br/>无法享受到 MyISAM 的全部功能，例如无法在 MERGE 类型上执行 FULLTEXT 搜索 <br/>它需要使用更多的文件描述符 <br/>读取索引更慢 <br/>这个时候，MySQL 5.1 中新增的分区(Partition)功能的优势也就很明显了：<br/><br/>与单个磁盘或文件系统分区相比，可以存储更多的数据 <br/>很容易就能删除不用或者过时的数据 <br/>一些查询可以得到极大的优化 <br/>涉及到 SUM()/COUNT() 等聚合函数时，可以并行进行 <br/>IO吞吐量更大 <br/>分区允许可以设置为任意大小的规则，跨文件系统分配单个表的多个部分。实际上，表的不同部分在不同的位置被存储为单独的表。<br/><br/><br/>Tags - <a href="tag.php?tag=mysql" rel="tag">mysql</a> , <a href="tag.php?tag=%E5%88%86%E8%A1%A8" rel="tag">分表</a> , <a href="tag.php?tag=%E5%88%86%E5%8C%BA" rel="tag">分区</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?622</link>
<title><![CDATA[mysql分区功能详细介绍以及实例]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[MySQL]]></category>
<pubDate>Sat, 27 Jul 2013 09:39:30 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?622</guid> 
<description>
<![CDATA[ 
	一，什么是数据库分区<br/>前段时间写过一篇关于mysql分表的的文章，下面来说一下什么是数据库分区，以mysql为例。mysql数据库中的数据是以文件的形势存在磁盘上的，默认放在/mysql/data下面（可以通过my.cnf中的datadir来查看），一张表主要对应着三个文件，一个是frm存放表结构的，一个是myd存放表数据的，一个是myi存表索引的。如果一张表的数据量太大的话，那么myd,myi就会变的很大，查找数据就会变的很慢，这个时候我们可以利用mysql的分区功能，在物理上将这一张表对应的三个文件，分割成许多个小块，这样呢，我们查找一条数据时，就不用全部查找了，只要知道这条数据在哪一块，然后在那一块找就行了。如果表的数据太大，可能一个磁盘放不下，这个时候，我们可以把数据分配到不同的磁盘里面去。<br/><br/>备注说明：上面是只对myisam存储引擎的，下面是innodb<br/>innodb的数据库的物理文件结构为：<br/><br/>.frm文件<br/><br/>.ibd文件和.ibdata文件：<br/><br/>这两种文件都是存放innodb数据的文件，之所以用两种文件来存放innodb的数据，是因为innodb的数据存储方式能够通过配置来决定是使用共享表空间存放存储数据，还是用独享表空间存放存储数据。<br/><br/>独享表空间存储方式使用.ibd文件，并且每个表一个ibd文件<br/><br/>共享表空间存储方式使用.ibdata文件，所有表共同使用一个ibdata文件<br/><br/><br/>分区的二种方式<br/>1，横向分区<br/>什么是横向分区呢？就是横着来分区了，举例来说明一下，假如有100W条数据，分成十份，前10W条数据放到第一个分区，第二个10W条数据放到第二个分区，依此类推。也就是把表分成了十分，根用merge来分表，有点像哦。取出一条数据的时候，这条数据包含了表结构中的所有字段，也就是说横向分区，并没有改变表的结构。<br/><br/>2，纵向分区<br/>什么是纵向分区呢？就是竖来分区了，举例来说明，在设计用户表的时候，开始的时候没有考虑好，而把个人的所有信息都放到了一张表里面去，这样这个表里面就会有比较大的字段，如个人简介，而这些简介呢，也许不会有好多人去看，所以等到有人要看的时候，在去查找，分表的时候，可以把这样的大字段，分开来。<br/><br/>感觉数据库的分区好像是切苹果，到底是横着切呢，还是竖着切，根据个人喜好了，mysql提供的分区属于第一种，横向分区，并且细分成很多种方式。下面将举例说明一下。<br/><br/>二，mysql的分区<br/>我觉着吧，mysql的分区只有一种方式，只不过运用不同的算法，規则将数据分配到不同的区块中而已。<br/><br/>1，mysql5.1及以上支持分区功能<br/>安装安装的时候，我们就可以查看一下<br/><br/>view sourceprint?1 [root@BlackGhost mysql-5.1.50]# ./configure --help &#124;grep -A 3 Partition &nbsp;<br/><br/>2 &nbsp;=== Partition Support === &nbsp;<br/><br/>3 &nbsp;Plugin Name: &nbsp; &nbsp; &nbsp;partition &nbsp;<br/><br/>4 &nbsp;Description: &nbsp; &nbsp; &nbsp;MySQL Partitioning Support &nbsp;<br/><br/>5 &nbsp;Supports build: &nbsp; static <br/><br/>6 &nbsp;Configurations: &nbsp; max, max-no-ndb <br/><br/>查看一下，如果发现有上面这个东西，说明他是支持分区的，默认是打开的。如果你已经安装过了mysql的话<br/><br/>view sourceprint?1 mysql> show variables like "%part%"; &nbsp;<br/><br/>2 +-------------------+-------+ &nbsp;<br/><br/>3 &#124; Variable_name &nbsp; &nbsp; &#124; Value &#124; &nbsp;<br/><br/>4 +-------------------+-------+ &nbsp;<br/><br/>5 &#124; have_partitioning &#124; YES &nbsp; &#124; &nbsp;<br/><br/>6 +-------------------+-------+ &nbsp;<br/><br/>7 1 row in set (0.00 sec) <br/><br/>查看一下变量，如果支持的话，会有上面的提示的。<br/><br/>2，range分区<br/>按照RANGE分区的表是通过如下一种方式进行分区的，每个分区包含那些分区表达式的值位于一个给定的连续区间内的行<br/><br/>view sourceprint?1 //创建range分区表 &nbsp;<br/><br/>2 mysql> CREATE TABLE IF NOT EXISTS `user` ( &nbsp;<br/><br/>3 &nbsp;-> &nbsp; `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', &nbsp;<br/><br/>4 &nbsp;-> &nbsp; `name` varchar(50) NOT NULL DEFAULT '' COMMENT '名称', &nbsp;<br/><br/>5 &nbsp;-> &nbsp; `sex` int(1) NOT NULL DEFAULT '0' COMMENT '0为男，1为女', &nbsp;<br/><br/>6 &nbsp;-> &nbsp; PRIMARY KEY (`id`) &nbsp;<br/><br/>7 &nbsp;-> ) ENGINE=MyISAM &nbsp;DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 &nbsp;<br/><br/>8 &nbsp;-> PARTITION BY RANGE (id) ( &nbsp;<br/><br/>9 &nbsp;-> &nbsp; &nbsp; PARTITION p0 VALUES LESS THAN (3), &nbsp;<br/><br/>10 &nbsp;-> &nbsp; &nbsp; PARTITION p1 VALUES LESS THAN (6), &nbsp;<br/><br/>11 &nbsp;-> &nbsp; &nbsp; PARTITION p2 VALUES LESS THAN (9), &nbsp;<br/><br/>12 &nbsp;-> &nbsp; &nbsp; PARTITION p3 VALUES LESS THAN (12), &nbsp;<br/><br/>13 &nbsp;-> &nbsp; &nbsp; PARTITION p4 VALUES LESS THAN MAXVALUE &nbsp;<br/><br/>14 &nbsp;-> ); &nbsp;<br/><br/>15 Query OK, 0 rows affected (0.13 sec) &nbsp;<br/><br/>16 &nbsp; &nbsp;<br/><br/>17 //插入一些数据 &nbsp;<br/><br/>18 mysql> INSERT INTO `test`.`user` (`name` ,`sex`)VALUES ('tank', '0') &nbsp;<br/><br/>19 &nbsp;-> ,('zhang',1),('ying',1),('张',1),('映',0),('test1',1),('tank2',1) &nbsp;<br/><br/>20 &nbsp;-> ,('tank1',1),('test2',1),('test3',1),('test4',1),('test5',1),('tank3',1) &nbsp;<br/><br/>21 &nbsp;-> ,('tank4',1),('tank5',1),('tank6',1),('tank7',1),('tank8',1),('tank9',1) &nbsp;<br/><br/>22 &nbsp;-> ,('tank10',1),('tank11',1),('tank12',1),('tank13',1),('tank21',1),('tank42',1); &nbsp;<br/><br/>23 Query OK, 25 rows affected (0.05 sec) &nbsp;<br/><br/>24 Records: 25 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>25 &nbsp; &nbsp;<br/><br/>26 //到存放数据库表文件的地方看一下，my.cnf里面有配置，datadir后面就是 &nbsp;<br/><br/>27 [root@BlackGhost test]# ls &#124;grep user &#124;xargs du -sh &nbsp;<br/><br/>28 4.0K &nbsp; &nbsp;user#P#p0.MYD &nbsp;<br/><br/>29 4.0K &nbsp; &nbsp;user#P#p0.MYI &nbsp;<br/><br/>30 4.0K &nbsp; &nbsp;user#P#p1.MYD &nbsp;<br/><br/>31 4.0K &nbsp; &nbsp;user#P#p1.MYI &nbsp;<br/><br/>32 4.0K &nbsp; &nbsp;user#P#p2.MYD &nbsp;<br/><br/>33 4.0K &nbsp; &nbsp;user#P#p2.MYI &nbsp;<br/><br/>34 4.0K &nbsp; &nbsp;user#P#p3.MYD &nbsp;<br/><br/>35 4.0K &nbsp; &nbsp;user#P#p3.MYI &nbsp;<br/><br/>36 4.0K &nbsp; &nbsp;user#P#p4.MYD &nbsp;<br/><br/>37 4.0K &nbsp; &nbsp;user#P#p4.MYI &nbsp;<br/><br/>38 12K &nbsp; &nbsp;user.frm &nbsp;<br/><br/>39 4.0K &nbsp; &nbsp;user.par &nbsp;<br/><br/>40 &nbsp; &nbsp;<br/><br/>41 //取出数据 &nbsp;<br/><br/>42 mysql> select count(id) as count from user; &nbsp;<br/><br/>43 +-------+ &nbsp;<br/><br/>44 &#124; count &#124; &nbsp;<br/><br/>45 +-------+ &nbsp;<br/><br/>46 &#124; &nbsp; &nbsp;25 &#124; &nbsp;<br/><br/>47 +-------+ &nbsp;<br/><br/>48 1 row in set (0.00 sec) &nbsp;<br/><br/>49 &nbsp; &nbsp;<br/><br/>50 //删除第四个分区 &nbsp;<br/><br/>51 mysql> alter table user drop partition p4; &nbsp;<br/><br/>52 Query OK, 0 rows affected (0.11 sec) &nbsp;<br/><br/>53 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>54 &nbsp; &nbsp;<br/><br/>55 /**存放在分区里面的数据丢失了，第四个分区里面有14条数据，剩下的3个分区 &nbsp;<br/><br/>56 只有11条数据，但是统计出来的文件大小都是4.0K，从这儿我们可以看出分区的 &nbsp;<br/><br/>57 最小区块是4K &nbsp;<br/><br/>58 */ <br/><br/>59 mysql> select count(id) as count from user; &nbsp;<br/><br/>60 +-------+ &nbsp;<br/><br/>61 &#124; count &#124; &nbsp;<br/><br/>62 +-------+ &nbsp;<br/><br/>63 &#124; &nbsp; &nbsp;11 &#124; &nbsp;<br/><br/>64 +-------+ &nbsp;<br/><br/>65 1 row in set (0.00 sec) &nbsp;<br/><br/>66 &nbsp; &nbsp;<br/><br/>67 //第四个区块已删除 &nbsp;<br/><br/>68 [root@BlackGhost test]# ls &#124;grep user &#124;xargs du -sh &nbsp;<br/><br/>69 4.0K &nbsp; &nbsp;user#P#p0.MYD &nbsp;<br/><br/>70 4.0K &nbsp; &nbsp;user#P#p0.MYI &nbsp;<br/><br/>71 4.0K &nbsp; &nbsp;user#P#p1.MYD &nbsp;<br/><br/>72 4.0K &nbsp; &nbsp;user#P#p1.MYI &nbsp;<br/><br/>73 4.0K &nbsp; &nbsp;user#P#p2.MYD &nbsp;<br/><br/>74 4.0K &nbsp; &nbsp;user#P#p2.MYI &nbsp;<br/><br/>75 4.0K &nbsp; &nbsp;user#P#p3.MYD &nbsp;<br/><br/>76 4.0K &nbsp; &nbsp;user#P#p3.MYI &nbsp;<br/><br/>77 12K &nbsp; &nbsp;user.frm &nbsp;<br/><br/>78 4.0K &nbsp; &nbsp;user.par &nbsp;<br/><br/>79 &nbsp; &nbsp;<br/><br/>80 /*可以对现有表进行分区,并且会按規则自动的将表中的数据分配相应的分区 &nbsp;<br/><br/>81 中，这样就比较好了，可以省去很多事情，看下面的操作*/ <br/><br/>82 mysql> alter table aa partition by RANGE(id) &nbsp;<br/><br/>83 &nbsp;-> (PARTITION p1 VALUES less than (1), &nbsp;<br/><br/>84 &nbsp;-> PARTITION p2 VALUES less than (5), &nbsp;<br/><br/>85 &nbsp;-> PARTITION p3 VALUES less than MAXVALUE); &nbsp;<br/><br/>86 Query OK, 15 rows affected (0.21 sec) &nbsp; //对15数据进行分区 &nbsp;<br/><br/>87 Records: 15 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>88 &nbsp; &nbsp;<br/><br/>89 //总共有15条 &nbsp;<br/><br/>90 mysql> select count(*) from aa; &nbsp;<br/><br/>91 +----------+ &nbsp;<br/><br/>92 &#124; count(*) &#124; &nbsp;<br/><br/>93 +----------+ &nbsp;<br/><br/>94 &#124; &nbsp; &nbsp; &nbsp; 15 &#124; &nbsp;<br/><br/>95 +----------+ &nbsp;<br/><br/>96 1 row in set (0.00 sec) &nbsp;<br/><br/>97 &nbsp; &nbsp;<br/><br/>98 //删除一个分区 &nbsp;<br/><br/>99 mysql> alter table aa drop partition p2; &nbsp;<br/><br/>100 Query OK, 0 rows affected (0.30 sec) &nbsp;<br/><br/>101 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>102 &nbsp; &nbsp;<br/><br/>103 //只有11条了，说明对现有的表分区成功了 &nbsp;<br/><br/>104 mysql> select count(*) from aa; &nbsp;<br/><br/>105 +----------+ &nbsp;<br/><br/>106 &#124; count(*) &#124; &nbsp;<br/><br/>107 +----------+ &nbsp;<br/><br/>108 &#124; &nbsp; &nbsp; &nbsp; 11 &#124; &nbsp;<br/><br/>109 +----------+ &nbsp;<br/><br/>110 1 row in set (0.00 sec) <br/><br/>3，list分区<br/>LIST分区中每个分区的定义和选择是基于某列的值从属于一个值列表集中的一个值，而RANGE分 区是从属于一个连续区间值的集合。<br/><br/> <br/><br/>view sourceprint?1 //这种方式失败 &nbsp;<br/><br/>2 mysql> CREATE TABLE IF NOT EXISTS `list_part` ( &nbsp;<br/><br/>3 &nbsp;-> &nbsp; `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', &nbsp;<br/><br/>4 &nbsp;-> &nbsp; `province_id` int(2) NOT NULL DEFAULT 0 COMMENT '省', &nbsp;<br/><br/>5 &nbsp;-> &nbsp; `name` varchar(50) NOT NULL DEFAULT '' COMMENT '名称', &nbsp;<br/><br/>6 &nbsp;-> &nbsp; `sex` int(1) NOT NULL DEFAULT '0' COMMENT '0为男，1为女', &nbsp;<br/><br/>7 &nbsp;-> &nbsp; PRIMARY KEY (`id`) &nbsp;<br/><br/>8 &nbsp;-> ) ENGINE=INNODB &nbsp;DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 &nbsp;<br/><br/>9 &nbsp;-> PARTITION BY LIST (province_id) ( &nbsp;<br/><br/>10 &nbsp;-> &nbsp; &nbsp; PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8), &nbsp;<br/><br/>11 &nbsp;-> &nbsp; &nbsp; PARTITION p1 VALUES IN (9,10,11,12,16,21), &nbsp;<br/><br/>12 &nbsp;-> &nbsp; &nbsp; PARTITION p2 VALUES IN (13,14,15,19), &nbsp;<br/><br/>13 &nbsp;-> &nbsp; &nbsp; PARTITION p3 VALUES IN (17,18,20,22,23,24) &nbsp;<br/><br/>14 &nbsp;-> ); &nbsp;<br/><br/>15 ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function <br/><br/>16 &nbsp; &nbsp;<br/><br/>17 //这种方式成功 &nbsp;<br/><br/>18 mysql> CREATE TABLE IF NOT EXISTS `list_part` ( &nbsp;<br/><br/>19 &nbsp;-> &nbsp; `id` int(11) NOT NULL &nbsp;COMMENT '用户ID', &nbsp;<br/><br/>20 &nbsp;-> &nbsp; `province_id` int(2) NOT NULL DEFAULT 0 COMMENT '省', &nbsp;<br/><br/>21 &nbsp;-> &nbsp; `name` varchar(50) NOT NULL DEFAULT '' COMMENT '名称', &nbsp;<br/><br/>22 &nbsp;-> &nbsp; `sex` int(1) NOT NULL DEFAULT '0' COMMENT '0为男，1为女' <br/><br/>23 &nbsp;-> ) ENGINE=INNODB &nbsp;DEFAULT CHARSET=utf8 &nbsp;<br/><br/>24 &nbsp;-> PARTITION BY LIST (province_id) ( &nbsp;<br/><br/>25 &nbsp;-> &nbsp; &nbsp; PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8), &nbsp;<br/><br/>26 &nbsp;-> &nbsp; &nbsp; PARTITION p1 VALUES IN (9,10,11,12,16,21), &nbsp;<br/><br/>27 &nbsp;-> &nbsp; &nbsp; PARTITION p2 VALUES IN (13,14,15,19), &nbsp;<br/><br/>28 &nbsp;-> &nbsp; &nbsp; PARTITION p3 VALUES IN (17,18,20,22,23,24) &nbsp;<br/><br/>29 &nbsp;-> ); &nbsp;<br/><br/>30 Query OK, 0 rows affected (0.33 sec) <br/><br/> <br/><br/>上面的这个创建list分区时，如果有主銉的话，分区时主键必须在其中，不然就会报错。如果我不用主键，分区就创建成功了，一般情况下，一个张表肯定会有一个主键，这算是一个分区的局限性吧。<br/><br/>如果对数据进行测试，请参考range分区的测试来操作<br/><br/>4，hash分区<br/>HASH分区主要用来确保数据在预先确定数目的分区中平均分布，你所要做的只是基于将要被哈希的列值指定一个列值或表达式，以 及指定被分区的表将要被分割成的分区数量。<br/><br/>view sourceprint?1 mysql> CREATE TABLE IF NOT EXISTS `hash_part` ( &nbsp;<br/><br/>2 &nbsp;-> &nbsp; `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '评论ID', &nbsp;<br/><br/>3 &nbsp;-> &nbsp; `comment` varchar(1000) NOT NULL DEFAULT '' COMMENT '评论', &nbsp;<br/><br/>4 &nbsp;-> &nbsp; `ip` varchar(25) NOT NULL DEFAULT '' COMMENT '来源IP', &nbsp;<br/><br/>5 &nbsp;-> &nbsp; PRIMARY KEY (`id`) &nbsp;<br/><br/>6 &nbsp;-> ) ENGINE=INNODB &nbsp;DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 &nbsp;<br/><br/>7 &nbsp;-> PARTITION BY HASH(id) &nbsp;<br/><br/>8 &nbsp;-> PARTITIONS 3; &nbsp;<br/><br/>9 Query OK, 0 rows affected (0.06 sec) <br/><br/>测试请参考range分区的操作<br/><br/>5，key分区<br/>按照KEY进行分区类似于按照HASH分区，除了HASH分区使用的用 户定义的表达式，而KEY分区的 哈希函数是由MySQL 服务器提供。<br/><br/>view sourceprint?1 mysql> CREATE TABLE IF NOT EXISTS `key_part` ( &nbsp;<br/><br/>2 &nbsp;-> &nbsp; `news_id` int(11) NOT NULL &nbsp;COMMENT '新闻ID', &nbsp;<br/><br/>3 &nbsp;-> &nbsp; `content` varchar(1000) NOT NULL DEFAULT '' COMMENT '新闻内容', &nbsp;<br/><br/>4 &nbsp;-> &nbsp; `u_id` varchar(25) NOT NULL DEFAULT '' COMMENT '来源IP', &nbsp;<br/><br/>5 &nbsp;-> &nbsp; `create_time` DATE NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '时间' <br/><br/>6 &nbsp;-> ) ENGINE=INNODB &nbsp;DEFAULT CHARSET=utf8 &nbsp;<br/><br/>7 &nbsp;-> PARTITION BY LINEAR HASH(YEAR(create_time)) &nbsp;<br/><br/>8 &nbsp;-> PARTITIONS 3; &nbsp;<br/><br/>9 Query OK, 0 rows affected (0.07 sec) <br/><br/>测试请参考range分区的操作<br/><br/>6，子分区<br/>子分区是分区表中每个分区的再次分割，子分区既可以使用HASH希分区，也可以使用KEY分区。这 也被称为复合分区（composite partitioning）。<br/><br/>1，如果一个分区中创建了子分区，其他分区也要有子分区<br/><br/>2，如果创建了了分区，每个分区中的子分区数必有相同<br/><br/>3，同一分区内的子分区，名字不相同，不同分区内的子分区名子可以相同（5.1.50不适用）<br/><br/>view sourceprint?1 mysql> CREATE TABLE IF NOT EXISTS `sub_part` ( &nbsp;<br/><br/>2 &nbsp;-> &nbsp; `news_id` int(11) NOT NULL &nbsp;COMMENT '新闻ID', &nbsp;<br/><br/>3 &nbsp;-> &nbsp; `content` varchar(1000) NOT NULL DEFAULT '' COMMENT '新闻内容', &nbsp;<br/><br/>4 &nbsp;-> &nbsp; `u_id` &nbsp;int(11) NOT NULL DEFAULT 0s COMMENT '来源IP', &nbsp;<br/><br/>5 &nbsp;-> &nbsp; `create_time` DATE NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '时间' <br/><br/>6 &nbsp;-> ) ENGINE=INNODB &nbsp;DEFAULT CHARSET=utf8 &nbsp;<br/><br/>7 &nbsp;-> PARTITION BY RANGE(YEAR(create_time)) &nbsp;<br/><br/>8 &nbsp;-> SUBPARTITION BY HASH(TO_DAYS(create_time))( &nbsp;<br/><br/>9 &nbsp;-> PARTITION p0 VALUES LESS THAN (1990)(SUBPARTITION s0,SUBPARTITION s1,SUBPARTITION s2), &nbsp;<br/><br/>10 &nbsp;-> PARTITION p1 VALUES LESS THAN (2000)(SUBPARTITION s3,SUBPARTITION s4,SUBPARTITION good), &nbsp;<br/><br/>11 &nbsp;-> PARTITION p2 VALUES LESS THAN MAXVALUE(SUBPARTITION tank0,SUBPARTITION tank1,SUBPARTITION tank3) &nbsp;<br/><br/>12 &nbsp;-> ); &nbsp;<br/><br/>13 Query OK, 0 rows affected (0.07 sec) <br/><br/>三，分区管理<br/>1，删除分区<br/><br/>mysql> alter table user drop partition p4; &nbsp;<br/>2，新增分区<br/><br/>view sourceprint?1 //range添加新分区 &nbsp;<br/><br/>2 mysql> alter table user add partition(partition p4 values less than MAXVALUE); &nbsp;<br/><br/>3 Query OK, 0 rows affected (0.06 sec) &nbsp;<br/><br/>4 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>5 &nbsp; &nbsp;<br/><br/>6 //list添加新分区 &nbsp;<br/><br/>7 mysql> alter table list_part add partition(partition p4 values in (25,26,28)); &nbsp;<br/><br/>8 Query OK, 0 rows affected (0.01 sec) &nbsp;<br/><br/>9 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>10 &nbsp; &nbsp;<br/><br/>11 //hash重新分区 &nbsp;<br/><br/>12 mysql> alter table hash_part add partition partitions 4; &nbsp;<br/><br/>13 Query OK, 0 rows affected (0.12 sec) &nbsp;<br/><br/>14 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>15 &nbsp; &nbsp;<br/><br/>16 //key重新分区 &nbsp;<br/><br/>17 mysql> alter table key_part add partition partitions 4; &nbsp;<br/><br/>18 Query OK, 1 row affected (0.06 sec) &nbsp; &nbsp;//有数据也会被重新分配 &nbsp;<br/><br/>19 Records: 1 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>20 &nbsp; &nbsp;<br/><br/>21 //子分区添加新分区，虽然我没有指定子分区，但是系统会给子分区命名的 &nbsp;<br/><br/>22 mysql> alter table sub1_part add partition(partition p3 values less than MAXVALUE); &nbsp;<br/><br/>23 Query OK, 0 rows affected (0.02 sec) &nbsp;<br/><br/>24 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>25 &nbsp; &nbsp;<br/><br/>26 mysql> show create table sub1_partG; &nbsp;<br/><br/>27 *************************** 1. row *************************** &nbsp;<br/><br/>28 &nbsp;Table: sub1_part &nbsp;<br/><br/>29 Create Table: CREATE TABLE `sub1_part` ( &nbsp;<br/><br/>30 &nbsp;`news_id` int(11) NOT NULL COMMENT '新闻ID', &nbsp;<br/><br/>31 &nbsp;`content` varchar(1000) NOT NULL DEFAULT '' COMMENT '新闻内容', &nbsp;<br/><br/>32 &nbsp;`u_id` varchar(25) NOT NULL DEFAULT '' COMMENT '来源IP', &nbsp;<br/><br/>33 &nbsp;`create_time` date NOT NULL DEFAULT '0000-00-00' COMMENT '时间' <br/><br/>34 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 &nbsp;<br/><br/>35 !50100 PARTITION BY RANGE (YEAR(create_time)) &nbsp;<br/><br/>36 SUBPARTITION BY HASH (TO_DAYS(create_time)) &nbsp;<br/><br/>37 (PARTITION p0 VALUES LESS THAN (1990) &nbsp;<br/><br/>38 &nbsp;(SUBPARTITION s0 ENGINE = InnoDB, &nbsp;<br/><br/>39 &nbsp;SUBPARTITION s1 ENGINE = InnoDB, &nbsp;<br/><br/>40 &nbsp;SUBPARTITION s2 ENGINE = InnoDB), &nbsp;<br/><br/>41 &nbsp;PARTITION p1 VALUES LESS THAN (2000) &nbsp;<br/><br/>42 &nbsp;(SUBPARTITION s3 ENGINE = InnoDB, &nbsp;<br/><br/>43 &nbsp;SUBPARTITION s4 ENGINE = InnoDB, &nbsp;<br/><br/>44 &nbsp;SUBPARTITION good ENGINE = InnoDB), &nbsp;<br/><br/>45 &nbsp;PARTITION p2 VALUES LESS THAN (3000) &nbsp;<br/><br/>46 &nbsp;(SUBPARTITION tank0 ENGINE = InnoDB, &nbsp;<br/><br/>47 &nbsp;SUBPARTITION tank1 ENGINE = InnoDB, &nbsp;<br/><br/>48 &nbsp;SUBPARTITION tank3 ENGINE = InnoDB), &nbsp;<br/><br/>49 &nbsp;PARTITION p3 VALUES LESS THAN MAXVALUE &nbsp;<br/><br/>50 &nbsp;(SUBPARTITION p3sp0 ENGINE = InnoDB, &nbsp; &nbsp;//子分区的名子是自动生成的 &nbsp;<br/><br/>51 &nbsp;SUBPARTITION p3sp1 ENGINE = InnoDB, &nbsp;<br/><br/>52 &nbsp;SUBPARTITION p3sp2 ENGINE = InnoDB)) &nbsp;<br/><br/>53 1 row in set (0.00 sec) <br/><br/><br/>3，重新分区<br/><br/>view sourceprint?1 //range重新分区 &nbsp;<br/><br/>2 mysql> ALTER TABLE user REORGANIZE PARTITION p0,p1,p2,p3,p4 INTO (PARTITION p0 VALUES LESS THAN MAXVALUE); &nbsp;<br/><br/>3 Query OK, 11 rows affected (0.08 sec) &nbsp;<br/><br/>4 Records: 11 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>5 &nbsp; &nbsp;<br/><br/>6 //list重新分区 &nbsp;<br/><br/>7 mysql> ALTER TABLE list_part REORGANIZE PARTITION p0,p1,p2,p3,p4 INTO (PARTITION p0 VALUES in (1,2,3,4,5)); &nbsp;<br/><br/>8 Query OK, 0 rows affected (0.28 sec) &nbsp;<br/><br/>9 Records: 0 &nbsp;Duplicates: 0 &nbsp;Warnings: 0 &nbsp;<br/><br/>10 &nbsp; &nbsp;<br/><br/>11 //hash和key分区不能用REORGANIZE，官方网站说的很清楚 &nbsp;<br/><br/>12 mysql> ALTER TABLE key_part REORGANIZE PARTITION COALESCE PARTITION 9; &nbsp;<br/><br/>13 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PARTITION 9' at line 1 <br/><br/>四，分区优点<br/>1，分区可以分在多个磁盘，存储更大一点<br/><br/>2，根据查找条件，也就是where后面的条件，查找只查找相应的分区不用全部查找了<br/><br/>3，进行大数据搜索时可以进行并行处理。<br/><br/>4，跨多个磁盘来分散数据查询，来获得更大的查询吞吐量<br/><br/>课外阅读<br/>：http://dev.mysql.com/doc/refman/5.1/zh/partitioning.html<br/><br/><br/>Tags - <a href="tag.php?tag=mysql" rel="tag">mysql</a> , <a href="tag.php?tag=%E5%88%86%E5%8C%BA" rel="tag">分区</a>
]]>
</description>
</item>
</channel>
</rss>