Your SlideShare is downloading. ×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

CouchConf_Developer Lab

620
views

Published on


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

  • Be the first to like this

No Downloads
Views
Total Views
620
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
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. Friday, December 7, 12
  • 2. Develop  with  Couchbase Jasdeep  Jaitla  /  John  Zablocki Technical  Evangelist  /  Developer  Advocate email:  jasdeep@couchbase.com twi7er:  @scalabl3            john@couchbase.com                                          @codevoyeurFriday, December 7, 12
  • 3. Develop  with  Couchbase Jasdeep  Jaitla  /  John  Zablocki Technical  Evangelist  /  Developer  Advocate email:  jasdeep@couchbase.com twi7er:  @scalabl3            john@couchbase.com                                          @codevoyeurFriday, December 7, 12
  • 4. Friday, December 7, 12
  • 5. COUCHBASE  SERVERFriday, December 7, 12
  • 6. Install  Couchbase  Server’s  Latest  Build Download  the  Latest  Build  of  Couchbase  Server 1. h7p://www.couchbase.com/downloads-­‐all 2. In  the  second  secRon  down  the  page...  Select  the  most  recent  build  of   Couchbase  (Build  1954)  in  the  dropdown 3. Download  for  your  OS,  then, 4. Install  based  on  your  OS,  instrucRons  are  on  the  leZ  under  each  logo If  you  are  Upgrading  your  installa=on  from  a  previous  version/build 1. Download  Couchbase  for  the  OS,  and  we  can  help  you  upgrade  at  the  lab 2. If  you  are  on  MacOSX,  there  are  Rps/instrucRons  at   h7p://CouchbaseOnRails.com/installFriday, December 7, 12
  • 7. (1)  Setup  Couchbase Browse  to  Couchbase  Admin  Panel h7p://localhost:8091/ (if  you  didn’t  install  on  local  machine,  subsRtute  IP  address  for  localhost)Friday, December 7, 12
  • 8. (2)  Setup  Couchbase  -­‐  RAM  Quota RAM  Quota  is  the  Memory  Cap  for   each  Couchbase  Server  in  the  Cluster   PorRons  of  this  quota  are  allocated  to  each  Bucket  (Database)  that  you  setup,  you  are   seeng  the  maximum  memory  to  allocate  in  this  step. Even  on  laptops,  it’s  typical  to  set  this   fairly  high,  it  won’t  all  get  used  unless   you  have  that  much  data  in  memory...   Recommended  to  use  at  least  1024  MB! FYI:  Changing  this  requires  using  command  line   and  couchbase  restart,  it’s  not  done  in  interfaceFriday, December 7, 12
  • 9. (2)  Setup  Couchbase  -­‐  RAM  Quota RAM  Quota  is  the  Memory  Cap  for   each  Couchbase  Server  in  the  Cluster   PorRons  of  this  quota  are  allocated  to  each  Bucket  (Database)  that  you  setup,  you  are   seeng  the  maximum  memory  to  allocate  in  this  step. Even  on  laptops,  it’s  typical  to  set  this   fairly  high,  it  won’t  all  get  used  unless   you  have  that  much  data  in  memory...   Recommended  to  use  at  least  1024  MB! FYI:  Changing  this  requires  using  command  line   and  couchbase  restart,  it’s  not  done  in  interfaceFriday, December 7, 12
  • 10. (3)  Setup  Couchbase  -­‐  Samples Op=onally  Setup  some  Sample  Data  with  Example   Views  (Map/Reduce  Indexes) This  can  also  be  done  at  a  later  Rme  aZer  things  are  setup...Friday, December 7, 12
  • 11. (4)  Setup  Couchbase  -­‐  Default  Bucket Setup  RAM  and  SeKngs  for  Default  Bucket   (percentage  of  server  RAM  Quota  in  first  step) You’ll  likely  setup  more  than  one  Bucket  while  playing  &  tesRng,  so  don’t  use  all   your  Quota  here,  300MB  is  a  good  size,  this  is  easily  changed  later  in  Web  Admin.Friday, December 7, 12
  • 12. (4)  Setup  Couchbase  -­‐  Default  Bucket Setup  RAM  and  SeKngs  for  Default  Bucket   (percentage  of  server  RAM  Quota  in  first  step) You’ll  likely  setup  more  than  one  Bucket  while  playing  &  tesRng,  so  don’t  use  all   your  Quota  here,  300MB  is  a  good  size,  this  is  easily  changed  later  in  Web  Admin.Friday, December 7, 12
  • 13. (4)  Setup  Couchbase  -­‐  Default  Bucket Setup  RAM  and  SeKngs  for  Default  Bucket   (percentage  of  server  RAM  Quota  in  first  step) You’ll  likely  setup  more  than  one  Bucket  while  playing  &  tesRng,  so  don’t  use  all   your  Quota  here,  300MB  is  a  good  size,  this  is  easily  changed  later  in  Web  Admin. Since you have a single node cluster locally, there won’t be any replicas even if enabled Allows you to delete all data in Bucket in one command, good for testingFriday, December 7, 12
  • 14. (5)  Setup  Couchbase  -­‐  NoRficaRons If  you  want  no=fica=ons  of  soNware  updates,   check  this  box  and  put  in  your  infoFriday, December 7, 12
  • 15. (6)  Setup  Couchbase  -­‐  Admin  U/P Set  your  Username/Password   to  the  Web  Admin  ConsoleFriday, December 7, 12
  • 16. Congrats! You’re  now  level  2.Friday, December 7, 12
  • 17. Web  Admin  Quick  Tour!Friday, December 7, 12
  • 18. Web  Admin  Quick  Tour! Overview of Cluster RAM, Disk, Ops, etc.Friday, December 7, 12
  • 19. Web  Admin  Quick  Tour! List of Cluster Nodes & Stats If you Enable Replication but have too few nodes, you’ll see this warningFriday, December 7, 12
  • 20. Web  Admin  Quick  Tour! List of Cluster Nodes & Stats List of Cluster Nodes & Stats If you Enable Replication but have too few nodes, you’ll see this warningFriday, December 7, 12
  • 21. Web  Admin  Quick  Tour! Buckets (Databases)Friday, December 7, 12
  • 22. Web  Admin  Quick  Tour! Buckets (Databases) Create New BucketFriday, December 7, 12
  • 23. Web  Admin  Quick  Tour! Buckets (Databases) Create New Bucket Document BrowserFriday, December 7, 12
  • 24. Web  Admin  Quick  Tour! Buckets (Databases) Create New Bucket Views (Indexes) Document BrowserFriday, December 7, 12
  • 25. Web  Admin  Quick  Tour! Buckets (Databases) Create New Bucket Views (Indexes) Document BrowserFriday, December 7, 12
  • 26. Web  Admin  Quick  Tour!Friday, December 7, 12
  • 27. Web  Admin  Quick  Tour!Friday, December 7, 12
  • 28. Friday, December 7, 12
  • 29. INSTALL  SDKFriday, December 7, 12
  • 30. Ruby h7p://www.couchbase.com/develop/c/next h7p://www.couchbase.com/develop/ruby/next Install  libcouchbase  (c  library) Visit  h7p://www.couchbase.com/develop/c/next  and  install  based  on  your  OS,  alternaRvely   you  can  go  to  my  Step-­‐By-­‐Step  guide  here: Mac  OSX  Step-­‐By-­‐Step  at  h7p://CouchbaseOnRails.com/libcouchbase Install  Latest  Couchbase  Gem $  gem  install  couchbase  -­‐-­‐preFriday, December 7, 12
  • 31. PHP h7p://www.couchbase.com/develop/c/next h7p://www.couchbase.com/develop/php/next Install  libcouchbase  (c  library) Visit  h7p://www.couchbase.com/develop/c/next  and  install  based  on  your  OS,  alternaRvely   you  can  go  to  my  Step-­‐By-­‐Step  guide  here: Mac  OSX  Step-­‐By-­‐Step  at  h7p://CouchbaseOnRails.com/libcouchbase Download  PHP  SDK  for  your  OS $  tar  xzf  php-­‐ext-­‐couchbase-­‐$system-­‐$arch.tar.gz >>  couchbase.so Edit  php.ini  and  add  line  aNer  JSON  extension  extension=/path/to/couchbase.soFriday, December 7, 12
  • 32. .NET h7p://www.couchbase.com/develop/net/next Use  Nuget  >  1.6 C:>  Install-­‐Package  CouchbaseNetClient  -­‐Pre Or,  Download  SDK h7p://www.couchbase.com/develop/net/next  and  click  on  Download Put  the  files  in  your  bin  folder  of  your  project Edit  app.config  <configSec=ons>  and  add <secRon  name="couchbase"        type="Couchbase.ConfiguraRon.CouchbaseClientSecRon,  Couchbase"  /> Edit  app.config  and  add <couchbase> <servers  bucket="default"  bucketPassword=""> <add  uri="h7p://127.0.0.1:8091/pools"/> </servers> </couchbase>Friday, December 7, 12
  • 33. Python h7p://www.couchbase.com/develop/python/next Install  via  pip $  pip  install  couchbase This  is  perhaps  the  easiest  of  them  all!Friday, December 7, 12
  • 34. Java h7p://www.couchbase.com/develop/java/next Download  Latest  Java  JARS h7p://www.couchbase.com/develop/java/next Put  the  JARS  in  your  Java  Classpath,  or  add  folder  to  Classpath,  or   put  under  your  project  resourcesFriday, December 7, 12
  • 35. Friday, December 7, 12
  • 36. MAKE  A  CONNECTIONFriday, December 7, 12
  • 37. Ruby Ruby  Connec=on  Op=ons require  ‘couchbase’ c  =  Couchbase.connect        OR    c  =  Couchbase.bucket Defaults  to  127.0.0.1:8091  and  bucket  “default” c  =  Couchbase.connect(“hcp://[IP]:8091/pools/default/bucket/[bucket]”) c  =  Couchbase.connect({ :hostname  =>  “[IP]”, :bucket  =>  “[bucket_name]”, :password  =>  “[bucket_password]” }) Ruby  Get  &  Set c.set(“a”,  1) c.get(“a”) c.set(“a”,  {  :test  =>  Time.now  }) c.get(“a”)Friday, December 7, 12
  • 38. PHP PHP  Connec=on //  new  Couchbase("[IP]:8091",  "[bucket_is_user]",  "[password]",  "[bucket]"); <?php $cb  =  new  Couchbase("127.0.0.1:8091",  "default",  "",  "default"); ?> PHP  Set  and  Get <?php $cb-­‐>set("a",  1); var_dump($cb-­‐>get("a")); ?>Friday, December 7, 12
  • 39. .NET .NET  Connec=on .NET  Set  and  Get using  Couchbase; client.Store(StoreMode.Set,  “a”,  1) using  Enyim.Caching.Memcached; client.Get(“a”) var  client  =  new  CouchbaseClient(); OR public  staRc  class  CouchbaseManager {      private  readonly  staRc  CouchbaseClient  _instance;            staRc  CouchbaseClient()      {              _instance  =  new  CouchbaseClient();      }      public  staRc  CouchbaseClient  Instance  {  get  {  return  _instance;  }  } }Friday, December 7, 12
  • 40. Python Python  Connec=on #!/usr/bin/env  python from  couchbase.client  import  Couchbase import  json couchbase  =  Couchbase("127.0.0.1:8091",  "default",  "") Python  Set  and  Get bucket  =  couchbase["default"] bucket.set(“a”,  0,  0,  1) bucket.get(“a”)Friday, December 7, 12
  • 41. Java Java  Connec=on  (1/2) import  java.net.URI; import  java.uRl.LinkedList; import  java.uRl.List; import  java.uRl.concurrent.TimeUnit; import  com.couchbase.client.CouchbaseClient; import  net.spy.memcached.CASResponse; import  net.spy.memcached.internal.GetFuture; import  net.spy.memcached.internal.OperaRonFuture;Friday, December 7, 12
  • 42. Java  Connec=on  (2/2) Java public  class  HelloWorld  {    public  staRc  void  main(String  args[])  {        //  Set  the  URIs  and  get  a  client h7p://goo.gl/yczAx        List<URI>  uris  =  new  LinkedList<URI>();        Boolean  do_delete  =  false;  //  Deletes  the  key                  uris.add(URI.create("h7p://127.0.0.1:8091/pools"));                CouchbaseClient  client  =  null;        try  {            client  =  new  CouchbaseClient(uris,  "default",  "",  "");        }  catch  (ExcepRon  e)  {            System.err.println("Error  connecRng  to  Couchbase:  "  +  e.getMessage());            System.exit(0);        }                //  Shutdown  the  client        client.shutdown(3,  TimeUnit.SECONDS);          System.exit(0);    } }Friday, December 7, 12
  • 43. Friday, December 7, 12
  • 44. OPERATIONSFriday, December 7, 12