| 主機參考: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
--------------------------------------------------------------
主機參考,收集國內外VPS,VPS測評,主機測評,云服務器,虛擬主機,獨立服務器,國內外服務器,高性價比建站主機相關優惠信息@m.k2270.com
詳細介紹和測評國外VPS主機,云服務器,國外服務器,國外主機的相關優惠信息,商家背景,網絡帶寬等等,也是目前國內最好的主機云服務器VPS參考測評資訊優惠信息分享平臺
這幾篇文章你可能也喜歡:
- lightlayer,國外獨立服務器特價5折優惠低至$75/月,美國洛杉磯機房,50Mbps優化/100Mbps直連/300Mbps國際帶寬可選
- lightlayer,免備案特價VPS云服務器$24.99/年,原生IP/最高200Mbps帶寬,中國(香港/臺灣)/新加坡/美國機房可選
- CloudCone,新機房上線/新西蘭奧克蘭獨立服務器上線$80.81/月起,支持虛擬化/安全策略等,默認1Gbps帶寬/10TB月流量
- ReliableSite,國外便宜獨立服務器/物理服務器特價低至$9/月,美國洛杉磯/紐約,1Gbps帶寬/5TB月流量
- ReliableSite,美國便宜高防服務器特價優惠低至$75/月,免費20G DDOS防御,美國洛杉磯/紐約/邁阿密,AMD Ryzen 5800X/64G內存/1Gbps帶寬/不限流量
本文由主機參考刊發,轉載請注明:Memcache高可用群集 http://m.k2270.com/12916.html
主機參考

















評論前必須登錄!
注冊