Best Deployment method using drush and svn in drupal

Events happening in the community are now at Drupal community events on www.drupal.org.
lalit774's picture

Deployment using drush is best thing in drupal. This is very important how to deploy on production without bringing down the live server. Drush provide this functionality. According to me following is procedure for deployment of drupal websites.

we have following flow for deployment.

  1. Local Machine

  2. SVN Server

  3. DEV Server

  4. UAT Server

  5. Production Server.

The flow should be like this 1 -> 2 -> 3 -> 4 -> 5

All the deployment should automatically be done using shell script.

step 1 we should write a shell script for SVN post-commit hook. when ever receive any commit promote code SVN Server to DEV server.

        #!/bin/sh
          REPOS="$1"
          REV="$2"
      rm -rf /tmp/code
   svn export -r $REV "file://$REPOS" /tmp/code

    rsync  --delete-after -az -e  --exclude 'sites/default/' ssh /tmp/code/ username@host:/path/to/drupal

Step 2 We should set Key Based Authentication.

          create a ssh Key on DEV SERVER
          ssh-keygen -t rsa
       
     Generating public/private rsa key pair.
     Enter file in which to save the key (/home/username/.ssh/id_rsa):
     Enter passphrase (empty for no passphrase):
     Enter same passphrase again:
     Your identification has been saved in /home/username/.ssh/id_rsa.
     Your public key has been saved in /home/username/.ssh/id_rsa.pub.
     The key fingerprint is:
     f6:61:a8:27:35:cf:4c:6d:13:22:70:cf:4c:c8:a0:23 username@domain

    - Copy id_rsa  file to local
    - Give permissions 640
    - ssh-add id_rsa
    - test with login ssh username@domain.com as Key Based Authentication

Step 3 Write local_project_name.aliases.drushrc.php

<?php
          $aliases
['local'] = array(
             
'uri' => 'project_url',
             
'root' => '/path/to/local/drupal/root',
             
'db-url' => 'mysql://username:password@host.com:port/databasename',
             
'path-aliases' => array(
                 
'%drush' => '/path/to/drush',
                 
'%drush-script' => '/path/to/drush/drush',
                 
'%dump' => '/path/to/dumps/mysql.sql',
                 
'%files' => 'sites/mydrupalsite.com/files',
                 
'%site' => '/path/to/sites',
              ),
            );
           
$aliases['dev'] = array(
             
'uri' => 'dev_project_url',
             
'root' => '/path/to/dev/drupal/root',
             
'db-url' => 'mysql://username:password@host.com:port/databasename',
             
'remote-host' => 'remote host',
             
'remote-user' => 'username',
             
'path-aliases' => array(
                 
'%drush' => '/path/to/drush',
                 
'%drush-script' => '/path/to/drush/drush',
                 
'%dump' => '/path/to/dumps/mysql.sql',
                 
'%files' => 'sites/mydrupalsite.com/files',
                 
'%site' => '/path/to/sites',
              ),
            );
?>

Step 4 test with drush
      - test local drush
      -/path/to/local/drupal/root$  drsuh status
       It displays current drupal project status

       -/path/to/local/drupal/root$ drush  username@host.com:/path/to/local/drupal#project_uri  status

       It displays remote drupal project status


      CODE RSYNC whole project
     - drush rsync @local  @dev

      CODE RSYNC particular files
     - drush rsync @local:%site/path/to/file  @dev:%site/path/to/file


     CODE RSYNC particular folder
    - drush rsync @local:%site/path/to/folder  @dev:%site/path/to/folder



     DATABASE RSYNC whole database
     - drush sql-sync --cache @local @dev


     DATABASE RSYNC  one table
     - drush sql-sync --cache --tables-list=tbl_name @local @dev

     DATABASE RSYNC  multiple table
     - drush sql-sync --cache --tables-list=tbl1_name,tbl2_name @local @dev

you can make shell script using above commands.

Thanks

Comments

Memcache configuration options emprove Performance

gpbuono's picture

Hi,
we have an issue on our environment. Following you can find the architecture details: we have 4 web front-end Centos 6.2 x86_64 hosts with this software installation:

drupal 7
php-5.3.3
apache 2.2
memcached-1.4.4-3
php-pecl-memcache-3.0.5-3

The Apache's document root (/var/www/html/) is shared (NFS) across the 4 front-ends and all the servers have three memcached istances with this configuration:

memcached -d -p 11213 -u memcached -m 2048 -c 5120 -P /var/run/memcached/memcached-3.pid
memcached -d -p 11211 -u memcached -m 2048 -c 5120 -P /var/run/memcached/memcached-1.pid
memcached -d -p 11212 -u memcached -m 2048 -c 5120 -P /var/run/memcached/memcached-2.pid

The drupal configuration for memcache (settings.php) is shared (is it correct?):

$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_form'] = 'DrupalDatabaseCache';

$conf['memcache_servers'] = array(
'host2:11211' => 'default',
'host3:11211' => 'default',but
'host4:11211' => 'default',

'host3:11212' => 'page',
'host4:11212' => 'page',
'host5:11212' => 'page',

'host2:11213' => 'menu',
'host4:11213' => 'menu',
'host5:11213' => 'menu',

'host5:11211' => 'users',
'host2:11212' => 'users',
'host3:11213' => 'users',
);
$conf['memcache_bins'] = array(
'cache' => 'menu',
'cache_menu' => 'menu',
'cache_bootstrap' => 'menu',
'cache_path' => 'menu',
'cache_page' => 'page',
'cache_block' => 'page',
'session' => 'users',
'users' => 'users',
);

Sometimes we have in /var/log/messager this error:
User error: Failed to connect to memcache server: host3:11212 in dmemcache_object() (line 415 of /var/www/html/sites/all/modules/memcache/dmemcache.inc)

and this error is also visible on the browser.

We noticed we have many time_wait (about 8000) on every server. Is it normal ?

We have already set the tcp_tw_reuse=1 parameter but we read that is not good in a load balancer environment the follow parameters tcp_tw_recycle=1

Any suggestions? Do you think it could be a better way to improve the configuration?

Is the typo in your configuration?

fluxsauce's picture

Is that "but" supposed to be there?

$conf['memcache_servers'] = array(
'host2:11211' => 'default',
'host3:11211' => 'default',but

Why are you running three memcached instances out of curiosity? HA? Or performance? If performance, that won't make a difference. There is moderate HA benefit, but I honestly have not crashed a memcached instance in the ~3 years I used it in an enterprise environment (about 2 million hits per day).

Hi, we thought this settings

gpbuono's picture

Hi,

we thought this settings for both HA and Performance.

Do we still have HA if we configure localhost:11211(2,3) and option "-s" in the settings.php? What happens if in my current configuration a single memcache istance dies? And what about in the configuration you suggest?

Do you think If I configure memcache with localhost:11211(2,3) and option "-s" in the settings.php I still have Memcahce HA?

Best regards

AI/Drupal Toronto

Group notifications

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