Skip to content

Commit

Permalink
improve es
Browse files Browse the repository at this point in the history
  • Loading branch information
chendelin1982 authored Feb 25, 2024
1 parent 6831f2a commit c33f740
Show file tree
Hide file tree
Showing 33 changed files with 106 additions and 291 deletions.
48 changes: 0 additions & 48 deletions apps/elastic/Notes.md

This file was deleted.

1 change: 0 additions & 1 deletion apps/elastic/src/after_up.sh

This file was deleted.

17 changes: 0 additions & 17 deletions apps/elastic/src/agent/config/filebeat.yml

This file was deleted.

13 changes: 0 additions & 13 deletions apps/elastic/src/elasticsearch/config/elasticsearch.yml

This file was deleted.

1 change: 0 additions & 1 deletion apps/elastic/src/elasticsearch/config/service_tokens

This file was deleted.

5 changes: 0 additions & 5 deletions apps/elastic/src/filelist

This file was deleted.

1 change: 0 additions & 1 deletion apps/elastic/src/get_version.sh

This file was deleted.

7 changes: 5 additions & 2 deletions apps/elasticsearch/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
W9_POWER_PASSWORD=spJNF09yzwWJaG!
W9_VERSION=8.11.3
W9_VERSION=8.12.2
W9_DIST=community
W9_REPO=elasticsearch

Expand All @@ -23,8 +23,11 @@ network.host="0.0.0.0"
xpack.license.self_generated.type=trial
xpack.security.enabled=true
xpack.monitoring.collection.enabled=true
xpack.security.enrollment.enabled=true
xpack.security.http.ssl.enabled=false

discovery.type=single-node
ES_JAVA_OPTS="-Xms4g -Xmx4g"
# set password for user elastic
ELASTIC_PASSWORD=${W9_LOGIN_PASSWORD}
ELASTIC_PASSWORD=${W9_LOGIN_PASSWORD}
KIBANA_PASSWORD=${W9_LOGIN_PASSWORD}
49 changes: 48 additions & 1 deletion apps/elasticsearch/Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,51 @@
```
# Test ES
curl -u elastic:yourpassword http://localhost:9200
```
```

ELK 即 Elastic Stack, 它是官方标准的名称。
值得注意的是,ELK 中所有组件的版本必须保持一致(精确到小版本)

> If you are using Elasticsearch 7.16.3, you install Beats 7.16.3, APM Server 7.16.3, Elasticsearch Hadoop 7.16.3, Kibana 7.16.3, and Logstash 7.16.3.
## 安装

1. Elasticsearch 对虚拟内存有[要求](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html)
```
sysctl -w vm.max_map_count=262144
```
## 账号密码
ES 和 Kibana 可以通过env 设置密码。 Logstash 可以通过 **ES容器名:password** 的方式传入米米
## 环境变量
通过配置文件或容器运行时带入均可,配置项与容器环境变量参数的对应关系[参考](https://www.elastic.co/guide/en/logstash/current/docker-config.html#docker-env-config)
## FAQ
#### 本应用支持在同一个网络安装2个吗?
不支持。因为部分连接采用的是服务名称
#### 启动时间多久?
3-8 分钟
#### Kibana 如何连接 ES?
从8.0之后,需要在 ES 中生产秘钥,方可连接
1. 首先在 ES 中生产密钥对(公钥存放在 elasticsearch/config/service_tokens)
```
# 生成秘钥
docker exec -it elk sh bin/elasticsearch-service-tokens create elastic/kibana test

# 测试秘钥
curl -H "Authorization: Bearer AAEAAWVsYXN0aWMva2liYW5hL3Rlc3Q6bU5CMTVuNEZTdG1BaHBvSWFjVXlHZw" http://47.242.60.114:9200"
```
3. 将私钥通过 kibana 的 ELASTICSEARCH_SERVICEACCOUNTTOKEN 环境变量传入
4 changes: 2 additions & 2 deletions apps/elasticsearch/variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{
"dist": "community",
"version": [
"8.11.3",
"7.17.16"
"8.12.2",
"7.17.18"
]
}
],
Expand Down
48 changes: 10 additions & 38 deletions apps/kibana/.env
Original file line number Diff line number Diff line change
@@ -1,46 +1,18 @@
W9_REPO=docker.io/websoft9dev/appname
W9_VERSION=8.12.2
W9_DIST=community
W9_VERSION=latest

W9_POWER_PASSWORD=1PrMxExC45LsCT

# Environments which for user settings when create application
# Named expression: W9_xxx_xxx_SET, xxx refer to file fields
W9_HTTP_PORT_SET=9001
W9_HTTPS_PORT_SET=9002
W9_DB_PORT_SET=3306
W9_SSH_PORT_SET=23
W9_KEY_SET="dfsjdkjf77xjxcjcj"
W9_REPO=kibana

#### -- Not allowed to edit below environments when recreate app based on existing data -- ####

W9_ID=mycrm

# W9_HTTP_PORT or W9_HTTPS_PORT is need at leaset and used for proxy for web application
# Some container (e.g teleport) need HTTPS access, then need to set this pra
W9_HTTP_PORT=80
W9_HTTPS_PORT=81

W9_LOGIN_USER=admin
# use https://1password.com/zh-cn/password-generator/ to genarate 14 bit password
# this password can also use password file
W9_LOGIN_PASSWORD=$W9_POWER_PASSWORD
W9_ADMIN_PATH="/wp-login"

# Container name's suffix must use one of the value
W9_DB_EXPOSE="mysql,postgresql,mariadb,mongodb,redis"

# It is used when the application APP needs to set an external URL, which can be IP(or domain), IP:PORT, http(s)://IP:PORT
W9_URL=internet_ip:$W9_HTTP_PORT
# modifies W9_URL on init when it is true
W9_URL_REPLACE=true

W9_HTTP_PORT=5601
W9_HTTP_PORT_SET=9001
W9_URL=appname.example.com
W9_NETWORK=websoft9

#### ----------------------------------------------------------------------------------------- ####
#### --------------------------------------------------------------------------------------- ####


# Below environment is created by apphub
SERVER_HOST="0.0.0.0"
SERVER_NAME="kibana"

#W9_NAME=""
#W9_RCODE=""
#ELASTICSEARCH_HOSTS='["http://{elastcisearch-host}:{port}"]'
#ELASTICSEARCH_SERVICEACCOUNTTOKEN={elastcisearch-serviceaccounttoken}
21 changes: 0 additions & 21 deletions apps/kibana/Dockerfile

This file was deleted.

9 changes: 7 additions & 2 deletions apps/kibana/Notes.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Appname
## FAQ
# Kibana

如果不提前提供 ES 的连接信息,Kibana 可以单独运行

## to do

- Test connecting to ES
26 changes: 0 additions & 26 deletions apps/kibana/README.jinja2

This file was deleted.

36 changes: 6 additions & 30 deletions apps/kibana/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,16 @@ version: '3.8'

services:

wordpress:
image: $W9_REPO:$W9_VERSION
container_name: $W9_ID
kibana:
image: ${W9_REPO}:${W9_VERSION}
container_name: ${W9_ID}
restart: unless-stopped
logging:
driver: "json-file"
options:
max-file: "5"
max-size: 10m
ports:
- $W9_HTTP_PORT_SET:80
env_file: .env
volumes:
- wordpress:/var/www/html
- ./src/php_exra.ini:/usr/local/etc/php/conf.d/php_exra.ini

mariadb:
image: mariadb:10.4
container_name: $W9_ID-mariadb
restart: unless-stopped
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb_log_buffer_size=30M
- ./src/kibana.yml:/usr/share/kibana/config/kibana.yml
ports:
- ${W9_HTTP_PORT_SET}:5601
env_file: .env
volumes:
- mysql_data:/var/lib/mysql
environment:
MYSQL_DATABASE: $W9_ID
MYSQL_USER: $W9_ID
MYSQL_PASSWORD: $W9_POWER_PASSWORD
MYSQL_ROOT_PASSWORD: $W9_POWER_PASSWORD

volumes:
wordpress:
mysql_data:

networks:
default:
name: $W9_NETWORK
Expand Down
1 change: 0 additions & 1 deletion apps/kibana/src/after_up.sh

This file was deleted.

12 changes: 0 additions & 12 deletions apps/kibana/src/encrypt.sh

This file was deleted.

3 changes: 0 additions & 3 deletions apps/kibana/src/filelist

This file was deleted.

1 change: 0 additions & 1 deletion apps/kibana/src/get_version.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
monitoring.ui.container.elasticsearch.enabled: true

## X-Pack security credentials

## ES Connect
#elasticsearch.ssl.verificationMode: none
#elasticsearch.hosts: ["http://elasticsearch_vs26o:9200"]
#elasticsearch.username: "kibana_system"
#elasticsearch.password: "aEk@4FUq2Us@ZgLB"
Loading

0 comments on commit c33f740

Please sign in to comment.