Otu esi etinye & hazie Memcached na openSUSE Leap 15

Debara aha A na-eji mee ka weebụsaịtị webụsaịtị na-akwalite nchekwa data ngwa ngwa site na ịchekwa data na ihe dị na RAM. Nke a na-ebelata ugboro ole a ga-agụrịrị isi iyi data mpụga, nke na-ewetu oke ego ma na-agba ọsọ oge nzaghachi. Akụrụngwa nchekwa nchekwa bụ ọrụ n'efu, mepere emepe nke onye ọ bụla nwere ike iji.

Na njedebe nke nkuzi, ị ga-ama otu esi etinye ma hazie Memcached na sistemụ arụmọrụ gị openSUSE Leap 15.

Prerequisites

  • OS akwadoro: mepereSUSE Leap - 15.x 
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo ma ọ bụ ohere mgbọrọgwụ.

Melite Sistemụ Ọrụ

Melite gi openSUSE Sistemụ arụmọrụ iji hụ na ngwugwu niile dị adị adịla ugbu a:

sudo zypper refresh

Nkuzi a ga-eji ya sudo iwu na na-eche na ị nwere ọnọdụ sudo.

Iji nyochaa ọkwa sudo na akaụntụ gị:

sudo whoami

Ihe atụ na-egosi ọkwa sudo:

[joshua@opensuse ~]$ sudo whoami
root

Ka ịtọlite ​​akaụntụ sudo dị adị ma ọ bụ ọhụrụ, gaa na nkuzi anyị na na-agbakwunye onye ọrụ na Sudoers na openSUSE.

Iji mgbọrọgwụ akaụntụ, jiri iwu na-esonụ na paswọọdụ mgbọrọgwụ banye.

su

Advertisement


Wụnye Memcached

Site na ndabara, openSUSE enweela Memcached na ebe nchekwa ya. Iji tinye Memcached, tinye iwu a:

sudo zypper install memcached libmemcached

Ihe atụ mmepụta:

Otu esi etinye & hazie Memcached na openSUSE Leap 15

ụdị Y, wee pịa Tinye igodo ịga n'ihu na nwụnye.

Rịba ama, nhọrọ nrụnye nke abụọ, "libmemcached” ngwugwu, na-enye ndị ọzọ iwu iji weta mmezi mmekọrịta na mebie ikike na Memcached.

Na-esote, gosi na etinyere Memcached nke ọma site na nyochaa ụdị ya wee wuo ya

sudo memcached --version

Ihe atụ mmepụta:

memcached 1.5.6

Ọrụ ahụ, na ndabara, agaghị arụ ọrụ. Ka ịmalite Memcached site na iji iwu a:

sudo systemctl enable memcached --now

Ekwesịrị ịgbalite Memcached na ndabara. Iji nyochaa nke a, jiri systemctl iwu iwu dị ka ndị a:

systemctl status memcached

Ihe atụ mmepụta:

Otu esi etinye & hazie Memcached na openSUSE Leap 15

Iwu ndị ọzọ bara uru maka ijikwa ọrụ Memcached bụ ndị a:

Iji mee ka ọrụ Memcached dị na buut sistemụ:

sudo systemctl enable memcached

Ka ịkwụsị ọrụ Memcached:

sudo systemctl stop memcached

Iji gbanyụọ ọrụ Memcached na buut sistemụ:

sudo systemctl disable memcached

Ka ịmalitegharịa ọrụ Memcached:

sudo systemctl restart memcached

Hazie Memcached

Memcached ga-abụrịrị na-ege ntị 127.0.0.1. Mepee ntọala ndabara na faịlụ nhazi dị na "/etc/sysconfig/memcached".

sudo nano /etc/sysconfig/memcached

Nhọrọ nke mbụ bụ ịgbanwe nọmba ọdụ ụgbọ mmiri ọdịnala maka Memcached.

Mbụ, pịgharịa gaa na MEMCACHED_PARAMAhịrị S:

MEMCACHED_PARAMS=" -l 127.0.0.1"

Ugbu a, Memcached ka atọrọ ka ọ gee localhost, ma ị nwere ike ịtọ adreesị IP nke ime ma ọ bụ mpụga ma ọ bụrụ na achọrọ ya site na ịgbanwe 127.0.0.1.

Ihe Nlereanya:

MEMCACHED_PARAMS=" -l 192.51.5.231"

Na-esote, n'otu ahịrị ahụ, ịnwere ike ịgbakwunye ọkọlọtọ ọzọ iji gbanwee ntọala. Otu n'ime ntọala kachasị ewu ewu iji gbanwee bụ nha ndabara nke 64MB ka ọ bụrụ ihe dị ịrịba ama ma ọ bụrụ na ị nwere ihe nkesa dị ike.

Ọmụmaatụ ịgbanwe RAM ka ọ bụrụ 2GB site na 64MB:

MEMCACHED_PARAMS=" -l 192.51.5.231 m - 2000"

Nhọrọ ọzọ na-ewu ewu bụ gbanyụọ UDP ma ọ bụrụ na achọrọghị ya.

Iji mee nke a, jiri ihe ndị a:

MEMCACHED_PARAMS=" -l 192.51.5.231 m - 2000 - U 0"

Nchịkọta nke nkuzi maka ihe ntọlite ​​gị nwere ike ịdị ka ozugbo emechara.

Ọmụmaatụ naanị:

Otu esi etinye & hazie Memcached na openSUSE Leap 15

Ugbu a, chekwaa faịlụ ahụ CTRL + O ma tie "Y," mgbe ahụ CTRL + X pụọ wee malitegharịa ihe atụ Memcached gị.

sudo systemctl restart memcached

Advertisement


Hazie Firewalld maka Memcached

Site na ndabara, ọ nweghị iwu edobere maka Memcached. Nke a pụtara na ị ga-achọ ịmepụta iwu ndị dị mkpa iji kwụsị ọgụ. Ọdịda n'ichekwa Memcached ga-ebute nsogbu na egwu ahụ, yabụ awụla nke a ma ọ bụrụ na ị nweghị ụzọ ọzọ iji chebe nrụnye gị.

Nke mbụ, tinye mpaghara raara onwe ya nye maka iwu Memcached firewalld:

sudo firewall-cmd --permanent --new-zone=memcached

Na-esote, kọwapụta adreesị IP anabatara nke enyere ikike ịnweta Memcached.

sudo firewall-cmd --permanent --zone=memcached --add-source=1.2.3.4

Dochie 1.2.3.4 na IP adreesị nke a ga-agbakwunye na ndepụta ikike.

Ozugbo itinyechara adreesị IP, mepee ọdụ ụgbọ mmiri Memcached.

Site na ndabara, nke a bụ TCP ọdụ ụgbọ mmiri 11211.

sudo firewall-cmd --permanent --zone=memcached --add-port=11211/tcp

Mara, ị nwere ike ịgbanwe ọdụ ụgbọ mmiri ndabara na faịlụ nhazi gị ma ọ bụrụ na ịgbanwee ọdụ ụgbọ mmiri firewall na-emeghe iwu n'elu na uru ọhụrụ.

Mgbe ịmechara iwu ndị ahụ, bugharịa firewall iji mejuputa iwu ọhụrụ:

sudo firewall-cmd --reload

Mwepụta ihe atụ ma ọ bụrụ na ọ ga nke ọma:

success

Wụnye ọba akwụkwọ PHP Memcached

Memcached na-abịa na ndọtị dị iche iche maka asụsụ mmemme, mana a na-eji ya maka PHP. Agbanyeghị, openSUSE chọrọ ụfọdụ ebe nchekwa agbakwunyere arụnyere iji dọpụta ngwugwu ndị a ka ha anaghị egosipụta na ebe nchekwa ndabara.

Bubata ihe nkesa: php: ndọtị maka openSUSE Leap 15.3:

sudo zypper addrepo https://download.opensuse.org/repositories/server:php:extensions/openSUSE_Leap_15.3/server:php:extensions.repo

Bubata ihe nkesa: php: ndọtị maka openSUSE Leap 15.2:

sudo zypper addrepo https://download.opensuse.org/repositories/server:php:extensions/openSUSE_Leap_15.2/server:php:extensions.repo

Ozugbo emechara, megharịa ebe nchekwa ahụ.

sudo zypper refresh

Na-esote, tinye nkwado PHP Memcached site na iji iwu na-esonụ.

Ihe atụ PHP 7.4:

sudo zypper install php7-memcached php7-memcached

Ihe atụ PHP 8.0:

sudo zypper install php8-memcached php8-memcached

Ihe atụ (PHP 8):

Otu esi etinye & hazie Memcached na openSUSE Leap 15

ụdị Y, wee pịa Tinye igodo ịga n'ihu na nwụnye.

Na mgbakwunye, maka nkwado Memcached na Python, ị nwere ike iwunye ngwugwu ndị a site na iji ọba akwụkwọ PIP.

pip3 install pymemcache --user
pip3 install python-memcached --user

Advertisement


Ịnweta Memcached site na Line Command

Enwere ike ikpokọta stats memcached site na ọtụtụ sọftụwia na WEB UI nke ọ na-arụ ọrụ na njikọ. Agbanyeghị, ụzọ ka mma iji lelee bụ iso Memcached na-emekọrịta ihe ozugbo site na iji ahịrị iwu.

Akpa, TELET banye n'ọrụ gị:

telnet localhost 11211

Ihe atụ mmepụta:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Mara, ọ bụrụ na arụnyeghị Telnet, mee iwu a ka ịwụnye.

sudo zypper install telnet

E kwesịghị ịhapụ TELNET ka ọ kparịta ụka na netwọk ọha yana machibido ya na gburugburu netwọkụ nkeonwe.

Na-esote, ị nwere ike nweta nkọwapụta nke ọrụ Memcached gị site na iji iwu a:

stats

Ihe atụ mmepụta:

STAT pid 5934
STAT uptime 1275
STAT time 1631930242
STAT version 1.6.9
STAT libevent 2.1.12-stable
STAT pointer_size 64
STAT rusage_user 0.113635
STAT rusage_system 0.000000
STAT max_connections 1024
STAT curr_connections 1
STAT total_connections 2
STAT rejected_connections 0
STAT connection_structures 2
STAT response_obj_oom 0
STAT response_obj_count 1
STAT response_obj_bytes 16384
STAT read_buf_count 2
STAT read_buf_bytes 32768
STAT read_buf_bytes_free 0
STAT read_buf_oom 0
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT cmd_meta 0
STAT get_hits 0
STAT get_misses 0
STAT get_expired 0
STAT get_flushed 0
STAT delete_misses 0
STAT delete_hits 0
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 7
STAT bytes_written 0
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT time_in_listen_disabled_us 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT slab_reassign_rescues 0
STAT slab_reassign_chunk_rescues 0
STAT slab_reassign_evictions_nomem 0
STAT slab_reassign_inline_reclaim 0
STAT slab_reassign_busy_items 0
STAT slab_reassign_busy_deletes 0
STAT slab_reassign_running 0
STAT slabs_moved 0
STAT lru_crawler_running 0
STAT lru_crawler_starts 6
STAT lru_maintainer_juggles 1325
STAT malloc_fails 0
STAT log_worker_dropped 0
STAT log_worker_written 0
STAT log_watcher_skipped 0
STAT log_watcher_sent 0
STAT unexpected_napi_ids 0
STAT round_robin_fallback 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT slab_global_page_pool 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evicted_active 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT crawler_items_checked 0
STAT lrutail_reflocked 0
STAT moves_to_cold 0
STAT moves_to_warm 0
STAT moves_within_lru 0
STAT direct_reclaims 0
STAT lru_bumps_dropped 0
END

Dị ka n'elu, nke a na-egosi ụfọdụ ihe dị mkpa ị nwere ike ịhụ, dị ka oge nkwụsị, ọnụ ọgụgụ nke ihe dị na cache, na ọnụ ọgụgụ nke njikọ ndị ahịa na ihe atụ.

Ị nwere ike imezi ọchụchọ ahụ site na ilele anya na ebe nchekwa dị iche iche Memcached slabs (nkebi) iji weghachi rịzọlt.

Ọmụmaatụ n'okpuru:

Depụta mbadamba nkume ndị dị na ihe atụ ejikọrọ:

stats slabs

Ndepụta slabs nke gụnyere ngụkọ nke ihe echekwara n'ime slab ọ bụla:

stats items

Na-esote, ị nwere ike ịnweta ma hichapụ data site na iji iwu cachedump iji depụta igodo.

Mbụ, mee ihe iwu cachedump:

stats cachedump [slab ID] [number of items, 0 for all items]

Ọmụmaatụ n'omume:

stats cachedump 1 0

Ihe atụ mmepụta:

ITEM testkey [9 b; 1296857316 s]
END

Dịka n'elu, SLAB 1 nwere otu ihe nwere igodo "Testkey." Iji nweta ezigbo uru, ị nwere ike iji "nweta igodo" nye iwu dika ndi a:

get testkey

Ihe atụ mmepụta:

VALUE testkey 0 9
test data
END

N'ikpeazụ, ka ihichapụ ihe echekwara, na nke a, a "igodo ule" jiri iwu a:

delete testkey

Ihe atụ mmepụta:

DELETED

Otu esi ewepu (wepụ) Memcached

Iji wepu Memcached, jiri iwu na-esonụ na ọdụ gị.

sudo zypper remove memcached libmemcached

Nke a ga-ewepụ Memcached na sistemụ gị ozugbo.


Advertisement


Okwu na mmechi

Nkuzi ahụ egosila gị otu esi etinye Memcached na sistemụ arụmọrụ gị openSUSE Leap 15, wụnye ọba akwụkwọ ndị ọzọ yana otu esi enweta ndepụta iwu ọnụ.

Maka akwụkwọ ndị ọzọ, ọrụ ahụ bụ Github Wiki ibe na-akọwa n'ihu n'ụzọ zuru oke maka ndị nchịkwa ihe nkesa nkọwa ma ọ bụ ozi ọ bụla ha chọrọ.

Idenye aha
Gwa nke
0 Comments
Inline nzaghachi
Lee echiche niile
0
Ga-ahụ n'anya gị echiche, biko okwu.x