Tuesday, December 29, 2009
Drupal Performance and Scalability
Monday, December 28, 2009
Adding Newsletters to a Web Site Using Drupal 6
Creating newsletters
A newsletter is a great way of keeping customers up-to-date without them needing to visit your web site. Customers appreciate well-designed newsletters because they allow the customer to keep tabs on their favorite places without needing to check every web site on a regular basis.
Creating a newsletter
Good Eatin' Goal: Create a new newsletter on the Good Eatin' site, which will contain relevant news about the restaurant, and will be delivered quarterly to subscribers.
Additional modules needed: Simplenews (http://drupal.org/project/simplenews).
Basic steps
Newsletters are containers for individual issues. For example, you could have a newsletter called Seasonal Dining Guide, which would have four issues per year (Summer, Fall, Winter, and Spring). A customer subscribes to the newsletter and each issue is sent to them as it becomes available.
- Begin by installing and activating the Simplenews module, as shown below:

At this point, we only need to enable the Simplenews module, and the Simplenews action module can be left disabled.
Next, select Content management and then Newsletters, from the Administer menu. Drupal will display an administration area divided into the following sections:
a) Sent issues
b) Drafts
c) Newsletters
d) SubscriptionsClick on the Newsletters tab and Drupal will display a page similar to the following:

As you can see, a default newsletter with the name of our site has been automatically created for us. We can either edit this default newsletter or click on the Add newsletter link to create a new newsletter.
Let's click the Add newsletter option to create our seasonal newsletter. Drupal will display a standard form where we can enter the name, description, and relative importance (relative importance weight) of the newsletter.
- Click Save to save the newsletter. It will now appear in the list of available newsletters.
If you want to modify the Sender information for the newsletter to use an alternate name or email address to your site's default ones, you can either expand the Sender information section when adding the newsletter, or you click Edit newsletter and modify the Sender information, as shown in the following screenshot:


Allowing users to sign-up for the newsletter
Good Eatin' Goal: Demonstrate how registered and unregistered users can sign-up for a newsletter, and configure the registration process.
Additional modules needed: Simplenews (http://drupal.org/project/simplenews).
Basic steps
- To allow customers to sign-up for the newsletter, we will begin by adding a block to the page.
Open the Block Manager by selecting Site building and then Blocks, from the Administer menu. Add the block for the newsletter that you want to allow customers to subscribe to, as shown in the following screenshot:

We will now need to give users permission to subscribe to newsletters by selecting User management and then Permissions, from the Administer menu. We will give all users permissions to subscribe to newsletters and to view newsletter links, as shown below:

If the customer does not have permission to subscribe to newsletters then the block will appear as shown in the following screenshot:

However, if the customer has permissions to subscribe to newsletters, and is logged in to the site, the block will appear as shown in the following screenshot:

If the customer has permission to subscribe, but is not logged in, the block will appear as follows:

- To subscribe to the newsletter, the customer will simply click on the Subscribe button. Once they he subscribed, the Subscribe button will change to Unsubscribe so that the user can easily opt out of the newsletter. If the user does not have an active account with the site, they will need to confirm that they want to subscribe to the site
Restoring a Broken Linux RAID Array
About 18 months ago I set up a Linux media server for my home. It was made from an old Dell desktop that my neighbor was (literally) discarding, and a pair of new, identical Seagate hard disks. Since I was going to be spending a lot of time copying my CDs to this server, I configured a RAID-1 array that mirrored the hard disks; that way, there would always be a current backup. The OS was Ubuntu Linux 6.06 Server, and it used software RAID.
One of the drives started failing last week, so happy though I was to have a handy backup, I was a bit daunted about the prospect of restoring a broken RAID array. You see, there’s plenty of tutorials on how to set up software RAID, but not that many resources on what to do after a drive breaks. It actually turned out to be really easy, thanks in large part to my friends Yossie’s and Eric’s guidance, so I decided to document the process here.
Determining if Your RAID Array is Broken
This part is really easy. Log in as root, and run:
cat /proc/mdstat
You should see something like this if there is a problem:
Personalities : [raid1]
md1 : active raid1 hda2[0]
1927680 blocks [2/1] [U_]md0 : active raid1 hda1[0]
310640768 blocks [2/1] [U_]unused devices:
Note the underscore in the [U_]. A healthy RAID array will not have the underscore. Instead, it would say [UU]. Also note that hda is active (it’s listed in the md0/md1 lines), but hdb is conspicuously absent. So hdb is in trouble.
Finding the Broken Drive
If you know which drive hdb is, then remove it, but it’s probably best to run a test to be sure it actually has errors. For this, I found a very versatile free tool called Ultimate Boot CD. You download the ISO and burn it onto a CD. You can use the CD to boot your PC. It’s packed with diagnostic tools, such as hard disk testers, memory testers, etc. Run the appropriate one for your brand of hard disk, on each disk in the array. The Seagate tester I used lists the hard disks serial numbers, so there’s no confusion once you open the case to remove the bad drive.
Ensure You Can Boot From the Good Drive
Depending on which drive is bad, and how you originally configured them, you may not be able to boot properly from the good drive. Best to test that you can. Remove the bad drive, and try to boot. You may need to modify jumper settings and/or move the good drive to the master plug on the IDE cable. If you can boot, great. If not, the Grub loader may be missing from the the good drive. To reinstall it, put the drives back where they were so that you can boot, log in as root, and run:
grub-install /dev/hda
(Assuming you need to install it on hda).
Retest that you can now boot off the remaining drive with the bad one removed.
Replace the Broken Drive
Obtain a matching drive, and install it in the case.
I only discovered (happily) after this happened that Seagate drives come with a 5-year warranty. If a drive goes bad, you can check if it’s covered using Seagate’s Warranty Checker. You don’t even need your original receipt to process the return, just the serial and model numbers. The whole process couldn’t be easier. I opted for their $20 premium service, where they send you a refurbished drive that matches yours immediately, via 2-day air shipping. The replacement drive comes with a box and a prepaid label to return the broken one to Seagate. The return shipping alone would have cost me $10, so that service seems like a bargain.
Rebuild the RAID Array
This is the bit I was daunted by, but it really turned out to be fairly simple. After the new drive is installed, boot up and log in as root.
Verify which drive is now part of the array. Run:
cat /proc/mdstat
You should see something like:
md1 : active raid1 hda2[1]
1927680 blocks [2/1] [_U]md0 : active raid1 hda1[1]
310640768 blocks [2/1] [_U]
In this case, hda is the working drive.
Look at the current partition table of the working drive (hda in my case). Run:
fdisk /dev/hda
p (for print)
q (to exit)
Output should be something like:
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytesDevice Boot Start End Blocks Id System
/dev/hda1 * 1 38673 310640841 fd Linux raid autodetect
/dev/hda2 38674 38913 1927800 fd Linux raid autodetect
Now configure the partitions of the new drive (hdb) to match the working one (hda). Run:
fdisk /dev/hda
- Enter n (for new partition).
- Enter p (for primary partition).
- Make it the first partition (i.e. 1).
- Start at cylinder 1 (the default).
- Use the End value for the last cylinder of partition 1 on hda (i.e. 38673).
- Change the new partition’s type to match the Id value of your first
partition (i.e. “fd”). This is important for the RAID controller to understand that this is part of the RAID array.
Enter t (for “change a partition’s system id”).
Enter fd. - That would have configured the first partition hdb1. Repeat steps 1-6 for all the partitions on hda. In my case, there was only one additional one. Remember to use the copy Start and End blocks.
- when you’re finished, enter w (for “write table to disk and exit”).
Now you’re ready to hot-add the new drive to your RAID array. You’ll need to run mdadm for each partition you need to restore (two in my case). Use the output of /proc/mdstat as a guide. e.g.
md1 : active raid1 hda2[1]
1927680 blocks [2/1] [_U]md0 : active raid1 hda1[1]
310640768 blocks [2/1] [_U]
Here md1 currently maps to hda2 only. We need to add hdb2 to md1. md0 currently maps to hda1 only. We need to add hdb1 to md0. So in this case, you would run the following commands:
mdadm /dev/md0 -a /dev/hdb1
mdadm /dev/md1 -a /dev/hdb2
That’s it! The RAID array should be doing its magic.
Verify That It’s Updating
Examine the output from /proc/mdstat now, and you should see something like:
Personalities : [raid1]
md1 : active raid1 hdb2[2] hda2[1]
1927680 blocks [2/1] [_U]
resync=DELAYEDmd0 : active raid1 hdb1[2] hda1[1]
310640768 blocks [2/1] [_U]
[>....................] recovery = 1.0% (3196864/310640768) finish=158.8min speed=32257K/secunused devices:
Since it’ll take several hours, you can log out of the shell, and let it synchronize the two disks.
Install the Grub Loader on Your New Drive
Since you just added hdb, you should install the Grub loader, in case hda ever fails or is removed. Run:
grub-install /dev/hdb
… and you should be good to go.
(http://www.antunkarlovac.com/blog/2008/09/30/restoring-a-broken-linux-raid-array/)
What is /dev/shm and its practical usage
Warning: tmpfs at /dev/shm is configured quite small with 1024 MB!
Minimum value is 2048 MB.
Recommended size is 75 % of RAM + swap.
(http://serverlinux.blogspot.com/2009/12/what-is-devshm-and-its-practical-usage.html)
Five resources to score a Drupal freelance job
Although the demand outweighs supply for Drupal talent, it's still not a given for Drupal freelancers or starters to score a job. Here are a couple of sources to look for Drupal related work.
1. Drupal.org
The Paid services forum on drupal.org is always a good place to start for Drupal related work. These jobs range from 5-minute 20$ quick fixes to long-term commitments. It's also a good place to post your reverse bounty.
2. Drupal Groups
Group Jobs on Drupal Groups are a great way to find a job in your Drupal field of interest. G.d.o offers the option to post job listings to up to 4 groups, so it's a good idea to keep an eye on the recent posts or the group's rss feed for such opportunities. The jobs are also listed in a useful "Group jobs" block.
3. Drupaljob.com
Drupal Jobs provides a forum where people can talk about jobs, categorized in different sections: "On-site Drupal Jobs", "US$500-$1,500 Drupal Jobs", "Drupal Theme and Template" Jobs et cetera. There's also a category where freelancers and service providers can post their resumes and company descriptions.
4. Drupalancers.com
Drupalancers focuses on freelancers and offers the ability to rate a freelancer after the job is done, listing the highest rated programmers on the front page.
5. SourceForge Marketplace
A couple of months ago SourceForge launched the SourceForge Marketplace. There are usually at least a couple of Drupal projects to be found. It has a userful table listing of job which is sortable by service type, price or contract duration for instance.
And plenty more...
I'm sure there's a ton of other useful resources for finding a Drupal (freelance) job. If you know some, please post them in a comment.
(http://mostrey.be/five-resources-score-drupal-freelance-job)