Wednesday, December 31, 2008
New and Improved www.endurotracker.com
This site is targeted towards the triathlete or endurance athlete who want to plan and track their training sessions from any available internet enabled device (PC, iphone, blackberry, etc).
If you have friends who do endurance sports like Triathlons, bike races, road races, or swim races refer them to www.endurotracker.com. ( a triathlon training log site )
On a technical note, www.EnduroTracker.com is now using substantial more hardware, and is now using several new redundancy strategies to handle large loads, maximize performance, and deal with hardware disaster scenarios. It uses redundant web servers, and redundant database servers.
Friday, December 19, 2008
Host Names in Linux
Configure the Hostname
On the shoulders of giants, this an excerpt from very detailed post on postfix (smtp software) at
http://souptonuts.sourceforge.net/postfix_tutorial.html
The computer that these examples are taken from is "squeezel.squeezel.com", and it exists on IP address 192.168.1.81. The short name is just squeezel. Another computer, on IP address "192.168.1.155" is "tape.squeezel.com".
/etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.1.81 squeezel.squeezel.com squeezel
192.168.1.155 tape.squeezel.com tape
You may also want to edit "/etc/sysconfig/network" and add or check the following.
HOSTNAME=squeezel.squeezel.com
Finally, to put all changes into effect now, run the following command with root privileges.
$ hostname squeezel.squeezel.com
Some of the settings in the postfix "main.cf" file depend upon the hostname.
Monday, December 1, 2008
Amazon Flexible Payments Service (FPS) Part I, An Overview
Requests can be made either via SOAP or REST. In my case I had to use REST because Mono (.Net on Linux) has not implemented WSE 2 or WSE 3.
Another important feature to be aware of is Instant Payment Notification (IPN). This frees up a developer from having to implement a scheduled job that queries Amazon FPS for completion of payments. Because IPN will push (publish) a response to your listening website/webservice for you.
References:
Getting Started Guide: http://docs.amazonwebservices.com/AmazonFPS/2007-01-08/FPSGettingStartedGuide/
Developers Guide: http://docs.amazonwebservices.com/AmazonFPS/2007-01-08/FPSDeveloperGuide/
Tuesday, November 18, 2008
Configuring SSL on a Web Server using Apache
http://www.onlamp.com/pub/a/onlamp/2008/03/04/step-by-step-configuring-ssl-under-apache.html
These are the steps that I followed from the article:
I am setting up a qa web server , so I did this :
1) " For testing purposes, or for small LANs, you can create a self-signed certificate. This can be done by issuing this command: "
openssl req -new -x509 -days 365 -sha1 -newkey rsa:1024 \
-nodes -keyout server.key -out server.crt \
-subj '/O=Company/OU=Department/CN=www.example.com'
Note: You will need to have setup a self-signing Certificate
Authority on your server. This enables you to create your own temporary
certificates for testing purposes. See my blog post on setting up
Email/SMTP on Amazon EC2 for how this is done.
2) Next, I installed mod_ssl on Apache:
For Fedora, command line: yum install mod_ssl
3) Update /etc/httpd/conf.d/ssl.conf,
add a reference to your certificate (server.crt) and your key (server.key),
For example:
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/httpd/certs/server.crt
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/httpd/certs/server.key
4) Enable Port 443 on your server and firewall
(Amazon EC2 command line:ec2-authorize default -p 443 )
Conclusion: You now have a QA Web server with a temporary certificate that can run web sites
using SSL ( https ). For production Web servers , you will need to purchase a permanent certificate
from a trusted certificate authority like Verisign.
Monday, November 17, 2008
Updated Email Setup on Amazon EC2
SMTP/Email Setup on Amazon EC2
Summary:
Create an Smtp server installation on Amazon EC2 that relays email to
your gmail email account. Gmail has a nice email client so this allows us to leverage gmail’s rich features. Our smtp software package is postfix.
Prerequisites:
Familiar with create and launching instances using Amazon EC2, and familiar with editing config files in linux.
Links to
documentation on Amazon EC2 and how to create and launch instances:
1. Install Postfix
For Fedora 8: yum install
postfix
2. Setup/Install Certificate Authority for Self Signing
yum install openssl-perl
3. Create Server Certificate
cd /et/pki/tls/misc
./CA.pl -newca
4. Copy cert file to postfix folder
cp /etc/pki/CA/cacert.pem
/etc/postfix
5. Create Certificates (self signed certificates for testing
purposes)
openssl
genrsa -out enduro.key 1024
openssl
req -new -key enduro.key -out enduro.csr
openssl
req -new -x509 -key enduro.key
-out enduro.pem
-days 1095
Authorize Port 587
At desktop/client command line: ec2-authorize default –p 587
7. Update Postfix Config file, master.cf
This file is located in /etc/postfix/master.cf.You need to specify port so that service runs on port 587
Sample entry:
#
==========================================================================
#
service type private unpriv chroot wakeup
maxproc command + args
#
(yes) (yes) (yes) (never) (100)
#
==========================================================================
127.0.0.1:587
inet n -
n -
- smtpd
Edit 2nd
Postfix config file, main.cf
This file is located in /etc/postfix/main.cf
I will not detail this entire config file because the configuration
details will depend on your environment. But, in a nutshell you want
to do the following: update the relevant hostname and ips in main.cf
and add something like this to end of main.cf:
## TLS
Settings
#auth
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps
= hash:/etc/postfix/sasl_passwd
#tls
smtp_use_tls =
yes
smtp_sasl_security_options =
noanonymous
smtp_sasl_tls_security_options =
noanonymous
smtp_tls_note_starttls_offer = yes
tls_random_source
= dev:/dev/urandom
smtp_tls_scert_verifydepth =
5
smtp_tls_key_file=/etc/postfix/enduro.key
smtp_tls_cert_file=/etc/postfix/enduro.pem
smtpd_tls_ask_ccert
= yes
smtpd_tls_req_ccert =no
smtp_tls_enforce_peername = no
9. Also make sure you have this entry in main.cf
relayhost = [smtp.gmail.com]:587
10. Using vi or your favorite editor, create the follwing file,
/etc/postfix/sasl_passwd
and using this format below for its content, add your email
address and password:
#
Contents of sasl_passwd
#
[smtp.gmail.com]:587
myemail@gmail.com:pa33w0r8
11. Now test
this file by running this simple "hash" key test.
$
postmap -q [smtp.gmail.com]:587 sasl_passwd
myemail@gmail.com:pa33w0r8
12. You'll
need to protect your password so that only the postfix group and root
can read it by changing the access rights as follows:
$
chown root.postfix sasl_passwd*
$ chmod 0640 sasl_passwd*
( PostFix binary location: /usr/sbin/postfix )
13.Start
PostFix,
command line:
postfix start
14. Use sendmail
from command line to test:
Cmd line:
sendmail mytargetemail@gmail.com this is test
Next: Hit Enter ,
then type a dot, then Hit Enter
(Note: make sure
Sendmail is started (cmd line: service sendmail restart)
(Note: logs errors
to /var/log/maillog)
Alternatively Test
Sendmail using this by creating a text file (mail.txt) in the below
format)
date:
todays-date
to: user@domain.com
subject:
subject
from: your-name@domain.com
Body of
message goes here
Then call sendmail with
that file as an input:
Command
line: /usr/sbin/sendmail email-address < mail.txt
Or you can use the -t
option to to tell sendmail to read the header of the message to
figure out who to send it to.
Command
line: /usr/sbin/sendmail -t < mail.txt
This will process the
To: and CC: lines for you and send the mail to the
correct addresses.
Wednesday, November 12, 2008
Blogspot Tip of the Day, You can use Google Docs to Publish directly to your blog
For example so you are writing a long article (in my case long technical thing), it is much easier
to write something using a word processor like Word or Google Docs.
If you write something in Google Docs, you have the option to "Publish as Web Page"
within this option you can then choose to publish it to your Blog.
If it is to blogspot, you click configure your blogspot settings, enter your info then click Publish to Blog.
Mono on Fedora 9 - Installation/Setup/Configuration
See blog post: http://endurotracker.blogspot.com
Summary:
Install and configure Mono (.net framework) on Fedora 9.
Notes: Yum did not seem to detect the dependencies of between xsp and mod_mono
if you follow the order of the steps at : http://www.inprose.com/articles/10-enable-aspnet-support-in-fedora-linux.html
You end up with fc9 version of mod_mono, but a fc10 version of xsp which is bad.
You want all your libraries to be a fc10 version.
Your web server, Apache can be the fc9 version.
Steps:
1) Install Apache fc9: yum install httpd
2) Disable SELinux, from UI , click System -> Administration -> SELinux Management ( from linked article above mentions that from command line: setenforce 0 , but I could not get this to work)
3) Install fc10 mod_mono from rawhide repository ( which depends on mono-core, mono-web, and xsp, so this will can installed all at the same time in this step):
yum install --enablerepo=rawhide mod_mono
4) Grant permissions to apache user to execute and create directories under var/run ( apache runs under user: apache by default), command line: chmod 777 /var/run -R
5) After the successful install we need to configure Apache to allow it to run Mono applications (typical usage asp.net web pages, and .asmx web services).
In this test case , we are using the test asp.net pages that got installed under /usr/lib/xsp/test when we installed xsp above in the install mod_mono step.
On completion of this step, we can open our browser and go to http://localhost/test to see our Mono Test Page in action.
Edit /etc/httpd/conf/httpd.conf
Add these entries to the end of the file:
#Test Mono Setup
MonoAutoApplication enabled
MonoServerPath test /usr/bin/mod-mono-server2
Alias test "/usr/lib/xsp/test"
MonoApplications test "/test:/usr/lib/xsp/test"
MonoSetServerAlias test
SetHandler mono
MonoSetEnv MONO_IOMAP=all6) Done! Go to go to http://localhost/test to test your setup.
Monday, November 10, 2008
Amazon Flexible Payment Service , A Series of Blog Posts
with Amazon's Flexible Payment Service.(http://aws.amazon.com/fps/) Amazon's offering competes with PayPal, Google Checkout, http://www.authorize.net/, and other payment api's.
I am creating a series of blogs because Amazon's FPS API is a large offering and a single blog post would only skim the surface.
Series topics will include:
Overview of Amazon FPS,
Setting up your Environment/Creating your FPS account,
Creating Payment Instructions,
Creating a database to store submitted transactions,
Using Co-Branded UI,
Creating Pay Request,
Pull Method - Create a Job to Polling Amazon's FPS Service for successful Pay Request,
Push Method - Use Amazon Notifications to get Status of Pay Requests
Sunday, September 28, 2008
JQuery and MonoRail
I took this opportunity because, Ayende (http://ayende.com/blog/) released some code on the Castle project mailing list as well as being added to the Trunk that helps people who prefer JQuery as one of their Javascript library. Ayende shared a JQueryGenerator class and a JQueryElementGenerator class.
Side Note to avoid conflicts with other javascript libraries add this to you layout template wrapped in the script tag:
<script type="text/javascript">
{
var jQuery = jQuery.noConflict();
});
</script>
I starting using them and created a few personal Unit test classes to test them. These test classes at the moment do not have full coverage, but they are a start.
When targeting the .Net 2.0 framework I ran into an issue with JSGeneratorDispatcher when it called a the hide method on JSQueryGenerator class. The resolution ended up being to add a params attribute to the method signature of methods that have an array in the signature. (Important: This is now patched in the trunk)
For example changing:
public override void Hide(string[] ids)
{
SelectRelevantElements(ids);
CodeGenerator.Write(".hide();");
}
To:
public override void Hide(params string[] ids)
{
SelectRelevantElements(ids);
CodeGenerator.Write(".hide();");
}
Steps to use JQuery in MonoRail
I recommend:
1) Either commenting out the other javascript libraries referenced in your layout view, or adding an alias for JQuery and wrap this in script tag.
<script type="text/javascript">
{
var jQuery = jQuery.noConflict();
});
</script>
2) Add JQuery to you layout:
<script type="text/javascript" src="$siteroot/content/js/jquery-1.2.6.js"> </script>
3) Use the latest Monorail source code from the Trunk, to take advantage of Javascript Generation using JQuery as you default.
Update global.asax.cs , add :
using Castle.MonoRail.Framework.JSGeneration;
using Castle.MonoRail.Framework.JSGeneration.jQuery;
also add method To Your Global.asax:
public void Configure(IMonoRailConfiguration config)
{
config.JSGeneratorConfiguration.AddLibrary("jquery-1.2.6", typeof(JQueryGenerator))
.AddExtension(typeof(CommonJSExtension))
.SetAsDefault();
}
3) Create yourself a helper class for JQuery to make it easier to create Ajax calls, etc. via JQuery.
Thursday, August 28, 2008
Cloud Computing: Setup Postgresql to use Amazon Elastic Block Store (EBS)
Cloud Computing: Setup Postgresql to use Amazon Elastic Block Store (EBS)
Prerequisites: Familiar with creating and launching instances using Amazon EC2, and familiar with editing config files in linux. Also make sure that Postgresql is installed on your instance, see installation steps at http://endurotracker.blogspot.com .
Overview
We will follow the same initial steps as outlined on Amazon’s developer website ( http://developer.amazonwebservices.com ). The latter steps will be specific to Postgresql.
1) Creating an Amazon EBS Volume
In this example, the user calls the CreateVolume API, specifying an 10 GB volume.
$ ec2-create-volume --size 10 --availability-zone us-east-1a
VOLUME vol-4d826724 858993459200 creating 2008-02-14T00:00:00+0000
$ ec2-describe-volumes vol-4d826724
VOLUME vol-4d826724 858993459200 available 2008-02-14T00:00:00+0000
2) Attach the Amazon EBS Volume to an Instance
In this example, the user calls the AttachVolume API to attach the volume vol-4d826724 to the instance i-6058a509 and expose it as the device /dev/sdh.
$ ec2-attach-volume vol-4d826724 -i i-6058a509 -d /dev/sdh
ATTACHMENT vol-4d826724 i-6058a509 /dev/sdh attaching 2008-02-14T00:
3) Describing Volumes and Instances
After creating Amazon EBS volumes and attaching them to instances, you can list them using the DescribeVolumes and the DescribeInstances functions.
To list all volumes owned by the user, including their status, the user invokes the DescribeVolumes function.
$ ec2-describe-volumes
VOLUME vol-4d826724 858993459200 in-use 2008-02-14T00:
ATTACHMENT vol-4d826724 i-6058a509 /dev/sdh attached 2008-02-14T00:
VOLUME vol-50957039 13958643712 available 2008-02-091T00:
VOLUME vol-6682670f 1073741824 in-use 2008-02-11T12:
ATTACHMENT vol-6682670f i-69a54000 /dev/sdh attached 2008-02-11T13:56:00+0000
The function returns the volume ID, capacity, status (in-use or available) and creation time of each volume. If the volume is attached, an attachment line shows the volume ID, the instance ID to which the volume is attached, the device name exposed to the instance, its status (attaching, attached, detaching, detached) and when it was attached.
The user can also view volumes that are attached to running instances by using the DescribeInstances function.
$ ec2-describe-instances
RESERVATION r-e112fc88 416161254515 default
INSTANCE i-3b887c52 ami-3fd13456 ec2-67-202-27-216.compute-1.amazonaws.com domU-12-31-38-00-35-94.compute-1.internalrunning gsg-keypair 0 m1.small 2007-11-26T13:
RESERVATION r-e612fc8f 416161254515 default
INSTANCE i-21b63c22 ami-3fd13456 ec2-67-202-18-227.compute-1.amazonaws.com domU-12-31-38-00-39-28.compute-1.internalrunning gsg-keypair 0 m1.small 2007-11-26T13:
4) Create ext3 filesystem on persistence volume (Amazon EBS) and mount the volume
Command line: yes | mkfs -t ext3 /dev/sdh
Command line: mkdir /mnt/pgsql
Command Line: mount /dev/sdh /mnt/pgsql
5) Stop Postgresql if it is already running on your instance
Cmd line: service postgresql stop
6) Copy postgresql folders to /mnt/pgsql
On Fedora 8, the folder is /var/lib/pgsql, copy the contents of the folder to /mnt/pgsql.
7) Change the owner of /mnt/pgsql to postgres user, and initial db cluster
Command line: chown –R postgres /mnt/pgsql
su –postgres
initdb –D /mnt/pgsql/data
8) Edit postgresql startup script and change all entries from /var/lib/pgsql to /mnt/pgsql
command line: vi /etc/rc.d/init.d/postgresql
9) Configure postgres for local access (see previous postgres setup post) (you will need to edit /mnt/pgsql/data/pg_hba.conf and /mnt/pgsql/data/postgresql.conf)
command line: service postgresql start
10) Enjoy !
Wednesday, August 27, 2008
DB Cloud Computing: Postgresql Setup on Amazon EC2 using Fedora 8
Postgresql Setup on Amazon EC2 using Fedora 8
Prerequisites: Familiar with creating and launching instances using Amazon EC2, and familiar with editing config files in linux.
Links to documentation on Amazon EC2 and how to create and launch instances:
http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=84
click on Technical documentation link.
Thanks goes to this article: http://www.postgresonline.com/journal/index.php?/archives/45-An-Almost-Idiots-Guide-to-PostgreSQL-YUM.html
There are some things missing from that article that I have addressed here.
1) Create Ami instance from pre-existing instance and launch instance.
Use ami-0abe5a63 for example, see url: http://www.nonhostile.com/mono-on-amazon-ec2.asp
url: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1616&categoryID=101
2) Logon to your instance using an SSH client (in windows you can use Putty)
3) Login as root
4) Edit /etc/yum/pluginconf.d/fastestmirror.conf and add to the end: exclude=postgresql*
(differs from the instructions at http://yum.pgsqlrpms.org/howtoyum.php to prevent your YUM update from getting postgresql from other sources)
5) Select the appropriate repository config file for your OS and choose 8.3 from here and navigating thru: http://yum.pgsqlrpms.org/reporpms/repoview/letter_p.group.htmlNote the install file - should look something like http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-fedora-8.3-4.noarch.rpm
6) Do a wget of the appropriate one: e.g.
wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-fedora-8.3-4.noarch.rpm
7) Next install the rpm config file with:
rpm -ivh pgdg-fedora-8.4-1.noarch.rpm
8) Install the things that you want. These are the ones we tend to install
yum install postgresql
yum install postgresql-server
yum install postgis
yum install pgadmin3
Note:On Fedora 8, postgresql default location is /var/lib/pgsql/data
9) Create a user postgres
Add command prompt : useradd postgres
10) Set new user’s password
Add command prompt: passwd postgres
11) Initialize postgreSql
At command prompt:
chown postgres /var/lib/pgsql/data
su postgres
initdb –D /var/lib/pgsql/data
12) Configure postgresql for local access
From command line ( start up vi and add the 2 entries):
vi /var/lib/pgsql/data/pg_hba.conf
- add:local all all trust
host all all 127.0.0.1 255.255.255.255 trust
host all all 0.0.0.0 255.255.255.255 reject
13) To configure remote access, from command line, pass in range of external ips to allow access to:
vi /var/lib/pgsql/data/postgresql.conf
listen_addresses = ‘*’
vi /var/lib/pgsql/data/pg_hba.conf
host all all [start ip range] [end ip range] trust
14) Assuming you have the AMI tools installed on your desktop, from the command line authorize the default port of 5432, by doing the following:
c:\amitools\ec2-authorize default –p 5432
Note: Now you can use the Postgres Admin UI Tools (pgAdmin III) from the machines that you granted remote access to. PgAdmin III allows you to administer Postgresql via a GUI. You can get this tool by installing Postgresql on your Windows desktop(s). I recommend this since it makes administration much easier.
15) Restart Postgresql, from command line (logged in as root):
service postgresql restart
16) Create a db if you like, from command line:
su – postgres
createdb db_name
17) Create a postgresql username with password for new db.
From command line: (-U postgres , means username postgres)
createuser –P –U postgres
18) Restart postgresql
19) Test your connection
login as root, then from command line:
psql –U db_username db_name
Cloud Computing: Mono Setup on Amazon EC2
Mono Setup on Amazon EC2 with optional config for MonoRail
Prerequisites: Familiar with create and launching instances using Amazon EC2, and familiar with editing config files in linux.
Links to documentation on Amazon EC2 and how to create and launch instances:
http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=84
click on Technical documentation link.
For porting application to Mono see article:
http://www.mono-project.com/Guide:_Porting_ASP.NET_Applications
1) Create Ami instance from pre-existing instance and launch instance.
Use ami-0abe5a63, see url: http://www.nonhostile.com/mono-on-amazon-ec2.asp
url: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1616&categoryID=101
2) Update Apache on this instance. This instance is a Fedora 8 image with Apache
Edit /etc/httpd/conf/httpd.conf
Add these entries to the end to use test app from mono:
MonoServerPath default /opt/mono-1.9.1/bin/mod-mono-server2
Alias / “/opt/mono-1.9.1/lib/xsp/test”
AddMonoApplications default “/:/opt/mono-1.9.1/lib/xsp/test”
<Location /> MonoSetServerAlias default SetHandler mono <Location /> Here is other entry example (notice using MonoApplications instead of AddMonoApplications) (not sure why examples differ), but both syntax work: Alias hellomonoweb “/opt/mono-1.9.1/lib/xsp/hellomonoweb” MonoApplications “/hellomonoweb:/opt/mono-1.9.1/lib/xsp/hellomonoweb” <Location /> SetHandler mono </Location> Important to disable case sensitivity for files and file paths add this entry. This prevents issues like file not found due to differences between Linux and Windows handling of case sensitivity for files and file paths: MonoSetEnv MONO_IOMAP=all 3) Optionally, if you are using MonoRail, a .Net implementation of Ruby on Rails ( see castleproject.org), add the following entry to /etc/httpd/conf.d/mod_mono.conf: AddType applications/x-asp-net .rails