Step-by-step: Installing Project Mercury 1.1 (Beta) on Centos 5.5

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

Here are step-by-step instructions for building Project Mercury 1.1 (BETA!!!) on a fresh Centos 5.5 server using the configuration manager BCFG2. Project Mercury is known to work on AWS, Rackspace, RackspaceCloud and Linode. We'll have Centos images up on AWS soon.

Voxel.net has official Mercury 1.1 images available using 64-bit Centos (VSE) 5.2!

Project Mercury Step By Step (using the BCFG2 configuration manager)

1) Start Centos 5.5:


For AWS, we recommend the following images (these are Centos 5.4 – there don't appear to be Centos 5.5 images on AWS yet):

32 bit:    ami-f8b35e91
64 bit:    ami-ccb35ea5

2) Configure repositories and get updates:


Here we download some additional repositories and make some modifications to exclude extraneous packages:

N.B. The URLs in the first three commands have been truncated by Drupal's URL filter, so you'll need to copy the link destinations to get the full addresses.

sudo rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/epel-release-1...
sudo rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ius-release-1....
sudo rpm -Uvh http://yum.fourkitchens.com/pub/centos/5/noarch/fourkitchens-release-5-6...
sudo rpm --import http://hudson-ci.org/redhat/hudson-ci.org.key
sudo wget http://hudson-ci.org/redhat/hudson.repo -O /etc/yum.repos.d/hudson.repo
case `uname -m` in "x86_64") EXCL_ARCH="*.i?86";; "i386" | "i586" | "i686") EXCL_ARCH="*.x86_64";; esac;
sudo sed -i -e 's/\[main\].*$/[main]\n\n### Added by PANTHEON ###\n@@here@@\n/' -e "s/@@here@@/exclude=yum3 $EXCL_ARCH/" /etc/yum.conf

Rackpsace:
Remove the non-x86_64 packages (you can use rpm -qa --queryformat '%{NAME} %{VERSION}-%{RELEASE} %{ARCH}\n' | column -t | grep -vE '(x86_64)|(noarch)|(none.$)' to find them):

sudo yum -y remove glibc.i686 libgcc.i386

i386:

sudo nano -w /etc/yum.repos.d/fourkitchens.repo (add to first repo)

enabled=0

Linode:

sudo echo -e "remove rsyslog\ninstall rsyslog4\ntransaction solve\ntransaction run" > /tmp/remrsys.txt; sudo yum -y shell /tmp/remrsys.txt; /etc/init.d/rsyslog start

All:

sudo yum clean all && sudo yum -y update

3) Install and configure BCFG2:


Time to install BCFG2 and BZR and some other packages used by Mercury and configure BCFG2:

sudo yum -y install bzr bcfg2 bcfg2-server gamin gamin-python python-genshi python-ssl python-lxml libxslt
sudo bcfg2-admin init

Will result in the following questions (recommended answers in bold):

Store bcfg2 configuration in [/etc/bcfg2.conf]: (accept default)
Location of bcfg2 repository [/var/lib/bcfg2]:(accept default)
Directory /var/lib/bcfg2 exists. Overwrite? [y/N]:y
Input password used for communication verification (without echoing; leave blank for a random):(accept default)
What is the server's hostname: [hostname]localhost
Input the server location [https://hostname:6789]: https://localhost:6789
Input base Operating System for clients:
1: Redhat/Fedora/RHEL/RHAS/Centos
2: SUSE/SLES
3: Mandrake
4: Debian
5: Ubuntu
6: Gentoo
7: FreeBSD
: 1

Warning: /etc/bcfg2.conf already exists. Overwrite? [y/N]: y
Generating a 1024 bit RSA private key
............................................................++++++
.................................++++++
writing new private key to '/etc/bcfg2.key'
-----
Signature ok
subject=/C=US/ST=Illinois/L=Argonne/CN=localhost
Getting Private key
Repository created successfuly in /var/lib/bcfg2

Now we want to download the BCFG2 config files from launchpad (If you see "You have not informed bzr of your Launchpad ID..." after the bzr command, launchpad is simply telling you that you need to login to "upload" - which we're not doing here - so you can ignore this message):

sudo rm -rf /var/lib/bcfg2/
sudo bzr branch lp:pantheon/1.1 /var/lib/bcfg2
echo -e "<Clients version=\"3.0\">\n</Clients>" | sudo tee -a /var/lib/bcfg2/Metadata/clients.xml
sudo sed -i "s/^plugins = .*$/plugins = Bundler,Cfg,Metadata,Packages,Probes,Rules,TGenshi\nfilemonitor = gamin/" /etc/bcfg2.conf
sudo sed -i '$a\\n[YUMng]\nverify_flags = nomtime' /etc/bcfg2.conf 
#uncomment the CentOS packages and comment out the Ubuntu packages that were set by default:
sudo nano -w /var/lib/bcfg2/Packages/config.xml

Ensure that bcfg2-server isn't running

ps -ef | grep bcfg2

If bcfg2-server is running, try stopping the server and check again to see if it's running:

#sudo /etc/init.d/bcfg2-server stop
ps -ef | grep bcfg2

If it is, kill all the bcfg2 processes:

sudo kill -9 {process number}

4) Start the BCFG2 server:


Here we start the bcfg2 server and wait until it spins up (this will require several minutes) - you know the server is ready when see "serve_forever() [start]" in the syslog (the tail -f command monitors the file).

sudo /etc/init.d/bcfg2-server start; sudo tail -f /var/log/messages

When the output stops, you can control-c to exit the tail and move on to the next steps.

5) Start the BCFG2 client:


Note that bcfg2 -vqed can take some time - it's done when the command prompt returns:

AWS servers:

sudo bcfg2 -vqed -p 'mercury-aws'

EBS-boot AWS servers:

sudo bcfg2 -vqed -p 'mercury-aws-ebs'

Non-AWS servers:

sudo bcfg2 -vqed

While you do need to specify if you're installing on an AWS server by using the "sudo bcfg2 -vqed -p 'mercury-aws'" command (or EBS-boot with the "sudo bcfg2 -vqed -p 'mercury-aws-ebs' command), you can don't need to identify the server anytime you want to run the bcfg2 client after that, "sudo bcfg2 -vqed" will work just fine.

If you get the error "Server failure: Protocol Error: 401 Unauthorized" make sure the first line in your /etc/hosts file looks like this (with localhost before localhost.localdomain):

127.0.0.1     localhost localhost.localdomain

6) Install Drush:


Drush is a very useful command-line Drupal management system (see http://drupal.org/project/drush):

wget http://ftp.drupal.org/files/projects/drush-All-versions-3.0.tar.gz
tar xvzf drush-All-versions-3.0.tar.gz
sudo chmod 555 drush/drush
sudo chown -R root:root drush
sudo mv drush /usr/local/
sudo ln -s /usr/local/drush/drush /usr/local/bin/drush
sudo drush dl drush_make

7) Install Mercury:


Here we ask drush to download code from our project page on launchpad.net and install some needed Drupal modules.

sudo rm -rf /var/www/html
sudo drush make --working-copy /etc/mercury/mercury.make /var/www/html

8) Install ApacheSolr:


We replace Drupal's built-in search with ApacheSolr which is faster, less resource-intensive and modular:

wget http://apache.osuosl.org/lucene/solr/1.4.0/apache-solr-1.4.0.tgz
tar xvzf apache-solr-1.4.0.tgz
sudo mkdir /var/solr
sudo mv apache-solr-1.4.0/dist/apache-solr-1.4.0.war /var/solr/solr.war
sudo mv apache-solr-1.4.0/example/solr /var/solr/default
sudo mv /var/www/html/sites/all/modules/apachesolr/schema.xml /var/solr/default/conf/
sudo mv /var/www/html/sites/all/modules/apachesolr/solrconfig.xml /var/solr/default/conf/
sudo chown -R tomcat:root /var/solr/

9) Prepare Pressflow files and dirs:


Pressflow (http://pressflow.org/) is a distribution of Drupal with integrated performance, scalability, availability, and testing enhancements:

sudo mkdir /var/www/html/sites/default/files
sudo cp /var/www/html/sites/default/default.settings.php /var/www/html/sites/default/settings.php
sudo chown -R root:apache /var/www/html/*
sudo chown apache:apache /var/www/html/sites/default/settings.php
sudo chmod 660 /var/www/html/sites/default/settings.php
sudo chmod 775 /var/www/html/sites/default/files

10) Add hudson to sudoers and restart hudson:


Initially, we're only using hudson for running init.sh, cron.php and bcfg2 -vqed but there's much more coming...
echo "hudson ALL = NOPASSWD: /usr/local/bin/drush, /etc/mercury/init.sh, /usr/bin/fab, /usr/sbin/bcfg2" | sudo tee -a /etc/sudoers
sudo sed -i 's/Defaults    requiretty/#Defaults    requiretty/' /etc/sudoers
sudo usermod -a -G root hudson
sudo chmod g+r /etc/shadow
sudo /etc/init.d/hudson restart

11) Run the Mercury Init Hudson job


Hudson provides an interface to some system scripts including the Mercury Init script. To run the script log into hudson by directing your browser to port 8081 and click on "Log In" in the upper left hand corner. Hudson is setup to use the system login/password. Some virtual servers providers, like AWS, don't have a password. You can change this by ssh'ing to the server and typing:

passwd username

Once logged in, click on "Mercury Init" and then "Build Job" which does the following:

  1. setup mysql, tomcat and varnish to use /mnt to save space on / (which is only 10GB on a EC2 small instance) - AWS servers only.
  2. configure postfix with a usable hostname and check for (and download) updates to mercury and pressflow (and apply the mercury updates via BCFG2).
  3. configure APC, varnish, tomcat and PHP memory usage based on the system memory using the /etc/mercury/config_mem.sh script
  4. send a unique but non-identifying hash to us so we can get an idea of how many Mercury users there are.

You can follow the progress of the script by clicking on the running job (lower left corner) and then "Console Output".

12) Configure Pressflow:

  1. Go to your site in your web browser
  2. Choose the Mercury profile (This will setup the appropriate modules and settings.)
  3. Database name = "pantheon"
  4. Datebase username ="root" (no password yet - we set it below)
  5. After pressflow is configured:

  6. Set the mysql root password and create a non-root account (changing new_user and new_password to appropriate values):
  7. # Login to MySQL as root
    mysql -u root
    # Set root user password
    mysql> set password for root@localhost=PASSWORD('new_password');
    # Create new user and give a password
    mysql> create user 'new_user'@'localhost' identified by 'new_password';
    # Set privileges for new user
    mysql> grant all on pantheon.* to new_user@localhost identified by 'new_password';
    mysql> flush privileges;
    mysql> \q
  8. Update your Pressflow install with the new mysql account information by editing
    /var/www/html/sites/default/settings.php (again using the appropriate new_user and new_password values):
  9. sudo nano -w /var/www/html/sites/default/settings.php

    And change:

    $db_url = 'mysqli://username:password@localhost/databasename';

    to what you set up for the new user above. Make sure to edit the 'mysqli:' and not the 'mysql:' portion.

    $db_url = 'mysqli://new_user:new_password@localhost/pantheon';

Next Steps

  • If you're interested in using the new multi-site ability, see http://groups.drupal.org/node/72488
  • To see what can be configured on your Mercury server, see http://groups.drupal.org/node/70258
  • We using hudson to run drupal/drush cron jobs. We intend to add much more to hudson in the future. if you choose to turn it off via the tuneable, then run the following to make sure cronjob get run:


    sudo crontab /etc/mercury/templates/cron

  • Time to populate your new Mercury server!

Mercury

Group organizers

Group categories

Post Type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: