分类: Linux系统

  • 在CentOS/RHEL 6.x上使用AtomicorpYUM源

    首先
    wget -q -O – http://www.atomicorp.com/installers/atomic.sh | sh
    会在yum的配置目录中增加一个新的yum源配置文件
    /etc/yum.repos.d/atomic.repo

    安装php等软件时会报错

    warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID 4520afa9: NOKEY
    Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt

    The GPG keys listed for the “CentOS / Red Hat Enterprise Linux 6 – atomicrocketturtle.com” repository are already installed but they are not correct for this package.
    Check that the correct key URLs are configured for this repository.

    解决

    yum update atomic-release
    升级下这个就 可以解决

     

  • NFS

    [root@www ~]# vim /etc/sysconfig/nfs
    RQUOTAD_PORT=1001 <==約在 13 行左右
    LOCKD_TCPPORT=30001 <==約在 21 行左右
    LOCKD_UDPPORT=30001 <==約在 23 行左右
    MOUNTD_PORT=1002 <==約在 41 行左右
    [root@www ~]# /etc/init.d/nfs restart
    [root@www ~]# rpcinfo -p | grep -E ‘(rquota|mount|nlock)’
    100011 2 udp 1001 rquotad
    100011 2 tcp 1001 rquotad
    100021 4 udp 30001 nlockmgr
    100021 4 tcp 30001 nlockmgr
    100005 3 udp 1002 mountd
    100005 3 tcp 1002 mountd

    防火墙设置

    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 111 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 111 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 2049 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 1001 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 30001 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 1002 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 2049 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 1001 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 30001 -j ACCEPT
    -A RH-Firewall-1-INPUT -m state –state NEW -m udp -p udp –dport 1002 -j ACCEPT

    cat /etc/exports
    /media/qingaodbshadow xx.xx.xx.xx(rw,sync)
    mount -t nfs xx.xx.xx.xx:/media/qingaodbshadow /mnt/shadow/

  • [apache] mod_reqtimeout模块

    ll /usr/lib64/httpd/modules/mod_reqtimeout.so
    -rwxr-xr-x. 1 root root 14576 Feb 22 2013 /usr/lib64/httpd/modules/mod_reqtimeout.so

     

    为了说明mod_reqtimeout模块的用途,需要先说明一下背景。

    【背景】

    客户端发送请求头(或者body)到web服务器,web服务器一直等待,直到它收到一个完整的请求头(或者body)。
    客户端继续发送新的请求,打开新的连接再次发送不完整的请求头(或者body)。
    这样可能导致大量的进程/线程等待客户端的数据,耗光了web服务器的资源,导致了正常请求无法得到处理。

    这个漏洞在Apache 1.x、 2.x都存在,其他的服务器nginx、dhttpd、 GoAhead WebServer、IIS6.0、 IIS7.0、lighttpd我没有确认。

    【解决方法】
    apache这个漏洞,会导致拒绝服务攻击(DoS攻击),请大家注意啦。
    可以通过HTTP DoS的工具“OWASP HTTP POST Tool”或者“Slowloris”来发起攻击,检查一下是否网站是否存在这个漏洞。

    apache发生问题时,从servser-status的状态看,下面的进程/线程都正在读取请求,

    —————————————————-

    64 requests currently being processed, 0 idle workers
    RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRWR

    Scoreboard Key:
    “_” Waiting for Connection, “S” Starting up, “R” Reading Request,
    “W” Sending Reply, “K” Keepalive (read), “D” DNS Lookup,
    “C” Closing connection, “L” Logging, “G” Gracefully finishing,
    “I” Idle cleanup of worker, “.” Open slot with no current process

    —————————————————-
    apache的mod_reqtimeout模块就是为了避免这个问题的出现。

    【设定方法】

    httpd.conf

    LoadModule reqtimeout_module modules/mod_reqtimeout.so
    <IfModule reqtimeout_module>
    RequestReadTimeout header=5-40,MinRate=500 body=20,MinRate=500
    </IfModule>
    ※header, body 单位:秒、Rate单位:Byte/秒。


    相应的工具)
    OWASP HTTP POST Tool
    http://www.owasp.org/index.php/OWASP_HTTP_Post_Tool
    Slowloris
    http://ha.ckers.org/slowloris/

    参考链接 http://httpd.apache.org/docs/2.2/en/mod/mod_reqtimeout.html

    http://www.acunetix.com/blog/web-security-zone/articles/slow-http-dos-attacks-mitigate-apache-http-server/

     

  • Starting httpd: (98)Address already in use: make_sock: could not bind to add

    service httpd start
    Starting httpd: (98)Address already in use: make_sock: could not bind to address
    (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    [FAILED]

    ps ax |grep httpd | awk ‘{if (NR = 2) { print “kill -KILL ” $1} }’ > /home/xxx.sh
    先把占用80端口的进程找出来 kill掉
    1.如果是windows下 netstat -aon|findstr “80”
    2.如果linux平台,使用:lsof -i:80
    kill -9 对应ID
    service httpd restart

     

    Starting httpd: (98)Address already in use: make_sock: could not bind to add

    Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
    (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    [FAILED]

    1.netstat -lnp|grep 80

    tcp        0      0 192.168.180.68:61027        0.0.0.0:*                   LISTEN      6289/oproxyd
    tcp        0      0 :::80                       :::*                        LISTEN      846/httpd
    tcp        0      0 ::ffff:192.168.180.68:7001 :::*                        LISTEN      32015/java

    找到pid 846

    #ps 846
    查看
    #kill -9 846
    杀掉

    #./apachectl start
    启动成功

    service httpd start
    Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:443
    no listening sockets available, shutting down
    Unable to open logs
    [FAILED]
    [root@mypiao ~]# netstat -lnp|grep 80
    tcp        0      0 :::80                       :::*                        LISTEN      11886/wget
    [root@mypiao ~]# kill -9 11886
    [root@mypiao ~]# service httpd start
    Starting httpd:                                            [  OK  ]

     

  • [Linux]svn服务的安装和启动设置 转

    在CentOS系统下,使用以下命令进行SVN服务的安装

    1.yum -y install subversion
    yum -y install subversion

    安装完毕后,svnserve服务就被添加到了系统的自动启动进程里面,但是尚未开启,所以依然无法随系统自动启动服务。为了安全起见,我们需要修改SVN服务端口,及自定义版本库所在目录。所以需要对以下文件进行相应的修改。

    1.vi /etc/rc.d/init.d/svnserve
    vi /etc/rc.d/init.d/svnserve

    找到以下内容

    1.pidfile=${PIDFILE-/var/run/svnserve.pid}
    2.lockfile=${LOCKFILE-/var/lock/subsys/svnserve}
    3.args=”–daemon –pid-file=${pidfile} $OPTIONS”
    pidfile=${PIDFILE-/var/run/svnserve.pid}
    lockfile=${LOCKFILE-/var/lock/subsys/svnserve}
    args=”–daemon –pid-file=${pidfile} $OPTIONS”

    修改为

    1.pidfile=${PIDFILE-/var/run/svnserve.pid}
    2.lockfile=${LOCKFILE-/var/lock/subsys/svnserve}
    3.logfile=/var/log/svnserve.log
    4.args=”–daemon –root /storage/repos –listen-port 621 –pid-file=${pidfile} –log-file=${logfile} $OPTIONS”
    pidfile=${PIDFILE-/var/run/svnserve.pid}
    lockfile=${LOCKFILE-/var/lock/subsys/svnserve}
    logfile=/var/log/svnserve.log
    #args=”–daemon –pid-file=${pidfile} $OPTIONS”
    args=”–daemon –root /opt/svndata –listen-port 621 –pid-file=${pidfile} –log-file=${logfile}  $OPTIONS”

    –root 是版本库所在的目录

    –listen-port 是SVN服务端口号
    –log-file 是SVN日志文件

    修改完成后使用以下命令将自动跟随系统启动功能进行激活

    1.chkconfig svnserve on
    chkconfig svnserve on
    也可以使用以下方式进行手工操作

    service svnserve start     启动服务
    1.service svnserve stop     停止服务
    2.service svnserve restart  重启服务

  • MySQL配置文件my.cnf优化详解(转)

    MySQL 5.5.13

    参数说明:

    [client]

    character-set-server = utf8

    port    = 3306

    socket  = /data/mysql/3306/mysql.sock

     

    [mysqld]

    character-set-server = utf8

     

    user    = mysql

    port    = 3306

    socket  = /data/mysql/3306/mysql.sock

    basedir = /usr/local/webserver/mysql

    datadir = /data/mysql/3306/data

    log-error = /data/mysql/3306/mysql_error.log

    pid-file = /data/mysql/3306/mysql.pid

     

    # table_cache 参数设置表高速缓存的数目。每个连接进来,都会至少打开一个表缓存。#因此, table_cache 的大小应与 max_connections 的设置有关。例如,对于 200 个#并行运行的连接,应该让表的缓存至少有 200 × N ,这里 N 是应用可以执行的查询#的一个联接中表的最大数量。此外,还需要为临时表和文件保留一些额外的文件描述符。

    #当 Mysql 访问一个表时,如果该表在缓存中已经被打开,则可以直接访问缓存;如果#还没有被缓存,但是在 Mysql 表缓冲区中还有空间,那么这个表就被打开并放入表缓#冲区;如果表缓存满了,则会按照一定的规则将当前未用的表释放,或者临时扩大表缓存来存放,使用表缓 存的好处是可以更快速地访问表中的内容。执行 flush tables 会#清空缓存的内容。一般来说,可以通过查看数据库运行峰值时间的状态值 Open_tables #和 Opened_tables ,判断是否需要增加 table_cache 的值(其中 open_tables 是当#前打开的表的数量, Opened_tables 则是已经打开的表的数量)。即如果open_tables接近table_cache的时候,并且Opened_tables这个值在逐步增加,那就要考 虑增加这个#值的大小了。还有就是Table_locks_waited比较高的时候,也需要增加table_cache。

    open_files_limit = 10240

    table_cache = 512

    #非动态变量,需要重启服务

    #指定MySQL可能的连接数量。当MySQL主线程在很短的时间内接收到非常多的连接请求,该参数生效,主线程花费很短的时间检查连接并且启动一个新线 程。back_log参数的值指出在MySQL暂时停止响应新请求之前的短时间内多少个请求可以被存在堆栈中。如果系统在一个短时间内有很多连接,则需要 增大该参数的值,该参数值指定到来的TCP/IP连接的侦听队列的大小。不同的操作系统在这个队列大小上有它自己的限制。试图设定back_log高于你 的操作系统的限制将是无效的。默认值为50。对于Linux系统推荐设置为小于512的整数。

    back_log = 600

    #MySQL允许最大连接数

    max_connections = 5000

    #可以允许多少个错误连接

    max_connect_errors = 6000

    #使用–skip-external-locking MySQL选项以避免外部锁定。该选项默认开启

    external-locking = FALSE

    #设置最大包,限制server接受的数据包大小,避免超长SQL的执行有问题 默认值为16M,当MySQL客户端或mysqld服务器收到大于max_allowed_packet字节的信息包时,将发出“信息包过大”错误,并关 闭连接。对于某些客户端,如果通信信息包过大,在执行查询期间,可能会遇到“丢失与MySQL服务器的连接”错误。默认值16M。

    #dev-doc: http://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html

    max_allowed_packet = 32M

    # Sort_Buffer_Size 是一个connection级参数,在每个connection(session)第一次需要使用这个buffer的时候,一次性分配设置的内存。

    #Sort_Buffer_Size 并不是越大越好,由于是connection级的参数,过大的设置+高并发可能会耗尽系统内存资源。例如:500个连接将会消耗 500*sort_buffer_size(8M)=4G内存

    #Sort_Buffer_Size 超过2KB的时候,就会使用mmap() 而不是 malloc() 来进行内存分配,导致效率降低。

    #技术导读 http://blog.webshuo.com/2011/02/16/mysql-sort_buffer_size/

    #dev-doc: http://dev.mysql.com/doc/refman/5.5/en/server-parameters.html

    #explain select*from table where order limit;出现filesort

    #属重点优化参数

    sort_buffer_size = 8M

    #用于表间关联缓存的大小

    join_buffer_size = 1M

    #服务器线程缓存这个值表示可以重新利用保存在缓存中线程的数量,当断开连接时如果缓存中还有空间,那么客户端的线程将被放到缓存中,如果线程重新被请 求,那么请求将从缓存中读取,如果缓存中是空的或者是新的请求,那么这个线程将被重新创建,如果有很多新的线程,增加这个值可以改善系统性能.通过比较 Connections 和 Threads_created 状态的变量,可以看到这个变量的作用

    thread_cache_size = 300

    #设置thread_concurrency的值的正确与否, 对mysql的性能影响很大, 在多个cpu(或多核)的情况下,错误设置了thread_concurrency的值, 会导致mysql不能充分利用多cpu(或多核), 出现同一时刻只能一个cpu(或核)在工作的情况。thread_concurrency应设为CPU核数的2倍. 比如有一个双核的CPU, 那么thread_concurrency的应该为4; 2个双核的cpu, thread_concurrency的值应为8

    #属重点优化参数

    thread_concurrency = 8

    #对于使用MySQL的用户,对于这个变量大家一定不会陌生。前几年的MyISAM引擎优化中,这个参数也是一个重要的优化参数。但随着发展,这个参数也 爆露出来一些问题。机器的内存越来越大,人们也都习惯性的把以前有用的参数分配的值越来越大。这个参数加大后也引发了一系列问题。我们首先分析一下 query_cache_size的工作原理:一个SELECT查询在DB中工作后,DB会把该语句缓存下来,当同样的一个SQL再次来到DB里调用 时,DB在该表没发生变化的情况下把结果从缓存中返回给Client。这里有一个关建点,就是DB在利用Query_cache工作时,要求该语句涉及的 表在这段时间内没有发生变更。那如果该表在发生变更时,Query_cache里的数据又怎么处理呢?首先要把Query_cache和该表相关的语句全 部置为失效,然后在写入更新。那么如果Query_cache非常大,该表的查询结构又比较多,查询语句失效也慢,一个更新或是Insert就会很慢,这 样看到的就是Update或是Insert怎么这么慢了。所以在数据库写入量或是更新量也比较大的系统,该参数不适合分配过大。而且在高并发,写入量大的 系统,建系把该功能禁掉。

    #重点优化参数(主库 增删改-MyISAM)

    query_cache_size = 512M

    #指定单个查询能够使用的缓冲区大小,缺省为1M

    query_cache_limit = 2M

    #默认是4KB,设置值大对大数据查询有好处,但如果你的查询都是小数据查询,就容易造成内存碎片和浪费

    #查询缓存碎片率 = Qcache_free_blocks / Qcache_total_blocks * 100%

    #如果查询缓存碎片率超过20%,可以用FLUSH QUERY CACHE整理缓存碎片,或者试试减小query_cache_min_res_unit,如果你的查询都是小数据量的话。

    #查询缓存利用率 = (query_cache_size – Qcache_free_memory) / query_cache_size * 100%

    #查询缓存利用率在25%以下的话说明query_cache_size设置的过大,可适当减小;查询缓存利用率在80%以上而且Qcache_lowmem_prunes > 50的话说明query_cache_size可能有点小,要不就是碎片太多。

    #查询缓存命中率 = (Qcache_hits – Qcache_inserts) / Qcache_hits * 100%

    query_cache_min_res_unit = 2k

    default-storage-engine = MyISAM

    #限定用于每个数据库线程的栈大小。默认设置足以满足大多数应用

    thread_stack = 192K

    # 设定默认的事务隔离级别.可用的级别如下:

    # READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, SERIALIZABLE

    # 1.READ UNCOMMITTED-读未提交2.READ COMMITTE-读已提交3.REPEATABLE READ -可重复读4.SERIALIZABLE -串行

    transaction_isolation = READ-COMMITTED

    # tmp_table_size 的默认大小是 32M。如果一张临时表超出该大小,MySQL产生一个 The table tbl_name is full 形式的错误,如果你做很多高级 GROUP BY 查询,增加 tmp_table_size 值。

    tmp_table_size = 246M

    max_heap_table_size = 246M

    #索引缓存大小: 它决定了数据库索引处理的速度,尤其是索引读的速度

    key_buffer_size = 512M

    # MySql读入缓冲区大小。对表进行顺序扫描的请求将分配一个读入缓冲区,MySql会为它分配一段内存缓冲区。read_buffer_size变量控 制这一缓冲区的大小。如果对表的顺序扫描请求非常频繁,并且你认为频繁扫描进行得太慢,可以通过增加该变量值以及内存缓冲区大小提高其性能。

    read_buffer_size = 4M

    # MySql的随机读(查询操作)缓冲区大小。当按任意顺序读取行时(例如,按照排序顺序),将分配一个随机读缓存区。进行排序查询时,MySql会首先扫 描一遍该缓冲,以避免磁盘搜索,提高查询速度,如果需要排序大量数据,可适当调高该值。但MySql会为每个客户连接发放该缓冲空间,所以应尽量适当设置 该值,以避免内存开销过大。

    read_rnd_buffer_size = 16M

    #批量插入数据缓存大小,可以有效提高插入效率,默认为8M

    bulk_insert_buffer_size = 64M

    # MyISAM表发生变化时重新排序所需的缓冲

    myisam_sort_buffer_size = 128M

    # MySQL重建索引时所允许的最大临时文件的大小 (当 REPAIR, ALTER TABLE 或者 LOAD DATA INFILE).

    # 如果文件大小比此值更大,索引会通过键值缓冲创建(更慢)

    myisam_max_sort_file_size = 10G

    # 如果一个表拥有超过一个索引, MyISAM 可以通过并行排序使用超过一个线程去修复他们.

    # 这对于拥有多个CPU以及大量内存情况的用户,是一个很好的选择.

    myisam_repair_threads = 1

    #自动检查和修复没有适当关闭的 MyISAM 表

    myisam_recover

     

    interactive_timeout = 120

    wait_timeout = 120

     

    innodb_data_home_dir = /data/mysql/3306/data

    #表空间文件 重要数据

    innodb_data_file_path = ibdata1:2000M;ibdata2:10M:autoextend

    #这个参数用来设置 InnoDB 存储的数据目录信息和其它内部数据结构的内存池大小,类似于Oracle的library cache。这不是一个强制参数,可以被突破。

    innodb_additional_mem_pool_size = 16M

    #这对Innodb表来说非常重要。Innodb相比MyISAM表对缓冲更为敏感。MyISAM可以在默认的 key_buffer_size 设置下运行的可以,然而Innodb在默认的 innodb_buffer_pool_size 设置下却跟蜗牛似的。由于Innodb把数据和索引都缓存起来,无需留给操作系统太多的内存,因此如果只需要用Innodb的话则可以设置它高达 70-80% 的可用内存。一些应用于 key_buffer 的规则有 — 如果你的数据量不大,并且不会暴增,那么无需把 innodb_buffer_pool_size 设置的太大了

    innodb_buffer_pool_size = 512M

    #文件IO的线程数,一般为 4,但是在 Windows 下,可以设置得较大。

    innodb_file_io_threads = 4

    # 在InnoDb核心内的允许线程数量.

    # 最优值依赖于应用程序,硬件以及操作系统的调度方式.

    # 过高的值可能导致线程的互斥颠簸.

    innodb_thread_concurrency = 8

    #如果将此参数设置为1,将在每次提交事务后将日志写入磁盘。为提供性能,可以设置为0或2,但要承担在发生故障时丢失数据的风险。设置为0表示事务日志 写入日志文件,而日志文件每秒刷新到磁盘一次。设置为2表示事务日志将在提交时写入日志,但日志文件每次刷新到磁盘一次。

    innodb_flush_log_at_trx_commit = 2

    #此参数确定些日志文件所用的内存大小,以M为单位。缓冲区更大能提高性能,但意外的故障将会丢失数据.MySQL开发人员建议设置为1-8M之间

    innodb_log_buffer_size = 16M

    #此参数确定数据日志文件的大小,以M为单位,更大的设置可以提高性能,但也会增加恢复故障数据库所需的时间

    innodb_log_file_size = 128M

    #为提高性能,MySQL可以以循环方式将日志文件写到多个文件。推荐设置为3M

    innodb_log_files_in_group = 3

    #推荐阅读 http://www.taobaodba.com/html/221_innodb_max_dirty_pages_pct_checkpoint.html

    # Buffer_Pool中Dirty_Page所占的数量,直接影响InnoDB的关闭时间。参数innodb_max_dirty_pages_pct 可以直接控制了Dirty_Page在Buffer_Pool中所占的比率,而且幸运的是innodb_max_dirty_pages_pct是可以动 态改变的。所以,在关闭InnoDB之前先将innodb_max_dirty_pages_pct调小,强制数据块Flush一段时间,则能够大大缩短 MySQL关闭的时间。

    innodb_max_dirty_pages_pct = 90

    # InnoDB 有其内置的死锁检测机制,能导致未完成的事务回滚。但是,如果结合InnoDB使用MyISAM的lock tables 语句或第三方事务引擎,则InnoDB无法识别死锁。为消除这种可能性,可以将innodb_lock_wait_timeout设置为一个整数值,指示 MySQL在允许其他事务修改那些最终受事务回滚的数据之前要等待多长时间(秒数)

    innodb_lock_wait_timeout = 120

    #独享表空间(关闭)

    innodb_file_per_table = 0

     

    #start mysqld with –slow-query-log-file=/data/mysql/3306/slow.log

    slow_query_log

    long_query_time = 1

     

    replicate-ignore-db = mysql

    replicate-ignore-db = test

    replicate-ignore-db = information_schema

    #配置从库上的更新操作是否写二进制文件,如果这台从库,还要做其他从库的主库,那么就需要打这个参数,以便从库的从库能够进行日志同步这个参数要和—logs-bin一起使用

    log-slave-updates

    log-bin = /data/mysql/3306/binlog/binlog

    binlog_cache_size = 4M

    #STATEMENT,ROW,MIXED

    #基于SQL语句的复制(statement-based replication, SBR),基于行的复制(row-based replication, RBR),混合模式复制(mixed-based replication, MBR)。相应地,binlog的格式也有三种:STATEMENT,ROW,MIXED。

    binlog_format = MIXED

    max_binlog_cache_size = 64M

    max_binlog_size = 1G

    relay-log-index = /data/mysql/3306/relaylog/relaylog

    relay-log-info-file = /data/mysql/3306/relaylog/relaylog

    relay-log = /data/mysql/3306/relaylog/relaylog

    expire_logs_days = 30

     

     

    skip-name-resolve

    #master-connect-retry = 10

    slave-skip-errors = 1032,1062,126,1114,1146,1048,1396

    server-id = 1

     

    [mysqldump]

    quick

    max_allowed_packet = 32M

     

    [myisamchk]

    key_buffer_size = 256M

    sort_buffer_size = 256M

    read_buffer = 2M

    write_buffer = 2M

     

    [mysqlhotcopy]

    interactive-timeout

    设Slow Query Log

    http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

    [mysqld]
    long_query_time=1
    log-slow-queries=/var/log/mysql/log-slow-queries.log

    You must create the file manually and change owners this way:

    mkdir /var/log/mysql
    touch /var/log/mysql/log-slow-queries.log
    chown mysql.mysql -R /var/log/mysql

     

    tmp_table_size=512M
    key_buffer_size = 1024M
    read_buffer_size = 32M
    max_connections = 5000
    query_cache_size = 512M

    query_cache_limit = 16M

    sort_buffer_size = 8M
    join_buffer_size = 1M

  • Fedora release 20

    1. 关闭防火墙

    systemctl stop firewalld                停止防火墙

    systemctl disable firewalld          禁用防火墙

    2. 停用selinux

    vi /etc/selinux/config

    将文件中的SELINUX选项修改为disable.

    #     enforcing – SELinux security policy is enforced.
    #     permissive – SELinux prints warnings instead of enforcing.
    #     disabled – No SELinux policy is loaded.
    SELINUX=disable

    3. 安装更新源

    a) yum install yum-fastestmirror

    b) 下载 http://download1.rpmfusion.org下的free和nonfree中fedora20的rpm包(双击安装即可). 地址如下:

    http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-20.noarch.rpm

    http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-20.noarch.rpm

    4. 安装一些软件(上面3步执行之后建议重启一下电脑)

    yum -y install unar p7zip p7zip-plugins ibus-table ibus-pinyin ibus-table-chinese-wubi-haifeng  gnome-tweak-tool stardict stardict-dic-zh_CN stardict-dic-en

    一些开发软件:  yum -y install  vim emacs gcc gcc-c++ glibc.i686 glibc ncurses make cmake

    yum -y install  samba xinetd tftp tftp-server ftp vsftpd

     

    5. 支持mp3 rmvb等一系列格式 (摘自: http://www.linuxidc.com/Linux/2012-06/62112.htm )

    yum localinstall –nogpgcheck  http://mirrors.163.com/rpmfusion/free/fedora/rpmfusion-free-release-stable.noarch.rpm

    yum install gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly libtunepimp-extras-freeworld xine-lib-extras-freeworld

    yum install ffmpeg ffmpeg-libs gstreamer-ffmpeg libmatroska xvidcore

     

    6. 安装flash player

    a) 到adobe网站上下载gz包.

    b) 解压, 将usr文件夹拷贝到/目录    cp -rf usr /

    c) 将解压的libflashplayer.so拷贝到firefox目录    cp -f libflashplayer.so /usr/lib64/mozilla/plugins/

     

    二.  所遇问题解决方法

    1. 不能安装flash player (注意: 此安装需要占用大量磁盘空间,多数会安装一些无用程序)

    先执行: sudo yum -y install gstream-*

    sudo yum -y install gstream1-*

    执行后一般能安装,默认音频和视频播放器能正常安装插件.

    2. bad ELF interpreter: 没有那个文件或目录

    出错: 64位机 安装glibc.i686即可

    解决: sudo yum install glibc.i686

    3. 安装qt出现错误

    出错: cannot find -Igl

    解决: yum install libGL libGL-devel

  • 转–virtualbox 下Ubuntu使用USB

    关于linux mint 下virtualbox使用USB 的一点经验或者可以说是教训,由于我的Andriod开发在linux系统下进行的 ,为了因为要经常下载软件,在linux下下载不方便,就在linux下安装了虚拟机跑XP,在XP 下下载软件,于是就出现了虚拟机使用USB 问题
    方法/步骤

    1

    确保已经安装了virtualbox 建议安装最新的 我安装的是4.2.16和对应的 Extend pack

    1、

    https://www.virtualbox.org/wiki/Downloads 下载对应于你的系统的版本(linux windows等)注意要对应于你的操作系统位数是32还是64

    2、exntend pack

    在这个网站中找到:

    VirtualBox 4.2.16 Oracle VM VirtualBox Extension Pack  All supported platforms

    该包适合与所有的平台 不管是linux 还是windows还是其他的
    2

    以上安装完毕后,在Virtualbox主界面中可以看到USB设备,在虚拟机中的可分配USB设备也可以看到,但是灰色不可用。按照如下步骤做:

    1、添加usbfs 用户组(virtualbox 装完成后会有 vboxusers 和vboxsf )

    sudo groupadd usbfs

    使用命令查看你添加的用户组成功没有:

    cat /etc/group  我的如下:

    ………………

    ……………….

    ……………….

    colord:x:120:pulse:x:121:pulse-access:x:122:saned:x:123:vboxsf:x:124:sambashare:x:125:kueinmdm:x:110:kuein:x:1000:vboxusers:x:116:kueinwinbindd_priv:x:126:usbfs:x:1001:kuein // 这个就是我添加的

    2、将你的linux常用用户添加到vboxusers、usbfs这个两个组中

    sudo adduser kuein vboxusers

    sudo adduser kuein usbfs

    有些资料上说 还有第三步:

    3)、修改fstab文件,添加如下内容:

    none /sys/bus/usb/drivers usbfs devgid=802,devmode=664 0 0

    我操作过程当中 做了也没有用 所以我就省略了这步

    然后重启电脑,只有重启才会有用
    3

    重启之后,插上你的USB设备 ,在virtualbox的第一个选项中选择settings菜单 选择USB项 将enable usb controler 、enable usb2.0 controler打勾。在USB device filler项点击“+”选择你的USB 设备,将你的USB 设备添加上,进入虚拟机安装的系统在状态栏(我的是XP 右下角)的USB图标上右击鼠标,选择你刚添加的你的USB 设备,没有弹出失败的框框说明已经成功。如果需要则会提示安装USB 驱动。注意:我在这里卡了很久,总是提示什么主机没有加载,明明我在linux下用lsusb 看到我的设备了,后来我就重启了虚拟机,再次点击还是同样的提示,哥郁闷,想了个歪招,切换到我的爽系统之一XP (不是Virtualbox中的这个XP 哦),格式化了我的USB 设备,再次进入虚拟机的XP 系统,成功提示安装USB驱动,OK 大功告成!下载软件 开机OK 。如果你是和我一样,注意一下我说的这两点。

    以上就是我的virtualbox使用USB 经验,由于刚刚搞这个东东,难免有很多地方让民间的高手觉得弱智,如果不对地方请大家多多包涵,并予以指正 ,多谢

    注意事项

    vritualbox版本最好用最新的版本,如果不是最新的版本 下载extend [pack 有点儿小麻烦

    如果你跟我一样是下软件到USB 设备的话 可能会有些不稳定 如果不能下载,点击右下角的USB图标,重新加载你的USB 就可以了

  • 转–ubuntu apt-get install

    sudo apt-get install ntfs-3g ntfs-config #ntfs写入支持,装完后运行ntfs-config,把两个钩打上即可。楼下方法作废
    sudo apt-get install googleearth googlizer gtalk#google相关,skyx友情提示:不推荐马甲 gtalk
    sudo apt-get install ghex #GNOME 上的十六进制文件编辑器
    sudo apt-get install kvm #Full virtualization on x86 hardware 华主席推荐
    sudo apt-get install vmware-player #Free virtual machine player from VMware
    sudo apt-get install makeself #utility to generate self-extractable archives
    sudo apt-get install sun-java6-jre#安装JAVA6环境
    sudo apt-get install sun-java6-jdk #安装JAVA6环境#
    sudo update-alternatives –config java#设定JAVA环境
    sudo apt-get install rox-filer#一个简单的文件管理软件
    sudo apt-get install socks4-server socks4-clients #一个socks 代理服务器/soks4代理客户端
    sudo apt-get install mc #类似norton commander 工具,skyx 吐血推荐
    sudo apt-get install liferea #超强的rss reader ,明显比akregator好用, 由zhuqin_83吐血推荐
    sudo apt-get install axel-kapt gwget aria2#多线程下载工具,也可在论坛search 超强工具prozilla,由雕啸长空吐血推荐
    sudo apt-get install privoxy tor mixmaster anon-proxy socat#突破风锁线和雁过无痕
    sudo apt-get install kdebluetooth #超简单的ubuntu与蓝牙手机互传文件工具
    #蓝牙请参见:   http://forum.ubuntu.org.cn/viewtopic.php?t=61426&;highlight=
    sudo apt-get install build-essential #build-essential
    sudo apt-get install proxychains #一个socks4 socks5代理软件 ,可以支持apt-get代理
    sudo apt-get install language-support-zh language-pack-zh#安装中文语言支持
    sudo apt-get install stardict stardict-common stardict-cdict-gbstardict-cedict-gb stardict-hanzim stardict-langdao-ce-gbstardict-langdao-ec-gb stardict-oxford-gb stardict-xdict-ce-gbstardict-xdict-ec-gb stardict-jcedict stardict-jedictstardict-jmdict-en-ja stardict-jmdict-ja-en wyabdcrealpeopletts#安装StarDict
    sudo apt-get install rxvt yakuake tilda kuake konsole multi-gnome-terminal pyqonsole #几个终端
    sudo apt-get install viewglob #一个shell相关的工具
    sudo apt-get install nautilus-open-terminal #在右键菜单中加入打开终端
    sudo apt-get instll eva amsn wengophone skype licq #安装im语音视频聊天软件
    sudo apt-get install beryl emerald emerald-themes#安装beryl
    sudo apt-get install pcmanx-gtk2 qterm mozilla-plugin-pcmanx #安装bbs 客户端
    sudo apt-get install gkrell* #很好的一个东东,装了就知道了
    sudo apt-get install conky# 有意思的一个系统monitor
    sudo apt-get install nmapfe #nmap前端
    sudo apt-get install meld #一个文件、目录比较器
    sudo apt-get install imagemagick# e主席(ee)大力推荐的批量修改图片的软件,现在论坛个别人在搞个人崇拜
    sudo apt-get install kolourpaint #又一个画图软件
    sudo apt-get install tuxpaint #好玩的画图软件
    rgbpaint #getdeb上有,最弱,但很小巧的画图软件
    mtpaint(getdeb上有,比gpaint强一点的画图软件)。
    sudo apt-get install kompare # 又一个文件比较器
    sudo apt-get install gnome-commander #gnome 上类似Total commander的工具
    sudo apt-get install krusader #kde 上类似Total commander的工具
    sudo sudo apt-get install bum #系统服务管理软件
    sudo apt-get install rbot # ruby写的irc bot
    sudo apt-get install sysv-rc-conf #一款基于perl的开机进程调整工具,sysv-rc-conf执行命令即可
    sudo apt-get install rcconf # Debian Runlevel configuration tool
    sudo apt-get install rar unrar p7zip* #安装rar 7zip
    sudo apt-get install rpm alien #安装rpm支持
    sudo apt-get install xpdf xpdf-chinese-simplified #安装pdf查看软件
    sudo apt-get install xchm xpdf-chinese* #安装chm查看软件
    sudo apt-get install gqview #一个图片浏览器
    sudo apt-get install gnomebaker k3b#安装刻录软件
    sudo apt-get install brasero #gnome上的刻录软件
    sudo apt-get install ksnapshot #一个抓屏程序
    sudo apt-get install kinstaller #application installer
    sudo apt-get install vncserver #vncserver,vncview默认已经安装了
    sudo apt-get install tightvncserver tightvnc-java #另一个vnc
    sudo apt-get install apt-build #frontend to apt to build, optimize and install packages
    sudo apt-get install vim-full #vim无法高亮显示,然后编辑 /etc/vim/vimrc,取消syntax on前面的”注释符号
    sudo apt-get install firestarter #图形接口的防火墙设定程序
    sudo apt-get install smbfs #smbfs挂载支持
    sudo apt-get install flashplugin-nonfree #安装浏览器Flash插件
    sudo apt-get install gftp kftpgrabber filezilla kasablanca#安装ftp客户端
    sudo apt-get install sun-java5-jdk #安装Java环境
    sudo apt-get install sun-java5-plugin #安装Java环境
    sudo apt-get install build-essential # 安装编译环境
    sudo apt-get install yum rpm #redhat相关
    sudo apt-get install mysql-client mysql-server #安装mysql服务
    sudo apt-get install kde-i18n-zhcn kde-i18n-zhtw#k程序中文支持,很讨厌kde ,但不太讨厌qt程序可以这样装
    sudo apt-get install qt4-qtconfig#qt4 gui配制工具, 如字体等,很讨厌kde ,但不太讨厌qt程序可以这样装
    sudo apt-get install kcontrol #k程序gui配制工具,很讨厌kde ,但不太讨厌qt程序可以这样装
    sudo apt-get apache2 mysql-server php4 php4-gd php4-mysql #安装LAMP
    sudo apt-get install d4x azureus amule ktorrent mldonkey-servermldonkey-gui rtorrent qtorrent bittornado-gui bittorrent-guitorrentflux deluge-torrent# 几个下载/bt/电驴 工具
    sudo apt-get install sysstat #安装sar, iostat and mpstat
    sudo apt-get install nmap #网络端口扫描工具
    sudo apt-get install nfs-common #nfs
    sudo apt-get install samba nfs-kernel-server #samba
    sudo apt-get install xvidcap gnome-splashscreen-manager #安装屏幕视频录制 / splash 管理
    sudo apt-get install istanbul #Desktop session recorder
    sudo apt-get install sysinfo xsysinfo#系统信息查看

    网络
    [pre]$ sudo apt-get install d4x //这是linux上的flashget,在apt中可以找到
    $ sudo apt-get install amule //这是linux上的emule,在apt中可以找到
    $ sudo apt-get install eva //这是linux下的qq,只不过狡猾的腾讯修改了协议,用了eva以后再用就必须输入验证码才能进入,但eva并不支持验证码,所以最终的结果就是eva再也没法用了。
    $ sudo apt-get install tor privoxy //匿名动态代理,与之类似的还有JAP和freedom,据说freedom速度更快一些
    $ sudo apt-get install liferea //一个GTK的离线RSS阅读器
    $ sudo apt-get install curl //一个利用URL语法在命令行下工作的文件传输工具
    [/pre]

    系统
    [pre]$ sudo apt-get install rar //安装rar支持,装了以后,压缩包管理器就可以支持rar格式了
    $ sudo apt-get install bum //一个不错的安装系统启动程序管理器
    $ sudo apt-get install xpdf-chinese-simplified  //xpdf的中文字体支持,不过经过试用,貌似乱码依旧,这个问题可以参考ubuntu 下Evince看pdf文档的乱码解决方案
    $ sudo apt-get install gnome-commander //类似norton-commander的文件管理器,功能还不错,比较适合用惯了norton-commander的用户
    $ sudo apt-get install nautilus-open-terminal //在nautilus的右键菜单里打开终端,要重登录才起效
    $ sudo apt-get install nautilus-gksu //在nautilus中以管理员身份打开,要重登录才起效
    $ sudo apt-get install ntp //系统时间与internet时间保持同步
    $ sudo apt-get install meld //基于gonme的目录差异比较工具,可以比较文件夹和文件的变化
    $ sudo apt-get install enca //一个非常不错的编码转换工具
    $ sudo apt-get install keepassx //一个密码管理软件,具有windows版本和linux版本
    $ sudo apt-get gparted //图形化分区工具
    $ sudo apt-get install gcolor2 //一个不错的基于gtk的图形化吸取颜色的工具。
    $ sudo apt-get install unison-gtk //一个基于gtk的文件和目录同步工具,具有比较和合并功能。
    $ sudo apt-get install conduit //一个很牛的资源同步工具,可以同步网络相册,文件夹,邮件、照片等等资源,非常牛X
    $ sudo apt-get install manpages-zh //中文man手册,linux操作系统的必备资料
    [/pre]
    办公软件
    [pre]$ sudo apt-get install scribus //一个类似microsoft publisher的排版软件
    $ sudo apt-get install kchmviewer-nokde //一个看chm的小软件,支持中文,只是安装后只能用命令行启动,执行kchmviewer即可
    [/pre]
    多媒体
    [pre]$ sudo apt-get install ksnapshot //抓图工具
    $ sudo apt-get install ogle ogle-gui  //dvd 播放器
    $ sudo apt-get install mkisofs //貌似是和刻录光盘有关
    $ sudo apt-get install wink //一个屏幕录像工具,可以用来制作视频教程
    $ sudo apt-get install gsopcast //一个网络电视
    $ sudo apt-get install gonmebaker //一个gonme下的刻录光盘软件
    $ sudo apt-get install isomaster //一个管理和生成ISO镜像的小工局,可以提取、修改、删除添加文件,功能挺全的。
    $ sudo apt-get krita //一个小巧的图像编辑软件,比GIMP小巧,但功能对付一般的照片修改已经足够了。
    $ sudo apt-get install xaralx imagemagick //一个巨好的免费矢量图绘制工具,功能不是一般的强,windows下收费,linux下免费。
    $ sudo apt-get install gnome-subtitles //linux下的divx电影的字幕调校工具,可视化的哦
    [/pre]
    游戏
    $ sudo apt-get install wormux //百战天虫linux版,据本人体验,比起百战天虫差不少
    [pre]$ sudo apt-get install assaultCube //一个类似CS的FPS游戏,不过据本人体验,效果比起CS差远了
    $ sudo apt-get install glest glest-data //一个类似魔兽争霸的3D即时战略游戏,相当不错,强烈推荐。

  • ProFTPD1.3配置

    ProFTPD 支持MySQL数据库添加虚拟用户认证及Quotas(磁盘限额)

    proftpd.conf配置指令手册(en):http://www.proftpd.org/docs/directives/linked/configuration.html
    ProFTPD官方网站(en): http://www.proftpd.org/
    proftpd.conf配置指令手册(zh):
    http://www.itlearner.com/article/3549/relate
    安装环境:
    操作系统centos-5.2
    mysql 5.0.67 源代码安装在/usr/local/mysql目录

    1、proftpd-1.3.2源代码编译安装

    ./configure –prefix=/usr/local/proftpd
    –with-modules=mod_sql:mod_sql_mysql #支持mysql数据库
    –with-modules=mod_quotatab:mod_quotatab_sql #支持磁盘配额
    –with-modules=mod_tls #支持SSL/TLS安全传输
    –with-includes=/usr/local/mysql/include
    –with-libraries=/usr/local/mysql/lib
    make
    make install

    cp sample-configurations/mod_sql.conf /usr/local/proftpd/etc/proftpd.conf

    2、proftpd.conf文件配置基本格式:

    #全局设置
    设置项目1 参数1
    设置项目2 参数2
    ……
    ……
    #某个目录的设置
    <Directory “路径名”>
    ……
    ……
    </Directory>
    #关于匿名用户的设置
    <Anonymous “匿名登录的目录”>
    ……
    ……
    <Limit 限制动作>
    ……
    ……
    </Limit>
    </Anonymous>

    3、proftpd.conf配置文件中的一些基本配置:

    ServerName 服务器名称
    ServerType 服务器工作类型(standalone/inted)
    DefaultServer 是否启用虚拟FTP (on/off)
    Port 运行端口
    Umask 默认文件权限(022)
    User 运行proftpd服务器的用户
    Group 运行proftpd服务器的用户组
    AllowOverwrite 是否允许客户端覆盖文件(安全上一般设置为off)
    RequireValidShell 用户shell不在/etc/shells文件中,默认不允许登陆(on/off)
    MaxInstances 20 最多有20个proftpd的PID
    MaxClients 10 最多允许10个用户在线
    MaxClientsPerHost 1 一个IP只允许一个帐号连接
    MaxClientsPerUser 2 每个帐号在每个客户端最多同时登陆2次,可防止多线程下载软件
    DisplayLogin welcome.msg ftp登陆欢迎信息文件
    <Directory /*> 登入时想进入的目录位置(/* 为通配符)
    <Anonymous ~ftp> 匿名用户设置
    <Global> 所有虚拟ftp的共同设置项

    3.1 虚拟FTP设置
    <VirtualHost 192.168.0.1>
    ServerName “……”
    ……
    ……
    </VitualHost>

    3.2 开启ftp上传/下载的续传功能
    AllowStoreRestart on #上传
    AllowRetrieveRestart on #下载

    3.3 限速设置

    格式为: TransferRate STOR|RETR 速度(kbytes/s) user 使用者
    STOR 为上传速度
    RETR 为下载速度
    后面不跟user的时候,针对全部用户进行限速

    3.4 让proftpd支持FXP传输
    AllowForeignAddress on
    PassivePorts 40000 40999

    3.5 加快连接速度,关闭DNS反解
    UseReverseDNS off
    IdentLookups off

    3.6 只允许部分网段访问FTP
    <Limit LOGIN>
    Order allow,deny
    Allow from 10.10.
    Deny from all
    </Limit>

    4、<Limit>参数说明

    4.1 限制的动作
    CWD: Change Working Directory 改变目录
    MKD: Make Directory 创建目录
    RNFR: ReName FRom 更改目录名
    DELE: DELEte 删除文件
    RMD: ReMove Directory 删除目录
    RETR: RETRieve 下载
    STOR: STORe 上传
    READ: 可读文件的权限,但不包括列目录
    WRITE: 写文件或目录的权限,包括MKD和RMD
    DIRS: 列目录的权限
    LOGIN: 登陆的权限
    ALL: 所有权限

    4.2 <Limit>所应用的对象

    AllowUser/DenyUser AllowGroup/DenyGroup AllowALL/DenyAll ……

    5、部分安全策略配置

    5.1 隐藏proftpd服务器的版本信息
    ServerIdent off

    5.2 伪装Proftpd服务器
    伪装成windows下的ftp服务器Serv-U
    ServerIdent on “Serv-U FTP Server v6.4 for Winsock ready ……”

    5.3 使用非root权限运行proftpd服务:
    User nobody
    Group nobody

    禁止root登陆:
    RootLogin off

    对ftp用户使用chroot限制:
    DefaultRoot ~

    控制ftp命令缓冲区大小:
    CommandBufferSize 512

    修改proftpd服务器使用的端口:
    Port 2121

    5.4 监控Proftpd服务器运行情况

    5.4.1 记录ftp连接数
    watch -n 360 /usr/local/proftpd/bin/ftpcount
    每隔360秒显示一次连接用户数量的信息

    5.4.2 查找谁与FTP服务器连接
    /usr/local/proftpd/bin/ftpwho

    5.5 服务器配置文件的修改(proftpd.conf)

    5.5.1 通过IP地址限制FTP访问
    #只允许10.10.0.0/16网段用户访问
    <Limit LOGIN>
    Order allow,deny
    Allow from 10.10.
    Deny from all
    </Limit>

    5.5.2 使用pam作为proftpd授权用户的鉴别方法
    AuthPAM on
    AuthPAMConfig ftp

    修改/etc/pam.d/ftp相应文件

    5.5.3 限制FTP命令特权

    *禁止一些用户创建和删除目录的特权
    <Directory /*>
    <Limit MKD RMD>
    Order deny,allow
    DenyGroup badusers
    AllowAll
    </Limit>
    </Directory>

    *建立只能上载的FTP服务器
    <Directory /*>
    <Limit RETE>
    DenyAll
    </Limit>
    </Directory>

    *限制对单个目录的访问
    <Directory /*>
    <Limit CWD>
    DenyAll
    </Limit>
    </Directory>

    *限制目录浏览特权
    <Directory /my/mp3s>
    <Limit DIRS>
    DenyGroup newfriends
    </Limit>
    </Directory>

    5.5.4 使不同用户之间相互隔离
    一些用户通常访问ISP的FTP服务器时,会看到一些不应当的系统信息,因此隐藏这些信息是必要的,下面是一个配置:
    DefaultRoot “/www”
    <Directory /www>
    HideNoAccess on
    <Limit ALL>
    IgnoreHidden on
    </Limit>
    </Directory>
    HideNoAccess指令将用户隐藏/www 目录下的所有条目,IgnoreHidden指令指示ProFTPD 服务器忽略用户所有指令。

    6、加密FTP服务器与客户端的连接
    需要在编译安装的时候配置支持相应模块
    ./configure –with-modules=mod_tls

    6.1 制作凭证
    # mkdir /etc/ssl/certs
    # mkdir /etc/ssl/private
    # chmod og-rwx /etc/ssl/private
    # mkdir /etc/ssl/crl
    # mkdir /etc/ssl/newcerts
    修改 /etc/ssl/openssl.cnf
    把 dir = ./demoCA 改成 dir = /etc/ssl

    6.2 制作最高层认证中心 (Root CA)
    Private Key ( Public Key )
    # openssl genrsa -des3 -out /etc/ssl/private/myrootca.key 2048
    # chmod og-rwx /etc/ssl/private/myrootca.key
    填写凭证申请书 (然后按照问题回答即可)
    #openssl req -new -key /etc/ssl/private/myrootca.key -out /tmp/myrootca.req
    签发凭证
    # openssl x509 -req -days 7305 -sha1 -extfile /etc/ssl/openssl.cnf -extensions v3_ca -signkey /etc/ssl/private/myrootca.key
    -in /tmp/myrootca.req -out /etc/ssl/certs/myrootca.crt
    # rm -f /tmp/myrootca.req

    6.3 用最高层认证中心签发凭证
    制作服务器用的凭证
    # openssl genrsa -out /etc/ssl/private/myhost.key 2048
    # chmod og-rwx /etc/ssl/private/myhost.key
    填写凭证申请书
    # openssl req -new -key /etc/ssl/private/myhost.key -out /tmp/myhost.req
    # openssl x509 -req -days 3650 -sha1 -extfile /etc/ssl/openssl.cnf -extensions v3_req -CA /etc/ssl/certs/myrootca.crt
    -CAkey /etc/ssl/private/myrootca.key -CAserial /etc/ssl/myrootca.srl
    -CAcreateserial -in /tmp/myhost.req -out /etc/ssl/certs/myhost.crt
    # rm -f /tmp/myhost.req

    6.4 接下来设定proftpd.conf,主要是在最后加上以下有关TLS的设

    < IfModule mod_tls.c >
    TLSEngine on
    TLSLog /var/log/tls.log
    TLSProtocol SSLv23
    TLSOptions NoCertRequest
    TLSRequired On
    TLSRSACertificateFile /etc/ssl/certs/myhost.crt
    TLSRSACertificateKeyFile /etc/ssl/private/myhost.key
    TLSCACertificateFile /etc/ssl/certs/myrootca.crt
    TLSVerifyClient On
    < /IfModule >

    7、有关MySQL+Quota的设置
    需要在编译安装的时候配置支持相应模块
    ./configure –with-modules=mod_sql:mod_sql_mysql
    –with-modules=mod_quotatab:mod_quotatab_sql
    –with-includes=/usr/local/mysql/include
    –with-libraries=/usr/local/mysql/lib
    7.1 数据库的导入

    mysql mysql -uroot -ppassword
    create database ftpdb
    grant select, update on ftpdb.* to proftpd@localhost identified by ‘password’
    use ftpdb
    CREATE TABLE `ftpgroup` (
    `groupname` varchar(16) NOT NULL default ”,
    `gid` smallint(6) NOT NULL default ‘5500′,
    `members` varchar(16) NOT NULL default ”,
    KEY `groupname` (`groupname`)
    ) TYPE=MyISAM COMMENT=’ProFTP group table’;

    INSERT INTO `ftpgroup` VALUES (’ftpgroup’, 5500, ‘ftpuser’);

    CREATE TABLE `ftpquotalimits` (
    `name` varchar(30) default NULL,
    `quota_type` enum(’user’,’group’,’class’,’all’) NOT NULL default ‘user’,
    `per_session` enum(’false’,’true’) NOT NULL default ‘false’,
    `limit_type` enum(’soft’,’hard’) NOT NULL default ’soft’,
    `bytes_in_avail` float NOT NULL default ‘0′,
    `bytes_out_avail` float NOT NULL default ‘0′,
    `bytes_xfer_avail` float NOT NULL default ‘0′,
    `files_in_avail` int(10) unsigned NOT NULL default ‘0′,
    `files_out_avail` int(10) unsigned NOT NULL default ‘0′,
    `files_xfer_avail` int(10) unsigned NOT NULL default ‘0′
    ) TYPE=MyISAM;

    CREATE TABLE `ftpquotatallies` (
    `name` varchar(30) NOT NULL default ”,
    `quota_type` enum(’user’,’group’,’class’,’all’) NOT NULL default ‘user’,
    `bytes_in_used` float NOT NULL default ‘0′,
    `bytes_out_used` float NOT NULL default ‘0′,
    `bytes_xfer_used` float NOT NULL default ‘0′,
    `files_in_used` int(10) unsigned NOT NULL default ‘0′,
    `files_out_used` int(10) unsigned NOT NULL default ‘0′,
    `files_xfer_used` int(10) unsigned NOT NULL default ‘0′
    ) TYPE=MyISAM;

    CREATE TABLE `ftpuser` (
    `id` int(10) unsigned NOT NULL auto_increment,
    `userid` varchar(32) NOT NULL default ”,
    `passwd` varchar(32) NOT NULL default ”,
    `uid` smallint(6) NOT NULL default ‘5500′,
    `gid` smallint(6) NOT NULL default ‘5500′,
    `homedir` varchar(255) NOT NULL default ”,
    `shell` varchar(16) NOT NULL default ‘/sbin/nologin’,
    `count` int(11) NOT NULL default ‘0′,
    `accessed` datetime NOT NULL default ‘0000-00-00 00:00:00′,
    `modified` datetime NOT NULL default ‘0000-00-00 00:00:00′,
    PRIMARY KEY (`id`)
    ) TYPE=MyISAM COMMENT=’ProFTP user table’ ;
    7.2 在proftpd.conf文件中加入sql相关配置:

    SQLAuthTypes Backend Plaintext
    #Backend表示用户认证方式为MySQL数据库的认证方式
    #Plaintext表示明文认证方式,排在最前面的为最先使用的方式
    SQLAuthenticate users* groups*

    # databasename@host database_user user_password
    SQLConnectInfo ftpdb@localhost proftpd password
    SQLUserInfo ftpuser userid passwd uid gid homedir shell
    SQLGroupInfo ftpgroup groupname gid members
    SQLHomedirOnDemand on
    #如果用户主目录不存在,则系统会根据此用户在用户数据表中的homedir字段的值新建一个目录
    # Update count every time user logs in
    SQLLog PASS updatecount
    SQLNamedQuery updatecount UPDATE “count=count+1,accessed=now() WHERE userid=’%u’” ftpuser
    # Update modified everytime user uploads or deletes a file
    SQLLog STOR,DELE modified
    SQLNamedQuery modified UPDATE “modified=now() WHERE userid=’%u’” ftpuser

    7.3 加入Quota磁盘配额相关设置

    QuotaEngine on
    QuotaDirectoryTally on
    QuotaDisplayUnits Mb
    QuotaShowQuotas on
    QuotaLog “/var/log/quota”
    SQLNamedQuery get-quota-limit SELECT “name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = ‘%{0}’ AND quota_type = ‘%{1}’”

    SQLNamedQuery get-quota-tally SELECT “name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = ‘%{0}’ AND quota_type = ‘%{1}’”

    SQLNamedQuery update-quota-tally UPDATE “bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used+ %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = ‘%{6}’ AND quota_type = ‘%{7}’” ftpquotatallies

    SQLNamedQuery insert-quota-tally INSERT “%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}” ftpquotatallies

    QuotaLimitTable sql:/get-quota-limit
    QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally

    7.4 ftpquotalimits表设置说明

    name: – 用户帐号
    quota type: – user, group, class, all (we use user)
    per_session: – true or false (we use true)
    limit_type: – 硬限制 or 软限制 (我们一般用硬限制)
    bytes_in_avail: – 允许上传的字节数
    bytes_out_avail: – 允许下载的字节数
    bytes_xfer_avail: – 允许传输的字节数(包括上传/下载)
    files_in_avail: – 允许上传的文件数
    files_out_avail: – 允许下载的文件数
    files_xfer_avail: – 允许传输的文件数(包括上传/下载)

    8、其他
    8.1 使用命令ftpshut
    基本格式:
    ftpshut [ -l min ] [ -d min ] time [ warning-message … ]
    参数说明:
    -l min: 在ftp关闭服务之前的几分钟内,尝试建立新的ftp连接均不被接受
    -d min: 在ftp关闭服务之前的几分钟内,已经建立的ftp连接将被中止
    time: 在多少时间后,服务器将关闭ftp服务,格式有两种
    +number 经过number分钟后关闭
    MMHH 在今天MM:HH服务器将关闭

    8.2 welcome.msg 欢迎文件可用参数

    %T 目前的时间
    %F 所在硬盘剩下的容量
    %C 目前所在的目录
    %R Client 端的主机名称
    %L Server 端的主机名称
    %U 使用者帐户名称
    %M 最大允许连接人数
    %N 目前的服务器连接人数
    %E FTP服务器管理员的 email
    %i 本次上传的文件数量
    %o 本次下载的文件数量
    %t 本次上传+下载的文件数量
    应用举例:
    欢迎您%U, 这是Frank的测试FTP服务器;
    目前时间是:%T;
    本服务器最多允许%M个用户连接数;
    目前服务器上已有%N个用户连接数;
    目前你所在的目录是%C;
    目录所在的硬盘还剩下%F字节。