当前位置:网站首页>启用MemCached的SASL认证
启用MemCached的SASL认证
2022-07-03 11:55:00 【星哥玩云】
MemCached从1.4.3版本开始,能支持SASL认证。比较适合多个应用共用一个MemCached集群,需要在编译时,加上–enable-sasl选项。
启动memcached时,增加-S的选项
“ ./configure –prefix=%{datadir} –enable-sasl
/usr/local/bin/memcached -S -d -u nobody ” SASL认证也可以有很多种认证机制,比如pam,shadow,ldap等
下面配置成使用shadow方式去认证
“ #修改/etc/sysconfig/saslauthd文件
MECH=shadow
#设置用户的SASL认证密码
saslpasswd2 -c -a memcached memuser
#最终生成的DB文件在/etc/下
-rw-r—– 1 root root 12288 Mar 6 11:52 /etc/sasldb2
#可以查看当前的SASL用户
sasldblistusers2 ”
下面配置成通过pam-mysql使用mysql数据库的方式去认证
“ #首先安装pam-mysql
wget "http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.7RC1.tar.gz"
./configure –with-mysql=/opt/apps_install/mysql-5.5.17
make & make install
#增加一个软链接
ln -s /lib/security/pam_mysql.so /lib64/security/pam_mysql.so
#修改saslauthd配置
MECH=pam
#编辑pam.d的memcached配置
auth sufficient pam_mysql.so user=sasl passwd=saslpwd host=xxx db=dbname table=t_app_info usercolumn=appid passwdcolumn=secret crypt=0 sqllog=1 verbose=1
account required pam_mysql.so user=sasl passwd=saslpwd host=xxx db=dbname table=t_app_info usercolumn=appid passwdcolumn=secret crypt=0 sqllog=1 verbose=1
#新增加memcached的配置文件/etc/sasl2/memcached.conf
pwcheck_method: saslauthd
#重启saslauthd
/etc/init.d/saslauthd restart
#测试saslauthd认证已经成功
/usr/sbin/testsaslauthd -s /etc/pam.d/memcached -u 10000 -p pwd
0: OK "Success." ”
memcached的java client,如spymemcached和xmemcached都已经支持SASL认证了
“ #xmemcached认证示例
MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses("10.x.xx.xx:11211"));
builder.addAuthInfo(AddrUtil.getOneAddress("10.x.xx.xx:11211"), AuthInfo.plain("10000", "pwd"));
builder.setCommandFactory(new BinaryCommandFactory());
client=builder.build();
String v = client.get("test2"); ” python版本的pylibmc也支持SASL认证
边栏推荐
- ES6新特性
- wpa_ cli
- QT OpenGL texture map
- 102. Sequence traversal of binary tree
- 阿里大于发送短信(用户微服务--消息微服务)
- Basic knowledge of OpenGL (sort it out according to your own understanding)
- 在网上炒股开户可以吗?资金安全吗?
- (construction notes) ADT and OOP
- Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
- Is it safe to open an account for online stock speculation? Who can answer
猜你喜欢
Prompt unread messages and quantity before opening chat group
Flutter 退出登录二次确认怎么做才更优雅?
Develop plug-ins for idea
(construction notes) ADT and OOP
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
Laravel time zone timezone
Sword finger offer03 Repeated numbers in the array [simple]
记录自己vulnhub闯关记录
使用BLoC 构建 Flutter的页面实例
What is more elegant for flutter to log out and confirm again?
随机推荐
[combinatorics] permutation and combination (summary of permutation and combination content | selection problem | set permutation | set combination)
lambda与匿名内部类的区别
If you can't learn, you have to learn. Jetpack compose writes an im app (II)
Eureka自我保护
Sword finger offer10- I. Fibonacci sequence
使用BLoC 构建 Flutter的页面实例
Sword finger offer05 Replace spaces
(构造笔记)MIT reading部分学习心得
Wechat applet - basic content
MySQL time zone solution
OpenGL draws colored triangles
2020-11_ Technical experience set
[ManageEngine] the role of IP address scanning
公纵号发送提示信息(用户微服务--消息微服务)
雲計算未來 — 雲原生
Flutter 退出登录二次确认怎么做才更优雅?
225. Implement stack with queue
Use bloc to build a page instance of shutter
232. Implement queue with stack
【ManageEngine】IP地址扫描的作用