Strolen's World · Legacy archive

MySQL Modifications - zensiz

Started by Strolen Aug 1, 2010 7 posts Locked

  1. MySQL Modifications - zensiz

    #1

    [root@server1 ~]# perl mysqltuner.pl


    >>  MySQLTuner 1.0.1 - Major Hayden
    >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
    >>  Run with '--help' for additional options and output filtering
    Please enter your MySQL administrative login: strolen_grothar
    Please enter your MySQL administrative password:


    -------- General Statistics --------------------------------------------------
    [--] Skipped version check for MySQLTuner script
    Currently running supported MySQL version 5.1.49
    Operating on 64-bit architecture


    -------- Storage Engine Statistics -------------------------------------------
    [--] Status: -Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
    [--] Data in MyISAM tables: 139M (Tables: 97)
    [--] Data in InnoDB tables: 5M (Tables: 16)
    [--] Data in MEMORY tables: 124K (Tables: 1)
    [!!] Total fragmented tables: 20


    -------- Performance Metrics -------------------------------------------------
    [--] Up for: 4d 19h 9m 55s (1M q [3.865 qps], 67K conn, TX: 1B, RX: 349M)
    [--] Reads / Writes: 84% / 16%
    [--] Total buffers: 34.0M global + 2.7M per thread (151 max threads)
    Maximum possible memory usage: 449.2M (58% of installed RAM)
    Slow queries: 0% (14/1M)
    Highest usage of available connections: 17% (27/151)
    Key buffer size / total MyISAM indexes: 8.0M/64.7M
    Key buffer hit rate: 99.6% (87M cached / 314K reads)
    [!!] Query cache is disabled
    Sorts requiring temporary tables: 0% (0 temp sorts / 232K sorts)
    [!!] Joins performed without indexes: 23278
    [!!] Temporary tables created on disk: 40% (85K on disk / 211K total)
    [!!] Thread cache is disabled
    [!!] Table cache hit rate: 0% (64 open / 31K opened)
    Open file limit used: 10% (104/1K)
    Table locks acquired immediately: 99% (2M immediate / 2M locks)
    InnoDB data size / buffer pool: 5.0M/8.0M


    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        Enable the slow query log to troubleshoot bad queries
        Adjust your join queries to always utilize indexes
        When making adjustments, make tmp_table_size/max_heap_table_size equal
        Reduce your SELECT DISTINCT queries without LIMIT clauses
        Set thread_cache_size to 4 as a starting value
        Increase table_cache gradually to avoid file descriptor limits
    Variables to adjust:
        query_cache_size (>= 8M)
        join_buffer_size (> 128.0K, or always use indexes with joins)
        tmp_table_size (> 16M)
        max_heap_table_size (> 16M)
        thread_cache_size (start at 4)
        table_cache (> 64)

  2. Re: MySQL Modifications - zensiz

    #2
    Using login values from ~/.my.cnf
    - INITIAL LOGIN ATTEMPT FAILED -
    Testing for stored webmin passwords:
    None Found
    Could not auto detect login info!
    Found Sockets: /var/lib/mysql/mysql.sock
    Using: /var/lib/mysql/mysql.sock
    Would you like to provide a different socket?: [y/N] n
    Do you have your login handy ? [y/N] : y

    Would you like me to create a ~/.my.cnf file for you? [y/N] : y

            -- MYSQL PERFORMANCE TUNING PRIMER --
                - By: Matthew Montgomery -

    MySQL Version 5.1.49 x86_64

    tuning-primer.sh: line 497: bc: command not found
    tuning-primer.sh: line 498: bc: command not found
    tuning-primer.sh: line 499: bc: command not found
    tuning-primer.sh: line 500: bc: command not found
    tuning-primer.sh: line 501: bc: command not found
    tuning-primer.sh: line 502: bc: command not found
    Uptime =  days  hrs  min  sec
    Avg. qps = 3
    Total Questions = 1603605
    Threads Connected = 10

    Server has been running for over 48hrs.
    It should be safe to follow these recommendations

    To find out more information on how each of these
    runtime variables effects performance visit:
    http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html
    Visit http://www.mysql.com/products/enterprise/advisors.html
    for info about MySQL's Enterprise Monitoring and Advisory Service

    SLOW QUERIES
    The slow query log is NOT enabled.
    Current long_query_time = 10.000000 sec.
    You have 14 out of 1603626 that take longer than 10.000000 sec. to complete
    tuning-primer.sh: line 403: bc: command not found
    tuning-primer.sh: line 606: [: -gt: unary operator expected
    Your long_query_time seems to be fine

    BINARY UPDATE LOG
    The binary update log is NOT enabled.
    You will not be able to do point in time recovery
    See http://dev.mysql.com/doc/refman/5.1/en/point-in-time-recovery.html

    WORKER THREADS
    Current thread_cache_size = 0
    Current threads_cached = 0
    Current threads_per_sec = 1
    Historic threads_per_sec = 0
    Your thread_cache_size is fine

    MAX CONNECTIONS
    Current max_connections = 151
    Current threads_connected = 10
    Historic max_used_connections = 27
    The number of used connections is 17% of the configured maximum.
    Your max_connections variable seems to be fine.

    INNODB STATUS
    tuning-primer.sh: line 440: bc: command not found
    Current InnoDB index space =  M
    tuning-primer.sh: line 440: bc: command not found
    Current InnoDB data space =  M
    Current InnoDB buffer pool free = 10 %
    tuning-primer.sh: line 440: bc: command not found
    Current innodb_buffer_pool_size =  M
    Depending on how much space your innodb indexes take up it may be safe
    to increase this value to up to 2 / 3 of total system memory

    MEMORY USAGE
    tuning-primer.sh: line 1321: bc: command not found
    tuning-primer.sh: line 1322: bc: command not found
    tuning-primer.sh: line 1346: bc: command not found
    tuning-primer.sh: line 1349: bc: command not found
    tuning-primer.sh: line 1350: bc: command not found
    tuning-primer.sh: line 1352: bc: command not found
    tuning-primer.sh: line 1354: [: -gt: unary operator expected
    tuning-primer.sh: line 459: [: max_memoryHR: integer expression expected
    tuning-primer.sh: line 465: [: max_memoryHR: integer expression expected
    tuning-primer.sh: line 471: [: max_memoryHR: integer expression expected
    tuning-primer.sh: line 478: export: `=max_memoryHR': not a valid identifier
    Max Memory Ever Allocated :  bytes
    tuning-primer.sh: line 459: [: per_thread_buffersHR: integer expression expected
    tuning-primer.sh: line 465: [: per_thread_buffersHR: integer expression expected
    tuning-primer.sh: line 471: [: per_thread_buffersHR: integer expression expected
    tuning-primer.sh: line 478: export: `=per_thread_buffersHR': not a valid identifier
    Configured Max Per-thread Buffers :  bytes
    tuning-primer.sh: line 459: [: global_buffersHR: integer expression expected
    tuning-primer.sh: line 465: [: global_buffersHR: integer expression expected
    tuning-primer.sh: line 471: [: global_buffersHR: integer expression expected
    tuning-primer.sh: line 478: export: `=global_buffersHR': not a valid identifier
    Configured Max Global Buffers :  bytes
    tuning-primer.sh: line 459: [: total_memoryHR: integer expression expected
    tuning-primer.sh: line 465: [: total_memoryHR: integer expression expected
    tuning-primer.sh: line 471: [: total_memoryHR: integer expression expected
    tuning-primer.sh: line 478: export: `=total_memoryHR': not a valid identifier
    Configured Max Memory Limit :  bytes
    tuning-primer.sh: line 440: bc: command not found
    Physical Memory :  M
    Max memory limit seem to be within acceptable norms

    KEY BUFFER
    tuning-primer.sh: line 754: bc: command not found
    tuning-primer.sh: line 755: bc: command not found
    tuning-primer.sh: line 440: bc: command not found
    Current MyISAM index space =  M
    tuning-primer.sh: line 440: bc: command not found
    Current key_buffer_size =  M
    Key cache miss rate is 1 : 278
    Key buffer free ratio =  %
    tuning-primer.sh: line 792: [: -le: unary operator expected
    tuning-primer.sh: line 796: [: -le: unary operator expected
    Your key_buffer_size seems to be fine

    QUERY CACHE
    Query cache is supported but not enabled
    Perhaps you should set the query_cache_size

    SORT OPERATIONS
    tuning-primer.sh: line 440: bc: command not found
    Current sort_buffer_size =  M
    tuning-primer.sh: line 440: bc: command not found
    Current read_rnd_buffer_size =  K
    Sort buffer seems to be fine

    JOINS
    tuning-primer.sh: line 440: bc: command not found
    Current join_buffer_size =  K
    You have had 23291 queries where a join could not use an index properly
    You should enable "log-queries-not-using-indexes"
    Then look for non indexed joins in the slow query log.
    If you are unable to optimize your queries you may want to increase your
    join_buffer_size to accommodate larger joins in one pass.

    Note! This script will still suggest raising the join_buffer_size when
    ANY joins not using indexes are found.

    OPEN FILES LIMIT
    Current open_files_limit = 1024 files
    The open_files_limit should typically be set to at least 2x-3x
    that of table_cache if you have heavy MyISAM usage.
    Your open_files_limit value seems to be fine

    TABLE CACHE
    Current table_open_cache = 64 tables
    Current table_definition_cache = 256 tables
    You have a total of 114 tables
    You have 64 open tables.
    Current table_cache hit rate is 0%
    , while 100% of your table cache is in use
    You should probably increase your table_cache

    TEMP TABLES
    tuning-primer.sh: line 440: bc: command not found
    Current max_heap_table_size =  M
    tuning-primer.sh: line 440: bc: command not found
    Current tmp_table_size =  M
    Of 126442 temp tables, 40% were created on disk
    Perhaps you should increase your tmp_table_size and/or max_heap_table_size
    to reduce the number of disk-based temporary tables
    Note! BLOB and TEXT columns are not allow in memory tables.
    If you are using these columns raising these values might not impact your
    ratio of on disk temp tables.

    TABLE SCANS
    tuning-primer.sh: line 440: bc: command not found
    Current read_buffer_size =  K
    Current table scan ratio = 185 : 1
    read_buffer_size seems to be fine

    TABLE LOCKING
    Current Lock Wait ratio = 1 : 10350
    Your table locking seems to be fine
  3. Re: MySQL Modifications - zensiz

    #3
    KeepAlive On
    Timeout 30
    MaxKeepAliveRequests 2
    KeepAliveTimeout 1
    MaxClients 150
    ServerLimit 150
    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    MaxRequestsPerChild 1000
    ================

    port            = 3306
    socket          = /var/lib/mysql/mysql.sock
    skip-locking
    log-queries-not-using-indexes
    log-slow-queries=/var/log/slow_queries.log
    long_query_time = 5

    max_user_connections = 150 ===300===100
    open_files_limit = 1500

    key_buffer_size = 16M ===32===18==17
    ((18=.0042))
    max_allowed_packet = 16M
    table_open_cache = 1024 === 250===100===150==110==130
    ((150=14.77))((110=106.8))((130=??)
    thread_cache_size = 8 ===200===150===75===50
    ((150=.12))(75=.4133)((50=?))
    interactive_timeout = 20
    wait_timeout = 100
    connect_timeout = 15
    max_connect_errors = 10
    connect_timeout = 15
    max_connect_errors = 10

    max_heap_table_size = 20M===30M
    tmp_table_size = 20M ===16===20==25==28
    ((25=.8052)) ((25=.8099))((28=?))

    query_cache_size = 20M ===15===17===20M
    query_cache_limit = 1M ===2
    query_cache_type = 1

    sort_buffer_size = 2M
    net_buffer_length = 8K
    join_buffer_size = 2M====3M
    read_buffer_size = 2M
    read_rnd_buffer_size = 512K

    myisam_sort_buffer_size = 20M ===32===14

    server-id      = 1

    # Uncomment the following if you are using InnoDB tables
    innodb_data_home_dir = /var/lib/mysql/
    innodb_data_file_path = ibdata1:10M:autoextend
    innodb_log_group_home_dir = /var/lib/mysql/
    # You can set .._buffer_pool_size up to 50 - 80 %
    # of RAM but beware of setting memory usage too high
    innodb_buffer_pool_size = 16M
    innodb_additional_mem_pool_size = 2M
    # Set .._log_file_size to 25 % of buffer pool size
    innodb_log_file_size = 5M
    innodb_log_buffer_size = 8M
    innodb_flush_log_at_trx_commit = 1
    innodb_lock_wait_timeout = 50


    quick
    max_allowed_packet = 16M


    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates

    [mysqld_safe]
    open_files_limit = 8192
    err-log=/var/log/mysqld.log


    key_buffer_size = 32M ===64
    sort_buffer_size = 32M ===64
    read_buffer = 2M ===16
    write_buffer = 2M ===16


    interactive-timeout

    =================
        query_cache_size (> 17M)
      - join_buffer_size (> 3.0M, or always use indexes with joins)
      - tmp_table_size (> 20M)
      - max_heap_table_size (> 20M)
      - table_cache (> 100)
    ==================
    query_cache_size (> 20M)
        tmp_table_size (> 25M)
        max_heap_table_size (> 25M)
        table_cache (> 110)
  4. Re: MySQL Modifications - zensiz

    #4
    /etc/my.cnf

    [--] Up for: 3h 29m 41s (290K q [23.089 qps], 21K conn, TX: 354M, RX: 87M)
    [--] Reads / Writes: 75% / 25%
    [--] Total buffers: 75.0M global + 4.5M per thread (200 max threads)
    [!!] Maximum possible memory usage: 973.4M (126% of installed RAM)
    [!!] Slow queries: 15% (44K/290K)
    Highest usage of available connections: 9% (19/200)
    Key buffer size / total MyISAM indexes: 17.0M/67.8M
    Key buffer hit rate: 99.7% (5M cached / 14K reads)
    Query cache efficiency: 50.1% (103K cached / 205K selects)
    Query cache prunes per day: 0
    Sorts requiring temporary tables: 0% (0 temp sorts / 25K sorts)
    [!!] Joins performed without indexes: 2699
    [!!] Temporary tables created on disk: 44% (4K on disk / 10K total)
    Thread cache hit rate: 99% (19 created / 21K connections)
    Table cache hit rate: 95% (224 open / 234 opened)
    Open file limit used: 15% (354/2K)
    Table locks acquired immediately: 99% (175K immediate / 175K locks)
    InnoDB data size / buffer pool: 6.2M/8.0M

    -------- Recommendations -----------------------------------------------------
    General recommendations:
        Run OPTIMIZE TABLE to defragment tables for better performance
        MySQL started within last 24 hours - recommendations may be inaccurate
        Reduce your overall MySQL memory footprint for system stability
        Adjust your join queries to always utilize indexes
        When making adjustments, make tmp_table_size/max_heap_table_size equal
        Reduce your SELECT DISTINCT queries without LIMIT clauses
    Variables to adjust:
      *** MySQL's maximum memory usage is dangerously high ***
      *** Add RAM before increasing MySQL buffer variables ***
        join_buffer_size (> 1020.0K, or always use indexes with joins)
        tmp_table_size (> 32M)
        max_heap_table_size (> 16M)

    ==============


    local-infile=0

    skip-networking
    skip-locking
    log-queries-not-using-indexes
    log-slow-queries=/var/log/slow_queries.log
    long_query_time = 5

    key_buffer=17M
    join_buffer=1M
    record_buffer=1M
    sort_buffer=2M

    table_cache=1028
    thread_cache_size=50
    max_allowed_packet=5M

    query_cache_limit=1M
    query_cache_size=32M
    query_cache_type=1

    thread_concurrency=2
    max_connections=200

    interactive_timeout = 20
    wait_timeout = 100
    connect_timeout = 15
    max_connect_errors = 10
    connect_timeout = 15
    max_connect_errors = 10

  5. Re: MySQL Modifications - zensiz

    #5
    http://aleembawany.com/2010/11/26/vps-configuration-for-apache-mysql-php/

    /etc/my.cnf


    key_buffer = 228M
    sort_buffer_size = 4M
    read_buffer_size = 4M
    read_rnd_buffer_size = 4M
    myisam_sort_buffer_size = 12M
    query_cache_size = 44M

    local-infile=0

    skip-networking
    skip-locking
    log-queries-not-using-indexes
    log-slow-queries=/var/log/slow_queries.log
    long_query_time = 5

    #key_buffer=17M
    join_buffer=1M
    record_buffer=1M
    sort_buffer=2M

    table_cache=1028
    thread_cache_size=50
    max_allowed_packet=5M

    query_cache_limit=1M
    #query_cache_size=32M
    query_cache_type=1

    thread_concurrency=2
    max_connections=200

    interactive_timeout = 20
    wait_timeout = 100
    connect_timeout = 15
    max_connect_errors = 10
    connect_timeout = 15
    max_connect_errors = 10

    ========
    /etc/httpd/conf/httpd.conf

    ServerLimit 1024
    StartServers 10
    MinSpareServers 10
    MaxSpareServers 20
    MaxClients 30
    MaxRequestsPerChild 500

    Timeout 90
    KeepAlive On
    KeepAliveTimeout 2

    =======
    /usr/local/lib/php.ini

    memory_limit = 32M      ; Maximum amount of memory a script may consume (128MB)
  6. Re: MySQL Modifications - zensiz

    #6
    full: httpd.conf

    #
    # This is the main Apache HTTP server configuration file.  It contains the
    # configuration directives that give the server its instructions.
    # See for detailed information.
    # In particular, see
    #
    # for a discussion of each configuration directive.
    #
    # Do NOT simply read the instructions in here without understanding
    # what they do.  They're here only as hints or reminders.  If you are unsure
    # consult the online docs. You have been warned. 

    ServerRoot "/etc/httpd"
    Listen 80

    #LoadModule dummy_module /usr/lib/apache/mod_dummy.so
    Include /etc/httpd/conf/extra/httpd-phpmodules.conf

    User apache
    Group apache

    ServerAdmin admin@localhost
    DocumentRoot "/var/www/html"


    ServerLimit 1024
    StartServers 10
    MinSpareServers 10
    MaxSpareServers 20
    MaxClients 30
    MaxRequestsPerChild 500

    Timeout 90
    KeepAlive On
    KeepAliveTimeout 2


        AllowOverride All
        Options -MultiViews -Indexes FollowSymlinks IncludesNoExec  Includes

        Order allow,deny
        Allow from all


        Order deny,allow
        Deny from all




        Options All
        AllowOverride All



        Options -Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
     
            suPHP_Engine On
            suPHP_UserGroup webapps webapps
    SetEnv PHP_INI_SCAN_DIR
     



        DirectoryIndex index.html index.htm index.shtml index.php index.php5 index.php4 index.php3 index.phtml index.cgi



        Order allow,deny
        Deny from all
        Satisfy All


    ErrorLog /var/log/httpd/error_log
    LogLevel warn


        #replace %b with %O for more accurate logging
       
          LogFormat "%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i"" combined
          LogFormat "%h %l %u %t "%r" %>s %O" common
          LogFormat "%O %I" bytes

          LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
       

        CustomLog /var/log/httpd/access_log common



        # Include some DirectAdmin alias
        Include conf/extra/httpd-alias.conf



        AllowOverride None
        Options None
        Order allow,deny
        Allow from all



    #-------------------------------------------------------------------------------
    # Turn off directory listings for increased security
    #-------------------------------------------------------------------------------
    Options -Indexes

    #-------------------------------------------------------------------------------
    # Turn on following symbolic links.
    #-------------------------------------------------------------------------------
    Options  FollowSymLinks

    #-------------------------------------------------------------------------------
    # Some web servers require this for index.php to be removed properly.  You may
    # try your .htaccess with or without the following line.
    # Most work fine with it.
    #-------------------------------------------------------------------------------
    Options -MultiViews

    #-------------------------------------------------------------------------------
    # Make index.php the directory index page
    #-------------------------------------------------------------------------------
    DirectoryIndex index.php

    #-------------------------------------------------------------------------------
    # Always make sure mod_rewrite is installed before using.
    # If you are on a Linux server, uncomment the line with mod_rewrite.c
    # If on a Windows server using XAMPP, uncomment the line with mod_rewrite.so
    #-------------------------------------------------------------------------------

      RewriteEngine on

      #-----------------------------------------------------------------------------
      # Set the base directory where the application root is located.
      #-----------------------------------------------------------------------------
      # If your application is at http://www.domain.tld/path/to/CI_Application/
      # then uncomment the following line. Change /path/to/CI_Application/ to the
      # actual URL path not including the domain.tld (or localhost).
      # This includes using a subdirectory on localhost, like
      # http://localhost/path/to/CI_Application/
      #RewriteBase /path/to/CI_Application/

      # If your application is at http://www.domain.tld/ (or is http://localhost/)
      # then uncomment the following line.
      RewriteBase /

      #-----------------------------------------------------------------------------
      # The following 2 lines will force a www.prefix.  If you want to make sure
      # your site always displays the www subdomain, then uncomment the following
      # 2 lines.
      #-----------------------------------------------------------------------------
      #RewriteCond %{HTTP_HOST} !^www.domain.tld$
      #RewriteRule ^(.*)$ http://www.domain.tld/$1

      #-----------------------------------------------------------------------------
      # The following 2 lines will remove a www prefix.  If you wish to remove the
      # www and always have http://domain.tld instead of http://www.domain.tld
      # then uncomment the following 2 lines.
      #-----------------------------------------------------------------------------
      RewriteCond %{QUERY_STRING} node=(.*)$
      RewriteRule ^content(.*)$ viewing/%1? [L,R=301]
      RewriteCond %{QUERY_STRING} node=(.*)$
      RewriteRule ^user(.*)$ author/%1? [L,R=301]
    #RedirectMatch 301 ^/content.php?node=(. )$ /viewing/$1
     
    # Option 1:
    # Rewrite "www.domain.com -> domain.com"


      RewriteCond %{HTTPS} !=on
      RewriteCond %{HTTP_HOST} ^www.(. )$
      RewriteRule ^(.*)$ http://%1/$1


      # If the file is NOT the index.php file
      RewriteCond %{REQUEST_FILENAME} !index.php
      # Hide all PHP files so none can be accessed by HTTP
    # RewriteRule (.*).php$ index.php/$1
       
      # If the file/dir is NOT real go to index
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php/$1 [QSA,L]

    #-------------------------------------------------------------------------------
    # Don't forget to end the IfModule check for the rewrite engine.
    #-------------------------------------------------------------------------------


    # ----------------------------------------------------------------------
    # gzip compression
    # ----------------------------------------------------------------------




    # force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/

     
        SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)s,?s(gzip|deflate)?|X{4,13}|~{4,13}|-{4,13})$ HAVE_Accept-Encoding
        RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
     

    # html, txt, css, js, json, xml, htc:

      FilterDeclare  COMPRESS
      FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
      FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
      FilterChain    COMPRESS
      FilterProtocol  COMPRESS  change=yes;byteranges=no



      # Legacy versions of Apache
      AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
      AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
      AddOutputFilterByType DEFLATE text/xml application/xml text/x-component


    # webfonts and svg:
     
        SetOutputFilter DEFLATE
     




    # ----------------------------------------------------------------------
    # Expires headers (for better cache control)
    # ----------------------------------------------------------------------

    # these are pretty far-future expires headers
    # they assume you control versioning with cachebusting query params like
    # 
    # additionally, consider that outdated proxies may miscache
    #  www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/

    # if you don't use filenames to version, lower the css and js to something like
    #  "access plus 1 week" or so


      ExpiresActive on

    # Perhaps better to whitelist expires rules? Perhaps.
      ExpiresDefault                          "access plus 1 month"

    # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
      ExpiresByType text/cache-manifest      "access plus 0 seconds"

    # your document html
      ExpiresByType text/html                "access plus 0 seconds"
     
    # data
      ExpiresByType text/xml                  "access plus 0 seconds"
      ExpiresByType application/xml          "access plus 0 seconds"
      ExpiresByType application/json          "access plus 0 seconds"

    # rss feed
      ExpiresByType application/rss xml      "access plus 1 hour"

    # favicon (cannot be renamed)
      ExpiresByType image/x-icon              "access plus 1 week"

    # media: images, video, audio
      ExpiresByType image/gif                "access plus 1 month"
      ExpiresByType image/png                "access plus 1 month"
      ExpiresByType image/jpg                "access plus 1 month"
      ExpiresByType image/jpeg                "access plus 1 month"
      ExpiresByType video/ogg                "access plus 1 month"
      ExpiresByType audio/ogg                "access plus 1 month"
      ExpiresByType video/mp4                "access plus 1 month"
      ExpiresByType video/webm                "access plus 1 month"
     
    # htc files  (css3pie)
      ExpiresByType text/x-component          "access plus 1 month"
     
    # webfonts
      ExpiresByType font/truetype            "access plus 1 month"
      ExpiresByType font/opentype            "access plus 1 month"
      ExpiresByType application/x-font-woff  "access plus 1 month"
      ExpiresByType image/svg xml            "access plus 1 month"
      ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
       
    # css and javascript
      ExpiresByType text/css                  "access plus 2 months"
      ExpiresByType application/javascript    "access plus 2 months"
      ExpiresByType text/javascript          "access plus 2 months"
     
     
        Header append Cache-Control "public"
     
     




    # ----------------------------------------------------------------------
    # ETag removal
    # ----------------------------------------------------------------------

    # Since we're sending far-future expires, we don't need ETags for
    # static content.
    #  developer.yahoo.com/performance/rules.html#etags
    FileETag None



    DefaultType text/plain


        TypesConfig conf/mime.types
        AddType application/x-gzip .tgz
        AddEncoding x-compress .Z
        AddEncoding x-gzip .gz .tgz
        AddType application/x-compress .Z
        AddType application/x-gzip .gz .tgz
        AddHandler cgi-script .cgi
        AddHandler type-map var
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
    AddType video/x-ms-asf .avi
    AddType video/mpeg .mpg
    AddType video/mpeg .mpeg
    AddType video/quicktime .mov
    AddType video/x-ms-wmv .wmv


    #EnableMMAP off
    #EnableSendfile off

    #######################################################################################
    # Do not change anything in included files, because they are rewritten by DirectAdmin #
    #######################################################################################

    # This is needed for PHP
    Include conf/extra/httpd-php-handlers.conf

    # Server-pool management (MPM specific)
    Include conf/extra/httpd-mpm.conf

    # Multi-language error messages
    Include conf/extra/httpd-multilang-errordoc.conf

    # Fancy directory listings
    Include conf/extra/httpd-autoindex.conf

    # Language settings
    Include conf/extra/httpd-languages.conf

    # User home directories
    #Include conf/extra/httpd-userdir.conf

    # Real-time info on requests and configuration
    Include conf/extra/httpd-info.conf

    # Virtual hosts
    Include conf/extra/httpd-vhosts.conf

    # Local access to the Apache HTTP Server Manual
    #Include conf/extra/httpd-manual.conf

    # Distributed authoring and versioning (WebDAV)
    Include conf/extra/httpd-dav.conf

    # Various default settings
    Include conf/extra/httpd-default.conf

    # Secure (SSL/TLS) connections
    Include conf/extra/httpd-ssl.conf

    # Deflate module settings
    Include conf/extra/httpd-deflate.conf

    # All the DirectAdmin vhosts
    Include conf/extra/directadmin-vhosts.conf

    # All suPHP directives
    Include conf/extra/httpd-suphp.conf

    # For user configurations not maintained by DirectAdmin. Empty by default.
    Include conf/extra/httpd-includes.conf

    #######################################################################################
    # End of included files that are rewritten by DirectAdmin                            #
    #######################################################################################


    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin

  7. Re: MySQL Modifications - zensiz

    #7
    auto linode update script updated for DA

    #!/bin/bash 
    #
    # StackScript Bash Library
    #
    # Copyright (c) 2010 Linode LLC / Christopher S. Aker 
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without modification,
    # are permitted provided that the following conditions are met:
    #
    # * Redistributions of source code must retain the above copyright notice, this
    # list of conditions and the following disclaimer.
    #
    # * Redistributions in binary form must reproduce the above copyright notice, this
    # list of conditions and the following disclaimer in the documentation and/or
    # other materials provided with the distribution.
    #
    # * Neither the name of Linode LLC nor the names of its contributors may be
    # used to endorse or promote products derived from this software without specific prior
    # written permission.
    #
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
    # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
    # SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
    # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
    # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
    # DAMAGE.

    function mysql_tune {
      # Tunes MySQL's memory usage to utilize the percentage of memory you specify, defaulting to 40%
      # $1 - the percent of system memory to allocate towards MySQL

      MYSQLCONF=/etc/my.cnf
      cp $MYSQLCONF $MYSQLCONF.backup

      if [ ! -n "$1" ];
          then PERCENT=40
          else PERCENT="$1"
      fi

      # sed -i -e 's/^#skip-innodb/skip-innodb/' $MYSQLCONF # disable innodb - saves about 100M

      MEM=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo) # how much memory in MB this system has
      MYMEM=$((MEM*PERCENT/100)) # how much memory we'd like to tune mysql with
      MYMEMCHUNKS=$((MYMEM/4)) # how many 4MB chunks we have to play with

      # mysql config options we want to set to the percentages in the second list, respectively
      OPTLIST=(key_buffer sort_buffer_size read_buffer_size read_rnd_buffer_size myisam_sort_buffer_size query_cache_size)
      DISTLIST=(75 1 1 1 5 15)

      for opt in ${OPTLIST[@]}; do
          sed -i -e "/\[mysqld\]/,/\[.*\]/s/^$opt/#$opt/" $MYSQLCONF
      done

      for i in ${!OPTLIST[*]}; do
          val=$(echo | awk "{print int((${DISTLIST[$i]} * $MYMEMCHUNKS/100))*4}")
          if [ $val -lt 4 ]
            then val=4
          fi
          config="${config}\n${OPTLIST[$i]} = ${val}M"
      done

      sed -i -e "s/\(\[mysqld\]\)/\1\n$config\n/" $MYSQLCONF
    }

    function apache_tune {
      # Tunes Apache's memory to use the percentage of RAM you specify, defaulting to 40%
      # $1 - the percent of system memory to allocate towards Apache

      APACHECONF=/etc/httpd/conf/httpd.conf

      cp $APACHECONF $APACHECONF.backup

      if [ ! -n "$1" ];
          then PERCENT=40
          else PERCENT="$1"
      fi

      PERPROCMEM=10 # the amount of memory in MB each apache process is likely to utilize
      MEM=$(grep MemTotal /proc/meminfo | awk '{ print int($2/1024) }') # how much memory in MB this system has
      MAXCLIENTS=$((MEM*PERCENT/100/PERPROCMEM)) # calculate MaxClients
      MAXCLIENTS=${MAXCLIENTS/.*} # cast to an integer
      MAXREQUESTSPERCHILD=500
      KEEPALIVETIMEOUT=2
      sed -i -e "s/\(^[ \t]*MaxClients[ \t]*\)[0-9]*/\1$MAXCLIENTS/" $APACHECONF
      sed -i -e "s/\(^[ \t]*MaxRequestsPerChild[ \t]*\)[0-9]*/\1$MAXREQUESTSPERCHILD/" $APACHECONF
      sed -i -e "s/\(^[ \t]*KeepAliveTimeout[ \t]*\)[0-9]*/\1$KEEPALIVETIMEOUT/" $APACHECONF
    }

    function php_tune {
      PHPINI=/usr/local/lib/php.ini

      # Tunes PHP to utilize up to 32M per process
      sed -i'-orig' 's/memory_limit = [0-9]\+M/memory_limit = 32M/' $PHPINI
    }

    mysql_tune 40
    apache_tune 40
    php_tune

    /etc/init.d/apache2 reload
    /etc/init.d/mysql reload

Strolen's World · All categories · Guildhall