Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Memcached highly available cluster deployment

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Environment deployment server role IP address needs to install the package master cache server 192.168.142.130Telnet, libevent, memcached, keepalived, magent slave cache server 192.168.142.131Telnet, libevent, memcached, Keepalived client 192.168.142.132Telnet step 1: configure memcached main cache server # Mount package mount.cifs / / 192.168.142.1/memcached / mntcd / mnt/memcached# create directory mkdir / opt/magent # extract installation package tar zxvf magent-0.5.tar.gz-C / opt/magent/tar zxvf libevent-2.1.8-stable.tar.gz-C / opttar zxvf memcached-1.5.6.tar.gz-C / opt# install necessary components yum install gcc gcc-c++ make-y # to compile and install cd / opt/libevent-2.1.8-stable/./configure & & make installcd / opt/memcached-1.5.6/./configure-- with-libevent=/usrmake & & make installcd / opt/magent/vim ketama.h#ifndef SSIZE_MAX#define SSIZE_MAX 32767#endif# add-lmvim MakefileLIBS =-levent-lm# to compile make# Ann at the end of the first line Install opensshyum install openssh-clients-ycp magent / usr/bin# push magent file scp magent root@192.168.142.131:/usr/bin# turn off firewall and security features systemctl stop firewalld.service setenforce install keepalivedyum install keepalived-y # modify configuration file vim / etc/keepalived/keepalived.conf! Configuration File for keepalived# writes the following Define function vrrp_script magent {script "/ opt/shell/magent.sh" interval 2} # modify route-idglobal_defs {notification_email {acassen@firewall.loc failover@firewall.loc sysadmin@firewall.loc} notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id MAGENT_HAL # modify id name} # modify Nic port Vrrp_instance VI_1 {state MASTER interface ens33 # modify network card information virtual_router_id 51 priority 100 advert_int 1 authentication {auth_type PASS auth_pass 1111} # modify Call the above function track_script {magent} virtual_ipaddress {192.168.142.100 # define a virtual IP address}} mkdir / opt/shellcd / opt/shell/# to configure the slave server script vim magent.shenxinxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Then magent-u root-n 51200-l 192.168.142.100-p 12000-s 192.168.45.132 192.168.142.131:11211elsepkill 11211-b 192.168.142.131:11211elsepkill-9 magentfichmod + x magent.sh# launch systemctl start keepalived.service# to check the migration address ip addr# launch main server memcached-m 512k-u root-d-l 192.168.142.130-p 1121 check whether the port is open netstat-anptu | grep 11211 step 2: configure Memcached unzips the installation package cd / mnt/memcachedtar zxvf libevent-2.1.8-stable.tar.gz-C / opttar zxvf memcached-1.5.6.tar.gz-C / optyum install gcc gcc-c++ make-ycd / opt/libevent-2.1.8-stable/./configure-- prefix=/usrmake & & make installcd / opt/memcached-1.5.6/./ from the cache server # mount package mount.cifs / / 192.168.142.1/memcached / mnt# Configure-- with-libevent=/usrmake & & make install [root@localhost memcached-1.5.6] # cd / etc/keepalived/ [root@localhost keepalived] # mv keepalived.conf keepalived.conf.bk [root@localhost keepalived] # touch keepalived.conf [root@localhost keepalived] # vim keepalived.confvrrp_script magent {script "/ opt/shell/magent.sh" interval 2} global_defs {notification_email {acassen@firewall.loc failover@firewall.loc Sysadmin@firewall.loc} notification_email_from Alexandre.Cassen@firewall.loc smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id MAGENT_HB # id name cannot be the same as master server} vrrp_instance VI_1 {state BACKUP # sets slave server interface ens33 virtual_router_id 52 # id number not to be the same as master server priority 90 # low priority with the master server advert_int 1 authentication {auth_type PASS auth_pass 1111} track_script {magent} virtual_ipaddress {192.168.142.100 # definition of virtual IP address}} mkdir / opt/shellcd / opt/shell/# configuration from the server script vim magent.shemaking server binram Bash K = `ip addr | grep 192.168.142.100 | | grep-v grep | wc-l`if [$K-gt 0] | Then magent-u root-n 51200-l 192.168.142.100-p 12000-s 192.168.142.130 192.168.142.131:11211elsepkill-9 magentfichmod + x magent.sh# start keepalivedsystemctl start keepalived.service# turn off firewall and secure full function systemctl stop firewalld.service setenforce "start from server memcached-m 512k-u root-d-l 192.168.142.131-p 1121" check if the port is open properly netstat-anptu | | grep 1121 install telent for testing yum install telnet-y step 3: client test # turn off firewall and security features systemctl stop firewalld.service setenforce install telent for testing yum install telnet-y # use drift address to log in to connect telnet 192.168.142.100 1200 to create a key-value pair | Verify master-slave synchronization add username 00 7123456dual hot standby # stop master server systemctl stop keepalived.service# use drift address to log in to connect to telnet 192.168.142.100 12000 Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report