centos7配置Memcached
memcached是一套分布式的高速缓存系统,用于提升网站访问速度,尤其对于一些大型的、需要频繁访问数据库的网站,访问速度提升效果十分显著。
1.安装memcached
yum install memcached
yum install libmemcached
netstat -ntpl
systemctl status memcached
systemctl start memcached
netstat -ntupl
2.配置memcached只监听127.0.0.1
vim /etc/sysconfig/memcached
port="11211"
user="memcached"
maxconn="1024"
cachesize="64"
options="-l 127.0.0.1 -u 0“ # -u 0 不启用udp监听
systemctl restart memcached
netstat -ntpl
systemctl status memcached
3.检查memcached运行,能看到很多信息
memstat --servers="127.0.0.1"
4.配置memcached启用sasl
vim /etc/sysconfig/memcached
port="11211"
user="memcached"
maxconn="1024"
cachesize="64"
options="-l 127.0.0.1 -u 0 -s -vv"
systemctl restart memcached
netstat -ntpl
memstat --servers="127.0.0.1"
echo $?
5.安装cyrus sasl库
yum install cyrus-sasl-devel cyrus-sasl-plain
6.配置sasl
vim /etc/sasl2/memcached.conf
mech_list: plain
log_level: 5
sasldb_path: /etc/sasl2/memcached-sasldb2
cat /etc/sasl2/memcached.conf
saslpasswd2 -a memcached -c -f /etc/sasl2/memcached-sasldb2 zeng
chown memcached:memcached /etc/sasl2/memcached-sasldb2
systemctl restart memcached
netstat -ntpl
memstat --servers="127.0.0.1"
echo $?
memstat --servers="127.0.0.1" --username=zeng --password=redhat