OCFS2 cluster – quick setup guide



OCFS2 is a POSIX-compliant shared-disk cluster file system for Linux capable of providing both high performance and high availability. Cluster-aware applications can make use of parallel I/O for higher performance. OCFS2 is mostly used to host Oracle Real application clusters (RAC) database on Linux clusters.

The below steps shows how to create ocfs2 filesystem on top a multipath’d SAN lun and mount it on Linux clusters.

1. Identify the nodes that will be part of your cluster.

2. Export/Zone the LUNs on the SAN end and check whether they are accessible on all the hosts of the cluster. (fdisk -l or multipath -ll)

3. If you need multipathing, configure multipath and the multipathing policy based on your requirement. For Linux multipath setup, refer Redhat’s multipath guide.

4. Create OCFS2 configuration file (/etc/ocfs2/cluster.conf) on all the cluster nodes.

How to Take Ownership of a File, Folder Using Command-line in Window 7 and Vista

Taking ownership of a file

Click Start, click All Programs, click Accessories, right-clickCommand Prompt, and then click Run as Administrator.
Type the following command and press ENTER:  TAKEOWN /F<filename>
(Replace the text <filename> with the full path of the actual file.)
If the operation was successful, you should see the following message:
“SUCCESS: The file (or folder): “filename” now owned by user “Computer Name\User name“.”
Then to assign the Administrators group Full Control Permissions for the file, you may use the ICACLS command.
Use this syntax:  ICACLS <filename> /grant administrators:F

Cài đặt thêm extension openssl vào PHP

Tải bản PHP tương ứng với bản đang chạy về server, giải nén
cd {php_dir (vừa giải nén)}/ext/openssl 
Chạy phpize (lưu ý phải chạy đúng với phiên bản php đang chạy trong trường hợp cài nhiều bản php trên server) Ví dụ:  sudo /u01/app/httpd2/php/bin/phpize
./configure –with-php-config=/u01/app/httpd2/php/bin/php-config
make
make install
Lưu ý: 
- Có thể file {php_dir (vừa giải nén)}/ext/openssl/config.m4  không tồn tại hoặc bị sai tên –> tìm file khác hoặc đổi lại tên là được.


Custom symfony error pages for 404 and 500 errors

500 error page
- Since symfony 1.2 your error page must be stored as error.html.php in the folder /config/errors/
- Default file:/lib/vendor/symfony/lib/exception/data/error.html.php
Available variables:  (một số biến được dùng trong file error)
- $exception: The exception.
- $code: The status code. Defaults to 500 but might have been replaced by $response->getStatusCode().
- $text: The status text. Defaults to “Internal server error” but might have been replaced by $response->getStatusText().
- $format: The request format. Defaults to “html” but might have been replaced by $response->getRequestFormat().

symfony execute raw query with doctrine

$query = ‘INSERT INTO table_name (`field1`, `field2 `, `content`, `created_at`) values ‘ ….

$conn = Doctrine_Manager::connection();
$pdo = $conn->execute($query);

Enable logging in the Symfony production environment

To enable symfony logging edit the file apps/frontend/config/settings.yml
prod:
  .settings:
    logging_enabled:        on
edit apps/frontend/config/factories.yml
prod:
  logger:
    class: sfAggregateLogger
    param:
      level: debug

DoubleClick in IE

The normal sequence of events fired leading up to a doubleclick go as follows.
    • mousedown
    • mouseup
    • click
    • mousedown
    • mouseup
    • click
    • doubleclick
but in IE, if you doubleclick on a link, and image or any element, the events fired are:
    • mousedown
    • mouseup
    • click
    • mousedown
    • mouseup
    • click
    • doubleclick
Thats right, no second mousedown?, and no second click!
As a developer, if you are tracking mousedown, mouseup, and click events… you need to be aware of this because if your users doubleclick by accident any actions that are designed to “stop” onmouseup might try and reference something that wasn’t started… and if the onclick was being used to quit listening for example… that event may never fire.

How to configure HTTPS on Apache 2

Configure HTTPS on Apache 2
1. Create httpd.pem & httpd.key file
# mkdir /data/www/project/ssl/
# openssl req -new -x509 -days 365 -nodes -out /data/www/project/ssl/httpd.pem -keyout /data/www/project/ssl/httpd.key

fix unknown table engine innodb

Hệ thống đang hoạt động bình thường. Nếu xảy ra lỗi “unknown table engine ‘innodb’ ”. Xử lý như sau:
1. Kiểm tra innodb có hoạt động không?
mysql> SHOW VARIABLES LIKE 'have_innodb';
   +---------------+-------+
   | Variable_name | Value |
   +---------------+-------+
   | have_innodb   | NO   |
   +---------------+-------+
--> disabled.

How To Create an IE-Only Stylesheet

Target ALL VERSIONS of IE

<!--[if IE]>
               <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

Target everything EXCEPT IE

<!--[if !IE]><!-->
               <link rel="stylesheet" type="text/css" href="not-ie.css" />
 <!--<![endif]-->

Run Crontab Every 5 Minutes, 10 minutes, Seconds, Hours, Days, Months

1. Execute a cron job every 5 Minutes
The first field is for Minutes. If you specify * in this field, it runs every minutes. If you specify */5 in the 1st field, it runs every 5 minutes as shown below.
*/5 * * * * /home/test/test.sh
In the same way, use */10 for every 10 minutes, */15 for every 15 minutes, */30 for every 30 minutes, etc.
2. Execute a cron job every 5 Hours
The second field is for hours. If you specify * in this field, it runs every hour. If you specify */5 in the 2nd field, it runs every 5 hours as shown below.
0 */5 * * * /home/test/test.sh
In the same way, use */2 for every 2 hours, */3 for every 3 hours, */4 for every 4 hours, etc.

Thống kê các bảng có dữ liệu lớn trong mysql


Thống kê các bảng có dữ liệu lớn trong mysql

Rất hữu ích khi cần thống kê để đánh partion.

SELECT table_name, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024 / 1024 ),4) as `Size(G)` FROM information_schema.TABLES WHERE table_schema = 'your_db_name' ORDER BY DATA_LENGTH DESC;

Một số lưu ý với CSS trên IE


Khi CSS cho các trình duyệt IE cần lưu ý các vấn đề sau:

1. padding, margin, width, height, float …
- Nếu đã set width thì không sử dụng padding 2 chiều left, right

- Nếu đã set height thì không sử dụng padding 2 chiều top, bottom

- Nếu đã float: left –> ko dùng margin-left

- Nếu đã float: right –> không dùng margin-right

(Ngược lại)


2. Bo góc bằng ảnh (img)
Ví dụ: bạn có 1 thẻ A, bao 2 thẻ IMG để bo góc thành 1 button

<a onclick=”networkManager.notifyUserFriend(’18′, ‘notifyremoveUser-18′);” href=”javascript:void(0);” class=”link-button2″> <img src=”/theme/images/pixshare_transparent.png” class=”corner-l”>

BUTTON NAME
<img src=”/theme/images/pixshare_transparent.png” class=”corner-r”>
</a>
Nếu có khoảng trắng giữa thẻ A và thẻ IMG thì sẽ bị lỗi giao diện trên IE

3. Z-index
z-index của 1 element con sẽ phụ thuộc vào z-index của element cha.
Tham khảo: http://www.brenelz.com/blog/squish-the-internet-explorer-z-index-bug/

4. Lỗi khi sử dụng onchange với thẻ SELECT Không dùng <select onchange=”function..”>, tren IE sẽ bị gọi 2 lan hàm onchange.
Khắc phục: Sử dụng jquery: $(‘select’).change(function() { .. } );

5. Event handlers trên thẻ OPTION
- Tất cả các version (6,7,8) của IE đều không hỗ trợ bất kỳ event handlers nào trên thẻ OPTION
–> Tốt nhất là ko nên bắt sự kiện trên thẻ option trên bất kỳ trình duyệt nào.

(Còn bổ sung …)

update terawurl data (wurfl.xml)


Download bản mới nhất về, giải nén và lấy file wurfl.xml trong thư mục data


http://sourceforge.net/projects/wurfl/files/WURFL%20Database/

How to remove all .svn directories from my application directories



xargs takes input, usually separated by newlines, and places them on the command line, so adding xargs makes what you had work:

find . -name .svn | xargs rm -fr

xargs is intelligent enough that it will only pass as many arguments to rm as it can accept. Thus, if you had a million files, it might run rm 1,000,000/65,000 times (if your shell could accept 65,002 arguments on the command line {65k files + 1 for rm + 1 for -fr}).

As persons have adeptly pointed out, the following also work:
find . -name .svn -exec rm -rf {} \; 
find . -depth -name .svn -exec rm -fr {} \; 
find . -type d -name .svn -print0|xargs -0 rm -rf 

The first two -exec forms both call rm for each folder being deleted, so if you had 1,000,000 folders, rm would be invoked 1,000,000 times. This is certainly less than ideal. Newer implementations of rm allow you to conclude the command with a + indicating that rm will accept as many arguments as possible:
find . -name .svn -exec rm -rf {} +

VirtualBox Add new resolutions into Virtual machine

Add new resolutions into Virtual machine
1. Shutdown virtual machine
2. Run command: VBoxManage setextradata “window xp sp3″ CustomVideoMode1 1366x768x32
(“window xp sp3″ is the machine name. )
3. Start virtual machine and change your display resolution.

 

MySQL DATETIME vs TIMESTAMP vs INT performance and benchmarking with InnoDB

Following my tests with DATETIME vs vs TIMESTAMP vs INT performance and benchmarking with MyISAM storage engine, I’ve wondered about the performance impact using InnoDB, which is usually more peaky with I/O.
Test environment was pretty much the same:
So I went to do some benchmarks to see what we can conclude. The tests were run with:
  • MySQL 5.4.0-beta (although specific 5.4/Google SMP patch configuration options left as defaults);
  • Intel Quad core x 2800 MHz
  • Solaris 10
  • For each test, the tables were recreated to be positively sure there was no caching at all (also, but not every iteration, I did a filesystem cache flush) and the test itself was repeated a couple of times.
  • I should also note that the InnoDB logs and datafiles and the exported data resided on the same storage device.

Tìm hiểu về PHP handler


1.PHP handler là cái gì ?

Khi chạy một site PHP, server phải cần thông dịch PHP và tạo ra trang web khi người dùng truy cập vào. Tùy vào từng người dùng, thời gian địa điểm mà webiste có thể được tạo ra khác nhau. Code PHP được phiên dịch dựa vào bộ thư viện PHP như PHP4 và PHP5. PHP handler sẽ điều khiển quá trình những gì load lên từ bộ thư viện PHP
Có nhiều PHP Handler hiện nay được sử dụng như DSO, CGI, SuPHP, FastCGI.Mỗi handler có những tác động đến performance của Apache khác nhau bởi vì nó xác định Apache sẽ dùng PHP như thế nào.
Có một vấn đề quan trọng là tùy thuộc vào tình hình (máy chủ, CPU, Ram, Nhu cầu, mục đích) mà chúng ta sẽ chọn handler thích hợp. Không có handler nào hoàn toàn tốt hơn cái nào. Vì vậy phải lựa chọn cho phù hợp.
Hiện tại thì FastCGI đang được dùng khá phổ biến.
Sau đây sẽ đề cập tổng quan về tất cả các PHP Handler. So sánh hiệu năng của các handler này.