Memcahce native connection after CentOS installation memcache service permission

Source: Internet
Author: User
Tags cas memcached

Oneself manually under the virtual machine installed under Memcache, the whole process is full of twists and turns, itself with php5.3 installation memcache expansion on a lot of trouble, can not be directly installed through Yum, installation method see HTTP://CHENWEI.ME/BLOG/SERVER/69. HTML, next install the Memcache service, after the installation succeeds, Telnet can succeed, but it does not seem to be effective immediately, after a while with the stats will be displayed in detail.

For this machine

<?php

$mem = new Memcache;

$mem->connect (' 192.168.124.129′,11211) or Die ("Connection failed");

$mem->getversion ();

?>

No matter how the commissioning is not successful, and then connect with Master machine is successful.

So the suspicion is the server memcache extension problem, but phpinfo () does have this extension, the use of

Ini_set (' display_errors ', true);

Error_reporting (E_all);

After that, you can display detailed errors.

"Memcache::get () [function.] Memcache-get]: Server 127.0.0.1 (TCP 11211) failed with:permission denied (in/var/www/)

Baidu can not find relevant information, but Google a lot more powerful, learned that this is the problem of selinuxd,

SELinux is a set of Linux security systems that specify the disk files, network ports, and so on that the application can access.

If SELinux is installed, the default SELinux will prevent the Memcache program from accessing Port 11211, so SELinux must be configured.

Method 1: Temporarily reduce the SELinux run level so that we can test

Command: Setenforce [Enforcing | Permissive]

Enforcing indicates that a policy violation is not allowed

Permissive indicates that a policy violation is allowed but is logged

We use Setenforce Permissive

Method 2: Modify the SELinux configuration file to turn off SELinux

Edit/etc/selinux/config file, change selinux=enforcing to Selinux=disabled

Method 3: Modify the SELinux HTTP policy so that the httpd process can access the network, so you can use Memcache

Command: Setsebool-p httpd_can_network_connect true

The parameter p means to maintain the validity of the setting so that the setting remains valid after a reboot, and does not change

I used to change/etc/selinux/config selinux=0 after reboot success.

Attached: How to install Memcache service in CentOS

1. Compile and install Libevent

CD ~

Curl-o http://www.monkey.org/~provos/libevent-2.0.13-stable.tar.gz

TAR-ZXVF libevent-2.0.13-stable.tar.gz

CD libevent-2.0.13-stable-tar.gz

./configure–prefix=/usr

Make && make install

Check to see if the installation:

Ls-al/usr/lib | grep libevent

#显示

Libevent.so-libevent-2.0.so.5.1.2

2. Installing Memcache

CD ~

Curl-o http://www.danga.com/memcached/dist/memcached-1.4.0.tar.gz

TAR-ZXVF memcached-1.4.0.tar.gz

CD memcached-1.4.0.tar.gz

./configure–with-libevent=/usr/

Make && make install

Detect whether the installation was successful

ls-al/usr/local/bin/mem*

#显示

/usr/local/bin/memcached

Turn on the memcached daemon

memcached-d-U Root

Full command

/usr/local/bin/memcached-d-M 200-u root-c 256-p 11211-p/tmp/memcache.pid

#无提证明开启成功

#连接参数

-P Listening Port

-L connected IP address, default is native

-D Start Memecache service

-D Restart Restart

-D stop|shutdown Shutdown service

-D Install installation

-D Uninstall Uninstall

-U Run as identity only valid under root

-m maximum memory usage, unit MB, default 64MB, Max 2G

-M error returned when memory is exhausted

-c Maximum number of simultaneous connections, default is 1024

-F Block Size growth because the default is 1.25

-N Minimum allocated space, key+value+flags default 48

-H Display Help

#使用telnet连接

telnet localhost 11211

#直接按回车会出现客户端错误.

#查看当前状态命令

Stats

Stats parameter Reference

STAT PID 22459 Process ID

STAT uptime 1027046 server running seconds

STAT time 1273043062 Server current UNIX timestamp

STAT version 1.4.4 Server version

STAT pointer_size 64 OS Word size (this server is 64-bit)

STAT rusage_user 0.040000 Process Cumulative User Time

STAT rusage_system 0.260000 Process Cumulative system time

STAT curr_connections 10 Number of currently open connections

STAT total_connections 82 Total connections that were opened

STAT connection_structures 13 Number of connection structures allocated by the server

STAT cmd_get 54 Execute Get Command Total

STAT Cmd_set 34 Execute SET command total

STAT Cmd_flush 3 points to the total number of FLUSH_ALL commands

STAT get_hits 9 Get hit count

STAT get_misses number of Get misses

STAT delete_misses 5 Delete misses

STAT delete_hits 1 Delete hit count

STAT incr_misses 0 incr number of misses

STAT incr_hits 0 incr hit count

STAT decr_misses 0 decr number of misses

STAT decr_hits 0 DECR hit count

STAT cas_misses 0 CAs misses

STAT cas_hits 0 CAs hit count

STAT Cas_badval 0 Use wipe count

STAT Auth_cmds 0

STAT auth_errors 0

STAT bytes_read 15785 Read Bytes total

STAT bytes_written 15222 Write Bytes Total

STAT limit_maxbytes 1048576 Allocated memory number (bytes)

STAT Accepting_conns 1 Number of links currently accepted

STAT Listen_disabled_num 0

STAT Threads 4 Thread Count

STAT Conn_yields 0

STAT bytes 0 Stores the item byte number

STAT Curr_items 0 Item number

STAT total_items Total number of item

STAT evictions 0 To get the total amount of space deleted item

Memcahce native connection after CentOS installation memcache service permission

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.