星期四, 4月 19, 2007

lifetype 掛了,看不到文章內容


又過了好幾天沒有給自己的部落格一點關愛的眼神,昨天突想到,連上網看了一下,哇!怎麼只看得到類別,而沒有文章內容?!


仔細一想,好像幾天前有過一次停電,該不會是這個原因吧?!用 mysql client 連上,SELECT * FROM plog_article_text,嘿!果然有點問題,看訊息似乎是資料表有些損毀,無法讀出來。


又借了一下 GOOGLE 的神威,看到 dev.mysql.com 的說明文章指出修復的方法與注意事項。把它記錄下來,以便參考。


※ 要做修復資料庫動作之前,請先停止 MySQL伺服器: mysqladmin shutdown,停止mysqld 命令執行之後,mysqld 可能還會運作一會兒,直到所有的查詢動作和索引更動做完為止。


步驟一: 命令列: 檢查資料表
執行 myisamchk *.MYI or myisamchk -e *.MYI


步驟二:命令列: 快速又安全地修復
myisamchk -r -q tbl_name (-r -q 表示「快速修復模式(quick recovery mode)」).





  1. Make a backup of the data file before continuing.




  2. Use myisamchk -r tbl_name (-r means 「recovery mode」). This removes incorrect rows and deleted rows from the data file and reconstructs the index file.




  3. If the preceding step fails, use myisamchk --safe-recover tbl_name. Safe recovery mode uses an old recovery method that handles a few cases that regular recovery mode does not (but is slower).





步驟三: Difficult repair





  1. Move the data file to a safe place.




  2. Use the table description file to create new (empty) data and index files:



    shell> mysql db_name
    mysql> SET AUTOCOMMIT=1;
    mysql> TRUNCATE TABLE tbl_name;
    mysql> quit


  3. Copy the old data file back onto the newly created data file. (Do not just move the old file back onto the new file. You want to retain a copy in case something goes wrong.)





Go back to Stage 2. myisamchk -r -q should work. (This should not be an endless loop.)


步驟四: Very difficult repair


You should reach this stage only if the .frm description file has also crashed. That should never happen, because the description file is not changed after the table is created:





  1. Restore the description file from a backup and go back to Stage 3. You can also restore the index file and go back to Stage 2. In the latter case, you should start with myisamchk -r.




  2. If you do not have a backup but know exactly how the table was created, create a copy of the table in another database. Remove the new data file, and then move the .frm description and .MYI index files from the other database to your crashed database. This gives you new description and index files, but leaves the .MYD data file alone. Go back to Stage 2 and attempt to reconstruct the index file.





星期一, 4月 09, 2007

星期四, 3月 29, 2007

Word 2003 的 XML 標籤


分頁
<w:p wsp:rsidR="00821EAD" wsp:rsidRDefault="002720BA">
<w:r>
<w:br w:type="page"/>
</w:r>
</w:p>


分行一(<P>)
<w:p wsp:rsidR="00D27109" wsp:rsidRPr="000A0F23" wsp:rsidRDefault="00D27109">
<w:pPr>
<w:rPr>
<w:rFonts w:ascii="新細明體" w:h-ansi="新細明體" w:hint="fareast"/>
<wx:font wx:val="新細明體"/>
<w:sz w:val="36"/>
</w:rPr>
</w:pPr>
</w:p>


分行二(<br />)
<w:br/>


星期三, 3月 21, 2007

MySQL新版本與舊版本密碼相容設定方式


在MySQL的設定檔裡頭,[mysqld]區段裡加入 old_passwords=1,重新啟動後會讓 mysql server 直接以舊式密碼函式來儲存 user 的密碼。不過,若原先已加入的使用者,就必須重新設定一次密碼。


這個設定,對於原有的 mysql 3.23 或 4.0來說還蠻好用的,但是除非有 mysql 4.1 以前的版本,不然,不建議用這個設定。


在 Mysql 實現複製( Replication )


圖書館系統目前運行中,為了避免更新程式或系統 Crash 時造成資料遺失的問題,在 DNS 這台機器也裝上 Mysql,然後兩台做 Replication,這兩邊的資料同步。


目前配置方式 :


A電腦: Master 1 / Slave 2
C:/Windows/my.ini 內 Replication 設定內容 (Windows 2003, MySQL 5.0.16 IP:192.168.1.23)
#################################################
#### Setting For Replication of MASTER
# old_passwords=1
server-id=1
log-bin
binlog-do-db=library
binlog-do-db=bank # input the database which should be replicated
binlog-ignore-db=mysql # input the database that should be ignored for replication
binlog-ignore-db=test
log-bin=win2k3-bin
relay-log=win2k3-relay-bin
#################################################
#### Setting For Replication of Slave
master-host = 192.168.1.1
master-user = replication
master-password = slave
master-port = 3306



B電腦: Master 2 / Slave 1
/etc/my.cnf 內 Replication 設定內容 (FreeBSD 6.1 R, MySQL 5.0.37 IP:192.168.1.1)
#################################################
server-id=2
log-bin=dns-bin
log-bin
relay-log=dns-relay-bin
binlog-do-db=library
#binlog-do-db=bank # input the database which should be replicated
binlog-ignore-db=mysql # input the database that should be ignored for replication
binlog-ignore-db=test


master-host = 192.168.1.23
master-user = replication
master-password = slave
master-port = 3306
#################################################


Step 1: 修改兩台電腦的 mysql設定檔(my.ini 或 my.cnf)


Step 2: 進入A電腦的 mysql, 在 mysql> 執行 grant replication slave on *.* to 'replication'@192.168.1.1 identified by 'slave';


Step 3: 進入B電腦的 mysql, 在 mysql> 執行 grant replication slave on *.* to 'replication'@192.168.1.23 identified by 'slave';


Step4: 將兩台電腦 MySQL Shutdown,並重新啟動。


Step5: 進入A電腦的 mysql,在 mysql> 執行 start slave;


Step6: 進入B電腦的 mysql,在 mysql> 執行 start slave;


-----------------------------------------------------------------------------------------------------------


檢查Replication 狀況:


mysql> show master status;


mysql> show slave status \G;


如果沒有問題的話,就完成 MySQL Replication 的設定了,若有問題的話,可以把開啟錯誤訊息檔來檢視,這個檔案通常會和 database放在一起,並以電腦名稱為檔案,副檔名為 err;如: windows安裝在 C:/AppServ/MySQL/,則該檔案預設會放在 C:/Windows/MySQL/DATA 目錄中;在FreeBSD裡,則會放在 /var/db/mysql/ 底下。


星期六, 1月 13, 2007

php5.2 安裝 PEAR 時出問題(windows)

由於 appserv 2.5.7 裝完後,在 dos 下一執行 php.exe 就會出現debug 的對話方塊,就下載 php5.2.0 把 appserv內的 php5.1.6 替換過來,不過,要安裝 PEAR 時卻發生一堆警告訊息:
Preparing to install...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.1.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.4.11.tar...

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/Archive/Ta
r.php on line 2334

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/Archive/Ta
r.php on line 2338
Could not get contents of package "". Invalid tgz file.
Cannot initialize 'phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.1.t
ar', invalid or missing package file

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/Archive/Ta
r.php on line 2334

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/Archive/Ta
r.php on line 2338
Could not get contents of package "". Invalid tgz file.
Cannot initialize 'phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.
tar', invalid or missing package file

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/Archive/Ta
r.php on line 2334

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/Archive/Ta
r.php on line 2338
Could not get contents of package "". Invalid tgz file.
Cannot initialize 'phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.4.11.tar', i
nvalid or missing package file

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/Comma
nd/Install.php on line 427

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/Comma
nd/Install.php on line 427

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/Comma
nd/Install.php on line 427

Warning: Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/Comma
nd/Install.php on line 429

install failed
Press any key to continue . . .

後來在網路上查到,可以至 http://snaps.php.net 下載再新的 php 版本,再把裡頭的 PEAR 複製過來,重新執行 go-pear.bat,就沒有問題了。

而且擾人的debug對話方塊也在換成 5.2之後就消失不見了!

星期五, 12月 08, 2006

[資訊組]工作日誌 12/7

圖書館四樓接單槍的電腦,從有老師反應出現問題,到昨日(12/7)才維修完畢,時間實在過長,除了這台電腦難搞以外,所在的位置及使用機制也是一大阻力。

這台電腦一開始利用ghost還原,由於出現問題,後來就重新安裝…想不到安裝之後,螢幕卻有"4色",不管怎麼調整,就是無法跑上256色或全彩,想到拆機器時卻又少了工具,結果機房與圖館4樓來來回回三、四趟,本來想帶舊的顯示卡裝上,不是壞掉,就是匯流排不對...,光是插拔顯示卡就不下十來次,結果....,本來想放棄直接叫廠商抱回去修理,把原先的顯示卡插回去後,不死心又開機一次,...........................哇!又正常了,真是夠了,早晚會被這些機器搞死#$%^&*()

ps:這台機器維修時間絕對超過一個星期以上,實在太不符合效益了。