Common Address Redundancy Protocol ( CARP ) 角色說明 主要會有兩種角色, 一種是Host( Primary ), 一種是Provider ( Secondary ) Host 主要就是我們提供服務的機器 Provider 就是當Host 掛掉後, 接手服務的機器 參數說明 ( 這部份看原文吧, 這是我看OpenBSD上找來的, FreeBSD上敘述的比較少, 請大家搭配著一起服用 ) vhid The Virtual Host ID. This is a unique number that is used to identify the redundancy group to other nodes on the network. Acceptable values [...]
網路上找來找去…… 沒看到有人寫相關的解法…. 加上不想用mysql-proxy來解這部份… 所以打算從code 的部份下手 看到最後只能動Zend Framework 的code 了(還沒想到可以不動ZF 的code 而做到DB LB的方法) 我是先從function save 下手去找.. Zend/Table/Row/Abstract.php: public function save() [sourcecode language='php'] public function save() { /** * If the _cleanData array is empty, * this is an INSERT of a new row. * Otherwise it is an UPDATE. */ if (empty($this->_cleanData)) { return $this->_doInsert(); } [...]
這是Jay Pipes 在Google 演講時有關MySQL Tuning 的Tips Direct URL: http://video.google.com/videoplay?docid=2524524540025172110 [02:20] Don’t benchmark without a goal. Have a goal like “improve performance by 20%”. Otherwise you’ll waste a lot of time tuning milliseconds out of your application. [02:50] Change just one thing at a time and re-run the benchmarks. [03:40] Disable the query cache by setting [...]
因為被slow query 搞的很煩….網站速度一直起不來 因為Database 設計上的問題…..(幾個比較常用的Table 大蓋都差不多有70萬個Record ) 且因為我Table Engine 是 MyISAM 用Rep 的話….若是crash 要修…好像很麻煩… 所以變成要用Rep 的話最好能先轉成InnoDB 不過因為我Slow Query 很多…若是我Rep Master Lock 的話 Slave 也會卡住….. 也不是完全的解決了Slow Query這問題…. 所以我想最完美的解法可能是 Rep + Aging… 不過要花不少時間來整個改…… 當前沒這麼多時間讓我來用這些… 所以我目前的解法是… 加Ram 然後把MySQL 的Ram 讓他吃愈多愈好… Ref MYSQL優化詳細介紹! 7.5.2. Tuning Server Parameters Section 5.1.3, “System Variables” 5.1.2. Command Options Section 5.1.5, “Status Variables”. 5.2.4. [...]
剛剛在Joehorn 的個人版上看到的…. 我整個很lag… ports 裡面已經有了…… 裝好後.. cp /usr/local/share/super-smack/* ~ 才會有 select-key.smack和update-select.smack 這兩個檔案…. 執行的話..就在console 下 #super-smack -d mysql select-key.smack 80 100 我的blog 機是FreeBSD 7.0 R CPU: Intel(R) Xeon(TM) CPU 2.60GHz (2591.61-MHz 686-class CPU), RAM:2G HD: 10K SCSI 36.4G FS: UFS2 數據是 Query_type num_queries max_time min_time q_per_s select_index 8000 102 0 1164.87 update_index 8000 73 0 1164.87 [...]
一如往常..在看訂閱的rss 的時後.. 其中這篇 有介紹幾個mysql 的工具.. 其中mytop 已經快樂使用中… 另一個就是 MySQL Active Report 看起來挺不錯的.. 一樣在ports 裡面也有.. #cd /usr/ports/databases/mysqlard/ #make install clean 裝好後的提示似乎不是很完整 1) Add the ‘mysqlar’ user with USAGE privileges to your mysql server: $ mysql -u root -p mysql mysql> GRANT USAGE ON *.* TO mysqlar@localhost; mysql> FLUSH PRIVILEGES; 2) Add the mysqlard crontab to root’s [...]
因為有遇到這個問題 所以特別寫出來備忘 SELECT * FROM bb_downloads a WHERE (SELECT count( * ) FROM bb_downloads b WHERE b.post_id = a.post_id AND b.url = a.url ) >1 ORDER BY `post_id`,`download_times` DESC reference UPDATE: 2007/10/14 找出不相同的資料 非常的easy select r.user_id from rtable r WHERE r.user_id not in (select a.user_id from atable a) 刪除不相同的資料 delete from rtable WHERE user_id not [...]
剛剛寫code發現在phpMyAdmin裡面的中文看起來非常正常 不過程式print 卻都是亂碼,很怪!! 後來google 了一下,發現是 有 SUPER 權限的 user 在連線的時候不會去執行 init_connect 所以說即使我的 init_connect=’SET NAMES utf8′ 還是沒用 因為我db是用root連的………. 所以才會是亂碼~~ :*-): 直接去開了一個新帳號來用就好了。 ref. MySQL 4.1.x SET NAMES UTF8
因為翰x要移機,所以要把db 上的資料轉出來,不過因為用mysql db < db.sql 常常會出他媽的鬼問題,很杜爛!!! 所以單純把資料dump 成 text file 會是一個比較好的方式,然後再透過mysqlimport 或是LOAD DATA INFILE。 我寫了兩個小小的scripts 就是dump和 restore 有須要的人請自行服用 ::-p: 1.import_db.sh db_dir=$1 db=$2 for file in `find $1 -type f -depth 1 | egrep txt` do table=`echo $file |cut -d “/” -f 5|cut -d “.” -f 1` echo ‘import data to ‘$table’ finished ‘ /usr/local/bin/mysql -u [...]
昨天和貓哥談到了關於備份移機的事, 有談到關於mysql replication so 找了一下有關於 mysql replication 的資料 簡單來說mysql replication 就是主要架設一台Mysql Master 和一些slave。 而slave 會主動和master 要資料, 且可以提供query ,來分散一些master 的load 當master 有更新時,slave 就會和master 要資料更新。 so 也就達到備份的效果 而mysql replication 有不少作法 如one-way, multi-way , circle One Way replicaton 例如A跟B B不write, 只有A write, 然後A是master 這叫做one-way Multi Way replication 如果A, B都能write, 互相以對方為master 就是multi-way Circle 而Circle 又分 circle, double circle, semi-double [...]