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

Memcache installation and Memcached Lab

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

Share

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

In 192.168.80.100 to turn off the firewall and SElinuxsystemctl stop firewalld / / turn off the firewall setenforce 0 / / turn off the monitoring memcached server: upload the source code package and plug-in package: yum install lrz*-y pull the memcached-1.5.6.tar.gzlibevent-2.1.8-stable.tar.gz package into

Decompress tar xf memcached-1.5.6.tar.gz-C / opt/tar xf libevent-2.1.8-stable.tar.gz-C / opt/cd / opt/libevent-2.1.8-stable

Yum install gcc gcc-c++ make-y./configure\-- prefix=/usr/local/libeventmake & & make install install memcached:cd / opt/memcached-1.5.6./configure\-- prefix=/usr/local/memcached\-with-libevent=/usr/local/libevent/make & & make installln-s / usr/local/libevent/lib/libevent-2.1.so.6.0.2 / usr/lib64/libevent-2.1.so.6 / / soft link is not allowed Missing cd / usr/local/memcached/bin/./memcached-d-m 32m-p 11211-u root / / allocate 32MB memory in daemon mode, specify port, specify user account bit root to run Memcached service

The above options are described as follows:-p: tcp port used, default is 11211-m: maximum memory size, default is 64m-vv: start in very vrebose mode, output debug information and errors to the console-d: run as daemon background-c: maximum number of concurrent connections running, default is 1024 Generally, set according to the load of the server-P: set the pid file to save Memcached-l: listen to the server IP address. If there are multiple addresses-u: users running Memcached, you cannot start with root by default. If you need-u to specify the root user to set up the Memcached service script: vi / ETC _ init. D _ PROG _ memcachedpurchase _ script: Bash # chkconfig: 35 99 2 steps description: memcached Service Control ScriptPROG= "/ usr/local/memcached/bin/memcached" case "$1" in start) $PROG-d-m 32-p 11211-u root ; stop) pkill-9 memcached & > / dev/null;; restart) $0 stop $0 start;; *) echo "Usage: $0 {start | stop | restart}" exit 1esacexit 0

Chmod + x / etc/init.d/memcached / / add run permission chkconfig-- add memcached / / add to service Manager service memcached start / / launch netstat-anpt | grep memcached

Yum install-y telnet / / install telnettelnet 127.0.0.1 11211 / / Connect login set userid 0 05 / / No compression and serialization identification data expiration time is never expired if the identification number is 5, you need to enter 5 digits. 12345 / / enter data to. End. Get userid / / get data stats / / display status information quit / / exit

The syntax of the key-value pair is as follows: command memcached modify command parameter usage key key is used to find cached values flags can include integer parameters of the key-value pair, and the client uses it to store additional information about the key-value pair expiration time the length of time (in seconds) that the key-value pair is saved in the cache 0 means forever) bytes stored in the cache word node value stored value (always on the second line) memcached basic operation command 1.setset command is used to add a new key-value pair to the cache, if it already exists, the previous value will be replaced, in response to STORED2.add when the key does not exist in the cache, the add command will add a key-value pair to the cache, if the key already exists in the cache, the previous value will remain the same The replace command will replace the key in the cache only if the key already exists. If the key does not exist in the cache, return the response NOT_STORED6.get to retrieve the value associated with the previously added key-value pair. 7.delete is used to delete any existing values in memcached. The delete is called with a key, and if the key exists in the cache, the value is deleted. If it does not exist, a NOT_FOUND message is returned. 8.stats dumps the current statistics of the connected memcached instance. 9.flush_all is only used to clean up all name / value pairs in the cache. Flush_all can be of great use if you need to reset the cache to a clean state. 10.quit / / exit example: set mykey 0 60 11hello worldget mykeyappend mykey 0 60 1aget mykeyprepend mykey 0 60 3hi get mykeydelete mykeyMemcached experiment (192.168.80.100 to network) 1. Install apacheyum install httpd httpd-devel-Y2. Set the httpd service to boot and start systemctl enable httpd3. Start the httpd service systemctl start httpd4. Check port snooping netstat-anpt | grep httpd or netstat-tunlp | grep httpd

6. Install mysql database yum install mariadb mariadb-server mariadb-libs mariadb-devel-y7. Check the package rpm-qa | grep mariadb8. Set the boot self-boot systemctl enable mariadb9. Start the mysql service systemctl start mariadb10. Check port snooping netstat-tunlp | grep mysql

11. Database security settings mysql_secure_installation y-y-n-y-y12. Log in to the mysql database to test mysql-u root-p

13. Install phpcd / etc/yum.repos.d/cp back/*. / yum-y install php php-devel

14. View the installed php-related package rpm-ql php

15. Php and mysql are associated with yum install php-mysql16. View rpm-ql php-mysql

17. Install the commonly used php module yum install-y php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-bcmath18. Create a php test page vi / etc/httpd/conf/httpd.conf to remove ServerName www.example.com:80 # from vi / var/www/html/info.php or cd / var/www/htmlvi info.php

19. Restart the httpd service systemctl restart httpd20. Client tests php client accesses http://192.168.80.100/info.php

21. Client installs PHP extension function of Memcache # installs autoconf package yum install autoconf-y pulls memcache-2.2.7.tgz into # decompress tar xf memcache-2.2.7.tgz-C / opt/# into directory cd / opt/memcache-2.2.7

# add the module to PHP and then configure the memcache to compile / usr/bin/phpize

# configure. / configure\-- enable-memcache\-- with-php-config=/usr/bin/php-config# compile and install make & & make install22. Edit the php.inivi / etc/php.ini#732 line, add the following command extension_dir = "/ usr/lib64/php/modules/" # 864, and add the following command extension = memcache.so

23. Write a test page to test whether memcached is working properly vi / var/www/html/index.php

24. Restart the httpd service service httpd restart25. Whether the client access test is successful or not, http://192.168.80.100/index.php

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