Ticker

6/recent/ticker-posts

Ad Code

Responsive Advertisement

How to Install and Configure Memcached Process/Server on Mac OS X?

How to Install and Configure Memcached on Mac OS X?

Memcached is one of the widely used distributed memory object caching solution out there. I’ve been using it since last 3 years actively for number of various projects.

Here are the key advantages of using Memcached for your application.

  1. Very light weight
  2. Easy and Simple installation steps
  3. Easy to setup server with single click
  4. Deploy on Mac OS X, Windows or cloud servers as per your need
  5. PHP, Java handy clients code available
  6. Nice documentation with API commands
  7. Light memory and CPU footprint
  8. Easy maintenance
  9. Open Sourced and Free

If you have any of below question about Memcached then you are at right place.

  • How to Install, configure, verify memcached?
  • Installing Memcached on Mac OS X
  • How to install Memcached using brew?

Let’s get started:

Approach-1)

Step-1 – Installation

Open Mac Terminal and type command brew install memcached.

bash$ brew install memcached

==> Installing dependencies for memcached: openssl and libevent
==> Installing memcached dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2q.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2q.mojave.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2q: 1,794 files, 12.1MB
==> Installing memcached dependency: libevent
==> Downloading https://homebrew.bintray.com/bottles/libevent-2.1.8.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libevent-2.1.8.mojave.bottle.tar.gz
🍺  /usr/local/Cellar/libevent/2.1.8: 846 files, 2.2MB
==> Installing memcached
==> Downloading https://homebrew.bintray.com/bottles/memcached-1.5.12.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring memcached-1.5.12.mojave.bottle.tar.gz
==> Caveats
To have launchd start memcached now and restart at login:
  brew services start memcached
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/memcached/bin/memcached
==> Summary
🍺  /usr/local/Cellar/memcached/1.5.12: 11 files, 198.9KB
==> Caveats
==> openssl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

==> memcached
To have launchd start memcached now and restart at login:
  brew services start memcached
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/memcached/bin/memcached

Step-2: Verification

Verify that it’s started successfully.

Type command ps -few | grep memcached.

bash-3.2$ ps -few | grep memcached
110048994 88258 88202   0 12:31PM ttys000    0:00.00 grep memcached

You will see memcached process as part of a result.

By default Memcached runs on port 11211.

Using brew is the safest and easiest way to install Memcached on Mac OS X. If you don’t have brew installed locally then follow below manual approach.

Approach-2)

Install libevent manually.

bash-3.2$ wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
--2018-12-05 12:45:32--  https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
Resolving github.com (github.com)... 192.30.255.113, 192.30.255.112
Connecting to github.com (github.com)|192.30.255.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/1856976/f9ea6922-e66b-11e6-9f5c-722c00daa657?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20181205%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181205T184532Z&X-Amz-Expires=300&X-Amz-Signature=4b210170c4bf645011fe368024396eb8854502f5efc0abc200bd0ab91fb4c66f&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlibevent-2.1.8-stable.tar.gz&response-content-type=application%2Foctet-stream [following]
--2018-12-05 12:45:32--  https://github-production-release-asset-2e65be.s3.amazonaws.com/1856976/f9ea6922-e66b-11e6-9f5c-722c00daa657?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20181205%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20181205T184532Z&X-Amz-Expires=300&X-Amz-Signature=4b210170c4bf645011fe368024396eb8854502f5efc0abc200bd0ab91fb4c66f&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlibevent-2.1.8-stable.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.97.155
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.97.155|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1026485 (1002K) [application/octet-stream]
Saving to: ‘libevent-2.1.8-stable.tar.gz’

libevent-2.1.8-stable.tar.gz                 100%[==============================================================================================>]   1002K   126KB/s    in 7.9s    

2018-12-05 12:45:41 (127 KB/s) - ‘libevent-2.1.8-stable.tar.gz’ saved [1026485/1026485]

bash-3.2$ tar xvfz libevent-2.1.8-stable.tar.gz 
bash-3.2$ cd libevent-2.1.8-stable
bash-3.2$ ./configure
bash-3.2$ make
bash-3.2$ sudo make install

Install memcached manually.

bash-3.2$ wget https://memcached.org/files/memcached-1.5.12.tar.gz
--2018-12-05 12:49:28--  https://memcached.org/files/memcached-1.5.12.tar.gz
Resolving memcached.org (memcached.org)... 107.170.231.145
Connecting to memcached.org (memcached.org)|107.170.231.145|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 457719 (447K) [application/octet-stream]
Saving to: ‘memcached-1.5.12.tar.gz’

memcached-1.5.12.tar.gz                      100%[==============================================================================================>] 446.99K   810KB/s    in 0.6s    

2018-12-05 12:49:29 (810 KB/s) - ‘memcached-1.5.12.tar.gz’ saved [457719/457719]

bash-3.2$ tar xvfz memcached-1.5.12.tar.gz 
bash-3.2$ cd memcached-1.5.12
bash-3.2$ ./configure
bash-3.2$ make
bash-3.2$ sudo make install

At this stage your memcached is installed successfully.

Next step is to start memcached process. Run below command and your memcached process will start on port 12345.

bash-3.2$ memcached -p 12345

Enjoy and happy coding guys!! Let me know if you face any issue installing Memcached.

What next? Create very simple Java Clients with 3 different approaches.

  1. Memcached Java client using net.spy.spymemcached Library
  2. Memcached Java client using com.whalin.Memcached-Java-Client and com.googlecode.xmemcached Libraries

The post How to Install and Configure Memcached Process/Server on Mac OS X? appeared first on Crunchify.

Enregistrer un commentaire

0 Commentaires