Friday, March 25, 2011

good tutorial for couchdb with couchapp

http://blog.edparcell.com/using-jquery-and-couchdb-to-build-a-simple-we

more easy on a ubuntu 9.10 system to install couchapp

adding the couchapp's PPA to Ubuntu 9.10 (Karmic) and later

$ sudo add-apt-repository ppa:couchapp/couchapp

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv E9AE0C6F64E1127BDAB2C06D9180CDCB0CC91448
gpg: ....
gpg: ....
gpg: ...: 1 (RSA: 1)

$ sudo apt-get update

install couchapp on your AWS EC2

if you have not install couchdb, plesae install it first. refer to "install couchdb for AWS" in this blog.
(on Linux ip-10-146-47-148 2.6.34.7-56.40.amzn1.i686 #1 SMP Fri Oct 22 18:48:33 UTC 2010 i686 i686 i386 GNU/Linux
)

$ cd /tmp
$ curl -O http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ sudo easy_install pip
$ sudo pip install couchapp

test: (you will see couchapp help)
$ couchapp

Tuesday, March 22, 2011

install couchdb 1.2.0 on AWS (AMI: ami-8e08a38f) successfuly

0. pre-isntall os dependencies.
on CentOS.
$ sudo yum install gcc glibc-devel make ncurses-devel openssl-devel yum install libicu-devel curl-devel git nmap

or on ubuntu 10.04
$ sudo apt-get install libtool libicu-dev libssl-dev libssl0.9.8 (for building couchdb, ssl is for erlang).

1. make sure your have curl

build it from source:

$ wget http://curl.haxx.se/download/curl-7.21.4.tar.gz
$ tar -xvzf curl-7.21.4.tar.gz
$ cd curl-7.21.4
$ ./configure --prefix=/usr/local
$ make
$ make test
$ sudo make install

result:
curl --version
curl 7.21.4 (i686-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

2. check your linux version

uname -a
Linux ip-10-146-47-148 2.6.34.7-56.40.amzn1.i686 #1 SMP Fri Oct 22 18:48:33 UTC 2010 i686 i686 i386 GNU/Linux

3. Install SpiderMonkey (Mozilla javascript is required for build couchDB)

$ wget http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz
$ tar xvzf js-1.8.0-rc1.tar.gz
$ cd js/src
$ make BUILD_OPT=1 -f Makefile.ref
$ sudo make BUILD_OPT=1 JS_DIST=/usr/local -f Makefile.ref export

4. Install Erlang (couchDB is written by Erlang)

Remark: pre-install ncurses-devel.i386 first on CentOS (yum install ncurses-devel.i386)
or (sudo apt-get install libncurses5-dev) on ubuntu 10.04.

$ wget http://erlang.org/download/otp_src_R14B02.tar.gz
$ tar xvzf otp_src_R14B02.tar.gz
$ cd otp_src_R14B02
$ ./configure && make && sudo make install

result:
erl -version
Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.8.3

5. build couchdb

$ svn co http://svn.apache.org/repos/asf/couchdb/trunk couchdb
$ cd couchdb
$ ./bootstrap
$ ./configure
$ make && sudo make install


6. configure couchdb

Edit the CouchDB configuration file (if necessary)

# vi /usr/local/etc/couchdb/local.ini

Create couchdb user and change file ownership

$ sudo adduser -r --home /usr/local/var/lib/couchdb -M --shell /bin/bash --comment "CouchDB Administrator" couchdb
$ sudo chown -R couchdb: /usr/local/var/lib/couchdb /usr/local/var/log/couchdb

Set CouchDB service to run on startup:

# ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb (on ubunutu, ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb)

# chkconfig --add couchdb
# chkconfig --level 345 couchdb on

Start CouchDB and verify it running:

# sudo service couchdb start
# sudo service couchdb status
# curl http://127.0.0.1:5984/
{"couchdb":"Welcome","version":"1.2.0a1084126"}

REMARKS:
1. first problem you may also encounter for sing in a new account or fix party admin. see also,
http://couchdbtw.blogspot.com/2011/03/first-problem-i-had-encountered-is-i.html

couchdb 1.2.0 installed on AWS EC2 successfully.

curl http://127.0.0.1:5984
{"couchdb":"Welcome","version":"1.2.0a1084126"}

with help from this cached page
http://webcache.googleusercontent.com/search?q=cache:v8EJh5QJwP0J:www.ipublic.org/blog/2011/02/install-couchdb-geocouch-on-centos-5/+install+couchdb+on+centos&cd=6&hl=zh-TW&ct=clnk&gl=tw&client=opera&source=www.google.com.tw

Saturday, March 19, 2011

set colorful prompts

$ echo 'export PS1="\e[0;35m[\u@\h \w]\$ \e[m"' | sudo tee -a /home/lou/.bashrc

add a new account, for example "lou"

$sudo useradd lou

ec2-user$ sudo su lou
lou$ mkdir -m 700 ~/.ssh
lou$ touch ~/.ssh/authorized_keys
lou$ chmod 600 ~/.ssh/authorized_keys
lou$ exit
ec2-user$ cat ~/id_rsa_ec2.pub | sudo tee -a /home/lou/.ssh/authorized_keys

add user account and others

http://codelikezell.com/setting-up-rails-mysql-php-apache-and-git-on-ec2/

Tutorial: how to run your first Cloud MapReduce job

http://code.google.com/p/cloudmapreduce/wiki/Tutorial

install couchDB to your aws ec2 with sprinkle (ruby gem)

http://knuthellan.com/2009/08/31/couchdb-on-amazon-ec2-centos-server-with-sprinkle/

install sprinkle when ruby and gem are ready on your AWS EC2 server

~/rubygems-1.6.2$ gem install sprinkle
Fetching: highline-1.6.1.gem (100%)
Fetching: net-ssh-2.1.3.gem (100%)
Fetching: net-ssh-gateway-1.0.1.gem (100%)
Fetching: net-sftp-2.0.5.gem (100%)
Fetching: net-scp-1.0.4.gem (100%)
Fetching: capistrano-2.5.20.gem (100%)
Fetching: sprinkle-0.3.3.gem (100%)
Successfully installed highline-1.6.1
Successfully installed net-ssh-2.1.3
Successfully installed net-ssh-gateway-1.0.1
Successfully installed net-sftp-2.0.5
Successfully installed net-scp-1.0.4
Successfully installed capistrano-2.5.20
Successfully installed sprinkle-0.3.3
7 gems installed
Installing ri documentation for highline-1.6.1...
Installing ri documentation for net-ssh-2.1.3...
Installing ri documentation for net-ssh-gateway-1.0.1...
Installing ri documentation for net-sftp-2.0.5...
Installing ri documentation for net-scp-1.0.4...
Installing ri documentation for capistrano-2.5.20...
Installing ri documentation for sprinkle-0.3.3...
Installing RDoc documentation for highline-1.6.1...
Installing RDoc documentation for net-ssh-2.1.3...
Installing RDoc documentation for net-ssh-gateway-1.0.1...
Installing RDoc documentation for net-sftp-2.0.5...
Installing RDoc documentation for net-scp-1.0.4...
Installing RDoc documentation for capistrano-2.5.20...
Installing RDoc documentation for sprinkle-0.3.3...

install ruby gem on Amazon EC2 CentOS server

1. assume you system already install ruby
2. wget http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz
4. gzip -d *gz
5. tar xvf *tar
6. cd ru*
7. ruby setup.rb

gem will be install to your /usr/loca/gem

refer to: http://rubygems.org/pages/download

Friday, March 18, 2011

Install SpiderMonkey on AWS

you may need to add a yum repository. Add rpmforge.repo in /etc/yum.repos.d containing:

# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
# URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
baseurl = ftp://ftp.pbone.net/mirror/atrpms.net/el5-i386/atrpms/stable
enabled = 1
protect = 0
gpgcheck = 0

(Put "x86_64" instead of "i386" if when appropriate.)

Now run:

yum clean all
yum install js-devel (--skip-broken)

install couchdb on amazone standard AMI for AWS EC2

you don't have to install EPEL.

1. sudo yum install ncurses-devel openssl-devel icu libicu-devel js js-devel curl-devel erlang erlang-devel libtool

2. mkdir svn; cd svn; svn checkout http://svn.apache.org/repos/asf/couchdb/trunk couchdb

3. cd couchdb; ./bootstrap

You need to install SpiderMonkey.

you may need to add a yum repository. Add rpmforge.repo in /etc/yum.repos.d containing:

# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
# URL: http://rpmforge.net/
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
baseurl = ftp://ftp.pbone.net/mirror/atrpms.net/el5-i386/atrpms/stable
enabled = 1
protect = 0
gpgcheck = 0

(Put "x86_64" instead of "i386" if when appropriate.)

Now run:

yum clean all
yum install js-devel


4. ./configure --with-erlang=/usr/lib/erlang/usr/include && \
make && \
make install

sudoyum updatbuild katdchttp://twd.cer24.com/usd/converter/e

sudo yum update
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
amzn | 2.1 kB 00:00
Skipping security plugin, no data
Setting up Update Process
Resolving Dependencies
Skipping security plugin, no data
--> Running transaction check
---> Package aws-amitools-ec2.noarch 0:1.3.57676-1.1.amzn1 set to be updated
---> Package aws-apitools-as.noarch 0:1.0.33.1-1.1.amzn1 set to be updated
---> Package aws-apitools-ec2.noarch 0:1.3.62308-1.1.amzn1 set to be updated
---> Package aws-apitools-mon.noarch 0:1.0.9.5-1.1.amzn1 set to be updated
---> Package aws-apitools-rds.noarch 0:1.3.003-1.1.amzn1 set to be updated
---> Package cloud-init.noarch 0:0.5.14-23.amzn1 set to be updated
---> Package java-1.6.0-openjdk.i686 1:1.6.0.0-44.1.9.1.18.amzn1 set to be updated
---> Package java-1.6.0-openjdk-devel.i686 1:1.6.0.0-44.1.9.1.18.amzn1 set to be updated
---> Package system-release.noarch 0:2010.11-2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================
Updating:
aws-amitools-ec2 noarch 1.3.57676-1.1.amzn1 amzn 87 k
aws-apitools-as noarch 1.0.33.1-1.1.amzn1 amzn 5.9 M
aws-apitools-ec2 noarch 1.3.62308-1.1.amzn1 amzn 8.3 M
aws-apitools-mon noarch 1.0.9.5-1.1.amzn1 amzn 5.9 M
aws-apitools-rds noarch 1.3.003-1.1.amzn1 amzn 6.0 M
cloud-init noarch 0.5.14-23.amzn1 amzn 78 k
java-1.6.0-openjdk i686 1:1.6.0.0-44.1.9.1.18.amzn1 amzn 31 M
java-1.6.0-openjdk-devel i686 1:1.6.0.0-44.1.9.1.18.amzn1 amzn 11 M
system-release noarch 2010.11-2 amzn 16 k

Transaction Summary
==============================================================================================================================================================
Install 0 Package(s)
Upgrade 9 Package(s)

Total download size: 68 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): aws-amitools-ec2-1.3.57676-1.1.amzn1.noarch.rpm | 87 kB 00:00
(2/9): aws-apitools-as-1.0.33.1-1.1.amzn1.noarch.rpm | 5.9 MB 00:00
(3/9): aws-apitools-ec2-1.3.62308-1.1.amzn1.noarch.rpm | 8.3 MB 00:00
(4/9): aws-apitools-mon-1.0.9.5-1.1.amzn1.noarch.rpm | 5.9 MB 00:00
(5/9): aws-apitools-rds-1.3.003-1.1.amzn1.noarch.rpm | 6.0 MB 00:00
(6/9): cloud-init-0.5.14-23.amzn1.noarch.rpm | 78 kB 00:00
(7/9): java-1.6.0-openjdk-1.6.0.0-44.1.9.1.18.amzn1.i686.rpm | 31 MB 00:00
(8/9): java-1.6.0-openjdk-devel-1.6.0.0-44.1.9.1.18.amzn1.i686.rpm | 11 MB 00:00
(9/9): system-release-2010.11-2.noarch.rpm | 16 kB 00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 29 MB/s | 68 MB 00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : aws-amitools-ec2-1.3.57676-1.1.amzn1.noarch 1/18
Updating : system-release-2010.11-2.noarch 2/18
Updating : cloud-init-0.5.14-23.amzn1.noarch 3/18
Updating : 1:java-1.6.0-openjdk-1.6.0.0-44.1.9.1.18.amzn1.i686 4/18
Updating : 1:java-1.6.0-openjdk-devel-1.6.0.0-44.1.9.1.18.amzn1.i686 5/18
Updating : aws-apitools-as-1.0.33.1-1.1.amzn1.noarch 6/18
Updating : aws-apitools-ec2-1.3.62308-1.1.amzn1.noarch 7/18
Updating : aws-apitools-mon-1.0.9.5-1.1.amzn1.noarch 8/18
Updating : aws-apitools-rds-1.3.003-1.1.amzn1.noarch 9/18
Cleanup : aws-apitools-rds-1.2.006-2.2.amzn1.noarch 10/18
Cleanup : aws-apitools-mon-1.0.2.3-2.1.amzn1.noarch 11/18
Cleanup : aws-apitools-ec2-1.3.57419-2.3.amzn1.noarch 12/18
Cleanup : aws-apitools-as-1.0.9.0-2.1.amzn1.noarch 13/18
Cleanup : aws-amitools-ec2-1.3.56066-2.5.amzn1.noarch 14/18
Cleanup : system-release-2010.11-1.noarch 15/18
Cleanup : cloud-init-0.5.14-22.amzn1.noarch 16/18
Cleanup : 1:java-1.6.0-openjdk-devel-1.6.0.0-44.1.9.1.16.amzn1.i686 17/18
Cleanup : 1:java-1.6.0-openjdk-1.6.0.0-44.1.9.1.16.amzn1.i686 18/18

Updated:
aws-amitools-ec2.noarch 0:1.3.57676-1.1.amzn1 aws-apitools-as.noarch 0:1.0.33.1-1.1.amzn1 aws-apitools-ec2.noarch 0:1.3.62308-1.1.amzn1
aws-apitools-mon.noarch 0:1.0.9.5-1.1.amzn1 aws-apitools-rds.noarch 0:1.3.003-1.1.amzn1 cloud-init.noarch 0:0.5.14-23.amzn1
java-1.6.0-openjdk.i686 1:1.6.0.0-44.1.9.1.18.amzn1 java-1.6.0-openjdk-devel.i686 1:1.6.0.0-44.1.9.1.18.amzn1 system-release.noarch 0:2010.11-2

Complete!

Monday, March 14, 2011

Thursday, March 10, 2011

How to create an Amazon Elastic Compute Cloud EC2 Machine Image (AMI)

a good reference from Phil Chen's Blog as the following link:

http://www.philchen.com/2009/02/14/how-to-create-an-amazon-elastic-compute-cloud-ec2-machine-image-ami

aki-d209a2d3 AWS EC2 AMI is not so bad.

1. user account (bitnami) bitnami@ec2-175-41-196-29.ap-northeast-1.compute.amazonaws.com
2. you can use 'sudo apt-get install xxx' to get new application, which Amazon AMI can't.

3. But it also hang here.

Setting up openjdk-6-jre-headless (6b20-1.9.7-0ubuntu1~10.04.1) ...
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/java to provide /usr/bin/java (java) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode.

bug report. i-8a47c78b in Tokyo region.

in i-8a47c78b (Tokyo AWS) it will hang as follows; you can't install any software though.

$ sudo dpkg --configure -a
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Setting up openjdk-6-jre-headless (6b20-1.9.7-0ubuntu1~10.04.1) ...
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/java to provide /usr/bin/java (java) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/keytool to provide /usr/bin/keytool (keytool) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/pack200 to provide /usr/bin/pack200 (pack200) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/rmiregistry to provide /usr/bin/rmiregistry (rmiregistry) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/unpack200 to provide /usr/bin/unpack200 (unpack200) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode.
update-alternatives: using /usr/lib/jvm/java-6-openjdk/jre/lib/jexec to provide /usr/bin/jexec (jexec) in auto mode.

Sunday, March 6, 2011

to create an AWS EC2 Instance in Japan Zone.

It is really fast. Much faster than US east zone when you use ssh to login them. Move your Instance to Japan now.

想裝其它 server 在你 AWS EC2 上嗎?

in AWS 想裝其它 server 在你 AWS EC2 上嗎? 例如 Tomcat, samba, LAMP 等...


ssh 進了你的 EC2後
$ sudo tasksel --section server

Saturday, March 5, 2011

AWS 如果你不想無緣無故被 Amazon 收錢.

https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=activity-summary

常常檢查以上網址, 了解現本月份帳單.

AWS Elastic IP is not free. Even you use free acount in the first year.

Elastic IP Addresses
$0.01 per non-attached Elastic IP address per complete hour 11 Hrs 0.11

Thursday, March 3, 2011

extra charge for Data Transfer (unknown reason)

Data Transfer (unknown reason)

$0.010 per GB - regional data transfer - in/out/between EC2 Avail Zones or when using public/elastic IP addresses or ELB 0.012 GB US$ 0.01

When I use Android AWS Demo to access my Simple DB.

CloudWatch may charged in free trial

Amazon CloudWatch - $0.015 per monitored instance-hour (or partial hour) 25 Hrs US$ 0.38

to reboot your instance (i-192f1074 for example)

$ ec2-reboot-instances i-192f1074

first command line (how to make your aws ec2 instance ping-able)

$ ec2-authorize default -P icmp -t -1:-1 -s 0.0.0.0/0