当前位置:网站首页>启用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认证
边栏推荐
- QT OpenGL texture map
- What is more elegant for flutter to log out and confirm again?
- temp
- 111. Minimum depth of binary tree
- Use of atomicinteger
- Dart: About zone
- 023(【模板】最小生成树)(最小生成树)
- 01_ Using the concurrent tool class library, is thread safety safe
- Sword finger offer03 Repeated numbers in the array [simple]
- repo Manifest Format
猜你喜欢

Shutter: add gradient stroke to font
![Sword finger offer04 Search in two-dimensional array [medium]](/img/c4/002c951f8d914aaea4f4133685ebd1.png)
Sword finger offer04 Search in two-dimensional array [medium]

【附下载】密码获取工具LaZagne安装及使用
![[official MySQL document] deadlock](/img/2d/04e97d696f20c2524701888ea9cd10.png)
[official MySQL document] deadlock

4000字超详解指针

Sword finger offer09 Implementing queues with two stacks

Shardingsphere sub database and sub table < 3 >

剑指Offer05. 替换空格

使用BLoC 构建 Flutter的页面实例

ES6 standard
随机推荐
102. Sequence traversal of binary tree
OpenGL index cache object EBO and lineweight mode
Sword finger offer05 Replace spaces
PHP export word method (one MHT)
SystemVerilog -- OOP -- copy of object
Sword finger offer03 Repeated numbers in the array [simple]
Cloud Computing future - native Cloud
Socket TCP for network communication (I)
PHP export word method (phpword)
【附下载】密码获取工具LaZagne安装及使用
(构造笔记)ADT与OOP
Flinksql can directly create tables and read MySQL or Kafka data on the client side, but how can it automatically flow and calculate?
Use of atomicinteger
023 ([template] minimum spanning tree) (minimum spanning tree)
regular expression
Shardingsphere sub database and sub table < 3 >
flinksql是可以直接客户端建表读mysql或是kafka数据,但是怎么让它自动流转计算起来呢?
(construction notes) grasp learning experience
Flutter Widget : KeyedSubtree
实现验证码验证