I've set a password for my Redis server and when I try to restart the Redis server with sudo service redis_6379 restart then I get the following error message:
NOAUTH Authentication required.
How can I pass my password through the restart command?
The Redis version is 3.0.3.
You could modify your init.d/redis_6379 script and use the -a parameter of redis-cli to specify the password:
CLIEXEC="/usr/local/bin/redis-cli -a your_secret"
redis-cli connect to your server and authenticate yourself.
$ redis-cli -a serverpassword
$ shutdown
$ quit
Related
This is my first time asking here.
Can anyone help me how to enable the Redis API in ScyllaDB?
I can't find anything about enabling the Redis API.
Also where/how should I set the redis_port is it in the scylla.yaml?
Thank you in advance :)
Add
redis_port: 6379
somewhere in scylla.yaml
more here
http://scylla.docs.scylladb.com/master/design-notes/protocols.html#redis-client-protocol
The config option code:
https://github.com/scylladb/scylla/blob/master/db/config.cc#L789
Adding info on how to use Redis API with Scylla Docker:
run Scylla Docker with mapped Redis port
docker run -p 6379:6379 --name some-scylla -d scylladb/scylla --smp 1 --memory 750M --overprovisioned 1
update the scylla.yaml
docker exec -it some-scylla bash
vi /etc/scylla/scylla.yaml (add redis_port: 6379)
supervisorctl restart scylla
from the host server you can now use
redis-cli
127.0.0.1:6379> ping
PONG
I am using elastic cache single node shard redis 4.0 later version.
I enabled In-Transit Encryption and gave redis auth token.
I created one bastion host with stunnal using this link
https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-connect-redis-node/
I am able to connect to elastic cache redis node using following way
redis-cli -h hostname -p 6379 -a mypassword
and i can do telnet also.
BUT
when I ping (expected response "PONG") on redis-cli after connection it is giving
"Error: Connection reset by peer "
I checked security group of both side.
Any idea ?
Bastion Host ubuntu 16.04 machine
As I mentioned in question, I was running the command like this:
redis-cli -h hostname -p 6379 -a mypassword
The correct way to connect into a ElastiCache cluster through stunnel should be using "localhost" as the host address,like this:
redis-cli -h localhost -p 6379 -a mypassword
There is explanation for using the localhost address:
when you create a tunnel between your bastion server and the ElastiCache host through stunnel, the program will start a service that listen to a local TCP port (6379), encapsulate the communication using the SSL protocol and transfer the data between the local server and the remote host.
you need to start the stunnel, check if the service is listening on the localhost address (127.0.0.1), and connect using the "localhost" as the destination address: "
Start stunnel. (Make sure you have installed stunnel using this link https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-connect-redis-node/)
$ sudo stunnel /etc/stunnel/redis-cli.conf
Use the netstat command to confirm that the tunnels have started:
$ netstat -tulnp | grep -i stunnel
You can now use the redis-cli to connect to the encrypted Redis node using the local endpoint of the tunnel:
$redis-cli -h localhost -p 6379 -a MySecretPassword
localhost:6379>set foo "bar"
OK
localhost:6379>get foo
"bar"
Most probably ElastiCache Redis Instance is using Encryption in-transit and Encryption at-rest and by design, the Redis CLI is not compatible with the encryption.
You need to setup stunnel to connect redis cluster
https://datanextsolutions.com/blog/how-to-fix-redis-cli-error-connection-reset-by-peer/
"Error: Connection reset by peer" indicates that Redis is killing your connection without sending any response.
One possible cause is you are trying to connect to the Redis node without using SSL, as your connection will get rejected by the Redis server without a response [1]. Make sure you are connecting through the correct port in your tunnel proxy. If you are connecting directly from the bastion host, you should be using local host.
Another option is that you have incorrectly configured your stunnel to not include a version of SSL that is supported by Redis. You should double check the config file is exactly the same as the one provided in the support doc.
It that doesn't solve your problem, you can try to build the cli included in AWS open source contribution.[2] You'll need to check out the repository, follow the instructions in the readme, and then do make BUILD_SSL=yes make redis-cli.
[1] https://github.com/madolson/redis/blob/unstable/src/ssl.c#L464
[2] https://github.com/madolson/redis/blob/unstable/SSL_README.md
I have URL and PORT of remote Redis server. I am able to write into Redis from Scala. However I want to connect to remote Redis via terminal using redis-server or something similar in order to make several call of hget, get, etc. (I can do it with my locally installed Redis without any problem).
redis-cli -h XXX.XXX.XXX.XXX -p YYYY
xxx.xxx.xxx.xxx is the IP address and yyyy is the port
EXAMPLE from my dev environment
redis-cli -h 10.144.62.3 -p 30000
REDIS CLI COMMANDS
Host, port, password and database By default redis-cli connects to the
server at 127.0.0.1 port 6379. As you can guess, you can easily change
this using command line options. To specify a different host name or
an IP address, use -h. In order to set a different port, use -p.
redis-cli -h redis15.localnet.org -p 6390 ping
There are two ways to connect remote redis server using redis-cli:
1. Using host & port individually as options in command
redis-cli -h host -p port
If your instance is password protected
redis-cli -h host -p port -a password
e.g. if my-web.cache.amazonaws.com is the host url and 6379 is the port
Then this will be the command:
redis-cli -h my-web.cache.amazonaws.com -p 6379
if 92.101.91.8 is the host IP address and 6379 is the port:
redis-cli -h 92.101.91.8 -p 6379
command if the instance is protected with password pass123:
redis-cli -h my-web.cache.amazonaws.com -p 6379 -a pass123
2. Using single uri option in command
redis-cli -u redis://password#host:port
command in a single uri form with username & password
redis-cli -u redis://username:password#host:port
e.g. for the same above host - port configuration command would be
redis-cli -u redis://pass123#my-web.cache.amazonaws.com:6379
command if username is also provided user123
redis-cli -u redis://user123:pass123#my-web.cache.amazonaws.com:6379
This detailed answer was for those who wants to check all options.
For more information check documentation: Redis command line usage
In Case of password also we need to pass one more parameter
redis-cli -h host -p port -a password
One thing that confused me a little bit with this command is that if redis-cli fails to connect using the passed connection string it will still put you in the redis-cli shell, i.e:
redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected>
You'll then need to exit to get yourself out of the shell. I wasn't paying much attention here and kept passing in new redis-cli commands wondering why the command wasn't using my passed connection string.
if you got Error: Server closed the connection
try with --tls switch:
redis-cli --tls -h my-redis.redis.cache.windows.net -p 6379 -a myRedisPassword
h 👉 hostname
p 👉 port
a 👉 password
I am using redis 2.4 . When I change the port in "redis.conf" file to another port redis-cli stops working. It shows
Could not connect to Redis at 127.0.0.1:6379: Unknown error not
connected>
The redis.conf file dictates the server's behavior. To tell the command line interface to connect to your newly-defined-non-default port, use the -p switch, e.g.:
$ redis-cli -p 12758
I have a Redis Service running inside a docker container but when connecting to it the cursor is not returned.
When using redis-cli the terminal just hangs with issuing commands, I hope someone can point out where I'm going wrong.
Instead of seeing regular redis-cli output like:
% redis-cli
redis 127.0.0.1:6379> set docker awesome
OK
redis 127.0.0.1:6379> get docker
"awesome"
redis 127.0.0.1:6379>
This is what I am seeing:
% redis-cli -p 49156
redis 127.0.0.1:49156> set docker awesome
There's no "OK" and the terminal just hangs until I Ctrl-C it.
I'm following the docker.io instructions from http://docs.docker.io/en/latest/examples/running_redis_service/
Here's my Dockerfile:
FROM ubuntu:12.10
RUN apt-get update
RUN apt-get -y install redis-server
EXPOSE 6379
ENTRYPOINT ["/usr/bin/redis-server"]
I build the image with:
sudo docker build -t rudijs/redis .
I run an instance of the image with:
sudo docker run -d -p 6379 -name redis rudijs/redis
% sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3888fa49b605 rudijs/redis:latest /usr/bin/redis-serve 5 seconds ago Up 4 seconds 0.0.0.0:49156->6379/tcp redis
The exposed container redis port is at:
% sudo docker port redis 6379
0.0.0.0:49156
% redis-cli -p 49156
redis 127.0.0.1:49156> set docker awesome
I've tried tinkering with different port bindings from the container to the host but the result is always the same - cli hang.
Issuing command like "help" seem to work fine
% redis-cli -p 49156
redis 127.0.0.1:49156> help
redis-cli 2.2.12
Type: "help #<group>" to get a list of commands in <group>
"help <command>" for help on <command>
"help <tab>" to get a list of possible help topics
"quit" to exit
redis 127.0.0.1:49156>
If I just let it sit I get a timeout:
% redis-cli -p 49156
redis 127.0.0.1:49156> set docker awesome
Error: Connection reset by peer
(248.52s)
redis 127.0.0.1:49156>
Any advice or tips with this problem much appreciated.
Thanks!
The fix for this was Firehol (iptables) rules were needed:
interface docker0 interface1 src "172.17.0.0/16" dst 172.17.42.1
server all accept
client all accept