Tuesday, November 5, 2019

How to increase Elasticsearch Shard recovery Speed

To Increase Shard recovery speed do this:


Increase node recovery speed


PUT http://es:9200/_cluster/settings

{
"persistent" : {
"indices.recovery.max_bytes_per_sec": "200mb",
"indices.recovery.max_concurrent_file_chunks": 5,
"cluster.routing.allocation.node_concurrent_recoveries" : 5
}
}


Links:

https://www.elastic.co/guide/en/elasticsearch/reference/current/shards-allocation.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/recovery.html


Wednesday, January 23, 2019

Shell Script to SSH into servers

This is a simple script that can ssh into a server by typing the password for you.

Filename: login
#!/usr/bin/expect
eval spawn ssh username@servername
expect "assword:"
send "server_password\r"
interact

# to run the script
# ./login
In this below script you can pass arguments to the shell script
Filename: login
#!/usr/bin/expect
set num [lindex $argv 0];
eval spawn ssh username@servername-$num
expect "assword:"
send "server_password\r"
interact

# make sure to give executable permission to script.

chmod +x login

# to run the script and login to server-01.

./login 01

Now add the script path to your .bashrc file as alias, so that you can access this script from any path.


# vi ~/.bashrc

alias login='/path/to/script/file/login'


After updating the .bashrc file, you will have to source.
source ~/.bashrc


Now call the script from anywhere in your shell.
login 01

Enjoy!!!