i working on centos 6. want perform mass insertion redis cache mysql table has more 10 million records. have read redis protocol , format. able copy table data redis protocol format in text file. when try execute pipe command error coming.
error reading server: connection reset peer
or
err protocol error: expected '$', got '3'
i using following command:
cat insert.txt | redis-cli --pipe
insert.txt contains data in format:
*3 $3 set $2 k1 $2 v1
if possible,please tell me format multiple commands in text file in above example, file contains 1 set command. thankful if give me example of text file has @ least 2 commands in it.
i have tried file data in format.
"*3\r\n$3\r\nset\r\n$3\r\nkey\r\n$5\r\nvalue\r\n"
it gives following error:
err unknown command '*3 $3 set $3 key $5 value '
right, it's important send data crlf
line separators -- not string \r\n
characters. means no regular unix line endings, lf
, or \n
.
how insert depending on editor use, easiest way work have have each symbol on it's own line:
*3 $3 set $2 k1 $2 v2
and use sed
:
cat insert.txt | sed 's/$/\r/g' | redis-cli --pipe
should trick.
then, in order send many commands in 1 go (pipelining), add end of file, so:
*3 $3 set $2 k1 $2 v2 *3 $3 set $2 k2 $2 v3
Comments
Post a Comment