I have one server Centos(called A) is running Apache and mysql server Now I have another one (called B) ,I set up Apache and mysql server in the same way with A. How can I synchronize the web folder and the database of server A -> server B in real time ?
For the Apache folders, why not just mount A's folder in B's filesystem? That way they'd both be looking at the same set of files with no need to sync. Alternatively, since you're using CentOS, you could try the GFS filesystem (http://www.centos.org/modules/news/article.php?storyid=108) if simple RSync isn't enough.
For the MySQL, the best way would be replication - the relevant documentation is here.