顯示具有 moodle 標籤的文章。 顯示所有文章
顯示具有 moodle 標籤的文章。 顯示所有文章

2010年10月14日 星期四

timestamp to date

moodle在mdl_log檔中的time是使用unix timestamp
為了調資料時讓人看的懂可以使用mysql的函式
FROM_UNIXTIME(unix_timestamp)

預設輸出是長降子
mysql> SELECT FROM_UNIXTIME(1196440219);
-> '2007-11-30 10:30:19'

後面也可以加參數指定格式囉

--
參考網頁
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_from-unixtime

2010年7月15日 星期四

kernel: EXT3-fs error (device dm-4): ext3_lookup: unlinked inode 58079497 in dir #58073509

昨天要下班前發現架設的網站登不進去,第一個想到的是table的錯誤,但事情不是憨人想的那麼簡單,repaire table後情況依舊。查看log檔才知道是檔案系統出錯了,導致磁碟變成read only,所以session檔寫不進硬碟,造成無法登入的情況。

Jul 14 17:37:54 myhost kernel: Aborting journal on device dm-4.
Jul 14 17:37:54 myhost kernel: __journal_remove_journal_head: freeing b_committed_data
Jul 14 17:37:54 myhost kernel: EXT3-fs error (device dm-4): ext3_lookup: unlinked inode 58078839 in dir #58073509
Jul 14 17:37:54 myhost kernel: ext3_abort called.
Jul 14 17:37:54 myhost kernel: EXT3-fs error (device dm-4): ext3_journal_start_sb: Detected aborted journal
Jul 14 17:37:54 myhost kernel: Remounting filesystem read-only

所以咧,第一個想到要用的指令就是e2fsck
它可以下參數-a自動修復,另外要注意使用前要把partition umount,如果是根目錄壞掉的話,只好進入single user mode囉(還好我都有分割的好習慣XD)

# e2fsck -a /dev/vg_data/lv_data
我是用lvm所以磁碟路徑是長這樣@@;

會出現錯誤其實是我手賤,測試伺服器直接mount正式伺服器的data partition在跑,結果也有寫入session的關係,在測試伺服器下線還是怎樣後,新增加session檔的inode發生錯誤,系統強制將partition轉為read only,才導致這次的事件發生。
因為session其實是紀錄client的狀態,當很多client端同時上線時就有可能會造成io wait(雖然寫的檔都很小),所以這次索性將session資料夾mount到tmpfs上,以ramdisk的型式在跑或多或少可以加快速度。

# mount -t tmpfs tmpfs /session

要注意的是因為是寫在記憶體裡,重開機就不見囉!!
不過session不見也還好,沒什麼關係。
--
參考網站
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=17036
http://www.hkcode.com/linux-bsd-notes/178
http://plog.longwin.com.tw/my_note-unix/2006/01/08/ram_disk_build_method

2010年7月12日 星期一

pclzip

同事之前幫moodle寫了作業打包下載功能,用的是pclzip。最近發現有幾筆產生的壓縮檔並沒有乖乖的在指定的位置!?於是按照課號查找,發現打包下載的連結並未出現在網頁上,而那幾筆在錯誤位址的壓縮檔,下載下來後無法解開(壓縮檔破損),且打包檔案也有缺少。
上網查了一下,在做create時可以加入參數PCLZIP_OPT_NO_COMPRESSION,以不加壓方式打包即可。
以網路上的範例來做修改
include_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list = $archive->create('data/file.txt,data/text.txt',
     PCLZIP_OPT_NO_COMPRESSION,
     PCLZIP_OPT_REMOVE_PATH, 'data',
     PCLZIP_OPT_ADD_PATH, 'install');
if ($v_list == 0) {
     die("Error : ".$archive->errorInfo(true));
}
除了這點之外,最令我頭大的是若檔名含有中文,則下載下來的壓縮檔內檔名便會出現亂碼。雖然有在寫網頁的人都知道要避免使用中文檔名,但是一般使用者可是不會管你那麼多的。由於OS是linux介面,而且這邊使用的pclzip似乎沒有支援utf-8,所以才會產生亂碼的情況。這時候需要修改pclzip.lib.php的第2780行附近,function privAddFile內其中一段設定打包進壓縮檔檔案名稱的地方(按照上面的例子來說stored_filename就會是file.txt跟text.txt,因為路徑data被設定為去除了--PCLZIP_OPT_REMOVE_PATH, 'data')
    $p_header['filename'] = $p_filename;
// TBC : Removed    $p_header['stored_filename'] = $v_stored_filename;
    $p_header['stored_filename'] =
                        iconv('utf-8','big5',$p_filedescr['stored_filename']);
這樣就可以看到中文囉!

學藝不精,花了一天時間才解決問題...
--
參考網站
http://moodle.club.tw/moodle/mod/forum/discuss.php?d=1392
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20091208184635ZIQ&fumcde=&PAGE=1
http://support.oss.org.tw/?q=node/147
http://itisjoe.pixnet.net/blog/post/14758894
http://modxcms.com/forums/index.php?topic=48191.0

2010年6月18日 星期五

/usr/bin/dvips: ! DVI file can't be opened.

moodle內有支援tex(latex)
因為是直接調控主機內的程式,所以安裝了
tetex-latex
及其他相依程式

測試過後發現圖片出不來
檢查/etc/httpd/logs/error_log

kpathsea: Running mktexfmt latex.fmt
kpathsea: Running mktexfmt latex.fmt
fmtutil: format directory `/.texmf-var/web2c' does not exist.
fmtutil: format directory `/.texmf-var/web2c' does not exist.
This is dvips(k) 5.95a Copyright 2005 Radical Eye Software (www.radicaleye.com)
/usr/bin/dvips: ! DVI file can't be opened.
sh: /var/www/html/moodle/filter/tex/mimetex.linux: Permission denied
This is dvips(k) 5.95a Copyright 2005 Radical Eye Software (www.radicaleye.com)
/usr/bin/dvips: ! DVI file can't be opened.
sh: /var/www/html/moodle/filter/tex/mimetex.linux: Permission denied
sh: /var/www/html/moodle/filter/tex/mimetex.linux: Permission denied
sh: /var/www/html/moodle/filter/tex/mimetex.linux: Permission denied
kpathsea: Running mktexfmt latex.fmt
fmtutil: format directory `/.texmf-var/web2c' does not exist.
This is dvips(k) 5.95a Copyright 2005 Radical Eye Software (www.radicaleye.com)
/usr/bin/dvips: ! DVI file can't be opened.
convert: unable to open image `/backup/temp/latex/d1e56126337cd6e29b16fe759232ce90.ps': No such file or directory.

將/moodledata/temp/latex內修改權限便可以看到圖片了

2010年5月19日 星期三

linux moodle 使用套件

php-common-5.1.6-3.7.fc6
php-odbc-5.1.6-3.7.fc6
php-cli-5.1.6-3.7.fc6
php-pgsql-5.1.6-3.7.fc6
php-mbstring-5.1.6-3.7.fc6
php-pdo-5.1.6-3.7.fc6
php-5.1.6-3.7.fc6
php-gd-5.1.6-3.7.fc6
php-xmlrpc-5.1.6-3.7.fc6
php-ldap-5.1.6-3.7.fc6
php-mysql-5.1.6-3.7.fc6

httpd-2.2.6-1.fc6
system-config-httpd-1.4.1-1.fc6
httpd-manual-2.2.6-1.fc6

libdbi-dbd-mysql-0.8.1a-1.2.2
mod_auth_mysql-3.0.0-3.1
mysql-server-5.0.27-1.fc6
mysql-connector-odbc-3.51.12-2.2
mysql-5.0.27-1.fc6
mysql-devel-5.0.27-1.fc6
php-mysql-5.1.6-3.7.fc6
mysql-bench-5.0.27-1.fc6