redis create cluster failed,what's the problem - redis

redis5 create cluster,use the command
redis-cli --cluster create ip1:port1 ip2:port2 ... ip6:port6 -cipherdir ../cipher/ -a password --cluster-replicas 1
and get "ERR the handshake failed".
the redis password is correct,and matsernode can login in other nodes.

Related

Redis Monitor mode with authentication

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.

How to delete everything in a redis cluster?

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

How to connect to remote Redis server?

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

How to start and stop redis service with authentication?

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

calling spark-ec2 from within an EC2 instance: ssh connection to host refused

In order to run Amplab's training exercises, I've create a keypair on us-east-1 , have installed the training scripts (git clone git://github.com/amplab/training-scripts.git -b ampcamp4) and created the env. variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY following the instructions in http://ampcamp.berkeley.edu/big-data-mini-course/launching-a-bdas-cluster-on-ec2.html
Now running
./spark-ec2 -i ~/.ssh/myspark.pem -r us-east-1 -k myspark --copy launch try1
generates the following messages:
johndoe#ip-some-instance:~/projects/spark/training-scripts$ ./spark-ec2 -i ~/.ssh/myspark.pem -r us-east-1 -k myspark --copy launch try1
Setting up security groups...
Searching for existing cluster try1...
Latest Spark AMI: ami-19474270
Launching instances...
Launched 5 slaves in us-east-1b, regid = r-0c5e5ee3
Launched master in us-east-1b, regid = r-316060de
Waiting for instances to start up...
Waiting 120 more seconds...
Copying SSH key /home/johndoe/.ssh/myspark.pem to master...
ssh: connect to host ec2-54-90-57-174.compute-1.amazonaws.com port 22: Connection refused
Error connecting to host Command 'ssh -t -o StrictHostKeyChecking=no -i /home/johndoe/.ssh/myspark.pem root#ec2-54-90-57-174.compute-1.amazonaws.com 'mkdir -p ~/.ssh'' returned non-zero exit status 255, sleeping 30
ssh: connect to host ec2-54-90-57-174.compute-1.amazonaws.com port 22: Connection refused
Error connecting to host Command 'ssh -t -o StrictHostKeyChecking=no -i /home/johndoe/.ssh/myspark.pem root#ec2-54-90-57-174.compute-1.amazonaws.com 'mkdir -p ~/.ssh'' returned non-zero exit status 255, sleeping 30
...
...
subprocess.CalledProcessError: Command 'ssh -t -o StrictHostKeyChecking=no -i /home/johndoe/.ssh/myspark.pem root#ec2-54-90-57-174.compute-1.amazonaws.com '/root/spark/bin/stop-all.sh'' returned non-zero exit status 127
where root#ec2-54-90-57-174.compute-1.amazonaws.com is the user & master instance. I've tried -u ec2-user and increasing -w all the way up to 600, but get the same error.
I can see the master and slave instances in us-east-1 when I log into the AWS console, and I can actually ssh into the Master instance from the 'local' ip-some-instance shell.
My understanding is that the spark-ec2 script takes care of defining the Master/Slave security groups (which ports are listened to and so on), and I shouldn't have to tweak these settings. This said, master and slaves all listen to post 22 (Port:22, Protocol:tcp, Source:0.0.0.0/0 in the ampcamp3-slaves/masters sec. groups).
I'm at a loss here, and would appreciate any pointers before I spend all my R&D funds on EC2 instances.... Thanks.
This is most likely caused by SSH taking a long time to start up on the instances, causing the 120 second timeout to expire before the machines could be logged into. You should be able to run
./spark-ec2 -i ~/.ssh/myspark.pem -r us-east-1 -k myspark --copy launch --resume try1
(with the --resume flag) to continue from where things left off without re-launching new instances. This issue will be fixed in Spark 1.2.0, where we have a new mechanism that intelligently checks the SSH status rather than relying on a fixed timeout. We're also addressing the root causes behind the long SSH startup delay by building new AMIs.