Skip to content

Instantly share code, notes, and snippets.

View denzhel's full-sized avatar
🇺🇦

Dennis Zheleznyak denzhel

🇺🇦
View GitHub Profile
@denzhel
denzhel / extend_lvm.md
Last active January 21, 2021 21:31
Linux: extend LV after increase the disk size

To extend a logical volume after increasing the disk size, lets say AWS EBS:

sudo pvresize /dev/sdb
sudo lvextend -l +100%FREE /dev/vgName/lvName
sudo resize2fs /dev/vgName/lvName
@denzhel
denzhel / ssh_key_aws.md
Created January 22, 2021 02:26
Upload SSH public key to AWS SecretManager

To create a ssh key:

ssh-keygen -f ~/.ssh/keyName_rsa -t rsa -b 4096

Then, upload it to AWS Secret Manager to be used as Terraform key_name when creating instances for example:

aws secretsmanager create-secret --name "Path/To/KeyName" --description "Added Manually" --secret-string "$(cat ~/.ssh/keyName_rsa.pub)"
@denzhel
denzhel / elastic_blocked_index.md
Last active January 22, 2021 23:07 — forked from hkulekci/solve.md
Elasticsearch "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)" error

If you are getting the following error while indexing:

{
  "error": {
    "root_cause": [
      {
        "type": "cluster_block_exception",
        "reason": "blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"
      }
@denzhel
denzhel / es_disk_usage.md
Created January 22, 2021 22:32
elasticsearch node disk usage

To get information about disk usage on every elasticsearch node:

curl -XGET "http://localhost:9200/_cat/allocation?v&pretty"
@denzhel
denzhel / mongo_shell_collections.md
Last active January 26, 2021 18:50
Show collections for the specific database

To show all collections for the specific database:

mongo <dbName> --quiet --eval "db.getCollectionNames().join('\n')”
@denzhel
denzhel / kubernetes_pods_nodes_location.md
Created January 24, 2021 09:05
Where my pods are running

If you want to know on which nodes your pods are running, use this alias:

konode='k get pod -o=custom-columns=NAME:.metadata.name,STATUS:.status.phase,NODE:.spec.nodeName'
@denzhel
denzhel / es_download_docs_from_index.md
Last active January 26, 2021 13:15
Elasticsearch download all documents from an index

To download all documents from an index, first you need to create a search ID:

curl -X POST "localhost:9200/<indexName>/_search?scroll=5m&pretty&size=10000"

This will keep a search session for 5 minutes

Then, send another query to scroll through the pages of data until there is no more:

curl -X GET "localhost:9200/_search/scroll?pretty&scroll=5m&scroll_id=<searchIdFromThePreviousStep>"
@denzhel
denzhel / mongo_export_collections.md
Last active January 26, 2021 21:32
Export all collections from a database

If you want to export specific collections from a specific database, you can use this bash loop:

for collection in \ 
$(mongo <databaseName> --quiet --eval "rs.slaveOk(); db.getCollectionNames().join('\n')" | grep <collectionPrefix) ; \
do mongoexport --collection=$collection --db=<databaseName> --out=$collection ; \
done
@denzhel
denzhel / elasticsearch_disk_usage.md
Created January 28, 2021 06:26
Query elasticsearch cluster for disk usage

Use this to query the disk usage of your elasticsearch cluster:

curl -XGET "http://localhost:9200/_cat/allocation?v&pretty"

Output:

shards disk.indices disk.used disk.avail disk.total disk.percent host          ip            node
  3213      460.2gb   584.9gb      1.3tb      1.9tb           29 1.1.1.1       1.1.1.1       host1.example.com
  3213      479.5gb   599.3gb      1.3tb      1.9tb           29 1.1.1.2       1.1.1.2       host2.example.com
@denzhel
denzhel / git_show_commits_file.md
Last active January 28, 2021 06:28
Show all commits that changed a file

If you want to know when and who changed a specific file in your Github repo:

git log --follow -- <fileName>