Setting up MySQL replication in V5.6.17

Setting up MySQL replication In this article the Master is 210.126.187.015 and the Slave is 210.126.187.016

On the Master, edit /etc/mysql/my.cnf (my.ini in Windows):
1) server-id = 126187015 # choose a unique integer
2) log_bin = /var/log/mysql/mysql-bin.log
3) bind-address = 0.0.0.0 # listen on all interfaces (by default 127.0.0.1 is used)
4) binlog_do_db = mydb # replicate only the ‘mydb’ database

On Windows environment:
1) server-id = 127001 # choose a unique integer
2) log_bin = C:/Documents and Settings/JohnDoe/My Documents/Application Data/MySQL/MySQL56/mysql-bin.log
3) bind-address = 0.0.0.0 # listen on all interfaces (by default 127.0.0.1 is used)
4) binlog_do_db = mydb # replicate only the ‘mydb’ database

Test your new configuration for syntax error:
1 bash# mysqld –help

Make sure the skip-networking option is not enabled. OFF on Windows
Make sure server-id is unique. You can for instance use the last 3 octets of the IP address of the server.

Create a replication user on the Master using the IP address of the Slave that will access it (200.126.187.66):
1) mysql> select version();
2) +——————-+
3) | version() |
4) +——————-+
5) | 5.1.37-1ubuntu5.1 |
6) +——————-+
7) 1 row in set (0.00 sec)
8 ) mysql> CREATE USER ‘replication’@’210.126.187.016’ IDENTIFIED BY ‘slavepass’;
9) mysql> GRANT REPLICATION SLAVE ON mydb.users TO ‘replication’@’200.126.187.66’;
10) mysql> GRANT SELECT ON mydb.users TO replication;

Restart MySQL for the changes to take effect:
1 bash# /etc/init.d/mysql restart (You can use MySQL Notifier or Command to restart server on Windows)

On the Slave, edit /etc/mysql/my.cnf to set the server-id:
1 server-id = 126187016 # choose a unique integer

Copy the current database on the Master with mysqldump and load it on the Slave.

Check the current status of the Master by retrieving its log file name and position:
1) mysql> SHOW MASTER STATUS;
2) +——————+———-+————–+——————+
3) | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
4) +——————+———-+————–+——————+
5) | mysql-bin.000001 | 23577 | mydb | |
6) +——————+———-+————–+——————+
7) 1 row in set (0.00 sec)

Start the replication on the Slave.

mysql> CHANGE MASTER TO MASTER_HOST='210.126.187.xxx', MASTER_USER='replication', MASTER_PASSWORD='slavepasswd',
 MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=0;
mysql> START SLAVE;

We did take some shortcuts here: the proper way would have been to:
1/ prevent the Master from committing anything
2/ backup the DB on the Master
3/ check the log file name and log position on the Master (‘SHOW MASTER STATUS’)
4/ load the backup on the Slave
5/ start replication using the log file name and position on the Master
6/ unlock the Master so the commits can happen again

A nightmare if the Master is already a live production server because it means from step 1/ to 6/ the Master is dead not committing anything.

As we did a ‘dirty’ backup, the replication will bump into errors that will stop the Slave (mainly because of entries already on the Slave, so we can safely skip them).
List them on the Slave with ’show slave status \G’ (look at the ‘Last_Error’) and if you can skip it, do it this way:
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
mysql> START SLAVE;

Continue skipping the failed insert (if they can be skipped of course) until the slave completely catches up with the Master.
How do I know when the Slave is done catching up with the Master?

Issue a ‘SHOW SLAVE STATUS’ on the Slave:
mysql> SHOW SLAVE STATUS \G

Modify Contact Us page in Zen-Cart

If you want to modify copy/text on this page, it’s very simple. Just go to YOUR-TEMPLATE directory under language dir to modify the way you want.

includes/languages/english/html_includes/YOUR_TEMPLATE/define_contact_us.php

However, if you plan to modify the form significantly, you’d look to spend more time to add codes in order to process the form. There’ll be multiple files you’ll have to open to modify in a PHP Editor such as EClipse or NuSphere client software. You can also add more php files and use require_once function to includes those files in your codes.

Number of files below will be involved during the changes:
– includes/languages/english/html_includes/YOUR_TEMPLATE/define_contact_us.php
– languages/english/contact_us.php : define all new constants in this file to be used in Contact Us form
– includes/modules/pages/contact_us/header_php.php : you can modify/add new logic in this file to collect user’s inputs from the form. You can add more functions to this file such as sending notification to more than 1 support admin, or filter inappropriate data from user’s inputs…

Which Hosting Server you want to choose?

Having worked on so many customers’ projects on many different hosting servers, I realize that I need to write this article to help some of you who need to choose a hosting provider for your private or business website. I have the most experience with 1and1, BlueHost, Yahoo, and GoDaddy. I’m just saying from my experience using their Admin Control Panel, I’m not trying to advertise for any of these companies or whatsoever. If you don’t like what I say, too bad. Go figure it out by yourself by purchasing 1 package from each provider, then you’ll know which one to stay with.

1and1.com
BlueHost.com
Yahoo Hosting
GoDaddy
The Good 1&1, as I said, is a better value for the money. The basic “starter” web hosting package includes a domain name, 250 2GB email boxes, 10 1GB of MySQL5 databases, secure ftp access, 50GB of hosting space and unlimited transfer volume. 1&1 hosting also supports SSH and many application scripts such as PHP5, Pearl, Python, and Ruby. The dashboard or hosting management interface is concise and allows you to manage all aspects of your package in one place. Setting up new databases or email accounts is a snap, and the hosting overall is very flexible.

Your shared hosting is also stored redundantly at two geographically separate data centers, so the failover is nice. My website has never really gone down for longer than a few minutes, or without prior notification from the web host.

For those who aren’t the most web savvy, there is a website builder interface that allows you to use a WYSIWYG “Website Builder” to set up and design your website. Using this feature does not bastardize the features of the package like with GoDaddy, which I am about to talk about shortly.

Quote: One of IT bloggers’ statement: “Pretty girls in the commercials, and the customer service may be slightly better than that of 1&1. Also, the “click and build” installation of commonly used platforms such as WordPress or Joomla, seems to be a little more efficient than building on 1&1.
Not as many options as 1&1 alleges to offer, but for now, it works, and usually is up an running within a couple hours. GoDaddy’s web based email interface seems to be very user friendly also.

The Domain manager is extremely powerful, with many options for creating subdomains, and managing CNAME or A records.”

The Bad They also use some German company for the domain registrations, which in itself probably isn’t that big a deal, but I’ve seen it become a hassle trying to transfer domains out of 1&1 once the accounts are already closed. There have also been reports I’ve read online that indicate that 1&1 will cancel your hosting if your shared hosting takes more than a lion’s share of the system resources on the computer housing your hosting package. I don’t know if they still do this, because most of these reports are from a few years ago, but if your website becomes “facebook” or “twitter” popular, you should probably put it on a dedicated server anyway, if for nothing else, for  performance/availability reasons. Go Daddy’s account manager is confusing at best. All aspects of the hosting seem to be managed from separate pages and interfaces. The domain manager is separate from the hosting manager, which is separate from the email account
manager, and so on. Furthermore, everything wants to open in a new window or tab. Getting around in your hosting package is fairly obnoxious.

I also found myself frustrated that you cannot point the destination of your domain name to any folder other than your hosting root without an “ugly hack.” I think linux hosting should allow for private folders outside of the site root for protecting files that certain applications may need access to.

Go Daddy “nickel and dimes” for everything. They give you a tiny number of email  addresses, and are ready to sell you more. Everything about GoDaddy in fact, seems about giving you less for your money, but allowing you to upgrade to add more.

The package supports SSH, but the setup is obnoxious, and I didn’t find a way to connect to the space to upload files securely, only FTP.

Easy of use of the Admin Control Panel Easy to use for IT novice and/or a businessman who knows nothing about IT Difficult Difficult Difficult
MySQL Database Accessibility Can’t use 3rd party client to access your MySQL DB (SQLYog, MySQLBench) Yes No Yes, you can only access 1 database at a time using client such as SQLYog. Not multiple MySQL DBs.
FTP accessibility Very fast, no delay Fast Very difficult to use FTP to access your server Fast, sometimes has delay during transfer files. Maybe once per day if you buy a lowest cost package.
Access your website thru iPhone, iPad, mobile devices Fast, no delay Fast Not so good The WORST – it’s slow everyday everytime you get on iPhone/iPad to review your own website
Email Config on your mobile devices Easy, fast, simple to config Not tried yet Not tried yet Not as easy. There’re many Ports you can try. If 1 doesn’t work, try another one. Sometimes, your email address has interrupted on GoDaddy Mail Server, you can’t be able to send/receive emails for days from your iPhone/iPad.
Customer Service

(when you have IT questions)

Fast Fast Slow Slow
Cost It’s not so much difference from each hosting provider if you choose Beginner or Medium Package or Business Package
My conclusion: I’d recommend 1and1.com for anyone who don’t have much experience in IT.

Temporarily disable some of Admin menu in Zen-Cart

Sometimes you may want to disable some menus that are not used by Store Admin for some reasons including security. You’ll need to do a few things to make it happen.
– Add a new field called “is_active” in database table admin_menus. Set 1 as default.
– Open the file admin/includes/functions/admin_access.php, look for the function zen_get_menu_titles(), change the query to get all menus that are active only.
$sql = “SELECT menu_key, language_key FROM ” . TABLE_ADMIN_MENUS . ” WHERE is_active = 1 ORDER BY sort_order”;
– Set is_active flag as 0 in the table if you don’t want that menu to display on Zen-cart Admin control panel.
– Go to database table admin_pages, set “display_on_menu” flag = ‘N’ of those submenu dropdown, so that they won’t be displayed on Admin menus.

How to detect screen resolution

PHP does not provide native function that can detect the device display resolution. Java Script can be used in this case, which will detect the display resolution. The script will do so, by using the width and height features of the screen. The required code for this has to be inserted into a HTML document. Once it is done, the settings can be switched to the PHP script through proper coding methods.

This will be the codes that you can use to make your website pages look better in all devices.

<script language="Javascript">
if(screen.width < 500)
// this space will look good on cellphone < 500px wide
document.write('<p><img src="images/pixel_trans.gif" height="430"></p>');
</script>

Based on this resolution detector, you can redirect users to a different domain name such as mobile.YOUR-DOMAIN.com or m.YOUR-DOMAIN.com or apply a different stylesheet .css.