Skip to content

Instantly share code, notes, and snippets.

View tankhuu's full-sized avatar

Tan Khuu tankhuu

  • Ho Chi Minh, Viet Nam
View GitHub Profile
@tankhuu
tankhuu / IssuesAndSolutions.txt
Last active September 17, 2017 10:44
Ubuntu 16.04 - Build Elasticsearch Site with Google authentication and authorization by Openresty-Nginx Lua Script
# Issue 1 - lua script variable convention
2017/09/16 03:37:40 [error] 28233#28233: *3524 failed to load external Lua file "/usr/local/openresty/nginx/conf/elasticsearch/authorize.lua": /usr/local/openresty/nginx/conf/elasticsearch/authorize.lua:78: '}' expected (to close '{' at line 54) near 'tankhuu', client: 123.21.100.186, server: , request: "GET / HTTP/1.1", host: "secure.elasticsearch.com"
--> Solution:
In lua script, if a variable contain the special characters such as [email protected], we have to cover it with ["[email protected]"]
# Issue 2 - missing library
2017/09/16 04:34:32 [error] 28996#28996: *6 lua entry thread aborted: runtime error: /usr/local/openresty/nginx/conf/elasticsearch/access.lua:5: module 'resty.http' not found:
no field package.preload['resty.http']
no file '/usr/local/openresty/site/lualib/resty/http.ljbc'
no file '/usr/local/openresty/site/lualib/resty/http/init.ljbc'
@tankhuu
tankhuu / amazon_linux_install_logstash.sh
Last active March 20, 2018 08:57
Ubuntu 16.04 - Elastic ELK Installation
#!/usr/bin/env bash
java_base_version="8"
java_sub_version="161"
java_base_build="12"
java_version="${java_base_version}u${java_sub_version}"
java_build="b${java_base_build}"
java_version_with_build="${java_version}-${java_build}"
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/${java_version_with_build}/2f38c3b165be4555a1fa6e98c45e0808/jdk-${java_version}-linux-x64.rpm"
@tankhuu
tankhuu / filter-geo-location.conf
Last active June 8, 2023 15:41
Logstash sample configuration files
filter {
mutate {
rename => { "lon" => "location" }
merge => { "location" => "lat" }
}
mutate {
convert => { "location" => "float" }
remove_field => ["lat"]
}
date {
@tankhuu
tankhuu / setup-aws-scripts-mon.sh
Last active November 22, 2017 12:12
AWS Utilities - Ubuntu 16.04
#!/usr/bin/env bash
cat << EOF > ~/setup-aws-scripts-mon.sh
#!/usr/bin/env bash
# VARIABLES #
AWSAccessKeyId=\$1
AWSSecretKey=\$2
CRON_DIR=/var/spool/cron/crontabs
# EXECUTE #
@tankhuu
tankhuu / add-swap.sh
Last active October 4, 2017 11:27
Ubuntu 16.04 - Utilities
# VARIABLES #
swapSize=4G
# EXECUTE #
# Check swap
sudo swapon -s
# Create swapfile
sudo fallocate -l $swapSize /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
@tankhuu
tankhuu / create-s3-snapshot-repository.json
Last active September 22, 2017 07:38
Elasticsearch - Tips
PUT _snapshot/s3_repo
{
"type": "s3",
"settings": {
"bucket": "bucket_name",
"base_path": "elasticsearch/snapshots"
}
}
GET /_snapshot/s3_repo
@tankhuu
tankhuu / boto3
Created October 17, 2017 08:24
Mac Installation Tricks
Problem:
```
sudo pip install boto3
The directory '/Users/tankhuu/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/tankhuu/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting boto3
Downloading boto3-1.4.7-py2.py3-none-any.whl (128kB)
100% |████████████████████████████████| 133kB 837kB/s
Collecting s3transfer<0.2.0,>=0.1.10 (from boto3)
Downloading s3transfer-0.1.11-py2.py3-none-any.whl (54kB)
## Using Dnsmasq for local development on OS X ##
## DNS & DHCP ##
# Installation
# Update your homebrew installation
brew up
# Install dnsmasq
brew install dnsmasq
# Configuration
@tankhuu
tankhuu / amazon_linux_extend_ebs_volume.sh
Last active July 19, 2019 09:59
Amazon Linux Utilities
# Take snapshot of current volume
# Modify volume and Increase Size
# Access into Server that is using this EBS
df -h
sudo growpart /dev/xvdh 1
sudo resize2fs /dev/xvdh1
# Clone new Project
mkdir -p project_folder
cd project_folder
git init
git clone https://user@passwordInUrlEncode@codeCommitGitHttpsURL
git fetch
# Edit current project
cd project_folder