WARN EACCES user “root” does not have permission to access the dev dir “/root/.node-gyp/11.15.0” ERR! stack Error: EACCES: permission denied, mkdir ‘node_modules/sqlite3/.node-gyp’
# docker compose exec -it elasticsearch bin/elasticsearch-setup-passwords interactive ****************************************************************************** Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This command will be removed in a future release. ******************************************************************************
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user. You will be prompted to enter passwords as the process progresses. Please confirm that you would like to continue [y/N]y
Enter password for [elastic]: Reenter password for [elastic]: Enter password for [apm_system]: Enter password for [apm_system]: Reenter password for [apm_system]: Enter password for [kibana_system]: Reenter password for [kibana_system]: ... Changed password for user [beats_system] Changed password for user [remote_monitoring_user] Changed password for user [elastic]
重置 elastic 用户密码
# docker compose exec elasticsearch bin/elasticsearch-reset-password -u elastic This tool will reset the password of the [elastic] user to an autogenerated value. The password will be printed in the console. Please confirm that you would like to continue [y/N]y
Password for the [elastic] user successfully reset. New value: GjJadE-ihZJ+Ddb5SvKs
# GET /_cat/nodes?v&h=name,ip,node.role,master name ip node.role master vp-elk-3 172.31.25.106 cdfhilmrstw - vp-elk-2 172.31.24.61 cdfhilmrstw * vp-elk-1 172.31.29.164 cdfhilmrstw -
mmaster
ddata
i **ingest
检查分片分布
# GET /_cat/shards?v index shard prirep state docs store dataset ip node .kibana_analytics_8.12.2_001 0 p STARTED 5 2.3mb 2.3mb 172.31.24.61 vp-elk-2 .kibana_analytics_8.12.2_001 0 r STARTED 5 2.3mb 2.3mb 172.31.29.164 vp-elk-1 .internal.alerts-observability.apm.alerts-default-000001 0 p STARTED 0 249b 249b 172.31.24.61 vp-elk-2 .internal.alerts-observability.apm.alerts-default-000001 0 r STARTED 0 249b 249b 172.31.29.164 vp-elk-1 .ds-.kibana-event-log-ds-2026.03.13-000001 0 p STARTED 1 6.3kb 6.3kb 172.31.25.106 vp-elk-3
检查索引状态
# GET /_cat/indices?v health status index uuid pri rep docs.count docs.deleted store.size pri.store.size dataset.size green open .internal.alerts-observability.logs.alerts-default-000001 QQ1ALFIwTS6Cr1IUjp384w 1 1 0 0 498b 249b 249b green open .internal.alerts-observability.threshold.alerts-default-000001 UzpYLZbzTMyK2yCYnmayKw 1 1 0 0 498b 249b 249b green open .kibana-observability-ai-assistant-kb-000001 yV9I-sIMQgyf0edNxw1kPA 1 1 0 0 498b 249b 249b green open .internal.alerts-observability.apm.alerts-default-000001 0HOJ4bCgT_2X4c29FryFCw 1 1 0 0 498b 249b 249b green open .internal.alerts-stack.alerts-default-000001 NJCmcGptQOWG6rd0I259Uw 1 1 0 0 498b 249b 249b green open .internal.alerts-observability.slo.alerts-default-000001 rSSFxAYfR0O9L9XXBIpZlA 1 1 0 0 498b 249b 249b green open .internal.alerts-ml.anomaly-detection.alerts-default-000001 fT9FJoirRiSMVXx1V3F7dQ 1 1 0 0 498b 249b 249b green open .internal.alerts-observability.metrics.alerts-default-000001 E9vjU7WETSebjg8Y_ddPHw 1 1 0 0 498b 249b 249b
检查 Master 选举
# GET /_cat/master?v id host ip node 5hG_mSEjRd6Ov-rClowAoQ 172.31.24.61 172.31.24.61 vp-elk-2
只有一个 Master 就正常
检查 JVM Heap
# GET /_cat/nodes?v&h=name,heap.percent name heap.percent vp-elk-3 20 vp-elk-2 48 vp-elk-1 57
# journalctl -f -u filebeat {"type":"illegal_argument_exception","reason":"Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [6924]/[3000] maximum shards open;"}
错误消息 {"type":"illegal_argument_exception","reason":"Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [6924]/[3000] maximum shards open;"} 显示当前集群已有 6924 个分片,超过了 3000 个的限制。
filebeat 启动后报错,elasticsearch 上未创建相应的索引,关键错误信息 Failed to connect to backoff(elasticsearch(http://1.57.115.214:9200)): Connection marked as failed because the onConnect callback failed: resource 'filebeat-7.5.2' exists, but it is not an alias
journalctl -f -u filebeat INFO [index-management] idxmgmt/std.go:269 ILM policy successfully loaded. ERROR pipeline/output.go:100 Failed to connect to backoff(elasticsearch(http://1.57.115.214:9200)): Connection marked as failed because the onConnect callback failed: resource 'filebeat-7.5.2' exists, but it is not an alias INFO pipeline/output.go:93 Attempting to reconnect to backoff(elasticsearch(http://1.57.115.214:9200)) with 3 reconnect attempt(s) INFO elasticsearch/client.go:753 Attempting to connect to Elasticsearch version 7.6.2 INFO [index-management] idxmgmt/std.go:256 Auto ILM enable success. INFO [index-management.ilm] ilm/std.go:138 do not generate ilm policy: exists=true, overwrite=false INFO [index-management] idxmgmt/std.go:269 ILM policy successfully loaded. ERROR pipeline/output.go:100 Failed to connect to backoff(elasticsearch(http://1.56.219.122:9200)): Connection marked as failed because the onConnect callback failed: resource 'filebeat-7.5.2' exists, but it is not an alias INFO pipeline/output.go:93 Attempting to reconnect to backoff(elasticsearch(http://1.56.219.122:9200)) with 3 reconnect attempt(s)
[OUTPUT] Name es Match * Host elasticsearch Port 9200 # 要配置 ES 用户密码才能同步数据 HTTP_User elastic HTTP_Passwd changeme Index fluentbit Type _doc Suppress_Type_Name On
# docker compose exec -it elasticsearch /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic This tool will reset the password of the [elastic] user to an autogenerated value. The password will be printed in the console. Please confirm that you would like to continue [y/N]y Password for the [elastic] user successfully reset. New value: xf52=nGPAf3TBOIbMuKR
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/testuser/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/testuser/.ssh/id_rsa. Your public key has been saved in /home/testuser/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Lzvl8GbOQETBVcTf8lf0Qk9KUQAESs9h8wARud+iQrk [email protected] The key's randomart image is: +---[RSA 2048]----+ | .BBB*=.o+.| | oo= =. o o| | o.o .+ *.| | .. = =| | .S. . +.| | o...+ . o| | . .o*.. .| | E o== | | ..=o | +----[SHA256]-----+
$ ssh-copy-id -p 30000 [email protected] /bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/testuser/.ssh/id_rsa.pub" The authenticity of host '[172.31.30.115]:30000 ([172.31.30.115]:30000)' can't be established. ECDSA key fingerprint is SHA256:vKD5th2QpWYv/hmt+180BsENDHWNcJdKiEBOH06h/K8. ECDSA key fingerprint is MD5:bf:8c:b9:e6:31:92:1f:a9:b6:7b:8f:50:d7:10:9e:fd. Are you sure you want to continue connecting (yes/no)? yes /bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new [email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh -p '30000' '[email protected]'" and check to make sure that only the key(s) you wanted were added.
在本地服务器上面验证可以免密登陆到目标服务器。
如果要配置双向免密,将以上步骤反过来操作一遍即可
常见配置
登录服务器,经常遇见以下提示信息,说明有主机一直在尝试暴力破解用户名密码
There were 696 failed login attempts since the last successful login.
AWS Managed Microsoft AD : AWS 托管的 Microsoft AD 域控服务。
Simple AD : 本质上是基于 Samba 4 的兼容方案
无论哪种 AD,都不支持直接通过 AWS 控制台管理,必须通过一台 Windows 管理机(EC2 或 WorkSpace)远程操作。
以下步骤以管理 Simple AD 为例提供参考步骤:
启动一台 Windows Server 实例(推荐)或一台现有的 WorkSpace。
确保这台机器已经加入到您的 Simple AD 域名下。方便起见最好是部署在 Directory 中 Workspace 云桌面,其已经在域中。
以管理员账户登陆并安装工具:
在服务器管理器中,点击 添加角色和功能 。
在 功能 列表中,勾选 组策略(Group Policy Management)管理工具 以及 远程服务器管理工具 (Remote Server Administration Tools,RSAT) -> 角色管理工具(Role Administration Tools) -> AD DS 和 AD LDS 工具 。
如果 Directory 配置了 禁用本地管理员设置 ,使用新部署的 Workspace 桌面会不具备管理员权限,无法安装工具。只需要有 域管理员账户密码即可解决 。在任务栏或开始菜单找到 Server Manager (服务器管理器) ,选择 Run as different user (以其他用户身份运行) 。
安装完成后,即可打开 Active Directory Users and Computers 工具查看 AD 域中的用户和计算机信息
创建 Prometheus Server 配置文件,如 /root/prometheus/prometheus.yml,内容如下 [1]
/data/prometheus/prometheus.yml
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus'
# metrics_path defaults to '/metrics' # scheme defaults to 'http'.
static_configs: - targets: ['localhost:9090']
使用 Docker 启动时挂载此文件,作为 Prometheus Server 的配置文件,之后需要修改配置,可以直接修改此文件。
vless://<UID>@<SERVER IP>:<Port>?encryption=none&flow=xtls-rprx-vision&security=reality&sni=www.microsoft.com&fp=chrome&pbk=<Public Key or Password>&sid=a1b2c3d4#Shanghai_MS_Reality
大多数客户端都支持从粘贴板复制以上内容自动导入配置。
Windows 中使用 v2rayN 连接 xray server
v2rayN 版本: v7.18.0
Windows 下载 v2rayN ,将其解压后,运行程序 v2rayN.exe 即可打开程序。复制配置链接( vless://<UID>@<SERVER IP>:<Port>?encryption=none&flow=xtls-rprx-vision&security=reality&sni=www.microsoft.com&fp=chrome&pbk=<Public Key or Password>&sid=a1b2c3d4#Shanghai_MS_Reality ),在 v2rayN 主界面点击 Configuration -> Import Share Links from clipboard 即可自动导入配置
要验证 xray server 工作正常,可以在 v2rayN 客户端进行 延迟检测(Test real delay) 。右键要检测的 xray server 选择 Test real delay 如果能够获取到延迟数据,说明 xray 工作正常,如果未获取到延迟数据,可以登陆服务器,通过命令 docker logs 检查服务端日志
apiVersion:apps/v1 # Use a stateful setup to ensure that for a rolling update Pods are restarted with a rolling strategy one-by-one. # This prevents losing in-memory information stored redundantly in two Pods. kind:StatefulSet metadata: name:keycloak labels: app:keycloak spec: serviceName:keycloak-discovery # Run with one replica to save resources, or with two replicas to allow for rolling updates for configuration changes replicas:2 selector: matchLabels: app:keycloak template: metadata: labels: app:keycloak spec: containers: -name:keycloak image:quay.io/keycloak/keycloak:26.5.4 args: ["start"] env: # 初始管理员账户和密码 -name:KC_BOOTSTRAP_ADMIN_USERNAME value:"admin" -name:KC_BOOTSTRAP_ADMIN_PASSWORD value:"admin" # In a production environment, add a TLS certificate to Keycloak to either end-to-end encrypt the traffic between # the client or Keycloak, or to encrypt the traffic between your proxy and Keycloak. # Respect the proxy headers forwarded by the reverse proxy # In a production environment, verify which proxy type you are using, and restrict access to Keycloak # from other sources than your proxy if you continue to use proxy headers. -name:KC_PROXY_HEADERS value:"xforwarded" -name:KC_HTTP_ENABLED value:"true" # In this explorative setup, no strict hostname is set. # For production environments, set a hostname for a secure setup. -name:KC_HOSTNAME_STRICT value:"false" -name:KC_HEALTH_ENABLED value:"true" -name:'KC_CACHE' value:'ispn' # Passing the Pod's IP primary address to the JGroups clustering as this is required in IPv6 only setups -name:POD_IP valueFrom: fieldRef: fieldPath:status.podIP # Instruct JGroups which DNS hostname to use to discover other Keycloak nodes # Needs to be unique for each Keycloak cluster -name:KC_CACHE_EMBEDDED_NETWORK_BIND_ADDRESS value:'$(POD_IP)' -name:'KC_DB_URL_DATABASE' value:'keycloak' -name:'KC_DB_URL_HOST' value:'<RDS_endpoint>' -name:'KC_DB' value:'postgres' # In a production environment, use a secret to store username and password to the database -name:'KC_DB_PASSWORD' value:'<RDS_PASSWORD>' -name:'KC_DB_USERNAME' value:'<RDS_USERNAME>' ports: -name:http containerPort:8080 -name:jgroups containerPort:7800 -name:jgroups-fd containerPort:57800 startupProbe: httpGet: path:/health/started port:9000 periodSeconds:1 failureThreshold:600 readinessProbe: httpGet: path:/health/ready port:9000 periodSeconds:10 failureThreshold:3 livenessProbe: httpGet: path:/health/live port:9000 periodSeconds:10 failureThreshold:3 resources: limits: cpu:2000m memory:2000Mi requests: cpu:500m memory:1700Mi
--server-side 选项用于解决可能的报错: The CustomResourceDefinition "applicationsets.argoproj.io" is invalid: metadata.annotations: Too long: may not be more than 262144 bytes