-
Notifications
You must be signed in to change notification settings - Fork 4
memcache相关
参考文章:
1.http://lguan.iteye.com/blog/1279537
2.http://blog.csdn.net/qwssd/article/details/77198839?utm_source=5ibc.net&utm_medium=referral
阿里云也是使用SASL作为memcache认证(memcache本身不支持支认证)。
rpm -qa | grep sasl
最全的是:
1.cyrus-sasl-plain-2.1.23-8.el6.i686
2.cyrus-sasl-devel-2.1.23-8.el6.i686
3.cyrus-sasl-2.1.23-8.el6.i686
4.cyrus-sasl-lib-2.1.23-8.el6.i686
5.cyrus-sasl-gssapi-2.1.23-8.el6.i686
6.cyrus-sasl-md5-2.1.23-8.el6.i686
我的是(阿里云亲测): 1.cyrus-sasl-2.1.23-13.el6_3.1.x86_64 2.cyrus-sasl-plain-2.1.23-13.el6_3.1.x86_64 3.cyrus-sasl-lib-2.1.23-13.el6_3.1.x86_64
查看密码验证机制,输入:saslauthd -v
我的是(阿里云亲测):
saslauthd 2.1.23
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
为简单起见,这里准备采用shadow验证方法,也就是直接用/etc/shadow文件中的用户账户及密码进行验证。因此,在配置文件/etc/sysconfig/saslauthd中,应修改当前系统所采用的密码验证机制为shadow,即: MECH=shadow
重启saslauthd进程: /etc/init.d/saslauthd restart
/etc/init.d/saslauthd status 或者 ps aux | grep saslauthd 查看是否启动。
为memcache-sasl添加专有用户:saslpasswd2 -a memcached -c testmemuser 要求输入密码,简单起见:123456。添加的用户必须是系统中的用户,上面命令的意思就是,给memcached服务添加可访问的用户,没有添加的系统用户仍然是不可以访问该服务的。
用户是否work: testsaslauthd –u testmemuser –p pwd(特别注意,这个pwd不是上边的那个123456密码,而是testmemuser这个用户登录Linux的密码!这里坑死我了!)
若提示失败:0: NO "authentication failed",需要开启allow_saslauthd_read_shadow: setsebool -P allow_saslauthd_read_shadow 1
**有可能提示:setsebool: SELinux is disabled. 说明selinux被关闭了,需要打开:vi /etc/selinux/config更改为:SELINUX=1,必须重启linux,不重启是没办法立刻开启selinux的。
再次testsaslauthd –u testmemuser –p pwd提示:0: OK "Success."。
要能够使用SASL服务应要确保有cyrus-sasl-devel和cyrus-sasl-lib两个包,如果缺少这两个包,在安装带—enable-sasl参数的Memcached时会有错误提示: configure: error: Failed to locate the library containing sasl_server_init
最终生成的DB文件在/etc/下:-rw-r—– 1 root root 12288 Mar 6 11:52 /etc/sasldb2
可以查看当前的SASL用户:sasldblistusers2
2.1.在 http://memcached.org/ 下载memcached
tar -zxvf memcached-1.4.6.tar.gz
cd memcached-1.4.6
./configure --enable-sasl --prefix=/opt/system/portaluser/memcached --with-libevent=/opt/system/portaluser/memcached/libevent
make
make install