EzDevInfo.com

linode interview questions

Top linode frequently asked interview questions

linode vs amazon ec2 vs heroku for project with amazon s3

I have a project in ruby on rails 3.1 like flickr, tumblr, pinterest...etc with a lot of pictures for maintenance.

My project have database Mongodb.

I'm using amazon s3 for host pictures.

I want to know what is the best hosting combination to get the most quality/price, linode + s3, or amazon ec2 + s3 or heroku + amazon s3.

I need enough scale because the project is growing fast.

Any other suggest is welcome :D.

After much reading I am not clear.


Source: (StackOverflow)

Premature end of script headers: media ( Issue related to :rails app deployment+passenger+ubuntu+apache)

i just setup a linode server and deploy my rails 3 app on it.its up and running.The problem is that some images are not showing up in the production.locally they are perfectly working.i double checked the log file(production.log) but nothing found.then i check server error.log file that says.

[Sat Dec 29 22:54:14 2012] [error] [client 182.177.228.157] Premature end of script headers: media, referer: http://50.116.57.152/app?v=11&o=33

Check out http://50.116.57.152/app?v=11&o=33  for live demo.

Thanking in advance.


Source: (StackOverflow)

Advertisements

What are some big sites that are using Linode? [closed]

Similar to this question; I'm looking for examples of large websites that are hosted on Linode.


Source: (StackOverflow)

Downloading MySQL dump from command line

I am moving away from Linode because I don't have the Linux sysadmin skills necessary; before I complete the transition to a more noob-friendly service, I need to download the contents of a MySQL database. Is there a way I can do this from the command line?


Source: (StackOverflow)

How to deploy a [Ruby on Rails] site in a scalable way?

I have been working on my [first] startup for a month now, and while it's probably atleast one more month away from an alpha release, I want to know how to deploy it the right way. The site will have an initial high amount of load (network + CPU) for a new user, so I am thinking of having a separate server/queue for this initial process, so that it doesn't slow down the site for existing users.

Based on my research so far, I am currently leaning towards nginx + haproxy + unicorn/thin + memcached + mysql, and deploying on Linode. However, I have no prior experience in any of the above; hence I am hoping to tap the community's experience.

  • Does the above architecture seem reasonable? Any suggestions/articles/books that you would recommend?
  • Is Linode a good choice? Heroku/EY seem too expensive for me (atleast until I have enough revenue), but am I missing some other better option? MediaTemple?
  • Any good suggestions on the load balancing architecture? I am still reading up on this.
  • Is it better have 2 separate Rails server instances on 2 separate linodes, or running 1 instance on a linode of twice capacity (in terms of RAM/storage/bandwidth)? How many Linodes should I start with?
  • Which Linux distribution should I choose? (Linode offers 8 different ones - http://www.linode.com/faq.cfm) Are there any relative advantages/disadvantages between them for a Rails site?

I apologize if any of my questions are stupid or contradictory; please attribute it to my inexperience.


Source: (StackOverflow)

Which is the most appropriate way to host multiple websites in linode?

I just purchased the basic linode package and I am wondering what to do next. I have 5 websites with light traffic hosted on multiple providers and I want to host them all in linode. The question is:

Should I host all the websites in separate folders in a main linode of 20Gb and use virtualhosts to forward them from different domains, or create a linode for each website? I can understand that much space is lost when you create multiple linodes because you copy linux system files over and over again (and swap space). In the other hand, If a website is attacked or fails, the other ones are kept intact.


Source: (StackOverflow)

rufus cron job not working in Apache/Passenger

I have a Rails app running on Apache/Passenger. It has a rufus-scheduler cron job that runs in the background and sends out notifications via email.

When I am running the app in development on the WEBrick server, the emails are sent like they are supposed to be sent.

When I start up the app in production on Apache/Passenger, the emails don't get sent. In the production logs it doesn't show any logs for rufus-scheduler.

I'm stuck in this problem. Your help will be appreciated, thank you in advance.


Source: (StackOverflow)

Composer escapeshellarg() has been disabled for security reasons

Hey I have a server on linode.com (Centos 7). I installed cpanel and composer in my server, when I run this command (via ssh) for creating a blank symfony project,

composer create-project symfony/framework-standard-edition '~2.6'

It outputs this:

Installing symfony/framework-standard-edition (v2.7.4)
  - Installing symfony/framework-standard-edition (v2.7.4)
    Downloading: 100%         



  [ErrorException]                                         
  escapeshellarg() has been disabled for security reasons  

How can i fix this?

I don't have much knowledge on server moreover it's my first server, if it's because of cpanel I think it will do it again and again in future, is cpanel an obstruction for me?


Source: (StackOverflow)

I don't understand this Python TypeError

I am trying to use the Linode API along with this linode-python SDK to manage my Linode servers. However, I'm getting a TypeError I don't understand when I run the linode-disk-list() command.

This is how the linode-python API defines the method I'm calling. As you can see, a LinodeID is required.

@__api_request(required=['LinodeID'],
                 returns=[{u'CREATE_DT': u'YYYY-MM-DD hh:mm:ss.0',
                           u'DISKID': 'Disk ID',
                           u'ISREADONLY': '0 or 1',
                           u'LABEL': 'Disk label',
                           u'LINODEID': 'Linode ID',
                           u'SIZE': 'Size of disk (MB)',
                           u'STATUS': 'Status flag',
                           u'TYPE': "in ['ext3', 'swap', 'raw']",
                           u'UPDATE_DT': u'YYYY-MM-DD hh:mm:ss.0'}])
  def linode_disk_list(self, request):
    """Lists all disk images associated with a Linode."""
    pass

My code creates an instance of the Linode Python API per the SDK's instructions and then calls the linode_disk_list method:

from linode import api as linode_api

api = linode_api.Api(<my_api_key>)
linode_id = 1800300
disks = api.linode_disk_list(linode_id)

My code generates this error:

TypeError: wrapper() takes exactly 1 argument (2 given)

I know I'm creating the api instance correctly as I'm using it to successfully call the linode_ip_list method prior to calling the disk list method.

Just to see what happens, if I don't provide the linode_id argument, I get this error:

linode.api.MissingRequiredArgument: 'LinodeID'

If I call the method with a linode ID, the error says I'm giving it two arguments. But if I don't give it any arguments, it says I'm missing an argument. At this point, I'm not sure if the LinodeID should be an integer or a string but I get the same error in either case. How do I call this method so that I don't get the TypeError argument?

Thanks!


Source: (StackOverflow)

Django getting lots of SuspiciousOperation: Invalid HTTP_HOST header

I'm using Django 1.5, Apache, mod_wsgi and python 2.7, debian hosted on linode.

Since I upgraded from django 1.3 to django 1.5, I started receive some error messages, for example: "ERROR (EXTERNAL IP): Internal Server Error: /feed/". With this traceback:

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 92, in get_response
    response = middleware_method(request)

  File "/usr/local/lib/python2.7/dist-packages/django/middleware/common.py", line 57, in process_request
    host = request.get_host()

  File "/usr/local/lib/python2.7/dist-packages/django/http/request.py", line 72, in get_host
    "Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): %s" % host)

SuspiciousOperation: Invalid HTTP_HOST header (you may need to set ALLOWED_HOSTS): tadjenanet.montadamoslim.com

But, a few days ago, the volume of this errors increased greatly, and for a lot of url's that I don't even have in my website.

I saw the answers here(Django's SuspiciousOperation Invalid HTTP_HOST header) and I understand why I'm getting this, but I need to know how to avoid this increasing my server security.


Source: (StackOverflow)

Development and production with docker with multiple sites

Currently I have 3 linode servers:

1: Cache server (Ubuntu, varnish)

2: App server (Ubuntu, nginx, rabbitmq-server, python, php5-fpm, memcached)

3: DB server (Ubuntu, postgresql + pg_bouncer)

On my app-server I have multiple sites (topdomains). Each site is inside a virtualenviroment created with virtualenvwrapper. Some sites are big with a lot of traffic, and some site are small with little traffic.

A typical site consist of python (django), celery (beat, flower) and gunicorn.

My current development pattern now is working inside a staging environment on the app-server and committing changes to git. Then change environment to the production environment and doing a git pull, and a ./manage.py migrate and restarting the process doing sudo supervisorctl restart sitename:, but this takes time! There must be a simpler method!

Therefore it seems like docker could help simplify everything, but I can't decide the best approach for how I could manage all my sites and containers inside each site.

I have looked at http://panamax.io and https://github.com/progrium/dokku, but not sure if one of them fit my needs.

Ideally I would run a development version of each site on my local machine (emulating cache-server, app-server and db-server), do code changes there and test them. When I would see the changes worked, I would execute a command that would do all the heavy lifting and send the changes to the linode servers (I would think mostly the app-server), do all the migration and restarting the project on the server.

Could anyone point me in the right direction as how to achieve this?


Source: (StackOverflow)

Dealing With Multiple Git Heads locally and on the server

I'm using Linonde to host my git repos and also the actual site files.

git branch -r looks like this:

company/master
company/stage
origin/HEAD -> origin/master
origin/master
prod/master

git branch looks like this:

master
stage

I think I'm trying to simply have my local stage branch point to my company/master head. When I do a git push company stage it seems to update my stage head on the server but I'm trying to get it to update the master head which is where my site seems to serve it's files from. Or I need to figure out how to point my site to the company/stage head.

I tried deleting my branch and making one with

git branch stage company/master

as I thought the start-point might be what I needed.

Put when I try to push after that I get the message:

error: failed to push some refs to 'root@foo:~repos/project_name'
To Prevent you from losing history, non-fasst-forward updates were rejected
Merge the remote changes (e.g. 'git    pull') before pushing again.)

I tried a git pull but it said everything was up to date and I couldn't see anything in the fast forward help docs addressing my situation.


Source: (StackOverflow)

How do I resolve a mysql Thread Stack Overrun?

I have a stored procedure on mysql. It worked on my local MAMP environment, the procedure worked well, but when I moved it to a linode server/host it does not run. I'm getting a "Thread Stack Overrun" error. I have tried upping the thread stack up from an initial value 64K. I changed the value to 128K then to 256K. but the problem still occurs.

i am working on a lucid ubuntu 512MB linode server. I am running on linode's suggested configuration in my mysql/my.cnf file:

key_buffer = 16K
max_allowed_packet = 1M
thread_stack = 64K 
table_cache = 4
sort_buffer = 64K
net_buffer_length = 2K

Can anyone help? Can you suggest different configurations?


Source: (StackOverflow)

Capistrano and GitHub Private Repo – Permission denied (publickey)

I've inherited a Rails project, hosted on Linode.

The previous developer was using a BitBucket repository, along with Capistrano for deployments.

I've since setup a private repository on GitHub, and I'm trying to get the Capistrano recipe to work. I'm having no luck. I continue to get a publickey error during deployment.

Here are the steps I've taken –

  1. Updated the Git remote (origin) URL on the Linode server to point to my new repository
  2. Updated the repository reference in the Capfile, to reference my new repository
  3. Ensured ssh_options[:forward_agent] was set to true in the Capfile
  4. Generated an SSH key locally (id_rsa.pub) and added it to my user account in GitHub
  5. Executed the ssh-add command, to ensure the identity was added for auth agent
  6. Ran ssh -T git@github.com to confirm ssh was properly setup locally
  7. Logged into my Linode server and ran ssh -T git@github.com to ensure it was working also

Additionally, just in case the forward_agent property wasn't working, I even tried generating an SSH key on the Linode server, and adding it to GitHub as well. No luck.

After all of this, when I run cap deploy, I get the following error:

Permission denied (publickey).
fatal: The remote end hung up unexpectedly    

Below is the recipe I'm using –

require "bundler/capistrano"

server "----SERVER IP----", :web, :app, :db, primary: true

set :application, "blog"
set :user, "deployer"
set :deploy_to, "/var/www/blog"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "git@github.com:--MY USERNAME--/blog.git"
set :branch, "master"

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
  task :start do; end
  task :stop do; end
  task :restart, roles: :app, except: {no_release: true} do
    run "touch #{deploy_to}/current/tmp/restart.txt"
  end

  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/apache.conf /etc/apache2/sites-available/blog"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"

  task :symlink_config, roles: :app do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
    run "ln -nfs #{shared_path}/public/avatars #{release_path}/public/avatars"    
  end
  after "deploy:finalize_update", "deploy:symlink_config"

  desc "Make sure local git is in sync with remote."
  task :check_revision, roles: :web do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts "WARNING: HEAD is not the same as origin/master"
      puts "Run `git push` to sync changes."
      exit
    end
  end
  before "deploy", "deploy:check_revision"
end

I can't seem to figure out where I'm going wrong – any help would be greatly appreciated.


UPDATE

I've also ensured the following was added to my local ~/.ssh/config file...

Host mydomain.com
  ForwardAgent yes

Source: (StackOverflow)

Rbenv stopped working after Capistranos `cap deploy:cold` - fails RailsCast episode 335

I'm following rails Cast episode 335: http://railscasts.com/episodes/335-deploying-to-a-vps

using a linode VPN,

running:

cap deploy:cold

* executing `deploy:cold'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:benamir/listpro.git master"
    command finished in 1546ms
  * executing "if [ -d /home/deployer/apps/listpro/shared/cached-copy ]; then cd /home/deployer/apps/listpro/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 84770c5b6f38dbfeca1b5ef619fb1b9940121a4e && git clean -q -d -x -f; else git clone -q git@github.com:benamir/listpro.git /home/deployer/apps/listpro/shared/cached-copy && cd /home/deployer/apps/listpro/shared/cached-copy && git checkout -q -b deploy 84770c5b6f38dbfeca1b5ef619fb1b9940121a4e; fi"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 2874ms
    copying the cached version to /home/deployer/apps/listpro/releases/20121012050310
  * executing "cp -RPp /home/deployer/apps/listpro/shared/cached-copy /home/deployer/apps/listpro/releases/20121012050310 && (echo 84770c5b6f38dbfeca1b5ef619fb1b9940121a4e > /home/deployer/apps/listpro/releases/20121012050310/REVISION)"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 8648ms
  * executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * executing `deploy:assets:symlink'
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/public/assets &&\\\n        mkdir -p /home/deployer/apps/listpro/releases/20121012050310/public &&\\\n        mkdir -p /home/deployer/apps/listpro/shared/assets &&\\\n        ln -s /home/deployer/apps/listpro/shared/assets /home/deployer/apps/listpro/releases/20121012050310/public/assets"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 246ms
  * executing "chmod -R g+w /home/deployer/apps/listpro/releases/20121012050310"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 878ms
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/public/system && mkdir -p /home/deployer/apps/listpro/releases/20121012050310/public/"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 99ms
  * executing "ln -s /home/deployer/apps/listpro/shared/system /home/deployer/apps/listpro/releases/20121012050310/public/system"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 96ms
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/log"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 95ms
  * executing "ln -s /home/deployer/apps/listpro/shared/log /home/deployer/apps/listpro/releases/20121012050310/log"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 95ms
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310/tmp/pids && mkdir -p /home/deployer/apps/listpro/releases/20121012050310/tmp/"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 99ms
  * executing "ln -s /home/deployer/apps/listpro/shared/pids /home/deployer/apps/listpro/releases/20121012050310/tmp/pids"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 95ms
    triggering after callbacks for `deploy:finalize_update'
  * executing `bundle:install'
  * executing "ls -x /home/deployer/apps/listpro/releases"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 132ms
  * executing "cd /home/deployer/apps/listpro/releases/20121012050310 && bundle install --gemfile /home/deployer/apps/listpro/releases/20121012050310/Gemfile --path /home/deployer/apps/listpro/shared/bundle --deployment --quiet --without development test"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
 ** [out :: 198.74.59.184] sh: bundle: not found
    command finished in 95ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deployer/apps/listpro/releases/20121012050310; true"
    servers: ["198.74.59.184"]
    [198.74.59.184] executing command
    command finished in 868ms
failed: "sh -c 'cd /home/deployer/apps/listpro/releases/20121012050310 && bundle install --gemfile /home/deployer/apps/listpro/releases/20121012050310/Gemfile --path /home/deployer/apps/listpro/shared/bundle --deployment --quiet --without development test'" on 198.74.59.184
[listpro-a(__git_ps1 " (%s)")]$ 

I apologize, we must backtrack...

after running rbenv installer:

 curl -L https://raw.github.com/fesplugas/rbenv-installer/master/bin/rbenv-installer | bash

I get

 Seems you still have not added 'rbenv' to the load path:

export RBENV_ROOT="${HOME}/.rbenv"

if [ -d "${RBENV_ROOT}" ]; then
   export PATH="${RBENV_ROOT}/bin:${PATH}"
   eval "$(rbenv init -)"
fi

The above is already saved in my .bashrc file

Yesterday: executing all these commands worked: rbenv bootstrap-ubuntu-10-04 rbenv install 1.9.3-p125 rbenv global 1.9.3-p125 gem install bundler --no-ri --no-rdoc rbenv rehash

but after cap deploy, rbenv is no longer in my path.

  rbenv: command not found

echo $PATH:

 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Source: (StackOverflow)