Saturday, April 2, 2011

success on getting Rails app working!

After a couple of nights of re-education on mysql and rails, I was able to get an instance of TrendingTopics up and running out in Amazon's cloud. This is using an OpenSuSE 11.4 instance:

Hooray!

However, if you look carefully at the data, you'll notice it's two years old. It would be nice to refresh the public dataset. It is two years old.

My next step is to understand DataWrangling's data update methodology using Hadoop Streaming (python scripts) to munge the weblog data with MapReduce and then stored into Hive datasets. Sounds complex.
;)
Tally ho!



Install Notes
Fire up new instance of EC2 micro OpenSuSE11.4 ami-00c83b69
setup ssh key
zypper in expect gcc git httpd make mysql mysql-devel mysql-server openssl-devel ruby rubygems ruby-devel s3cmd zlib*

note that s3cmd requires a manual install on OpenSuse 11.4
sudo python setup.py install

mysql
# start mysql
/etc/init.d/mysql start

# set a password
/usr/bin/mysqladmin -u root password '***'
# test the login
mysql -u root -p

# note the new open port
ip-10-117-78-175:~ # ns
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN


Gems Installs
# install base rails gem
sudo gem install rails --no-ri --no-rdoc
# install mongrel and mongrel_cluster gems
(–include-dependencies not needed)
sudo gem install mongrel --no-ri --no-rdoc
sudo gem install mongrel_cluster --no-ri --no-rdoc


If you're behind a proxy, this command will work with ntlmaps installed:
[sodo@computer ~]$ sudo gem install rails --no-ri --no-rdoc --http-proxy http://localhost:5865
Successfully installed rails-3.0.7
1 gem installed


Back to pete's doc..
# install version specific rails gem
sudo gem install -v=2.3.2 rails --no-ri --no-rdoc
# install mysql gem
sudo gem install mysql --no-ri --no-rdoc
# install memcached
sudo gem install cached_model --no-ri --no-rdoc

May encounter this problem with the cached_model
[sodo@computer ~]$ sudo gem install cached_model --no-ri --no-rdoc --http-proxy http://localhost:5865
ERROR: Error installing cached_model:
hoe requires RubyGems version >= 1.4. Try 'gem update --system' to update RubyGems itself.
[sodo@computer ~]$ sudo gem update --system --no-ri --no-rdoc --http-proxy http://localhost:5865
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.7.2
Updating RubyGems to 1.7.2
Installing RubyGems 1.7.2
RubyGems 1.7.2 installed

------------------------------------------------------------------------------

RubyGems installed the following executables:
/usr/bin/gem


After which, you'll have to update the Rails 2.3.2 gem.

Nice trick to delete all gems at once:
sudo gem list | cut -d" " -f1 | xargs sudo gem uninstall -aIx

Rails config
git clone git://github.com/datawrangling/trendingtopics.git
$ cd trendingtopics
cp config/config.yml.sample config/config.yml
domain: '`hostname`'
admin_user: root
admin_password:

cp config/database.yml.sample config/database.yml
username: root
password:
socket: /var/run/mysql/mysql.sock


# rake time!
sudo rake gems:install

# rails app error
error: rake aborted! undefined local variable or method 'version_requirements'
http://www.redmine.org/boards/2/topics/22358?r=22797#message-22797

# edit config/environment.rb between bootstrap and initializer:
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end

#change "jpignata-bossman" to 'bossman'
$ rake db:create
$ rake db:migrate
$ rake db:develop


# start the Rails app
ip-10-117-78-175:~/trendingtopics # script/server
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

# edit EC2 instance security settings to allow for inbound rails traffic on port 3000


Add a proxy to your environment.rb
For some reason, gem install wasn't recognizing my http_proxy environment variable. I discovered a really ugly workaround. For example:
Rails::Initializer.run do |config|
# Specify gems that this application depends on and have them installed with rake gems:install
config.gem "ya2yaml --http-proxy http://username:password@http-proxy"
config.gem 'rubaidh-google_analytics --http-proxy http://username:password@http-proxy', :lib => 'rubaidh/google_analytics', :source => 'http://gems.github.com'


Assorted Problems
sodo@linux-z6tw:~> sudo /sbin/chkconfig --level 35 mysql on
insserv: FATAL: service network is missed in the runlevels 2 to use service mysql
insserv: exiting now!
/sbin/insserv failed, exit code 1
sodo@linux-z6tw:~> vi /etc/init.d/mysql
sodo@linux-z6tw:~> sudo vi /etc/init.d/mysql  # remove Default Start Runlevel of 2
sodo@linux-z6tw:~> sudo /sbin/chkconfig --level 35 mysql on


Run "rcmysql start" to help debug issues

Reference
http://s3tools.org/download
MySQL Tutorial
Ruby on Rails Guide
Rails: Basics of Layouts
Rails: Enabling Forgery Protection
Cache Mgmt in Rails
Sweeping the Rails cache
Google Charts for Rails
Memcached.org
Memcached Basics
http://dev.mysql.com/doc/mysql/en/crashing.html
Suse 11.4 Download Link 

No comments:

Post a Comment