What is memcached in linux

Работа с memcached в Unix/Linux

Очередная статья на тему «Работа с memcached в Unix/Linux» и я в ней расскажу как работать с memcached в ОС Unix/Linux и приведу наглядные примеры.

Установка memcached в Unix/Linux

Вот статья как установить memcached, можно прочитать:

Возможно, приведу пример подробной настройке ( но попозже).

Работа с memcached в Unix/Linux

Приведу наглядные примеры по работе с memcached.

Получить ( Показать) статус memcached.

# echo stats | nc 127.0.0.1 11211 STAT pid 1250 STAT uptime 5099765 STAT time 1483695061 STAT version 1.4.22 STAT libevent 1.4.13-stable STAT pointer_size 64 STAT rusage_user 3144.195009 STAT rusage_system 15863.643359 STAT curr_connections 15 STAT total_connections 14347484 STAT connection_structures 908 STAT reserved_fds 30 STAT cmd_get 424027417 STAT cmd_set 16380427 STAT cmd_flush 20 STAT cmd_touch 0 STAT get_hits 212115737 STAT get_misses 211911680 STAT delete_misses 259355 STAT delete_hits 3729812 STAT incr_misses 0 STAT incr_hits 0 STAT decr_misses 0 STAT decr_hits 0 STAT cas_misses 0 STAT cas_hits 0 STAT cas_badval 0 STAT touch_hits 0 STAT touch_misses 0 STAT auth_cmds 0 STAT auth_errors 0 STAT bytes_read 93778486542 STAT bytes_written 2478939093660 STAT limit_maxbytes 4294967296 STAT accepting_conns 1 STAT listen_disabled_num 0 STAT threads 6 STAT conn_yields 0 STAT hash_power_level 16 STAT hash_bytes 524288 STAT hash_is_expanding 0 STAT malloc_fails 0 STAT bytes 18891891 STAT curr_items 4120 STAT total_items 16380427 STAT expired_unfetched 0 STAT evicted_unfetched 0 STAT evictions 0 STAT reclaimed 170726 STAT crawler_reclaimed 0 STAT lrutail_reflocked 79 END

Вот простой «top» эмулятор для memcached:

# watch "echo stats | nc 127.0.0.1 11211"

PS: Я использую локальную машину ( локалхост, 127.0.0.1), если вы хотите подключатся к удаленной машине, то замените ИП. Так же, не забываем сменить порт ( если настроили по другому).

Если вы хотите просмотреть подробную информацию об использовании кэша найти конкретный ключ, вы можете использовать одну из следующих команд:

    stats items — показывает информацию о количестве элементов в каждой плите (slab) со включающей нумерацией времени ( элементы, которые были очищены, прежде чем они истекли (inserted) или элементы не смогли быть вставлены потому, что slab вышел за пределы памяти (out of memory):
    Для начала подключимся:

> stats items STAT items:1:number 2 STAT items:1:age 526034 STAT items:1:evicted 0 STAT items:1:outofmemory 0
# echo stats items | nc 127.0.0.1 11211
> stats slabs STAT 5:chunk_size 240 STAT 5:chunks_per_page 4369 STAT 5:total_pages 1 STAT 5:total_chunks 4369 STAT 5:used_chunks 7 STAT 5:free_chunks 1 STAT 5:free_chunks_end 4361
# echo stats slabs | nc 127.0.0.1 11211
> stats cachedump 6 3 ITEM cache_menu-links%3Asecondary-links [160 b; 1275506090 s] ITEM cache_menu-links%3Aprimary-links [159 b; 1275506090 s] ITEM cache_menu-links%3Anavigation [158 b; 1275506090 s]
# echo stats items | nc 127.0.0.1 11211

Для тех у кого нет nc, но есть php:

# watch 'php -r '"'"'$m=new Memcache;$m->connect("127.0.0.1", 11211);print_r($m->getstats());'"'"

Очистить ( сбросить) memcached кеш

Вы можете очистить все существующие элементы кэша с помощью команды flush_all. Вы можете отправить flush_all команду, используя nc или netcat утилиты:

# echo 'flush_all' | nc localhost 11211

Или можно еще одним способом:

# echo 'flush_all' | netcat localhost 11211
  • 192.168.1.10 или localhost– сервер где установлен memcached
  • 11211 – порт который использует memcached.
Читайте также:  Создать файл linux alt

Сейчас я расскажу как можно сбросить кэш с помощью telnet:

# telnet Your_Server_or_IP Your_Memcached_Port

Статья «Работа с memcached в Unix/Linux» завершена.

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Рубрики

  • Arch Linux (167)
  • Commands (36)
  • Debian’s (635)
    • Administration tools Ubuntu (37)
    • Backups Debian’s (7)
    • Database в Ubuntu (58)
    • Games (игры) (1)
    • Monitoring в Debian и Ubuntu (49)
    • Virtualization в Ubuntu / Debian/ Linux Mint (41)
      • Docker (22)
      • Kubernetes (6)
      • KVM (4)
      • OpenVZ (3)
      • Vagrant (5)
      • VirtualBox (6)
      • ArgoCD (1)
      • Concourse (1)
      • Gitlab (1)
      • Jenkinks (4)
      • Spinnaker (1)
      • Apache (32)
      • Cherokee (1)
      • FTP-services (5)
      • Lighttpd (1)
      • Nginx (26)
      • PHP (27)
      • Proxy для Debian’s (2)
      • Tomcat (4)
      • Панели управления в Ubuntu/Debian/Mint (24)
      • Установка и настройка почты на Ubuntu/Debian (12)
      • Хранилища (clouds) (2)
      • Administration tools freeBSD (19)
      • Database во FreeBSD (52)
      • Monitoring во freeBSD (37)
      • Virtualization во FreeBSD (22)
      • VoIP (1)
      • Установка Web сервисов (91)
      • Установка и настройка почты (6)
      • Установка из ports (пакетов) (19)
      • Установка из sorce code (исходников) (23)
      • Непрерывная интеграция (CI) (27)
      • Database в MacOS (36)
      • Monitoring в Mac OS (31)
      • Security (безопасность) (12)
      • Virtualization в Mac OS (30)
        • Docker (19)
        • Kubernetes (6)
        • Vagrant (5)
        • VirtualBox (5)
        • ArgoCD (1)
        • CircleCI (1)
        • Concourse (1)
        • Gitlab (1)
        • Jenkinks (4)
        • Spinnaker (1)
        • Administration tools CentOS (49)
        • Backups RPM’s (4)
        • Database в CentOS (68)
        • Monitoring в CentOS (67)
        • Virtualization в CentOS/ Red Hat/ Fedora (42)
          • Docker (23)
          • Kubernetes (6)
          • KVM (5)
          • OpenVZ (2)
          • Vagrant (5)
          • VirtualBox (6)
          • VMWare (3)
          • ArgoCD (1)
          • Concourse (1)
          • Gitlab (1)
          • Jenkinks (4)
          • Spinnaker (1)
          • Apache (35)
          • Cherokee (1)
          • DNS (3)
          • FTP (10)
          • Nginx (33)
          • PHP (34)
          • Proxy для RedHat’s (2)
          • Tomcat (2)
          • Voice (2)
          • Панели управления в CentOS/Red Hat/Fedora (27)
          • Прокси сервер на CentOS/RHEL/Fedora (4)
          • Установка и настройка почты на CentOS/RHEL/Fedora (14)
          • Хранилища (clouds) (1)

          соц сети

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Unix-Linux- в примерах

          Архив новостей

          Свежие записи

          Свежие комментарии

          • Глеб к записи Установка Adobe Flash Player в Debian/Ubuntu/Mint
          • Максим к записи Заблокировать User Agents используя Nginx
          • Денис к записи Как включить EPEL репозиторий на CentOS
          • Гость к записи Закомментировать/Раскомментировать строки vi/vim в Unix/Linux
          • Sergey к записи Установка и настройка OpenVPN сервера на Debian/Ubuntu/Linux Mint

          Источник

          memcached(1) — Linux man page

          memcached is a flexible memory object caching daemon designed to alleviate database load in dynamic web applications by storing objects in memory. It’s based on libevent to scale to any size needed, and is specifically optimized to avoid swapping and always use non-blocking I/O.

          Options

          These programs follow the usual GNU command line syntax. A summary of options is included below. -s Unix socket path to listen on (disables network support). -a Permissions (in octal format) for Unix socket created with -s option. -l Listen on ; default to INADDR_ANY. This is an important option to consider as there is no other way to secure the installation. Binding to an internal or firewalled network interface is suggested. -d Run memcached as a daemon. -u Assume the identity of (only when run as root). -m Use MB memory max to use for object storage; the default is 64 megabytes. -c Use max simultaneous connections; the default is 1024. -R This option seeks to prevent client starvation by setting a limit to the number of sequential requests the server will process from an individual client connection. Once a connection has exceeded this value, the server will attempt to process I/O on other connections before handling any further request from this connection. The default value for this option is 20. -k Lock down all paged memory. This is a somewhat dangerous option with large caches, so consult the README and memcached homepage for configuration suggestions. -p Listen on TCP port , the default is port 11211. -U Listen on UDP port , the default is port 11211, 0 is off. -M Disable automatic removal of items from the cache when out of memory. Additions will not be possible until adequate space is freed up. -r Raise the core file size limit to the maximum allowable. -f Use as the multiplier for computing the sizes of memory chunks that items are stored in. A lower value may result in less wasted memory depending on the total amount of memory available and the distribution of item sizes. The default is 1.25. -n Allocate a minimum of bytes for the item key, value, and flags. The default is 48. If you have a lot of small keys and values, you can get a significant memory efficiency gain with a lower value. If you use a high chunk growth factor (-f option), on the other hand, you may want to increase the size to allow a bigger percentage of your items to fit in the most densely packed (smallest) chunks. -C Disable the use of CAS (and reduce the per-item size by 8 bytes). -h Show the version of memcached and a summary of options. -v Be verbose during the event loop; print out errors and warnings. -vv Be even more verbose; same as -v but also print client commands and responses. -i Print memcached and libevent licenses. -P Print pidfile to , only used under -d option. -t Number of threads to use to process incoming requests. This option is only meaningful if memcached was compiled with thread support enabled. It is typically not useful to set this higher than the number of CPU cores on the memcached server. The default is 4. -D Use as the delimiter between key prefixes and IDs. This is used for per-prefix stats reporting. The default is «:» (colon). If this option is specified, stats collection is turned on automatically; if not, then it may be turned on by sending the «stats detail on» command to the server. -L Try to use large memory pages (if available). Increasing the memory page size could reduce the number of TLB misses and improve the performance. In order to get large pages from the OS, memcached will allocate the total item-cache in one large chunk. Only available if supported on your OS. -B Specify the binding protocol to use. By default, the server will autonegotiate client connections. By using this option, you can specify the protocol clients must speak. Possible options are «auto» (the default, autonegotiation behavior), «ascii» and «binary». -I Override the default size of each slab page. Default is 1mb. Default is 1m, minimum is 1k, max is 128m. Adjusting this value changes the item size limit. Beware that this also increases the number of slabs (use -v to view), and the overal memory usage of memcached.

          License

          The memcached daemon is copyright Danga Interactive and is distributed under the BSD license. Note that daemon clients are licensed separately.

          Источник

Оцените статью
Adblock
detector