Skip to content

Instantly share code, notes, and snippets.

@k8s8
k8s8 / escluster.sh
Last active October 28, 2020 02:55
escluster.sh
amazon-linux-extras install java-openjdk11 -y
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sh -c 'echo "[elasticsearch]" >> /etc/yum.repos.d/elasticsearch.repo'
sh -c 'echo "name=Elasticsearch repository for 7.x packages" >> /etc/yum.repos.d/elasticsearch.repo'
sh -c 'echo "baseurl=https://artifacts.elastic.co/packages/7.x/yum" >> /etc/yum.repos.d/elasticsearch.repo'
sh -c 'echo "gpgcheck=1" >> /etc/yum.repos.d/elasticsearch.repo'
sh -c 'echo "gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch" >> /etc/yum.repos.d/elasticsearch.repo'
sh -c 'echo "enabled=0" >> /etc/yum.repos.d/elasticsearch.repo'
sh -c 'echo "autorefresh=1" >> /etc/yum.repos.d/elasticsearch.repo'
@k8s8
k8s8 / nginx_logrotated
Created August 25, 2020 15:21
Nginx Log Rotate
/var/log/nginx/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 nginx adm
sharedscripts
postrotate
@k8s8
k8s8 / nginx.service
Created August 24, 2020 23:51
Nginx service
[Unit]
Description=nginx - high performance web server
Documentation=https://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
@k8s8
k8s8 / nginx_configure.sh
Created August 24, 2020 23:49
Nginx Configure command
./configure --prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--user=nginx \
--group=nginx \
--build=CentOS \
@k8s8
k8s8 / nginx_setup.sh
Last active February 12, 2021 11:35
Build Nginx from Source
# Ref: https://www.howtoforge.com/how-to-build-nginx-from-source-on-centos-7/
sudo yum -y install epel-release
yum update -y
yum install -y vim curl wget
yum install -y gcc gcc-c++
yum groupinstall -y 'Development Tools'
yum install -y perl perl-devel perl-ExtUtils-Embed libxslt libxslt-devel libxml2 libxml2-devel gd gd-devel GeoIP GeoIP-devel
ARG ELK_VERSION
# https://www.docker.elastic.co/
FROM docker.elastic.co/elasticsearch/elasticsearch:${ELK_VERSION}
# Add your elasticsearch plugins setup here
# Example: RUN elasticsearch-plugin install analysis-icu
RUN elasticsearch-plugin install repository-s3
ctc-usprod-kibana.calamplabs.com {
reverse_proxy * 127.0.0.1:5601
}
ctc-usprod-kibana.calamplabs.com:9200 {
reverse_proxy * 127.0.0.1:9201
}
ctc-usprod-kibana.calamplabs.com:9001 {
reverse_proxy * 127.0.0.1:9000
}
ctc-usprod-kibana.calamplabs.com:8200 {
version: '3.2'
services:
apm-server:
image: docker.elastic.co/apm/apm-server:7.6.2
depends_on:
- elasticsearch
- kibana
cap_add: ["CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID"]
cap_drop: ["ALL"]
#!/bin/sh
mkdir -p /disk/elasticsearch
/usr/bin/docker volume create --driver local --opt type=none --opt device=/disk/elasticsearch --opt o=bind elasticsearch
sed -i 's/trial/basic/g' /var/docker-elk/elasticsearch/config/elasticsearch.yml
/usr/local/bin/docker-compose up -d elasticsearch
sleep 1m && /usr/local/bin/docker-compose exec -T elasticsearch bin/elasticsearch-setup-passwords auto --batch > passwords.txt
EPASSWORD=$(cat passwords.txt | awk '/elastic = / {print $4}')
version: '3.2'
services:
apm-server:
image: docker.elastic.co/apm/apm-server:7.6.2
depends_on:
- elasticsearch
- kibana
cap_add: ["CHOWN", "DAC_OVERRIDE", "SETGID", "SETUID"]
cap_drop: ["ALL"]