pkg_libchk 用來檢查 Library Dependency,若有 Dependency 錯誤會列出錯誤訊息,若沒有錯誤訊息,就是 Dependency 都正確。
pkg_libchk 被包含在此 Ports 中 /usr/ports/sysutils/bsdadminscripts
2012年9月19日 星期三
FreeBSD 檢查 Library Dependency 工具 pkg_libchk
2012年7月13日 星期五
2012年7月12日 星期四
FreeBSD 中設定 MySql log 與 定時 rotate
設定 /etc/rc.conf
mysql_enable="YES"
mysql_args="--log=/LOG_PATH/mysql.log"
設定 /etc/newsyslog.conf 以定時 rotate
/LOG_PATH/mysql.log mysql:wheel 660 30 * @T00 JC /var/db/mysql/HOSTNAME.pid
Subversion 修正 local unversioned, incoming add upon update 的方法
狀況:
本地端在 svn up 的時候,與 repository 有同名的資料夾,且此資料夾尚未 svn add。
解決方法:
以 repository 的資料夾為準。
# svn resolve --accept working conflicted_directory
# svn revert conflicted_directory
PS. 若本地端檔案要留下來,請先複製一份做備份,解決完衝突後,再將檔案覆蓋回來即可。
@
下午2:05
#
FreeBSD,
Subversion
2012年6月28日 星期四
FreeBSD 查看 Process 詳細資料
1. 可使用 procstat 查看 Process 詳細詳細資料。
常用選項:
#顯示執行檔資訊
-b Display binary information for the process.
#顯示執行這個 Process 時的 Command Line 參數
-c Display command line arguments for the process.
#顯示 Process 所開啟的檔案相關資訊
-f Display file descriptor information for the process.
2. 可使用 pstree 列出目前執行中的 Process 狀態與相互之間的關係。
2012年3月26日 星期一
FreeBSD 利用 Xvfb (xorg-vfbserver) 執行 X Window 程式
Xvfb 在 FreeBSD 的 ports 裡面叫 xorg-vfbserver。
安裝 ports:
/usr/ports/x11-servers/xorg-vfbserver
/usr/ports/x11/xkeyboard-config
啟用 Xvfb,並指定 顯示 的 X server。
啟用 Xvfb 於 server 1 並指定第 0 個 screen 為 1920x1080x16
# Xvfb :1 -screen 0 1920x1080x16 &
# setenv DISPLAY :1.0
2012年3月22日 星期四
FreeBSD 中 MySQL InnoDB 檔案損毀無法卸除問題解決
當 MySQL InnoDB 的資料庫檔案損毀造成無法載入,且無法下 Query 時,可以使用參數強制 InnoDB 跳過錯誤處理流程,讓我們可以將資料盡量 Dump 出來,或卸載資料庫。
my.cnf
[mysqld]
innodb_force_recovery = 4
MySQL 官方網站參數說明:
1 (SRV_FORCE_IGNORE_CORRUPT)
Let the server run even if it detects a corrupt page. Try to make SELECT * FROM tbl_name jump over corrupt index records and pages, which helps in dumping tables.
2 (SRV_FORCE_NO_BACKGROUND)
Prevent the main thread from running. If a crash would occur during the purge operation, this recovery value prevents it.
3 (SRV_FORCE_NO_TRX_UNDO)
Do not run transaction rollbacks after recovery.
4 (SRV_FORCE_NO_IBUF_MERGE)
Prevent insert buffer merge operations. If they would cause a crash, do not do them. Do not calculate table statistics.
5 (SRV_FORCE_NO_UNDO_LOG_SCAN)
Do not look at undo logs when starting the database: InnoDB treats even incomplete transactions as committed.
6 (SRV_FORCE_NO_LOG_REDO)
Do not do the log roll-forward in connection with recovery.
2012年3月14日 星期三
FreeBSD xargs 無法處理一個以上參數之替代方案
1.將資料 pipe 給 sed
2.於 sed 中使用 regular expression 切割字串
3.重組字串成 指令 輸出
4.pipe 給 tcsh
example:
# ls */*road | xargs -I @ -n 1 realpath @ | sed 's/\(.*\)\/\(.*\)\/\([0-9]*\)\(.*\)/mv \1\/\2\/\3\4 \1\/\2\/\3_\2_\4/' | tcsh
FreeBSD xargs 中使用 | pipe
使用 xargs 時,若組合出的指令中需要使用到 | pipe,則會發指令無法執行,因為 pipe 後面的東西會被當成一個新的指令。
可使用 tcsh -c 來執行組合出來的指令,以避免此問題。
# echo 'abcdef' | xargs -I @ -n 1 tcsh -c "echo @ | grep 'abc' "
2012年3月13日 星期二
FreeBSD 新增硬碟
*於機器上安裝新硬碟
*檢視 /var/run/dmesg.boot 確認有抓到新硬碟
*以 root 執行 sysinstall
*選 Configure > Fdisk 分割硬碟 (記得 Q 之前要用 W 寫入)
*重開機
*以 root 執行 sysinstall
*選 Configure > Lable 指定分割區名稱 (記得 Q 之前要用 W 寫入) (若非第一次安裝系統,則 Label mount point 不重要)
*編輯 /etc/fstab, 加入新增的分割區資訊
*重開機
2012年2月8日 星期三
FreeBSD 設定 ports 抓取檔案 Server
修改 /etc/make.conf
加入以下設定:
# Port master sites.
#
# If you want your port fetches to go somewhere else than the default
# (specified below) in case the distfile/patchfile was not found,
# uncomment this and change it to a location nearest you. (Don't
# remove the "/${DIST_SUBDIR}/" part.)
#
MASTER_SITE_BACKUP?= \
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp5.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp10.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp3.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp4.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp8.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp9.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp11.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp12.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
#
# If you want your port fetches to check the above site first (before
# the MASTER_SITES specified in the port Makefiles), uncomment the
# line below. You can also change the right side to point to wherever
# you want.
#
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
2011年6月29日 星期三
tmux 解決 not a terminal 問題
直接下指令改目前設定
# sysctl net.inet.udp.maxdgram=65536
# sysctl net.local.stream.sendspace=8192
或者修改 /etc/sysctl.conf 將以上的設定值放進去,以後開機即自動生效。
2011年5月11日 星期三
2011年4月21日 星期四
FreeBSD 以 csup 更新 ports
設定 csup 設定檔
#cp /usr/share/examples/cvsup/ports-supfile /etc
#vim /etc/ports-supfile
將 CHANGE_THIS.FreeBSD.org 改為 FreeBSD.twaren.net
之後開始更新 ports
#csup -g -L 2 /etc/ports-supfile
完成!
2010年7月19日 星期一
測試 UDP Port 狀態
FreeBSD 需由 ports 安裝 nmap
nmap -p PORT -sU -P0 IP
結果:
[root@XXX] ~# nmap -p 1812 -sU -P0 127.0.0.1
Starting Nmap 5.21 ( http://nmap.org ) at 2010-07-19 17:22 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (1.0s latency).
PORT STATE SERVICE
1812/udp open radius
Nmap done: 1 IP address (1 host up) scanned in 2.11 seconds
[root@XXX] ~# nmap -p 1815 -sU -P0 127.0.0.1
Starting Nmap 5.21 ( http://nmap.org ) at 2010-07-19 17:22 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00051s latency).
PORT STATE SERVICE
1815/udp closed unknown
Nmap done: 1 IP address (1 host up) scanned in 1.19 seconds
2010年4月26日 星期一
FreeBSD 找不到 Share Library 的解決方法
- 定義 LD_LIBRARY_PATH 於 環境變數中,將 Share Library 的所有可能路徑都設上去
# setenv LD_LIBRARY_PATH /path/to/share/library:$LD_LIBRARY_PATH - 以 Root 身份執行 /etc/rc.d/ldconfig restart
# /etc/rc.d/ldconfig restart - 打完收工
2009年6月18日 星期四
FreeBSD 下 使用 BASH 進行多重 PipeLine 資料處理
目前看起來好像只有 Bash 可以下達多重 PipeLine 資料處理的指令。
利用 tee 與 Process Substitution 語法 >() 兜出指令。
tee >(process1) >(process2) >(process3) | process4
example:
ls -A | tee >(grep ^[.] > hidden-files) >(grep -v ^[.] > normal-files) | less
2009年3月22日 星期日
使用 Xdebug + Vim 對 PHP 逐行除錯
[Vim]
檢查 python 與 sign 前面是否為 + 號
# vim
:version
若為 - 號的話,就需要重裝 Vim
# /usr/ports/editors/vim/make WITH_PYTHON=yes install clean
接下來要安裝 Xdebug Client 在 Vim 上。
下載:http://www.vim.org/scripts/script.php?script_id=1929
解開後將 debugger.py 與 debugger.vim 複製到 /usr/local/share/vim/vim72/plugin/
PS.後來發現有人放出改過得 debugger.py,解決了原版只等待 5 秒的問題,並修改了一些切割視窗的配置。
文章在此:
http://www.workingsoftware.com.au/index.php?h=WebLog&author_id=11&entry_id=1
下在位址在此:
http://www.workingsoftware.com.au/debugger.py
[Xdebug]
安裝 Xdebug for PHP
# cd /usr/ports/devel/php-xdebug
# make install clean
修改 php.ini,加入 Xdebug 設定
# vim /usr/local/etc/php.ini
找到 Module Settings,在下面加入:
zend_extension=/usr/local/lib/php/20060613/xdebug.so
[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=
; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32
; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32
重開 apache,並檢查 phpinfo 中有 Xdebug 資訊即為安裝成功。
[使用方法]
從瀏覽器啟動 Debug:
在你的網站上隨便開一個 PHP 網址,並在後面加上 ?XDEBUG_SESSION_START=1 參數,這樣就會啟動 Xdebug。
接下來用 Vim 開啟你要 Debug 的 PHP 檔,開啟後按下 F5。
這時候 Vim 畫面下方會出現一行字:
waiting for a new connection on port 9000 for 5 seconds
看到這行字後請在 5 秒鍾內用覽器開啟你正在編輯的這個 PHP 網頁,這樣 Vim 就會進入 Debug 模式了。
從 Command Line(CLI) 啟動 Debug:
# setenv "XDEBUG_CONFIG=vim=1"
打開 Vim,按下 F5。
# php -f debug_target.php
再回到 Vim 裡面去看,Debug 就已經啟動了!
如果要 Debug 用 system 開出來的 CLI PHP,則需要在 system 之前用 putenv 來設定環境變數
putenv("XDEBUG_CONFIG=vim=1");
system("php -f debug_target.php");
使用 Vim 進行 Debug 時會出現很多 畫面切割的小視窗,要其中移動必須按下 Ctrl + w,之後再按 上下左右,進行視窗的切換。
要改變視窗的大小則是按 Ctrl + w,之後再按 + 是變大,而 - 則是變小,按 = 則是回到預設值。最後按 F1 就會把目前視窗放到最大。
為瞭解決因為 Vim 共用 temp 檔而開啟多個 Vim 進行 debug 時每次都會說 暫存檔已經存在,只需要在 Vim 中下這個指令,並將每個 Vim 的 dir 都設成不一樣就可以了。
:set dir=/tmp
參考資料:
我同事 JohnPuPu的 Blog:http://blog.johnpupu.tw/?p=208