Need help. Redis works like a turtle with centos swap - redis

Need help. Redis works like a turtle with centos 7 swap.
I create swap in centos 7:
sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB;
sudo chmod 600 /swapfile;
sudo mkswap /swapfile;
sudo swapon /swapfile;
sudo echo "/swapfile swap swap sw 0 0" >> /etc/fstab;
Install Redis:
yum -y install epel-release;
yum -y install redis;
systemctl enable redis;
When my redis db became more than 380 MB (380 mb is a ram limit on my VPS) redis began to work like a turtle. Because of swap.
Is any way to store all db values and keys in a base file, and use for example 64Mb of ram not swap. Without keys delete.
(P.S Sorry for my English I am from Ukraine)

Related

error while restoring dump.rdb

i had a backup from dump.rdb database in my last server and i just copied it with scp command to new server and i restore it like this :
service redis-server stop
cp -r /root/dump.rdb/ /var/lib/redis/
cd /var/lib/redis && chown redis:redis dump.rdb
service redis-server start
but after using the last command i got this error :
Job for redis-server.service failed because a configured resource limit was exceeded. See "systemctl status redis-server.service" and "journalctl -xe" for details.
as i know it maybe from redis version but i dont know what version is my Dump.rdb is for .
do you have any solution for this ?
at least i found this out that my redis version was lower than Database's Saved redis version .
you can load the lower redis databases on high versions but you can't lost higher versions in lower versions .
and when i use sudo apt-get install redis-server it just installs the lower versions of redis which is commited in ubuntu community .
so i installed the new one with the commands :
wget redis-4.0.8.tar.gz
tar -xzf redis-4.0.8.tar.gz
cd redis-4.0.8
make
make install
make test
then i have to edit redis.conf like this :
nano redis.conf
i set the database name like this :
dbfilename dump.rdb
and at least i set the database directory :
dir /var/lib/redis/
then press CTRL + X then Y then ENTER .
then use these commands :
cd src
redis-server
now just close the terminal without anything .
now reconnect and test :
redis-cli get PING
it have to treat like this :
127.0.0.1:6379> "PONG"

Redis installed on FreeBSD via pkg or ports can not run

I had installed redis on FreeBSD via pkg yesterday.And also add redis_enable="YES"in my /etc/rc.conf.
When I run service redis start,It displays Starting redis,but when run service redis status,displays redis is not running.
After run redis-server,It runs,but use redis-cli cannot connect the server.
When run redis-cli or redis-cli ping,it will jammed with no error.
The redis log file also has no error.
I cannot find the solution with google or others。How should I do to use redis?
The same with installed redis via ports
The followings are the base information about my company:
FreeBSD version: 10.3-RELEASE-p18
Pkg version: 1.10.1
Redis version: 3.29
I would suggest to update, reinstall by doing this:
# pkg update
then:
# pkg upgrade -y
To reinstall redis:
# pkg remove -y redis
To install it again:
# pkg install -y redis
At this point you should see this in the terminal:
===> CONFIGURATION NOTE:
To setup "redis" you need to edit the configuration file:
/usr/local/etc/redis.conf
To run redis from startup, add redis_enable="YES"
in your /etc/rc.conf.
To ensure redis is enabled on startup use sysrc
# sysrc redis_enable="YES"
Not this time try to starting calling the script directly:
# /usr/local/etc/rc.d/redis start
You could use sockstat to check if is up and listenin:
# sockstat -4l
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
redis redis-serv 9553 4 tcp4 127.0.0.1:6379 *:*
After this, redis-cli, or telnet 0 6379 should be working:
# telnet 0 6379
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
If that still not working, maybe ktrace can help to find more details:
To trace a PID:
$ ktrace -p 9553
To stop tracing:
# ktrace -C
use kdump to display kernel trace data
# kdump -f my-ktrace.out | less
The first thing to do on BSD when a command "hungs" is to press ^T (ie ctrl-t). Can you do that and paste the output?

how to perform precopy memory migration in LXC /LXD so that I can perform live migration from one host to another

how to perform precopy memory migration in LXC /LXD so that I can perform live migration from one host to another?How do I set to precopy migration in CRIU?
The Pre-copy memory migration for Live migration with CRUI
Live Migration of Linux Containers between hosts (there is migration script), LXC and CRUI:
You should have built and installed a recent (>= 1.3.1) version of
CRIU.
LXC upstream has begun to integrate checkpoint/restore support through
the lxc-checkpoint tool. This functionality has been in the recent
released version of LXC---LXC 1.1.0 , you can install the LXC 1.1.0 or
you can check out the development version on Ubuntu by doing:
sudo add-apt-repository ppa:ubuntu-lxc/daily
sudo apt-get update
sudo apt-get install lxc
And add the following lines (as above) to LXC container config:
cat | sudo tee -a /var/lib/lxc/u1/config << EOF
# hax for criu
lxc.console = none
lxc.tty = 0
lxc.cgroup.devices.deny = c 5:1 rwm
EOF
checkpoint the container:
lxc-checkpoint -s -D /tmp/checkpoint -n u1
At this point, the container's state is stored in /tmp/checkpoint, and the filesystem is in /var/lib/lxc/u1/rootfs. You can restore the container by doing:
lxc-checkpoint -r -D /tmp/checkpoint -n u1
PS:
You can do live migration for processes:
Dump
Take tasks you're about to migrate and dump them into some place, asking criu to leave them in stopped state after dump:
criu dump --tree <pid> --images-dir <path-to-existing-directory> --leave-stopped
The directory you put images to can reside on the shared file-system if you're using one. In this case you can skip the Copy step and proceed to Restore.
Copy
Copy images to destination node:
scp -r <path-to-images-dir> <dst>:/<path-to-images>
Restore
Go to the destination node and restore the apps from images on it:
criu restore --tree <pid> --images-dir <path-to-images>

redis-server in ubuntu14.04: Bind address already in use

I started redis server on ubuntu by typing this on terminal: $redis-server
This results in following > http://paste.ubuntu.com/12688632/
aruns ~ $ redis-server
27851:C 05 Oct 15:16:17.955 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
27851:M 05 Oct 15:16:17.957 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
27851:M 05 Oct 15:16:17.957 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
27851:M 05 Oct 15:16:17.958 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
27851:M 05 Oct 15:16:17.958 # Creating Server TCP listening socket *:6379: bind: Address already in use
How can I fix this problem, it there any manual or automated process to fix this binding.
$ ps aux | grep redis
Find the port that its running on.. In my case..
MyUser 8821 0.0 0.0 2459704 596 ?? S 4:54PM 0:03.40 redis-server *:6379
And then close the port manually
$ kill -9 8821
Re-run redis
$ redis-server
sudo service redis-server stop
I solved this problem on Mac by just typing redis-cli shutdown, after this just
re open the terminal and type redis-server and it will work .
for me, after lots of problems, this solved my issue:
root#2c2379a99b47:/home/ ps -aux | grep redis
redis 3044 0.0 0.0 37000 8780 ? Ssl 14:59 0:00 /usr/bin/redis-server *:6379
after finding redis, kill it!
root#2c2379a99b47:/home# sudo kill -9 3044
root#2c2379a99b47:/homek# sudo service redis-server restart
Stopping redis-server: redis-server.
Starting redis-server: redis-server.
root#2c2379a99b47:/home# sudo service redis-server status
redis-server is running
So as it says, the process is already running so the best to do is to stop it, analyse and restart it and todo so here are the following commands :
redis-cli ping #should return 'PONG'
And this solved my issue:
$ ps -ef |grep redis
root 6622 4836 0 11:07 pts/0 00:00:00 grep redis
redis 6632 1 0 Jun23 ? 04:21:50 /usr/bin/redis-server *:6379
Locate redis process, and stop it!
$ kill -9 6632
$ service redis restart
Stopping redis-server: [ OK ]
Starting redis-server: [ OK ]
$ service redis status
Otherwise if all this doesn't work just try to type redis-cli
Hope it helps :)
This works for me:
$ killall redis-server
And combining everything in one line:
$ killall redis-server; redis-server
I read the documentation on http://www.redis.io , I opened the redis.conf file to configure the redis-server, its located at /etc/redis/redis.conf
$ sudo subl /etc/redis/redis.conf
Instead of sublime editor you can use editor of your choice, viz. nano, vi, emacs, vim, gedit.
In this file I uncommented the #bind 127.0.0.1 line. Hence, instead of 0.0.0.0:6379 now its 127.0.0.1:6379
Restart the redis server
$ sudo service redis-server restart
It will state, The server is now ready to accept connections on port 6379
This will put your server up, For any more detailed configuration and settings you can follow this redis-server on ubuntu
I prefer to use the command param -ef,
ps -ef|grep redis
the -efmeans
-A Display information about other users' processes, including those
without controlling terminals.
-e Identical to -A.
-f Display the uid, pid, parent pid, recent CPU usage, process start
time, controlling tty, elapsed CPU usage, and the associated com-
mand. If the -u option is also used, display the user name
rather then the numeric uid. When -o or -O is used to add to the
display following -f, the command field is not truncated as se-
verely as it is in other formats.
then kill the pid
kill -9 $pid
You may try
$ make
then
$ sudo cp src/redis-cli /usr/local/bin/ on terminal to install the redis and it's redis-cli command.
finally, you can use the redis-cli shutdown command. Hope this answer could help you.
Killing the process that was running after booting in the OS worked for me. To prevent redis from starting at startup in Ubuntu OS:
sudo systemctl disable redis-server
In my case, I tried several times to kill the port manually and didn't work. So I took the easy path, reinstallation and worked like charm after that. If you're in Debian/Ubuntu:
sudo apt remove redis-server // No purge needed
sudo apt update
sudo apt install redis-server // Install once again
sudo systemctl status redis-server // Check status of the service
redis-server // initializes redis
Not the most technical-wise path, but nothing else worked.
It may also happen if you installed Redis via snap and are trying to run it from somewhere else.
If this is the case, you can stop the service via sudo snap stop redis.
I'm not sure, but when I first time installed redis and faced this message, turned out that's due to the redis-server first of all takes configure parameters or path/to/redis.conf, so when I passed nothing after "redis-server" it was trying to execute default redis.conf (bind 127.0.0.1, port 6379 ...) thereby overwrite the existing default redis.conf (which contains same "bind" and "port"!!). That's why I've seen this error, but it's possibly you have another reasons
The problem shows that the default port that redis uses 6379is already in use by some other process.
So simply change the port of redis server
redis-server --port 7000 will start a Redis server using port number 7000.
and then
redis-cli -p 7000 - Now use this to make your client listen at this port.

How to use Couchbase 3.0+ for tests in Travis

I need to know how to make couchbase 3.0.+ work in a Travis context.
I have been able to start a Couchbase 2.0 on a Travis context but the 3.0.+ does not seem to actually start (the service daemon on linux says it is started but netstat does not find the web console on port 8091 but the bucket interface is running on 8092, the java-sdk cannot use it).
Here is the script I have tried using in my .travis.yml
before_install:
- sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1204.list
- sudo wget http://packages.couchbase.com/ubuntu/couchbase.key && sudo cat couchbase.key
| sudo apt-key add -
- sudo apt-get update
- sudo apt-get install libcouchbase2 libcouchbase-dev
- sudo wget http://packages.couchbase.com/releases/3.0.2/couchbase-server-enterprise_3.0.2-ubuntu12.04_amd64.deb
- sudo dpkg -i couchbase-server-enterprise_3.0.2-ubuntu12.04_amd64.deb
- sudo service couchbase-server restart
- /opt/couchbase/bin/couchbase-cli cluster-init -c 127.0.0.1:8091 --cluster-username=Administrator --cluster-password=password --cluster-ramsize=512
PS: I know Travis instances are only 3GB but the couchbase doc do mention that it can run on 1GB ... I have not been able to find instructions on how to achieve that.