Redis Data Bulk Import Export
One way to do this is to export and import Redis data from one server to a new server in a work-redis-dump tool, but he needs to install a ruby environment, and there may be unexpected errors in the installation environment. So I have to choose another way. A few ideas for reference.
1, data export, do not write themselves, and do not use third-party scripts,
echo "Hgetall xxx" | Redis-cli-h localhost-p 6379
echo "Hgetall xxx" | Redis-cli-h localhost-p 6379 >> Wordlist.raw
2. As a result, you can view the Wordlist.raw file on the server
3. Organize the file format to enter
$f = ' xx.oo ';
$lines = 0;
$inkey = 0;
$rawfile = ' xx.oo ';
$hashkey = ' xx ';
$buff = ';
$fp = fopen ($rawfile, ' W ');
$fps = fopen ($f, ' R ');
while ($line = fgets ($fps)) {
$inkey =! $inkey;
if ($inkey) {
$f = ' Bayes_wordlist.raw ';
$lines = 0;
$inkey = 0;
$rawfile = ' Bayes_wordlist.3.raw ';
$hashkey = ' bayes_wordlist ';
$buff = ';
$fp = fopen ($rawfile, ' W ');
$fps = fopen ($f, ' R ');
while ($line = fgets ($fps)) {
$inkey =! $inkey;
if ($inkey) {
$line = sprintf ('%s ', trim ($line));
$buff = "Hset $hashkey". Trim ($line);
else
{
$buff. = ' "'. Trim ($line).
Fwrite ($FP, $buff. " \ r \ n ");
}
}
$buff = "Hset $hashkey". Trim ($line);
else
{
$buff. = ' "'. Trim ($line).
Fwrite ($FP, $buff. " \ r \ n ");
}
}
If you choose which library to write to select X on the first line
4. Using REDIS-CLI to import
echo ' Date ' > Pipe.log && cat xx.oo | REDIS-CLI >> pipe.log && echo ' Date ' >> pipe.log
5. Add a time record, and record the results of the import, the actual execution of the import statement is
Cat Wordlist.raw | REDIS-CLI, of course, more rigorous words redis-cli after also add-H localhost-p 6379 parameters.