搭建4.xdebug+mysql general_log

來源:互聯網
上載者:User

標籤:http   io   ar   color   os   使用   for   strong   on   

1.先把tgz的包在本地解壓,把裡面的tar包傳到 centos的/root目錄,使用tar -xvf 解壓tar包,解壓出了xdebug-2.2.4、package.xml,
2。進入xdebug,執行phpize
3.不報錯的話 執行./configure --enable-xdebug
4、make && make install

6.vi /etc/php.ini,後面加入
    [Xdebug]
    zend_extension ="/usr/lib/php/modules/xdebug.so"
    xdebug.profiler_enable=on
    xdebug.trace_output_dir="/tmp/xdebug"
    xdebug.profiler_output_dir="/tmp/xdebug"
    xdebug.remote_enable=on
    xdebug.remote_handler=dbgp
7.建立log輸出目錄 mkdir -p /tmp/xdebug
8.給log輸出目錄賦許可權 chmod 777 /tmp/xdebug
9.重啟apache ,service httpd restart
10.訪問網站後,在/tmp/xdebug中會有日誌
11、使用wincachegrind查看日誌。
12、分析日誌:overall中 call:調用次數;self 方法自己的時間;cum 方法總時間,包括了調用其他方法的

安裝xhprof函數層級的效能分析()
1、1.先把tgz的包在本地解壓,把裡面的tar包傳到 centos的/root目錄,使用tar -xvf 解壓tar包,解壓出了xdebug-2.2.4、package.xml,
2。進入xhprof,再進入cd extension/,執行phpize
3、./configure --with-php-config=/usr/bin/php-config
4、make && make install
5.建立目錄 mkdir -p /tmp/xhprof
6.給l目錄賦許可權 chmod 777 /tmp/xhprof
7.vi /etc/php.ini,後面加入
[xhprof]
extension=xhprof.so

; directory used by default implementation of the iXHProfRuns
; interface (namely, the XHProfRuns_Default class) for storing
; XHProf runs.
;xhprof.output_dir=<directory_for_storing_xhprof_runs>

xhprof.output_dir=/tmp/xhprof
8.重啟apache ,service httpd restart
9.在php檔案打點
// cpu:XHPROF_FLAGS_CPU 記憶體:XHPROF_FLAGS_MEMORY
// 如果兩個一起:XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY
xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);

// 要測試的php代碼
foo();

$data = xhprof_disable();   //返回運行資料
 
// xhprof_lib在下載的包裡存在這個目錄,記得將目錄包含到啟動並執行php代碼中
include_once "xhprof_lib/utils/xhprof_lib.php";  
include_once "xhprof_lib/utils/xhprof_runs.php";  
 
$objXhprofRun = new XHProfRuns_Default();

// 第一個參數j是xhprof_disable()函數返回的運行資訊
// 第二個參數是自訂的命名空間字串(任一字元串),
// 返回運行ID,用這個ID查看相關的運行結果
$run_id = $objXhprofRun->save_run($data, "xhprof");
var_dump($run_id);
echo "\nhttp://192.168.0.99/xxx/xhprof_html/index.php?run={$run_id}&source=xhprof\n";

10、http://192.168.0.99/xhproftest/xhprof_html/index.php?run=54779d94bfa61&source=xhprof
查看統計報告
  calls 調用次數
  incl.wall time
  excl.wall time自身時間
    cpu毫秒
    memuse位元組
    peakmemuse 記憶體峰值
圖表中紅色為瓶頸、黃色為路徑和耗時。

 

 

MYSQL_general_log

mysql> show global variables like "%general%";
+------------------+----------------------------------+
| Variable_name    | Value                            |
+------------------+----------------------------------+
| general_log      | OFF                              |
| general_log_file | /opt/lampp/var/mysql/centos1.log |
+------------------+----------------------------------+
2 rows in set (0.00 sec)

mysql> set global general_log=ON;
Query OK, 0 rows affected (0.04 sec)

mysql> show global variables like "%general%";
+------------------+----------------------------------+
| Variable_name    | Value                            |
+------------------+----------------------------------+
| general_log      | ON                               |
| general_log_file | /opt/lampp/var/mysql/centos1.log |
+------------------+----------------------------------+
2 rows in set (0.04 sec)

用完了記得關掉

mysql> set global general_log=OFF;
Query OK, 0 rows affected (0.01 sec)

mysql> show global variables like ‘general%‘;
+------------------+----------------------------------+
| Variable_name    | Value                            |
+------------------+----------------------------------+
| general_log      | OFF                              |
| general_log_file | /opt/lampp/var/mysql/centos1.log |
+------------------+----------------------------------+
2 rows in set (0.00 sec)

搭建4.xdebug+mysql general_log

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.