admin 发布的文章

在ThinkPHP里面通过自动验证定义来验证数据的长度是否符合要求,在你的模型类里面添加下面的定义即可:

protected $_validate = array(
array('title','5,100','标题长度不符!',3,'length'), // 验证标题长度
array('phone','11','电话长度不符!',3,'length'), // 验证电话号码长度
);

1、关闭DA监控服务

vi /usr/local/directadmin/data/admin/services.status
把exim和dovecot值改为OFF

2、停止服务和禁止开机启动

service exim stop
chkconfig exim off
service dovecot stop
chkconfig dovecots off

3、损坏(重命名)exim目录

mv /usr/sbin/exim /usr/sbin/exim.old

4、清理邮件队列

cd /var/spool  
mv exim exim.old  
mkdir -p exim/input  
mkdir -p exim/msglog  
mkdir -p exim/db  
chown -R mail:mail exim 

64位系统需要安装libunwind

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
tar zxvf libunwind-1.1-alpha.tar.gz
cd libunwind-1.1-alpha/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install

安装TCMalloc

wget http://pkgs.fedoraproject.org/repo/pkgs/gperftools/gperftools-2.4.tar.gz/2171cea3bbe053036fb5d5d25176a160/gperftools-2.4.tar.gz
tar zxvf  gperftools-2.4.tar.gz
cd gperftools-2.4/
./configure
make && make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig

MySQL载入

vi /usr/bin/mysqld_safe
#找到 # executing mysqld_safe,在下面加入:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so
service mysqld restart
#检查是否生效
lsof -n | grep tcmalloc

优化MySQL配置文件

[mysqld]
# WEED 2015-06-06
#default-storage-engine=MyISAM
open_files_limit=60000
innodb_file_per_table=1
local-infile=0
key_buffer_size = 32M
max_allowed_packet = 128M
max_connections = 150
max_user_connections = 50
wait_timeout=30
interactive_timeout=45
connect_timeout=10
tmp-table-size = 256M
max-heap-table-size = 256M
sort_buffer_size = 1M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-flush-log-at-trx-commit = 1
innodb-buffer-pool-size = 64M
#innodb-buffer-pool-instances = 2
innodb_buffer_pool_instances = 1
join_buffer_size = 32M
table_open_cache=64
innodb_buffer_pool_size=2G
innodb_thread_concurrency=8
tmpdir = /dev/shm

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

该处可参考:http://help.directadmin.com/item.php?id=44

Mod_cache可以缓存常见的静态文件,如:css、js等,提升网页加载速度。

安装

cd /usr/local/directadmin/custombuild/configure/ap2
vi configure.apache

在最底部添加

"--enable-cache" \
"--enable-disk-cache" \
"--enable-mem-cache"

cd /usr/local/directadmin/custombuild
./build apache

配置

cd /etc/httpd/conf/extra/    #进入目录
vi httpd-includes.conf    #编辑配置文件

在配置文件中加入以下内容

<IfModule mod_cache.c>
#CacheForceCompletion 100      #缓存文件数(默认不限制)
CacheDefaultExpire 3600        #缓存默认过期时间(秒)
CacheMaxExpire 86400           #缓存最大过期时间(秒)
CacheLastModifiedFactor 0.1    #缓存时间计算公式,详情请查阅网络资料

<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 512000            #内存缓冲区大小,根据服务器内存大小调整(单位:kb)
MCacheMaxObjectCount 10000   #缓冲区文件数
MCacheMinObjectSize 1        #缓冲区最小文件(单位:kb)
MCacheMaxObjectSize 51200    #缓冲区最大文件(单位:kb)
</IfModule>
</IfModule>

安装

wget https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod a+rx speedtest_cli.py
sudo mv speedtest_cli.py /usr/local/bin/speedtest-cli
sudo chown root:root /usr/local/bin/speedtest-cli

使用

speedtest-cli

得知所谓郑苗哥哥不过是以前一个很好的同学,我有一种说不上来的感觉,她为了所谓哥哥多次叫我从她家回去。因为所谓哥哥要来过夜。两年了,将近,今天我才知道。

说不上来的感觉,我越来越不信任郑苗,问我为何总因为一点小事儿多疑,这就是原因吧!如果,同样的事情换作她,我不知道她会怎么样。如果是叫我回家的时候跟我说这件事情,我肯定不会这么久还和她在一起,分手是必然的。

我想起以前林青梅那么骚的一个人,喜欢我我不喜欢她以后和陈炜好,便不再和其他男生有任何瓜葛,即便是以前喜欢过的人。

为什么会隐瞒这么久,有没发生什么,我不知道,我也不愿想。我不敢再信任她,因为我不知道,真的不知道,她还有多少事情瞒着我。

买到二手破车并不可怕,可怕的是车主还有钥匙,没事儿就偷偷开去玩儿,完事儿用的是我的油,坏了是我修。这真是无奈!

我已经把钱花光了,已经在悬崖边上了,我已经没有钱交服务器的月租了。每一次赚到些小钱,我会以赚钱就是为了让爱自己的人开心、幸福为由,花的无节制,最后变成月光族。去年的这个月,我把野草主机交出去了,今年我把野草主机弄回来了,但这个月我仍然面临了与以前同样的生存威胁。我把自己带上了绝路,只能向前,或坠落。

我再一次有了把野草主机交出去的想法,但如果交出去我不是又和以前一样。我想人生不就是为了挑战解决问题,而之后不就是为了迎接新的挑战吗?或许这和游戏有些类似吧,当我们把所有关卡都通关了,把所有的问题都解决完了迎接我们的是空虚,我们的人生或许就画上句号了吧。

When creating a large number of partitions or tables, MySQL may mysteriously stop working and you find this type of error on

/var/lib/mysql/$HOSTNAME.err: [ERROR] /usr/sbin/mysqld: Can't open file: './database/table.frm' (errno: 24)rrno: 24

simply means that too many files are open for the given process. There is a read-only mysql variable called open_files_limit that will show how many open files are allowed by the

mysqld

:

SHOW VARIABLES LIKE 'open%'

A lot systems set this to something very low, like 1024. Unfortunately, the following will NOT work:

SET open_files_limit=100000

MySQL will respond with:

ERROR 1238 (HY000): Variable 'open_files_limit' is a read only variable

However, it is possible to make a change to /etc/my.cnf. This file may not exist, if not, just create it. Be sure it has the following contents:

[mysqld]
open_files_limit = 100000
Then, be sure to restart mysql:

sudo /etc/init.d/mysql restart

Now, SHOW VARIABLES LIKE 'open%' should show 100000. The number you use may be different.

If the tally is using up too much disk I/O, you can slow down the dataskq using the ionice binary, if you have it.

限制 dataskq IO占用率, e编辑:

/etc/cron.d/directadmin_cron

or on FreeBSD:

/etc/crontab

打开文件并找到

* * * * * root /usr/local/directadmin/dataskq

修改为:

* * * * * root /usr/bin/ionice -c2 -n7 /usr/local/directadmin/dataskq

of course, you'll need to ensure that you actually have the /usr/bin/ionice binary. Install it if you don't.
Reload crond (or cron) after you make the change.

For backups, you can have the dataskq insert the ionice command in front of all tar, zip and unzip commands:
http://www.directadmin.com/features.php?id=1423

CentOS 安装 ionice:

yum install util-linux

Debian:

apt-get install util-linux

相关官方文档:http://help.directadmin.com/item.php?id=525