<![CDATA[Messages posted by "phuongtnotv"]]> /hvaonline/posts/listByUser/274945.html JForum - http://www.jforum.net Lỗi Mysql Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'  ]]> /hvaonline/posts/preList/45517/280074.html#280074 /hvaonline/posts/preList/45517/280074.html#280074 GMT Trong php-fpm nên sử dụng listen TCP/IP hay Socket /hvaonline/posts/preList/45163/278479.html#278479 /hvaonline/posts/preList/45163/278479.html#278479 GMT Bật hàn ftp trong linux

nguyenga86 wrote:
nếu có quyền root thì vào bạn vào file Php.ini rồi enable nó lênlaf được ( nếu server chạy php , cái khác mình không biết) , nếu không có root thì bó tay ( có thể tìm cách khai thác RFI hoặc LFI ) 
Mình tìm trong file php.ini ko có hàm nào ftp . Cậu nói cụ thể hơn đc ko :(]]>
/hvaonline/posts/preList/45025/277968.html#277968 /hvaonline/posts/preList/45025/277968.html#277968 GMT
Bật hàm ftp trong linux /hvaonline/posts/preList/45025/277904.html#277904 /hvaonline/posts/preList/45025/277904.html#277904 GMT Mysql chiếm tải CPU :(
]]>
/hvaonline/posts/preList/44822/276380.html#276380 /hvaonline/posts/preList/44822/276380.html#276380 GMT
Lỗi database trên Centos

quanta wrote:
Mình cần full processlist lúc gần chạm ngưỡng ấy chứ 10 cái mà lại toàn Sleep thế kia thì có tác dụng gì. `my.cnf` nhìn tạm ổn ngoài việc nên tăng `innodb_buffer_pool_size` lên nữa. Bạn có 32G RAM, trước mắt cứ tăng lên... gấp đôi con số hiện tại (16G), sau này có thể tăng lên 24G cũng được (nếu server này không chạy dịch vụ gì khác ngoài MySQL). 
Mình dùng nginx + php-fpm . Do php-fpm chiếm nhiều ram quá (~ 25G) nên mình giảm innodb_buffer_pool_size xuống 8G]]>
/hvaonline/posts/preList/44787/276148.html#276148 /hvaonline/posts/preList/44787/276148.html#276148 GMT
Lỗi database trên Centos

quanta wrote:
- Cho mình xem full processlist luôn nhé. - Cài mysqltuner, chạy và gửi kết quả lên. - Kiểm tra lại phía ứng dụng xem có chỗ nào dùng persistent connection không. 
processlist mysql full Code:
mysql> SHOW FULL PROCESSLIST\G
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    758726
Current database: *** NONE ***

*************************** 1. row ***************************
     Id: 758695
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 2. row ***************************
     Id: 758697
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 3. row ***************************
     Id: 758704
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 4. row ***************************
     Id: 758706
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 5. row ***************************
     Id: 758711
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 6. row ***************************
     Id: 758712
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 7. row ***************************
     Id: 758713
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 8. row ***************************
     Id: 758714
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 9. row ***************************
     Id: 758722
   User: admin_domain
   Host: localhost
     db: admin_domain
Command: Sleep
   Time: 0
  State:
   Info: NULL
*************************** 10. row ***************************
     Id: 758726
   User: root
   Host: localhost
     db: NULL
Command: Query
   Time: 0
  State: NULL
   Info: SHOW FULL PROCESSLIST
10 rows in set (0.01 sec)
mysqltuner Code:
[root@server ~]# ./mysqltuner.pl

 >>  MySQLTuner 1.0.1 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
 >>  Run with '--help' for additional options and output filtering

-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.51a-community-log
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 3G (Tables: 258)
[--] Data in InnoDB tables: 14G (Tables: 146)
[--] Data in MEMORY tables: 14M (Tables: 32)
[!!] Total fragmented tables: 27

-------- Performance Metrics -------------------------------------------------
[--] Up for: 3h 4m 34s (7M q [690.153 qps], 723K conn, TX: 167B, RX: 3B)
[--] Reads / Writes: 76% / 24%
[--] Total buffers: 8.8G global + 6.1M per thread (1024 max threads)
[OK] Maximum possible memory usage: 15.0G (47% of installed RAM)
[OK] Slow queries: 0% (536/7M)
[OK] Highest usage of available connections: 33% (340/1024)
[OK] Key buffer size / total MyISAM indexes: 512.0M/3.2G
[OK] Key buffer hit rate: 97.7% (56M cached / 1M reads)
[OK] Query cache efficiency: 37.6% (1M cached / 4M selects)
[!!] Query cache prunes per day: 16234235
[OK] Sorts requiring temporary tables: 0% (314 temp sorts / 629K sorts)
[!!] Joins performed without indexes: 493
[OK] Temporary tables created on disk: 2% (3K on disk / 120K total)
[OK] Thread cache hit rate: 96% (22K created / 723K connections)
[!!] Table cache hit rate: 0% (64 open / 1M opened)
[OK] Open file limit used: 0% (32/5K)
[OK] Table locks acquired immediately: 97% (7M immediate / 7M locks)
[!!] InnoDB data size / buffer pool: 14.8G/8.0G

-------- Recommendations -----------------------------------------------------
General recommendations:
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
    Adjust your join queries to always utilize indexes
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    query_cache_size (> 1M)
    join_buffer_size (> 1020.0K, or always use indexes with joins)
    table_cache (> 64)
    innodb_buffer_pool_size (>= 14G)
]]>
/hvaonline/posts/preList/44787/276145.html#276145 /hvaonline/posts/preList/44787/276145.html#276145 GMT
Lỗi database trên Centos

quanta wrote:
145 chưa phải là cao lắm nhỉ, mình thấy bạn để max_connections những 1024 mà. Lúc nào chạm ngưỡng, bạn lọc tiếp theo Command (post #4) xem chúng đang làm gì: Code:
mysql -e "show full processlist\G" | awk -F ": " '/Command/ { print $(NF-2) }' | sort | uniq -c | sort -rn
Nên lập một chủ đề khác cho câu hỏi liên quan đến Dovecot. 
Code:
[root@server ~]# mysql -e "show full processlist\G" | awk -F ": " '/Command/ { print $(NF-2) }' | sort | uniq -c | sort -rn
    186 Command: Query
     15 Command: Sleep
Mình dùng php-fpm . khi connections lên đến 260 là lỗi 502 bad gateway rồi Kiểm tra status của php-fpm Code:
pool:                 domain
process manager:      static
accepted conn:        6139
listen queue len:     0
max listen queue len: -1
idle processes:       1
active processes:     255
total processes:      256
max children reached: 0
]]>
/hvaonline/posts/preList/44787/276133.html#276133 /hvaonline/posts/preList/44787/276133.html#276133 GMT
Lỗi database trên Centos

quanta wrote:
`wait_timeout` của bạn đã set là 1 phút, đủ nhỏ rồi. Vậy lý do có thể là gì nhỉ? Nói chung là mình muốn có cơ chế giám sát `Threads_connected`, khi nào gần chạm `max_connections` thì chạy: Code:
mysql -e "show full processlist\G" | awk -F ": " '/User/ { print $2 }' | sort | uniq -c | sort -rn
xem ai đang mở nhiều connections nhất. PS: không phải cứ tăng max_connections lên vô tội vạ là sẽ giải quyết được vấn đề này đâu.  
KQ khi chạy tại thời điểm cao Code:
[root@server ~]# mysql -e "show full processlist\G" | awk -F ": " '/User/ { print $2 }' | sort | uniq -c | sort -rn
    145 admin_db
      1 Lan_nana A new account by the name of [URL=http://www.domain.com/member.php?u=196398]Hân_nana[/URL] has been registered. The new account has been moved to the Prevention Usergroup.\r\n\r\nOther recognized logins for this user are
      1 da_admin
Cho mình hỏi luôn 1 chút , cứ 1 tiếng mình lại nhận đc 1 mail cảnh báo này . Code:
A new message or response with subject:

The service 'dovecot' on server server.domain.com is currently down

has arrived for you to view.
Follow this link to view it:

 http://domain.com:2222/CMD_TICKET?action=view&number=000014857&type=ticket


======================================================
Automatically generated email produced by DirectAdmin 1.38.3
]]>
/hvaonline/posts/preList/44787/276127.html#276127 /hvaonline/posts/preList/44787/276127.html#276127 GMT
Lỗi database trên Centos

quanta wrote:

phuongtnotv wrote:
mysqli_real_connect(): (08004/1040): Too many connections  
Nghĩa là hiện đang có quá nhiều kết nối đến DB. Nếu bạn cũng không vào được thì chỉ còn cách đợi thôi. Khi nào login vào DB được thì bạn chạy lệnh sau và gửi kết quả lên: Code:
mysql> show global variables like '%timeout';
mysql> show global variables like '%connections';
Nhân tiện cũng nên gửi `my.cnf` lên. Server bạn có bao nhiêu RAM, dùng InnoDB hay MyISAM là chủ yếu?  
Đây là show global variables like '%timeout'; Code:
mysql> show global variables like '%timeout';
+----------------------------+-------+
| Variable_name              | Value |
+----------------------------+-------+
| connect_timeout            | 60    |
| delayed_insert_timeout     | 300   |
| innodb_lock_wait_timeout   | 50    |
| innodb_rollback_on_timeout | OFF   |
| interactive_timeout        | 120   |
| net_read_timeout           | 30    |
| net_write_timeout          | 60    |
| slave_net_timeout          | 3600  |
| table_lock_wait_timeout    | 50    |
| wait_timeout               | 60    |
+----------------------------+-------+
10 rows in set (0.00 sec)
Code:
mysql> show global variables like '%connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| max_connections      | 1024  |
| max_user_connections | 0     |
+----------------------+-------+
2 rows in set (0.00 sec)
đây là my.cnf Code:
[mysqld]
back_log                        = 100
open-files-limit                = 2048
open-files                      = 256
#max_connect_errors = 100000

skip-external-locking
skip-name-resolve
log_error                       = mysql-error.err
log_slow_queries                = mysql-slow.log

## Per-Thread Buffers * (max_connections) = total per-thread mem usage
thread_stack                    = 64K     #default: 32bit: 192K, 64bit: 256K
sort_buffer_size                = 2M      #default: 2M, larger may cause perf issues
read_buffer_size                = 1M      #default: 128K, change in increments of 4K
read_rnd_buffer_size            = 2M      #default: 256K
join_buffer_size                = 1M      #default: 128K
#binlog_cache_size              = 64K     #default: 32K, size of buffer to hold TX queries
#table_definition_cache = 10000
#table_open_cache = 10000
thread_cache_size = 1024
## total per-thread buffer memory usage: 8832000K = 8.625GB

## Query Cache
#query_cache_type               = 1
query_cache_size                = 1M    #global buffer
query_cache_limit               = 128M  #max query result size to put in cache

## Table and TMP settings
max_heap_table_size             = 256M  #recommend same size as tmp_table_size
bulk_insert_buffer_size         = 256M  #recommend same size as tmp_table_size
tmp_table_size                  = 256M    #recommend 1G min
#net_buffer_length = 16384
## Table cache settings
table_cache                     = 1000  #5.0.x <default: 64>

## Thread settings
thread_concurrency              = 8  #recommend 2x CPU cores
thread_cache_size               = 10  #recommend 5% of max_connections

#Query cache
#query_cache_size = 52428800;
query_cache_type = 1

local-infile=0
socket=/var/lib/mysql/mysql.sock
skip-locking
#skip-innodb
#query_cache_type=1
#query_cache_limit=32M
#query_cache_size=512M
max_connections=1024
interactive_timeout=120
wait_timeout=15
connect_timeout=60

key_buffer= 1M
record_buffer=1M

myisam_sort_buffer_size=256M
myisam_max_sort_file_size       = 2048M


#innodb_read_ahead = none
innodb_file_per_table = 1
innodb_open_files = 1000
#innodb_data_home_dir = /var/lib/mysql/ibdatadir
innodb_data_file_path= ibdata1:4G:autoextend
innodb_buffer_pool_size = 8G
innodb_additional_mem_pool_size = 64M

#innodb_log_group_home_dir = /var/lib/mysql/ibdlogdir
innodb_log_files_in_group = 2
innodb_log_file_size = 128M
innodb_log_buffer_size = 256M
innodb_flush_log_at_trx_commit = 2
#innodb_thread_concurrency = 0
#innodb_lock_wait_timeout=50
#innodb_flush_method = O_DIRECT
innodb_support_xa=0

# 200 * # DISKS
# plugin only
#innodb_io_capacity = 400
#innodb_read_io_threads = 4
#innodb_write_io_threads = 4

max_allowed_packet=128M
max_heap_table_size=32M
key_buffer_size = 512M
#low_priority_updates=1
#concurrent_insert=2
server-id=1

[safe_mysqld]
err-log=/var/log/mysqld.log
nice = -5
open_files_limit=8192

[mysqldump]
quick
max_allowed_packet=256M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer=2048M
sort_buffer=2048M
read_buffer=512M
write_buffer=512M

[myisamchk]
key_buffer=2048M
sort_buffer=2048M
read_buffer=512M
write_buffer=512M

[mysqlhotcopy]
interactive-timeout
Mình dùng InnoDB ]]>
/hvaonline/posts/preList/44787/276094.html#276094 /hvaonline/posts/preList/44787/276094.html#276094 GMT
Lỗi database trên Centos /hvaonline/posts/preList/44787/276079.html#276079 /hvaonline/posts/preList/44787/276079.html#276079 GMT Mysql tự nhiên ngốn CPU, Apache vượt max client allowed

quanta wrote:
- Ai đang SELECT * FROM `hd_log_errors`\G? - Tìm hiểu ý nghĩa các cột của EXPLAIN (đặc biệt là possible_keys, key, rows) - Chạy `SHOW KEYS FROM tbl_name` và tìm hiểu thêm về Indexes: http://dev.mysql.com/doc/refman/5.5/en/mysql-indexes.html 
Mình cũng bị tình trạng thế này mysql và php-fpm lúc nào cũng chiếm CPU trên 100%
]]>
/hvaonline/posts/preList/44704/275697.html#275697 /hvaonline/posts/preList/44704/275697.html#275697 GMT
Sever bị lỗi 502 bad gateway (nginx, php-fpm)

conmale wrote:
Chậc.... Máy có bao nhiêu core mà set "worker_processes 16;"? Sao không chỉnh "pm = dynamic" cho php-fpm mà chỉnh "pm = static"? Máy cấu hình mạnh hay nhẹ? Nên chỉnh lại hết mấy cái này tùy theo cấu hình. Không nên nhét các con số vô trong đó mà không theo dõi và rút tỉa từ tình hình và khả năng của máy trên thực tế.: pm.max_children = 128 pm.start_servers = 128 pm.min_spare_servers = 30 pm.max_spare_servers = 80 pm.max_requests = 500 
Sv em 16core nên em để worker_processes 16 Trên sv có 1 site chạy thì em nghĩ để static sẽ tốt hơn ]]>
/hvaonline/posts/preList/44530/275186.html#275186 /hvaonline/posts/preList/44530/275186.html#275186 GMT
Sever bị lỗi 502 bad gateway (nginx, php-fpm) /hvaonline/posts/preList/44530/274997.html#274997 /hvaonline/posts/preList/44530/274997.html#274997 GMT Sever bị lỗi 502 bad gateway (nginx, php-fpm)

xwm wrote:
Mình thấy file cấu hình php-fpm bạn ok rồi. Bạn kiểm tra lại xem php-fpm coi có đang chạy không (service php-fpm status). Nếu đang chạy mà vẫn báo lỗi bạn thử thay bằng đoạn này: location ~ \.php$ { root /home/admin/domains/domain.com/public_html/; index index.php index.html index.htm; fastcgi_pass php; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } Có thắc mắc bạn liên hệ với mình qua email root@xgr0up.net cho tiện nhé. 
Thỉnh thoảng vẫn lỗi cậu ơi Khi lỗi thì restart lại php-fpm là lại vào đc :( ]]>
/hvaonline/posts/preList/44530/274839.html#274839 /hvaonline/posts/preList/44530/274839.html#274839 GMT
Sever bị lỗi 502 bad gateway (nginx, php-fpm) Code:
[abc]

listen = /tmp/php-fpm.sock

listen.backlog = -1


listen.allowed_clients = 127.0.0.1


listen.owner = nobody
listen.group = nobody
listen.mode = 0666


user = nobody
group = nobody


pm = static

pm.max_children = 128

pm.start_servers = 128

pm.min_spare_servers = 30

pm.max_spare_servers = 80

pm.max_requests = 500


pm.status_path = /php-fpm-status/status.php

ping.path = /php-fpm-ping/ping.php

ping.response = pong
nginx.conf Code:
worker_processes        16;

events {
        use                     epoll;
        worker_connections      1024;
}

http {
        # php-fpm backend
        upstream php {
                server          unix:/tmp/php-fpm.sock;
        }

        # general proxying rules
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        Host            $host;
        proxy_buffer_size       32k;
        proxy_buffers           16      32k;
        proxy_wwwect          off;

        # fastcgi configuration
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout    180;
        fastcgi_read_timeout    180;
        fastcgi_buffer_size     128k;
        fastcgi_buffers         32      32k;
        fastcgi_busy_buffers_size       256k;
        fastcgi_temp_file_write_size    256k;
        fastcgi_intercept_errors        on;

#       access_log              on;
#       error_log               off;
        include                 mime.types;
        default_type            application/octet-stream;

        keepalive_timeout       0;

        gzip                    on;
        gzip_types              text/css text/xml application/x-javascript application/atom+xml application/rss+xml text/plain text/javascript;

        server_tokens           off;

        sendfile                on;
        tcp_nopush              on;
        tcp_nodelay             on;

        client_max_body_size    32M;

server {
                listen          xxx.xxx.xxx.xxx:80;
                server_name     domain.comt;

                root            /home/admin/domains/domain.com/public_html;

                location / {
                        index           index.html      index.php;
#               access_log              on;

               }


                location /clear.gif {
                        empty_gif;
        access_log              off;
                }


                location ~ \.(png|gif|jpg|jpeg|swf|css|js|ico)$ {
                        expires         90d;
        access_log              off;
                }

                location ~ ^/php-fpm-(status|ping)$ {
                        include         fastcgi_params;
                        fastcgi_pass    php;
                        fastcgi_param   SCRIPT_FILENAME $fastcgi_script_name;
                }


                location /archive/index.php {
                        include         fastcgi_params;
                        fastcgi_pass    php;
                        fastcgi_param   SCRIPT_FILENAME $document_root/archive/index.php;
        access_log              off;
                }

                location ~ \.php$ {
#        access_log              on;
                        if ($remote_addr = 0) {
                                rewrite ^(.*)$  http://lol.com/$1       break;
                        }

                        include         fastcgi_params;
                        if ($uri !~ "^/customavatars/"){
                                fastcgi_pass    php;
                        }
#                       fastcgi_param   SCRIPT_FILENAME $fastcgi_script_name;
                }

        error_page  502              /502.html;
        location = /502.html {
            root   /usr/local/nginx/html;
        }




        }
}
]]>
/hvaonline/posts/preList/44530/274715.html#274715 /hvaonline/posts/preList/44530/274715.html#274715 GMT
Sever bị lỗi 502 bad gateway (nginx, php-fpm) Code:
2013/04/04 16:57:49 [error] 28414#0: *10337 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:49 [error] 28414#0: *10166 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:49 [error] 28414#0: *10335 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:49 [error] 28414#0: *10341 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:49 [error] 28414#0: *10005 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:49 [error] 28414#0: *10345 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:49 [error] 28414#0: *10344 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10350 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10353 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10362 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10360 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10366 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10367 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10370 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10371 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
2013/04/04 16:57:50 [error] 28414#0: *10374 connect() to unix:/tmp/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client:
]]>
/hvaonline/posts/preList/44530/274696.html#274696 /hvaonline/posts/preList/44530/274696.html#274696 GMT