litespeedtech/lsmcd

LSMCD not work with unix socket

Opened this issue · 3 comments

I use cPanel and Cloulinux and Litespeed
I installed the LSMCD via cPanel plugin file in this command:

sudo git clone https://github.com/litespeedtech/lsmcd.git
sudo cd lsmcd
sudo ./lsmcd_cpanel.sh

LSMCD is working properly with TCP connection, but when I configured to unix socket, it shows nothing.

test.php

<?php

$mc = new Memcached();
$mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$mc->setOption(Memcached::OPT_COMPRESSION, false);
$mc->addServer('/tmp/lsmcd/lsmcd.sock', 0);
$mc->setSaslAuthData('testuser', 'testpass');
$mc->set("foo", "bar");
$value = $mc->get('foo');
echo $value;

And it doesn't show anything.

/usr/local/lsmcd/conf/node.conf

Repl.HeartBeatReq=30
Repl.HeartBeatRetry=3000
Repl.MaxTidPacket=2048000
Repl.GzipStream=YES
Repl.LbAddrs=127.0.0.1:12340
Repl.ListenSvrAddr=127.0.0.1:12340
REPL.DispatchAddr=127.0.0.1:5501
RepldSockPath=/tmp/repld.usock
CACHED.PRIADDR=127.0.0.1:11000

#CACHED.ADDR=127.0.0.1:11211
CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
#default is 8, it can be bigger depending on cache data amount
Cached.Slices=8
Cached.Slice.Priority.0=100
Cached.Slice.Priority.1=100
Cached.Slice.Priority.2=100
Cached.Slice.Priority.3=100
Cached.Slice.Priority.4=100
Cached.Slice.Priority.5=100
Cached.Slice.Priority.6=100
Cached.Slice.Priority.7=100

Cached.ShmDir=/dev/shm/lsmcd
Cached.UseSasl=true
Cached.DataByUser=true
Cached.Anonymous=false
Cached.SaslDB=/etc/sasllsmcd

##this is the global setting, no need to have per slice configuration.
User=nobody
Group=nobody
#depends CPU core
CachedProcCnt=4
CachedSockPath=/tmp/cached.usock.
TmpDir=/tmp/lsmcd
LogLevel=notice
#LogLevel=dbg_medium
LogFile=/tmp/lsmcd.log

But it works when I switch to TCP:

CACHED.ADDR=127.0.0.1:11211
#CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
sudo systemctl restart lsmcd
$mc->addServer('127.0.0.1', 11211);

it returns "bar"

In this article: Using Memcached in a UNIX socket, it is mentioned that:

1.Stop Memcached systemctl stop memcached
2. Copy the service file cp /usr/lib/systemd/system/memcached.service /etc/systemd/system/memcached.service
3. Add the following content to /etc/systemd/system/memcached.service. After [Service], please change username to the same user that runs PHP: User=username Group=username The contents of the file should look like this:

But there isn't any memcached service in the system. Because I installed lscmd, not memcached.

The article is not appropriate. So long as the lsmcd process is running on your system, you should be fine. It looks to me like you had everything setup correctly for UDS and your test was a good one. It should have worked. So let's go back to that. Please open a ticket with LiteSpeed and we can work closely on this problem. In particular I'll need root access into your system so I can diagnose your issue and we shouldn't put that kind of info on a public forum like this. You can open a ticket here: https://store.litespeedtech.com/store/submitticket.php?step=2&deptid=2 and make sure that LSMCD is in the subject line and we can help you with the problem. Thanks,

Bob

Honestly I prefer to debug that personally.
I guess the problem related to SASL over unix socket:

/tmp/lsmcd.log

2022-08-28 19:32:12.748 [ERROR] [PID: 43902] Successful SASL authentication not performed
2022-08-28 19:32:13.665 [ERROR] [PID: 43902] Successful SASL authentication not performed
2022-08-28 19:40:03.525 [ERROR] [PID: 43903] Successful SASL authentication not performed

Debug High Level Log:

2022-08-28 21:38:59.073 [DEBUG] [PID: 12668] Memcache New connection from [0.0.0.0:0]
2022-08-28 21:38:59.073 [DEBUG] [PID: 12668] New connection - reset user
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, m_bufIncoming size:40
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Tracing 40 bytes (allocated 178, used 168):
0000: 80010004 08000000 00000010 00010000 ................
0010: 00000000 00000000 00000000 00000000 ................
0020: 74657374 776f726b                  testwork
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 1
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 2
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 3
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 4
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 5
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 7
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] SASL test, parm for sasl: YES, isAuthenticated: NO, opcode: 1
2022-08-28 21:38:59.074 [ERROR] [PID: 12668] Successful SASL authentication not performed
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binErrRespond err: 32
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binRespond, 24 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binRespond, 13 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] SendEx pid: 12668
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Tracing 37 bytes (allocated 178, used 166):
0000: 81010000 00000020 0000000d 00010000 ....... ........
0010: 00000000 00000000 41757468 20666169 ........Auth fai
0020: 6c757265 2e                         lure.
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 10
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Close connection - reset user and other cached stuff
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] memcacheconn::setUser: (null)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Conn 0x14a2730 set pHash: (nil)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Memcache New connection from [24.0.0.0:0]
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] New connection - reset user
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, m_bufIncoming size:40
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Tracing 40 bytes (allocated 178, used 168):
0000: 80010004 08000000 00000010 00020000 ................
0010: 00000000 00000000 00000000 00000000 ................
0020: 74657374 776f726b                  testwork
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 1
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 2
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 3
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 4
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 5
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 7
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] SASL test, parm for sasl: YES, isAuthenticated: NO, opcode: 1
2022-08-28 21:38:59.074 [ERROR] [PID: 12668] Successful SASL authentication not performed
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binErrRespond err: 32
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binRespond, 24 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binRespond, 13 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] SendEx pid: 12668
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Tracing 37 bytes (allocated 178, used 166):
0000: 81010000 00000020 0000000d 00020000 ....... ........
0010: 00000000 00000000 41757468 20666169 ........Auth fai
0020: 6c757265 2e                         lure.
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 10
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Close connection - reset user and other cached stuff
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] memcacheconn::setUser: (null)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Conn 0x14a2730 set pHash: (nil)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] Memcache New connection from [0.0.0.0:0]
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] New connection - reset user
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming pid:12667, addr:0x14a2730, m_bufIncoming size:40
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] Tracing 40 bytes (allocated 178, used 168):
0000: 80010004 08000000 00000010 00030000 ................
0010: 00000000 00000000 00000000 00000000 ................
0020: 74657374 776f726b                  testwork
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming 1
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming 2
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming pid:12667, addr:0x14a2730, 3
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming pid:12667, addr:0x14a2730, 4
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming pid:12667, addr:0x14a2730, 5
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming pid:12667, addr:0x14a2730, 7
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] SASL test, parm for sasl: YES, isAuthenticated: NO, opcode: 1
2022-08-28 21:38:59.074 [ERROR] [PID: 12667] Successful SASL authentication not performed
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] binErrRespond err: 32
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] binRespond, 24 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] binRespond, 13 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] SendEx pid: 12667
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] Tracing 37 bytes (allocated 178, used 166):
0000: 81010000 00000020 0000000d 00030000 ....... ........
0010: 00000000 00000000 41757468 20666169 ........Auth fai
0020: 6c757265 2e                         lure.
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] MemcacheConn processIncoming 10
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] Close connection - reset user and other cached stuff
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] memcacheconn::setUser: (null)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12667] Conn 0x14a2730 set pHash: (nil)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Memcache New connection from [0.0.0.0:0]
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] New connection - reset user
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, m_bufIncoming size:52
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Tracing 52 bytes (allocated 237, used 223):
0000: 800d0004 00000000 00000004 00040000 ................
0010: 00000000 00000000 74657374 800a0000 ........test....
0020: 00000000 00000000 00050000 00000000 ................
0030: 00000000                           ....
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 1
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 2
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 3
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 4
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 5
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming pid:12668, addr:0x14a2730, 7
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] SASL test, parm for sasl: YES, isAuthenticated: NO, opcode: 13
2022-08-28 21:38:59.074 [ERROR] [PID: 12668] Successful SASL authentication not performed
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binErrRespond err: 32
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binRespond, 24 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] binRespond, 13 bytes
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] SendEx pid: 12668
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Tracing 37 bytes (allocated 178, used 166):
0000: 810d0000 00000020 0000000d 00040000 ....... ........
0010: 00000000 00000000 41757468 20666169 ........Auth fai
0020: 6c757265 2e                         lure.
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] MemcacheConn processIncoming 10
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Close connection - reset user and other cached stuff
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] memcacheconn::setUser: (null)
2022-08-28 21:38:59.074 [DEBUG] [PID: 12668] Conn 0x14a2730 set pHash: (nil)

when I enable the Cached.Anonymous, it works well with no error and prints the output.

CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
Cached.Anonymous=true

However it doesn't solve the issue, because I want to use username/password authentication.

Btw it's the journal error while starting the lsmcd:

Aug 28 19:32:08 server systemd[1]: Starting LSB: lsmcd...
Aug 28 19:32:08 server lsmcd[43899]: sql_select option missing
Aug 28 19:32:08 server lsmcd[43899]: auxpropfunc error no mechanism available
Aug 28 19:32:08 server lsmcd[43899]: _sasl_plugin_load failed on sasl_auxprop_plug_init for plugin: sql
Aug 28 19:32:08 server lsmcd[43899]: auxpropfunc error invalid parameter supplied
Aug 28 19:32:08 server lsmcd[43899]: _sasl_plugin_load failed on sasl_auxprop_plug_init for plugin: ldapdb
Aug 28 19:32:08 server lsmcd[43899]: ldapdb_canonuser_plug_init() failed in sasl_canonuser_add_plugin(): invalid parameter supplied
Aug 28 19:32:08 server lsmcd[43899]: _sasl_plugin_load failed on sasl_canonuser_init for plugin: ldapdb
Aug 28 19:32:09 server lsmcd[43880]: start lsmcd                                 [        OK        ]
Aug 28 19:32:09 server systemd[1]: Started LSB: lsmcd.
[root@server ~]# ps aux | grep lsmcd
root     43899  0.0  0.0 198188  4112 ?        S    19:32   0:00 /usr/local/lsmcd/bin/lsmcd -f /usr/local/lsmcd/conf/node.conf
nobody   43901  0.0  0.0 198188  1696 ?        S    19:32   0:00 /usr/local/lsmcd/bin/lsmcd
nobody   43902  0.0  0.0 198188  1696 ?        S    19:32   0:00 /usr/local/lsmcd/bin/lsmcd
nobody   43903  0.0  0.0 198188  1696 ?        S    19:32   0:00 /usr/local/lsmcd/bin/lsmcd
nobody   43904  0.0  0.0 198188  1696 ?        S    19:32   0:00 /usr/local/lsmcd/bin/lsmcd
nobody   43905  0.0  0.0 198188  1692 ?        S    19:32   0:00 /usr/local/lsmcd/bin/lsmcd
root     47441  0.0  0.0 112808   976 pts/0    S+   19:53   0:00 grep --color=auto lsmcd