01 July 2020

auto mount smb folder on boot

1- manual mount:

sudo mount -t cifs -o username=pakAbu,password=takselamat //1.1.1.1/sharefolder  /mnt/mount_disini/



2- mount on boot

/etc/fstab:

//1.1.1.1/sharefolder /mnt/mount_disini cifs username=pakAbu,password=takselamat 0 0



3- use third file to store credential

/etc/mywinlogin.txt:
username=pakAbu
password=takselamat
domain=WORKGROUP

/etc/fstab:
//1.1.1.1/sharefolder /mnt/mount_disini cifs credential=/etc/mywinlogin.txt 0 0


This will make folder /mnt/mount_disini own by user root, and group root.


4- to change mount dir to normal user
//1.1.1.1/sharefolder /mnt/mount_disini cifs credential=/etc/mywinlogin.txt,uid=1001,guid=1001 0 0

Notice parameter uid and gid. uid number refer to /etc/passwd. gid refer to /etc/group


07 June 2020

ssh legacy option

some older ssh server only support limited key exchange algorithm.

When you get this error:
no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1


Use this option :
-oKexAlgorithms=+diffie-hellman-group1-sha1


eg:
ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 user@legacyhost


or put this in your .ssh/config file:
Host myhost.example.org
 KexAlgorithms +diffie-hellman-group1-sha1






18 May 2020

elastic: how many shard should I have

settings": {
    "index": {
      "number_of_shards": "1",
      "number_of_replicas": "1",


number _of_shard: how many shard per index
number_of_replicas: how many clone for each shard



#notes to have different index for each day, might be too much(max shard per ES node is 1000.)
You should try separate the index per month, (and increase number_of_shards).

How much is too many shard? Basically number of shard is ~ number of total CPU core across your cluster.(or you might one to double it if you have Hyper-Threading). More than this, it might not help you to go any quicker in searching data.

#some say it would be ok if your shard size between 2GB - 8GB


ref:  https://qbox.io/blog/optimizing-elasticsearch-how-many-shards-per-index

17 May 2020

filebeat -> logstash -> rabbitmq - > logstash -> elastic

1) filebeat - logstash
  normal case, you can google it

2) logstash - rabbitmq
  https://stackoverflow.com/questions/23207812/logstash-rabbitmq-output-never-posts-to-exchange
output { 
   rabbitmq {
      codec => plain
      host => localhost
      exchange => yomtvraps
      exchange_type => direct
      key => yomtvraps

      # these are defaults but you never know...
      durable => true
      port => 5672
      user => "guest"
      password => "guest"
   }
}



3) rabbitmq -logstash
  https://discuss.elastic.co/t/rabbitmq-as-logstash-input/95756
input { rabbitmq { host => "localhost" port => 15672 heartbeat => 30 durable => true exchange => "logging_queue" exchange_type => "logging_queue" } } output { elasticsearch { hosts => "localhost:9200" } stdout {} }




4) logstash - elastic
   normal case, please google

good tmux tutorial for beginner

https://www.hamvocke.com/blog/a-quick-and-easy-guide-to-tmux/


https://linuxize.com/post/getting-started-with-tmux/

Below are some most common commands for managing Tmux windows and panes:
  • Ctrl+b c Create a new window (with shell)
  • Ctrl+b w Choose window from a list
  • Ctrl+b 0 Switch to window 0 (by number )
  • Ctrl+b , Rename the current window
  • Ctrl+b % Split current pane horizontally into two panes
  • Ctrl+b " Split current pane vertically into two panes
  • Ctrl+b o Go to the next pane
  • Ctrl+b ; Toggle between the current and previous pane
  • Ctrl+b x Close the current pane

16 May 2020

elastic roles privileges



To write/ingest indices,  user must have role with:
- cluster: "manage_index_templates", "monitor", "manage_ilm"
- indices privileges: "write","create","delete","create_index","manage","manage_ilm"



To read the indices, minumum priveleges:
- "read","view_index_metadata"