VPS参考测评推荐
专注分享VPS主机优惠信息
衡天云优惠活动
华纳云优惠活动
荫云优惠活动

Memcache高可用群集

主机参考:VPS测评参考推荐/专注分享VPS服务器优惠信息!若您是商家可以在本站进行投稿,查看详情!此外我们还提供软文收录、PayPal代付、广告赞助等服务,查看详情!
我们发布的部分优惠活动文章可能存在时效性,购买时建议在本站搜索商家名称可查看相关文章充分了解该商家!若非中文页面可使用Edge浏览器同步翻译!PayPal代付/收录合作

Memcache高可用群集

实验环境:

实验目的:

实现存储内容的主从备份

实验搭建:

一、主服务器

1、挂载软件包

#挂载软件包mount.cifs //192.168.100.3/lzp /mnt#创建目录mkdir /opt/magent #解压必要安装包cd /mnt/memtar 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#安装必要组件yum install gcc gcc-c++ make -y

2、对组件进行编译安装

#编译安装libeventcd /opt/libevent-2.1.8-stable/./configure --prefix=/usrmake make install#编译安装memcachedcd /opt/memcached-1.5.6/./configure --with-libevent=/usrmake make install#编译安装magentcd /opt/magent/#修改ketama.h配置文件vim ketama.h#ifndef SSIZE_MAX#define SSIZE_MAX 32767#将#endif移动到第三行,删除掉末尾的#endifvim Makefile#第一行末尾添加-lmLIBS = -levent-lm#编译make

#编译好的magent文件

3、将编译好的magent文件复制到/usr/bin目录下,并推送给从服务器

#安装openssh推送软件yum install openssh-clients -y#将编译好的magent文件复制到/usr/bin目录下cp magent /usr/bin#推送magent文件scp magent root@192.168.45.131:/usr/binThe authenticity of host '192.168.45.131 (192.168.45.131)' can't be established.ECDSA key fingerprint is SHA256:bw2256OHr5apf7CliZv/fAOyVNVsMmRn+lZ5efeQgTg.ECDSA key fingerprint is MD5:6f:f6:70:4f:46:64:ec:17:a7:ae:c0:15:1c:8b:55:1c.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.45.131' (ECDSA) to the list of known hosts.root@192.168.45.131's password: magent 100% 112KB 5.8MB/s 00:00

4、关闭防火墙和安全功能

systemctl stop firewalld.service setenforce 0

5、安装keepalived,并进行修改

#安装keepalivedyum install keepalived -y#修改配置文件vim /etc/keepalived/keepalived.conf ! Configuration File for keepalived#写入下列内容vrrp_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 #修改route-id router_id MAGENT_HA}vrrp_instance VI_1 { state MASTER #修改网卡端口 interface ens33 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } #修改,调用上边函数 track_script { magent } virtual_ipaddress { #设置虚拟指向地址 192.168.45.188 }}

6、创建magent脚本

mkdir /opt/shellcd /opt/shell/vim magent.sh#!/bin/bashK=`ps -ef | grep keepalived | grep -v grep | wc -l`if [ $K -gt 0 ];then magent -u root -n 51200 -l 192.168.45.188 -p 12000 -s 192.168.45.132:11211 -b 192.168.45.131:11211elsepkill -9 magentfi#给于运行权限chmod +x magent.sh

7、启动服务,并查看

#启动keepalivedsystemctl start keepalived.service#查看迁移地址ip addr#启动memcached memcached -m 512k -u root -d -l 192.168.45.132 -p 11211

安装telent进行测试

yum install telnet -y

二、从服务器

1、挂载软件包,并关闭防火墙和安全功能

mount.cifs //192.168.100.3/lzp /mnt#关闭防火墙和安全功能systemctl stop firewalld.service setenforce 0

2、解压安装包,并进行编译

#解压安装包cd /mnt/memtar zxvf libevent-2.1.8-stable.tar.gz -C /opttar zxvf memcached-1.5.6.tar.gz -C /opt#安装必要组件包yum install gcc gcc-c++ make -y#编译安装libeventcd /opt/libevent-2.1.8-stable/./configure --prefix=/usrmake make install#编译安装memcachedcd /opt/memcached-1.5.6/./configure --with-libevent=/usrmake make install

3、安装keepalived

#安装keepalivedyum install keepalived -y#修改keepalived文件cd /etc/keepalived/mv keepalived.conf keepalived.conf.bkvim keepalived.conf! Configuration File for keepalivedvrrp_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 router_id MAGENT_HB}vrrp_instance VI_1 { state BACKUP #修改网络接口 interface ens33 #修改virtual_router_id virtual_router_id 52 #修改优先级 priority 90 advert_int 1 authentication { auth_type PASS auth_pass 1111 } track_script { magent } virtual_ipaddress { #修改地址 192.168.45.188 }}

4、创建magent脚本

mkdir /opt/shellcd /opt/shell/vim magent.sh#!/bin/bashK=`ip addr | grep 192.168.45.188 | grep -v grep | wc -l`if [ $K -gt 0 ];then magent -u root -n 51200 -l 192.168.45.188 -p 12000 -s 192.168.45.132:11211 -b 192.168.45.131:11211elsepkill -9 magentfichmod +x magent.sh

4、启动服务

#启动keepalivedsystemctl start keepalived.service #启动memcachedmemcached -m 512k -u root -d -l 192.168.45.131 -p 11211

安装telent进行测试

yum install telnet -y

三、客户机

#关闭防火墙和安全功能systemctl stop firewalld.service setenforce 0#安装telnet yum install telnet -y#在telnet中写入文件[root@manager ~]# telnet 192.168.45.188 12000Trying 192.168.45.188...Connected to 192.168.45.188.Escape character is '^]'.add username 0 0 71234567STORED

在从服务器上查看在主服务器上查看


Memcache high availability cluster

Experimental environment:

Objective:

Realize master-slave backup of storage content

Experimental setup:

1、 Primary server:

1. Mount package

#Install the necessary components Yum install GCC gcc-c + + make - y

2. Compile and install components

#Compile and install libeventcd / opt / libevent-2.1.8-stable /. Configure -- prefix = / usrmake make install ා compile and install memcached / opt / memcached-1.5.6 /. / configure -- with libevent = / usrmake make; Make

#Compiled magent file

3. Copy the compiled magent file to the / usr / bin directory and push it to the slave server

#Vnvsmmrn + lz5efeqgtg.ecdsa key fingerprint is MD5:6f:f6:70:4f:46:64:ec:17:a7:ae:c0:15:1c:8b:55:1c.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.45.131' (ECDSA) to the list of known hosts.root@192.168.45.131's password: magent 100% 112KB 5.8MB/s 00:00

4. Turn off firewall and security features

systemctl stop firewalld.service setenforce 0

5. Install and modify keepalived

#Install keepalivedium install keepalived - y ා modify the configuration file VIM / etc / keepalived / keepalived.conf! Configuration file for keepalived ා write the following VRRP ᦉ script make {script "/ opt / shell / make. Sh" interval 2} global {notification {email {acassen @ firewall. LOC failover @ firewall. LOC sysadmin @ firewall. LOC} Pass 1111 }Modify, call the upper function track {script {magent} virtual {IPAddress {set virtual point address 192.168.45.188}}}

6. Create a magent script

Chmod + X magent.sh

7. Start the service and view

#Start keepalivedsystemctl start keepalived.service? View the migration address IP addr? Start memcached - M 512k - U root - D - L 192.168.45.132 - P 11211

Install telent for testing

yum install telnet -y

2、 From server

1. Mount the package and turn off the firewall and security functions

Mount.cifs / / 192.168.100.3/lzp/mnt ා turn off the firewall and security function systemctl stop firewall.service setenforce 0

2. Extract the installation package and compile it

#Unzip the installation package CD / MNT / memtar zxvf libevent-2.1.8-stable.tar.gz - C / optar zxvf memcached-1.5.6.tar.gz - C / opt ා install the necessary component package Yum / MNT / memtar zxvf libevent-2.1.8-stable /. / configure -- prefix = / usrmake ; Make install compile and install memcachedcd / opt / memcached-1.5.6 /. / configure -- with libevent = / usrmake make install

3. Install keepalived

#In this paper, the author analyzes the characteristics of ID 52 modify priority 90 Advertisement {auth {type pass auth} track {magent} virtual {IPAddress {modify address 192.168.45.188}}}}

4. Create a magent script

mkdir /opt/shellcd /opt/shell/vim magent.sh#!/bin/bashK=`ip addr | grep 192.168.45.188 | grep -v grep | wc -l`if [ $K -gt 0 ];then magent -u root -n 51200 -l 192.168.45.188 -p 12000 -s 192.168.45.132:11211 -b 192.168.45.131:11211elsepkill -9 magentfichmod +x magent.sh

4. Start service

#Start keepalivedsystemctl start keepalived.service. Start memcachedmemcached - M 512k - U root - D - L 192.168.45.131 - P 11211

Install telent for testing

yum install telnet -y

3、 Client

#Turn off the firewall and security function systemctl stop firewall.service setenforce 0 ා install telnet Yum install telnet - y ා write the file [root @ manager ~] # telnet 192.168.45.188 12000 trying 192.168.45.188... Connected to 192.168.45.188. Escape character is' ^] '. Add username 0 0 71234567stored

View on slave view on master

--------------------------------------------------------------
主机参考,收集国内外VPSVPS测评主机测评云服务器虚拟主机独立服务器,国内外服务器高性价比建站主机相关优惠信息@zhujicankao.com
详细介绍和测评国外VPS主机,云服务器,国外服务器,国外主机的相关优惠信息,商家背景,网络带宽等等,也是目前国内最好的主机云服务器VPS参考测评资讯优惠信息分享平台

这几篇文章你可能也喜欢:

本文由主机参考刊发,转载请注明:Memcache高可用群集 https://zhujicankao.com/12916.html

【腾讯云】领8888元采购礼包,抢爆款云服务器 每月 9元起,个人开发者加享折上折!
打赏
转载请注明原文链接:主机参考 » Memcache高可用群集
主机参考仅做资料收集,不对商家任何信息及交易做信用担保,购买前请注意风险,有交易纠纷请自行解决!请查阅:特别声明

评论 抢沙发

评论前必须登录!