In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Four computers
Memcache:192.168.1.201 192.168.1.202
Magent: 192.168.1.100 192.168.1.101
Experiment:
1. Install libevent software (4 sets)
[root@localhost] # tar-zxvf libevent-2.0.21-stable.tar.gz-C / usr/src/
[root@localhost ~] # cd / usr/src/libevent-2.0.21-stabl
[root@localhost libevent-2.0.21-stable] #. / configure-prefix=/usr/
[root@localhost libevent-2.0.21-stable] # make & & make install
2. Install memcached software (2 Memcached servers)
[root@localhost] # tar-zxvf memcached-1.4.31.tar.gz-C / usr/src/
[root@localhost ~] # cd / usr/src/memcached-1.4.31/
[root@localhost memcached-1.4.31] # / configure-- enable-memcache-- with-libevent=/usr/
[root@localhost memcached-1.4.31] # make & & make install
Master cache:
[root@localhost] # memcached-d-m 1024-u root-l 192.168.1.201-p 11211
Prepare the cache:
[root@localhost] # memcached-d-m 1024-u root-l 192.168.1.202-p 11211
[root@localhost ~] # netstat-anpt | grep memcached
3. Install magent software (2 Magent servers)
[root@localhost ~] # mkdir / usr/magent
[root@localhost] # tar-zxvf magent-0.6.tar.gz-C / usr/magent/
[root@localhost ~] # cd / usr/magent/
[root@localhost magent] # vim ketama.h
Add (header add):
# ifndef SSIZE_MAX
# define SSIZE_MAX 32767
# endif
[root@localhost magent] # ln-s / usr/lib64/libm.so / usr/lib64/libm.a
[root@localhost magent] # ln-s / usr/lib64/libevent-1.4.so.2 / usr/lib64/libevent.a
You need to install libevent-1.4.so.2 when you cannot make
[root@localhost magent] # / sbin/ldconfig
[root@localhost magent] # sed-I "s#LIBS =-levent#LIBS =-levent-lm#g" Makefile
[root@localhost magent] # make
[root@localhost magent] # cp magent / usr/bin/
The master cache and slave cache have the same startup command (- l is drift IP has not yet set up the Keepalived service, do not start the Magent service for the time being)
[root@localhost] # magent-u root-n 51200-l 192.168.1.10-p 12000-s 192.168.1.201purl 11211-b 192.168.1.202
[root@localhost] # magent-u root-n 51200-l 192.168.1.10-p 12000-s 192.168.1.201purl 11211-b 192.168.1.202
-u: user
-n: maximum number of connections
-l:magent external monitoring IP address
-p:magent external listening port
-s:magent main cache IP address and port
-b:magent cache IP address and port
[root@localhost ~] # ps-elf | grep magent
4. Install keepalived software (2 Magent servers)
[root@localhost ~] # yum-y install openssl*
[root@localhost] # tar-zxvf keepalived-1.2.13.tar.gz-C / usr/src/
[root@localhost ~] # cd / usr/src/keepalived-1.2.13/
[root@localhost keepalived-1.2.13] # / configure-- prefix=/-- with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64
[root@localhost keepalived-1.2.13] # make & & make install
Configure the main cache server
[root@localhost ~] # vim / etc/keepalived/keepalived.conf
Modify:
Global_defs {
Router_id LVS_DEVEL_R1
}
Vrrp_instance VI_1 {
State MASTER
Interface eth0
Virtual_router_id 51
Priority 100
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.1.10
}
}
[root@localhost ~] # service keepalived restart
[root@localhost ~] # ip add show dev eth0
Configure standby cache server
[root@localhost ~] # vim / etc/keepalived/keepalived.conf
Modify:
Global_defs {
Router_id LVS_DEVEL_R2
}
Vrrp_instance VI_1 {
State BACKUP
Priority 99
.
Virtual_ipaddress {
192.168.1.10
}
-other parameters are consistent with the main cache server-
}
[root@localhost ~] # service keepalived restart
[root@localhost ~] # ip add show dev eth0
Verify:
The client ping 192.168.1.10 looks at the changes in VIP.
5. Verify:
1) use the main cache node to connect the port 1200 of the main cache to insert data
[root@localhost ~] # telnet 192.168.1.10 12000
Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is'^]'.
Set key 33 0 5
Ggggg
STORED
Quit
Connection closed by foreign host.
2) View the inserted data
[root@localhost ~] # telnet 192.168.1.10 12000
Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is'^]'.
Get key
VALUE key 33 5
Ggggg
END
Quit
Connection closed by foreign host.
3) connect port 11211 of the main cache node to view
[root@localhost ~] # telnet 192.168.1.201 11211
Trying 192.168.1.100...
Connected to 192.168.1.100.
Escape character is'^]'.
Get key
VALUE key 33 5
Ggggg
END
Quit
Connection closed by foreign host.
4) connect port 11211 of the main cache node to view
[root@localhost ~] # telnet 192.168.1.202 11211
Trying 192.168.1.200...
Connected to 192.168.1.200.
Escape character is'^]'.
Get key
VALUE key 33 5
Ggggg
END
Quit
Connection closed by foreign host.
Indicates that both the primary cache node and the standby cache node have data.
Shut down the main cache node.
1) stop the memcached process (or disconnect the network card of the primary cache node)
2) client view
[root@localhost ~] # telnet 192.168.1.10 12000
Trying 192.168.1.10...
Connected to 192.168.1.10.
Escape character is'^]'.
Get key
VALUE key 33 5
Ggggg
END
Summary:
Advantages of memcache: it can be multi-master or multi-slave.
The disadvantage of memcache: when the main cache node is pawned and restored, the previously cached data will be lost.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
Interpreting the details of SQL in-memory database About Me....
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.