MySQL优化
打开/etc/my.cnf文件,修改以下设置,如果没有,可手动添加.调整设置时,请量力而行,这与你的服务器的配置有关,特别是内存大小.以下设置比较适合于1G内存的服务器,但并不绝对.
#指定索引缓冲区的大小,它决定索引处理的速度,尤其是索引读的速度.通过检查状态值 Key_read_requests和Key_reads,可以知道key_buffer_size设置是否合理.比例key_reads / key_read_requests应该尽可能的低,至少是1:100,1:1000更好(上述状态值可以使用show status like 'key_reads'获得).key_buffer_size只对MyISAM表起作用.即使你不使用MyISAM表,但是内部的临时磁盘表是 MyISAM表,也要使用该值.可以使用检查状态值created_tmp_disk_tables得知详情.
key_buffer = 384M
#要求MySQL能有的连接数量.当主要MySQL线程在一个很短时间内得到非常多的连接请求,这就起作 用,然后主线程花些时间(尽管很短)检查连接并且启动一个新线程.back_log值指出在MySQL暂时停止回答新请求之前的短时间内多少个请求可以被 存在堆栈中.只有如果期望在一个短时间内有很多连接,你需要增加它,换句话说,这值对到来的TCP/IP连接的侦听队列的大小.你的操作系统在这个队列大 小上有它自己的限制.试图设定back_log高于你的操作系统的限制将是无效的.默认数值是50
back_log = 200
#一个包的最大尺寸.消息缓冲区被初始化为net_buffer_length字节,但是可在需要时增加到 max_allowed_packet个字节.缺省地,该值太小必能捕捉大的(可能错误)包.如果你正在使用大的BLOB列,你必须增加该值.它应该象你 想要使用的最大BLOB的那么大.
max_allowed_packet = 4M
#允许的同时客户的数量.增加该值增加 mysqld要求的文件描述符的数量.这个数字应该增加,否则,你将经常看到 Too...
解决error specifies multiple packages
第一次用--nodeps来卸载rpm包,出现错误:
error: specifies multiple packages
于是再加一个--allmatches这下可以成功卸载了.
[root@localhost courier-imap-4.1.0]# rpm -qa | grep cyrus-sasl | xargs rpm -e --nodeps
error: "cyrus-sasl-lib-2.1.22-5.el5_4.3" specifies multiple packages
error: "cyrus-sasl-lib-2.1.22-5.el5_4.3" specifies multiple packages
error: "cyrus-sasl-plain-2.1.22-5.el5_4.3" specifies multiple packages
error: "cyrus-sasl-plain-2.1.22-5.el5_4.3" specifies multiple packages
[root@localhost courier-imap-4.1.0]# rpm -qa | grep cyrus-sasl | xargs rpm -e -nodeps
[root@localhost courier-imap-4.1.0]# rpm -qa | grep cyrus-sasl | xargs rpm -e --allmatches
error: Failed dependencies:
libsasl2.so.2()(64bit) is needed by (installed) openldap-2.3.43-12.el5.x86_64
libsasl2.so.2()(64bit) is needed by (installed) autofs-5.0.1-0.rc2.143.el5.x86_64
libsasl2.so.2()(64bit) is needed by (installed)...
httpd Could not reliably determine...
解决方案: 进入apache的安装目录:
Windows : D:/Program Files/Apache Software Foundation/Apache2.2conf
linux : /usr/local/apache/conf
用记事本打开httpd.conf 将里面的:
#ServerName localhost:80
注释去掉即可. 再执行:
service httpd start
然后可以通过浏览器访问http://localhost:80,如果页面显示"It works!",即表示apache已安装并启动成功.
删除已经创建的iptables(防火墙)规则
首先使用 iptables -L -n 命令来查看已经创建的防火墙规则,
[root@webxn ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 173.231.17.71 0.0.0.0/0
DROP all -- 173.231.17.71 0.0.0.0/0
ACCEPT all -- 173.252.192.205 0.0.0.0/0
DROP all -- 173.252.192.205 0.0.0.0/0
DROP all -- 173.252.192.205 0.0.0.0/0
ACCEPT all -- 173.252.192.205 0.0.0.0/0
DROP all -- 173.252.192.205 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
我们可以看到我创建了很多规则. 然后我们可以使用命令:
iptables -D INPUT *
来删除制定规则, 比如我们删除第一行的规则, 那我们就可以执行:
iptables -D INPUT 1
就可以了.
No module dm-mem-cache found for...
执行mkinitrd命令时,提示:
"No module dm-mem-cache found for kernel 2.6.27, aborting."
表明该版本的mkinitrd有bug.
解决方法:
1是当使用mkinitrd时,使用"-without-dmraid"这个参数.
2是在使用mkinitrd之前,先创建一个noraid文件.创建方法如下:
$ echo "DMRAID=no" > /etc/sysconfig/mkinitrd/noraid
$ chmod 755 /etc/sysconfig/mkinitrd/noraid
然后再运行mkinitrd命令.
linux下查看CPU型号的命令命令
2019年8月16日更新:
要查看cpu型号也可以使用如下命令:
cat /proc/cpuinfo
还能看到主频核心数之类的信息.
以下为原文章:
[root@localhost nginx-1.0.13]$ cat /proc/cpuinfo | grep "model name"
model name : Pentium(R) Dual-Core CPU E5700 @ 3.00GHz