Redis monitor cmd is not working with authentication:
Cmd: redis-cli -h <redis_endpoint> -p <port> -n <database> -a <password> monitor
error: (error) ERR wrong number of arguments for 'MONITOR' command
But the same works with Redis without authentication:
redis-cli -h <redis_endpoint> -p 6379 monitor
Can someone help with correct redis-cli monitor cmd that works with database and password.
Related
My redis cluster is borked. One node seems to think it's a 3-node cluster with no replication, another node seems to think it's alone, and the third node agrees with the first. I want to have a 3-node cluster with 2 replicated nodes (no splitting).
I don't want to have to figure out how to un-bork my redis cluster, instead: I want to start over.
The existing question How do I delete everything in Redis? doesn't include clusters, for which everything is way more complicated.
Desired result: Clean installation. No cluster config.
Unfortunately simply reinstalling the whole program appears insufficient. How do I tell it to really --yes-I-am-really-sure forget everything about itself and all the other nodes it knows? In particular:
Remove all non-config-file-cluster-configuration.
The command CLUSTER FORGET gets me partway there, but nodes can't forget themselves? Why not? Anyway, somehow convincing them to do that might be enough.
The difficult part is in realizing these three things:
There's both redis-cli CLUSTER and redis-cli --cluster, and the cluster commands are randomly divided between the two.
When usingredis-cli --cluster for something involving two nodes, the -a password parameter must be provided twice, both before and after the --cluster part. The one provided after is for the target node, the one provided before is for the 'config' node.
Commands using redis CLUSTER only apply to one node, so must be repeated for each node. (They cannot access the other nodes)
Knowing this, we can proceed wiping the necessary things:
redis-cli -h host01 -a password CLUSTER NODES
prints a list of nodes with long identifiers. Proceed with
# forget about the other nodes in the cluster on each node
redis-cli -h host01 -a password1 CLUSTER FORGET <host02 key>
redis-cli -h host01 -a password1 CLUSTER FORGET <host03 key>
redis-cli -h host02 -a password2 CLUSTER FORGET <host01 key>
redis-cli -h host02 -a password2 CLUSTER FORGET <host03 key>
redis-cli -h host03 -a password3 CLUSTER FORGET <host01 key>
redis-cli -h host03 -a password3 CLUSTER FORGET <host02 key>
# flush all data so that the node can be reset
redis-cli -h host01 -a password1 FLUSHALL
redis-cli -h host02 -a password2 FLUSHALL
redis-cli -h host03 -a password3 FLUSHALL
# reset the node
redis-cli -h host01 -a password1 CLUSTER RESET
redis-cli -h host02 -a password2 CLUSTER RESET
redis-cli -h host03 -a password3 CLUSTER RESET
In my redis database, I'm trying to delete a series of keys that start with:
EPOCH_vgsOwnedVehs_
I have tried the following:
redis-cli -h 127.0.0.1 -p myport -a mypassword --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli unlink
and
redis-cli -h 127.0.0.1 -p myport -a mypassword --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli -h 127.0.0.1 -p myport -a mypassword unlink
But, I get the following error message:
'xargs' is not recognized as an internal or external command, operable program or batch file.
Could anyone help as to why xargs won't work in this case? I see that same syntax above being mentioned quite a few times here and seems to work for others...
EDIT: I forgot to mention that when I run the first half of the line before the pipe, it does return all the keys that match the criteria.
The following should do the work; (added an example print-out)
redis-cli -h 127.0.0.1 -p 6379 -a mypass --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli -h 127.0.0.1 -p 6379 -a mypass unlink
127.0.0.1:6379> config set requirepass mypass
OK
127.0.0.1:6379> auth mypass
OK
127.0.0.1:6379> set EPOCH_vgsOwnedVehs_a a
OK
127.0.0.1:6379> set EPOCH_vgsOwnedVehs_b a
OK
127.0.0.1:6379> set EPOCH_vgsOwnedVehs_c a
OK
127.0.0.1:6379> set EPOCH_vgsOwnedVehs_d a
OK
127.0.0.1:6379>
redis-cli -h 127.0.0.1 -p 6379 -a mypass --scan --pattern EPOCH_vgsOwnedVehs_* | xargs redis-cli -h 127.0.0.1 -p 6379 -a mypass unlink
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
(integer) 4
127.0.0.1:6379> auth mypass
OK
127.0.0.1:6379> exists EPOCH_vgsOwnedVehs_a
(integer) 0
xargs is a common Linux utility and the message you are seeing indicates you are using Windows. You have a couple of choices here to get this working - you can find a Windows alternative of xargs, use Cygwin, use Powershell, etc.
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
Read through https://redistogo.com/documentation/introduction_to_redis?language=en but couldn't get it to work.
redis-cli -h my-host -p 1234 -a mypassword
What is my-host?
How to see the database?
The web console seems to not display all the data. keys fails.
redis-cli -h returns "Could not connect to Redis"
On https://redistogo.com/heroku/resources/934839 where your app installs redistogo.
The following link is given:-
redis://redistogo:12340994131cb8c2f2402ffdsafds3333129#birdeye.redistogo.com:3244/
using this you type on console:-
redis-cli -h my-host -p 1234 -a mypassword
redis-cli -h birdeye.redistogo.com -p 3244 -a 12340994131cb8c2f2402ffdsafds3333129
and you will log onto console.
"My-host" is the hostname you get from Redis To Go.
I know if I do redis-cli -h {ip_address} -p {port} I can connect to a specific port/ip but I've set my instance to not listen to any tcp/ip ports instead it listens to local socket.
How can I establish a socket connection with the redis client?
You can connect from redis-cli or redis-benchmark simply by using the -s option and providing the path of your unix domain socket.
For instance:
redis-cli -s /tmp/redis.sock
redis-benchmark -q -n 10000 -s /tmp/redis.sock