FreeBSD系统优化部分内核

[ 2007/11/18 16:48 | by Johnny.He ]
很多人想优化自己的FreeBSD,特别是在网络性能以及内核调整上,因为这些是最直接的优化方式。在这里我收集整理并用中文注释了一下,相信很多人用得到。

#最大的待发送TCP数据缓冲区空间
net.inet.tcp.sendspace=65536

#最大的接受TCP缓冲区空间
net.inet.tcp.recvspace=65536

#最大的接受UDP缓冲区大小
net.inet.udp.sendspace=65535

#最大的发送UDP数据缓冲区大小
net.inet.udp.maxdgram=65535

#本地套接字连接的数据发送空间
net.local.stream.sendspace=65535

#加快网络性能的协议
net.inet.tcp.rfc1323=1
net.inet.tcp.rfc1644=1
net.inet.tcp.rfc3042=1
net.inet.tcp.rfc3390=1

MySQL的my.cnf配置参数详解

[ 2007/11/17 16:24 | by Johnny.He ]
   key_buffer
  索引块是缓冲的并且被所有的线程共享。key_buffer_size是用于索引块的缓冲区大小,增加它可得到更好处理的索引(对所有读和多重写),到你能负担得起那样多。如果你使它太大,系统将开始换页并且真的变慢了。默认数值是8388600(8M),我的 MySQL主机有2GB内存,所以我把它改为402649088(400MB)
  max_connections
  允许的同时客户的数量。增加该值增加 mysqld 要求的文件描述符的数量。这个数字应该增加,否则,你将经常看到 Too many connections 错误。 默认数值是100
  max_allowed_packet
  导入时一个包的最大尺寸。消息缓冲区被初始化为net_buffer_length字节,但是可在需要时增加到max_allowed_packet个字节。缺省地,该值太小必能捕捉大的(可能错误)包。如果你正在使用大的BLOB列,你必须增加该值。它应该象你想要使用的最大BLOB的那么大。
  table_cache
  为所有线程打开表的数量。增加该值能增加mysqld要求的文件描述符的数量。MySQL对每个唯一打开的表需要2个文件描述符。默认数值是64,我把它改为512
Tags:

Cacti 安装笔记

[ 2007/11/17 10:43 | by Johnny.He ]
服务器已经放入机房有一段时间了,基本环境如下:
apache22+mysql5+php5+zend3.3+..... 很多很多记不大清楚了,前两天机房通知我流量比较大,所以就打算安装一个Cacti 在服务器上,这样我可以看到运行情况。
安装cacti需要snmp支持还有RRDtools,
所有推荐使用Ports方式安装~~!用不了多长时间,为以后好管理,应该这样做。

需要先安装net-snmp,其实是Cacti需要用到net-snmp中的两个命令,我们可以直接在系统中运行snmpwalk和snmpget看是否有该命令,如果有则不用安装了,如果不能执行则进入/usr/ports/net-mgmt/net-snmp/目录
#make
#make install clean

完成后 在/usr/local/share/snmp/这个目录下创建snmpd.conf文件(可能已经存在,如果没有就新建),内容如下:
syslocation  WwwEr.ORG
syscontact  Johnny.He@Live.com
sysservices 77
rocommunity  public
load  12 12 12

保存退出

FreeBSD的systat命令备忘

[ 2007/11/14 13:09 | by Johnny.He ]
systat 是一个在FreeBSD中帮助你查看、观察系统状况的命令,并且显示在屏幕。
systat -- display system statistics on a crt

使用方法:
systat [-display] [更新-时间]
示范:
systat -vmstat 1
如果需要把 aaa.com bbb.com ccc.com全部指向/usr/local/www下,就在/usr/local/etc/apache22/extra/httpd-vhosts.conf中设置虚拟机的地方添加一条
ServerAlias aaa.com bbb.com ccc.com

范例如下:
<VirtualHost ***.***.***.**:80>
    ServerAdmin Johnny.He#Live.com
    DocumentRoot "/usr/local/www"
    ServerName wwwer.org
    ServerAlias aaa.com bbb.com ccc.com  
    ErrorLog "/usr/local/www/log/abc-error_log"
    CustomLog /usr/local/www/log/abc-access_log common
</VirtualHost>
Tags: ,

FreeBSD修改IP

[ 2007/11/12 07:51 | by Johnny.He ]
FreeBSD下如何更改IP
1.进入  /etc/rc.conf  文件
2.修改  ifconfig_lnc0="inet xxx.xxx.xxx.xxx netmask 255.255.255.0"
  别忘了defaultrouter="xxx.xxx.xxx.xxx (gateway ip address)"
如果想一次性的话,只要直接输入  ifconfig lnc0 xxx.xxx.xxx.xxx netmask 255.255.255.0
即时生效
重启后失效!!

图形界面配置IP
sysinstall --> configure --> Networking -->interfaces -->相应网卡名
Tags: ,

MySQL 服务器内存使用

[ 2007/11/11 15:02 | by Johnny.He ]
原文作者: Peter Zaitsev
原文来源: http://www.mysqlperformanceblog.com/2006/05/17/mys...
译者:叶金荣(Email:),转载请注明译者和出处,并且不能用于商业用途,违者必究。

Every so often people ask me the question how should they estimate memory consumption by MySQL Server in given configuration. What is the formula they could use.

经常有人问我配置MySQL时该如何估算内存的消耗。那么该使用什么公式来计算呢?

The reasons to worry about memory usage are quite understandable. If you configure MySQL Server so it uses too small amount of memory it will likey perform suboptimally. If you however configure it so it consumes too much memory it may be crashing , failing to execute queries or make operation to swap seriously slowing down. On now legacy 32bit platforms you could also run out of address space so that had to be watched as well.
Having said so, I do not think looking for the secret fomula to compute your possible memory usage is the right approach to this problem. The reasons are - this formula is very complex nowadays and what is even more important “theoretically possible” maximum it provides have nothing to do with real memory consumptions. In fact typical server with 8GB of memory will often run with maximum theoretical memory usage of 100GB or more. Furthermore there is no easy “overcommit factor” you can use - it really depends on application and configuration. Some applications will drive server to 10% of theoretical memory consumptions others only to 1%.

关心内存怎么使用的原因是可以理解的。如果配置MySQL服务器使用太少的内存会导致性能不是最优的;如果配置了太多的内存则会导致崩溃,无法执行查询或者导致交换操作严重变慢。在现在的32位平台下,仍有可能把所有的地址空间都用完了,因此需要监视着。
话虽如此,但我并不觉得找到什么可以计算内存使用的秘诀公式就能很好地解决这个问题。原因有 — 如今这个公式已经很复杂了,更重要的是,通过它计算得到的值只是“理论可能”并不是真正消耗的值。事实上,有8GB内存的常规服务器经常能运行到最大的理论值 — 100GB甚至更高。此外,你轻易不会使用到“超额因素” — 它实际上依赖于应用以及配置。一些应用可能需要理论内存的 10% 而有些仅需 1%。
Tags:

Apache2开启mod_rewrite的方法

[ 2007/11/10 23:57 | by Johnny.He ]
本来要开启rewrite,只要打开httpd.conf,把下面这行前面的#去掉就可以了。

#LoadModule rewrite_module modules/mod_rewrite.so


可是昨天装了apache2最新版却出了意外,去掉了这行,rewrite还没打开

用了一个下午,百思不得其解.终于发现httpd.conf里有这么一段

<Directory "/usr/local/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#opt...
# for more information.
#
Options Indexes FollowSymLinks

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

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

将AllowOverride None改为AllowOverride All
重启Apache,终于搞定!
Tags:
分页: 5/9 第一页 上页 1 2 3 4 5 6 7 8 9 下页 最后页 [ 显示模式: 摘要 | 列表 ]