iOS AND ANDROID
Topics:Choose a tag
Had to import a large DB into a Rackspace cloud site today and the phpmyadmin kept failing. Spoke with tech support and they sent me to this article: Original Article here
“Here is an example to assist you with setting this up:
#!/bin/sh mysql -h DB_HOST -u DB_USER -p'DB_PASSWORD' DB_NAME < /path/to/file/db_restore.sql
Create a new text file and add the above code to it and save it as restore.sh
In the above script, you will need to replace the portions in ALL CAPS with your actual information as follows ::
/path/to/file/ – This is the absolute path to your files. You can find this path by clicking on Hosting, Cloud Sites, Features, and scrolling down. This will be the “Linux Path” listed there. An example would be: /mnt/target02/123456/www.domain.com (Note, the filename is not included in that path)
DB_HOST – Database Host an example would be mysql5-9.wc1
DB_PASSWORD – the password of the target database
DB_USER – the database username
DB_NAME – the name of the database you are restoring to
Upload this file to your Cloud Site (for security purposes, we recommend keep this file outside your webroot) and create a cron job to schedule the task. Note, for step by step instructions on how to create a cron, Please review this article How_do_I_enable/disable_a_cron_job?
Put the name of the file, which, in our example is restore.sh in the “Command To Run” field. Select Perl as the Command Language and then select the minimum interval in which you wish to run your restore script (5 minutes).
There are logs available in your /logs/ folder each time a cron task is performed and you receive an email confirmation letting you know if the task was successful or not.
Please note: The Cron task has 15 minutes to complete. If the script takes longer than 15 minutes to complete, it will timeout. If this is a problem for you please break up the import into smaller pieces (.sql files) and re-schedule the task as necessary.”
Got this error today with Gregg Helfman on a client site that is using IIS7 with WordPress: “Before you can upload your import file, you must fix the following error: Unable to create directory c:\intepub\sitename/wp-content/uploads/2012/03. Is it’s parent directory writable by the server?”
In order to fix, we spent a few minutes trying permissions out until we went to the web to find out that “IUSR” had to have the permission to do the writing. I found the solution here: http://www.iisworkstation.com/2010/02/wordpress-theme-upload-error-on-iis-7.html
There was this other article that helped clarify why also: http://www.php.net/manual/en/install.windows.iis7.php
“As you can see it says that php-cgi.exe was impersonating IUSR account for the write operation in this case. As soon as I gave write access to IUSR on the wp-content directory everything started to run smooth.
But what I really wanted to know was – Why is IUSR account coming into all this?
Answer: Time to go back to basics :)
When I noticed the process name once again, that is when it hit me. My machine is running PHP with Fast CGI and I have the following setting in my php.ini:
Which esentially means when fastcgi impersonation is enabled, PHP will perform all file system operations with the user id that is currently authenticated by IIS. In my case I was using Anonymous Authentication with default settings. Hence IUSR. “
Found the need for query caching when I found one of our client’s MySQL boxes having CPU spikes around 80% very frequently. I realized the amount of content on the site had grown along with the amount of traffic to the site, to a point that it was starting to query the DB very frequently. So I start to look up optimizing MySQL and caching to see what I could find, and this blog post came up: http://www.howtogeek.com/howto/programming/speed-up-your-web-site-with-mysql-query-caching/
Here’s the portion of the post I was able to directly use on our client’s box to bring the CPU usage back down to the single digit to teens range. Thanks to The Geek for this!
Enable Caching with Server Running
The first thing you’ll want to do is make sure that your installation of MySQL actually has query caching support available. Most distributions do, but you should check anyway.
You’ll want to run this command from your MySQL console, which will tell you if query caching is available.
mysql> show variables like 'have_query_cache'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | have_query_cache | YES | +------------------+-------+
Don’t mistake this as meaning that query caching is actually enabled, because most hosting providers aren’t going to enable this by default. Oddly enough, my Ubuntu Feisty installation already had it enabled…
Next we’ll need to check and see if query caching is enabled. We’ll need to check more than one variable, so we may as well do it all at once by checking for the variable query%
mysql> show variables like 'query%'; +------------------------------+---------+ | Variable_name | Value | +------------------------------+---------+ | query_alloc_block_size | 8192 | | query_cache_limit | 1048576 | | query_cache_min_res_unit | 4096 | | query_cache_size | 8388608 | | query_cache_type | ON | | query_cache_wlock_invalidate | OFF | | query_prealloc_size | 8192 | +------------------------------+---------+
Here’s the important items in the list and what they mean:
If the query_cache_size value is set to 0 or you just want to change it, you’ll need to run the following command, keeping in mind that the value is in bytes. For instance, if you wanted to allocate 8MB to the cache we’d use 1024 * 1024 * 8 = 8388608 as the value.
SET GLOBAL query_cache_size = 8388608;
Similarly, the other options can be set with the same syntax:
SET GLOBAL query_cache_limit = 1048576;SET GLOBAL
Now how do we tell if it’s actually working? You can use the SHOW STATUS command to pull all the variables that start with “Qc” to take a look at what is going on under the hood.
mysql> SHOW STATUS LIKE 'Qc%'; +-------------------------+--------+ | Variable_name | Value | +-------------------------+--------+ | Qcache_free_blocks | 65 | | Qcache_free_memory | 201440 | | Qcache_hits | 18868 | | Qcache_inserts | 2940 | | Qcache_lowmem_prunes | 665 | | Qcache_not_cached | 246 | | Qcache_queries_in_cache | 492 | | Qcache_total_blocks | 1430 | +-------------------------+--------+ 8 rows in set (0.00 sec)
You’ll notice in the stats that I have plenty of free memory left. If your server shows a lot of lowmem prunes, you might need to consider increasing this value, but I wouldn’t spend too much memory on query caching for a web server… you need to leave memory available for apache, php, ruby, or whatever you are using.”
It’s that time of year again, when allergies and Hackathons run rampant. This weekend Mike and I had the privilege of judging another hackathon, this time at Rutgers University, our Alma mater. Unlike the Hack Princeton hackathon we judged, the HackRU event lasted only 24 hours and included project submissions from 18 groups.
The hackathon started with API presentations from a number tech companies which allowed students to interact with the company representatives. Mike and I were thrilled to see such a diverse group of hackers with different ideas and a range of skill sets. You could definitely feel the air charged with creative electricity.
While a hackathon can be a great place to network and meet people from different areas and backgrounds we noticed that they also serve as a great opportunity to learn from one another. Sharing information about different platforms or software was a huge part of this weekend’s event and many of the participants, sponsors, and organizers knew a great deal about a number of different technologies.
Some of our greatest achievements at Local Wisdom are the apps we’ve created. Nothing feels better than seeing a final product that you’ve worked so hard to create come to life. Hackathons offer this same feeling because you not only develop the concept for your application, but you build it and present it. This puts your coding skills to the test and also encourages you to think outside the box both in the application’s creation and presentation. This type of thinking can only help in the future.
We were thrilled with the projects that the teams created. They ranged from a web app that helps a person learn a the definition of words to a mobile app that uses information from Nextbus and Google Maps to calculate whether the user will make it to class on time. The concepts for this hackathon were not only unique, but well thought-out and quite intuitive.
In the end, the project Get Mad Hipster Points Yo, an app that uses the accelerometers in smartphones as controllers over wifi to simulate a table tennis-like game, came in first place. Stereo Laser, used two Arduino boards to control laser light shows for left and right channel audio input and took second. Following closely in third place was FriendTrend that allows users to see what’s trending with only the people they follow rather than everyone on Twitter. See the full list of the projects we judged here.
Overall, we had a fantastic time and got to meet some awesome people. We can’t wait for the next one!