Your SlideShare is downloading. ×
Drupal, Memcache and Solr on Windows
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Drupal, Memcache and Solr on Windows

2,748
views

Published on

This webcast will show you how to properly configure and deploy Memcached and Solr on Windows, including all the required Drupal integration. The webcast includes also instructions on proper …

This webcast will show you how to properly configure and deploy Memcached and Solr on Windows, including all the required Drupal integration. The webcast includes also instructions on proper configuration of your Drupal cron tasks for Solr indexing in conjunction with Windows Task Scheduler.

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,748
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Drupal, Memcachedand Solr on Windows Alessandro Pilotti @alexpilotti MVP ASP.NET / IIS MCSD, MCAD, MCSE, MCDBA, MCT Red Hat Certified Engineer
  • 2. Why Memcached? It’s a very popular object caching system To speed up web sites by offloading work from the DBMS Simple key / value store with cache invalidation Low CPU usage Half client / half server Servers are unaware of each other (no sync)
  • 3. Memcached on Windows Memcached supports *nix daemon mode Ports for Windows exist  Most binaries available on the web are old (1.2.x) The official git repository contains a Windows compatible branch  git clone --branch engine-pu https://github.com/memcached/memcached.git  Currently version 1.6.0 beta Older version 1.3.3 available here:  https://github.com/trondn/memcached.git Building Memcached on Windows is not difficult:  http://trondn.blogspot.de/2010/03/building-memcached-windows.html Build x64 version if you need more than 4GB of memory per instance Prebuilt binaries:  http://www.cloudbasesolutions.com/downloads/memcached_x86_1_3_3.zip  http://www.cloudbasesolutions.com/downloads/memcached_x86_1_6_0_beta1.zip
  • 4. Installing Memcached on Windows The best way is to run it as a service We can use e.g. Apache Procrun to wrap it  http://www.apache.org/dist/commons/daemon/binaries/windows / For security reasons don’t use an account like Administrator or System to run it! Open the required firewall port(s)  Default: 11211 Limit the client IP range as a best practice If possible use SASL for authentication
  • 5. Script 1/2 Create user:  net user memcached yourpassword /add  wmic path Win32_UserAccount where Name=memcached set PasswordExpires=false Set service rights  note: using free Windows 2003 Resource Kit  ntrights –u memcached +r SeServiceLogonRight  ntrights –u memcached +r SeBatchLogonRight
  • 6. Script 2/2 Create Windows service using Apache Procrun prunsrv install memcached --Startup=auto --StartMode=exe --StartImage="c:memcachedmemcached.exe" ++StartParams=-p;11211;-m;256;-l;127.0.0.1 --ServiceUser=.memcached --ServicePassword=yourpassword For remote host access  Remove “–l 127.0.0.1”  Open firewall port  netsh advfirewall firewall add rule name="memcached" dir=in action=allow protocol=TCP localport=11211 Start service  net start memcached
  • 7. Memcached and PHP It requires a PECL extension, two are available:  Memcache  Win32 binary: http://downloads.php.net/pierre/  Memcached  More advanced Drupal works with both
  • 8. Memcached protocol Memcache can use an ascii (default) or binary protocol (faster) Binary protocol supported from version 1.3 Memcache PECL extension:  PHP.INI  memcache.protocol = binary Memcached PECL extension:  Drupal settings.php $conf[memcache_options] = array( Memcached::OPT_BINARY_PROTOCOL => TRUE, );
  • 9. Memcached and Drupal 7 drush @Drupal7 dl memcache In “sitesallmodulesmemcachedmemcache.inc”:  comment //drupal_set_message(t(You must enable the PECL memcached or memcache extension to use memcache.inc.), error); drush @Drupal7 -y en memcache_admin In settings.php  $conf[cache_backends][] = sites/all/modules/memcache/memcache.inc;  $conf[cache_default_class] = MemCacheDrupal;  $conf[memcache_key_prefix] = drupal7; You can now setup separate bins and servers  Examples: http://drupal.org/node/1131468
  • 10. Apache Solr Open source search platform  Full text search  Optimized for high volume web traffic  Based on Apache Lucene Download version 3.5.0 from:  http://www.apache.org/dyn/closer.cgi/lucene/solr
  • 11. Solr, Windows and Drupal 7 Drupal  drush @Drupal7 dl apachesolr Expand the content of “example” in “apache- solr-3.5.0.zip“ to e.g. c:Solr Move c:SolrSolrConf folder to c:SolrConf  Replace solrconfig.xml and schema.xml and protwords.txt with copies from:  <drupal site>sitesallmodulesapachesolrsolr-conf  Version 3.x: solrconfig-solr3x.xml schema-solr3x.xml
  • 12. Create Windows Solr user net user solr yourpassword /add wmic path Win32_UserAccount where Name=solr set PasswordExpires=false ntrights -u solr +r SeServiceLogonRight ntrights -u solr +r SeBatchLogonRight Set proper folder permissions  icacls c:solr /inheritance:d /grant solr:(OI)(CI)(F) /remove Users
  • 13. Create Windows service Download and install Java JRE 7  http://www.oracle.com/technetwork/java/javase/downloads/index.html Using Apache Procrun x64: prunsrv install solr --Startup=auto --StartMode=jvm ++JvmOptions=- Dsolr.solr.home=C:/solr/;-Djetty.home=C:/solr/;-Djetty.logs=C:/solr/logs/ - -ServiceUser=.solr –ServicePassword=yourpassword -- Classpath=C:/solr/lib/*.jar;C:/solr/start.jar -- StartClass=org.mortbay.start.Main Start service  Net start solr Open firewall port if remote access is required  netsh advfirewall firewall add rule name="solr" dir=in action=allow protocol=TCP localport=8983
  • 14. Setup Drupal 7 Solr search Enable solr search module:  drush @drupal7 en –y apachesolr_search http://yourdrupalsite/admin/config/search/settings  Set Apache Solr Search as the only active search module  Set Apache Solr Search as the default search module http://drupal7/admin/config/search/apachesolr/settings  Set your Solr url, e.g.: http://solrserver:8983/solr
  • 15. Autocommit maxTime Default settings is 120s In Drupal, this means that after your data changes are received by Solr, your search results will not be updated for 2 minutes To have a shorter delay (e.g. 20s) change maxTime in solrconfig.xml (in ms): <maxTime>20000</maxTime>
  • 16. Drupal cron Drupal sends data to Solr for indexing using cron  This might provide big delays between data changes Download elysia_cron module  drush @drupal7 dl elysia_cron  drush @drupal7 en elysia_cron –y Set cron scheduling as:  Never / Use external crontab Set apachesolr_cron settings to (e.g. every 2’)  */2 * * * *
  • 17. “crontab” on Windows Windows uses scheduled tasks instead of crontab To create a scheduled task for Drupal elysia_cron to run e.g. every 2’: schtasks.exe /create /tn drupal7_cron /tr "wget -O - -q -t 1 http://drupal7/sites/all/modules/elysia_cron/cron.php?cron_ke y=yourcronkey" /sc MINUTE /mo 2 /ru solr /rp  put wget.exe in the path  Get your cron key from:  http://yourdrupalsite/admin/config/system/cron/settings To run the task once (troubleshooting, etc):  schtasks.exe /run /tn drupal7_cron To delete the task:  schtasks.exe /delete /tn drupal7_cron
  • 18. Drush integration drush @drupal7 solr-search something drush @drupal7 solr-index drush @drupal7 solr-reindex drush @drupal7 solr-delete-index