分类 Linux 下的文章

第一步

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

第二步

echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

第三步

sudo apt-get update && sudo apt-get install elasticsearch

这就安装完了。

编辑elasticsearch.yml文件 设置远程访问:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 192.168.1.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["192.168.1.1"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don't have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html

编辑jvm.options文件 控制内存使用

-Xms1g
-Xmx1g

注意不要留空格,保存文件并启动elasticsearch服务

sudo systemctl enable elasticsearch.service && sudo systemctl start elasticsearch.service

安装中文搜索优化插件

cd /usr/share/elasticsearch/
bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-stconvert/7.17.29
bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/7.17.29

注意版本号跟elasticsearch版本号对应。

添加 iptables 控制未授权访问

-A INPUT -s 74.48.174.64 -p tcp --dport 9200 -j ACCEPT

创建docker-compose.yml 配置文件
粘贴以下配置文件:

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    restart: unless-stopped
    environment:
      DOMAIN: "域名"
      ADMIN_TOKEN: "openssl rand -base64 48" //用来访问管理员控制面板
    volumes:
      - ./vw-data/:/data/
    ports:
      - 8043:80 

然后 docker-compose up -d 拉起项目启动容器。

nginx 反向代理配置文件:


location / {
proxy_pass http://127.0.0.1:8043;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

找了一圈发现这个开源客户端很美观并且部署方便。
先安装nodejs以及git

1.先把仓拉取到库本地

git clone https://github.com/bclswl0827/ChatGemini

2.进入目录:

cd ChatGemini

3.安装依赖:

npm install

4.修改.evn应用配置

# MD5 形式站点访问密码,留空则为公开站点
REACT_APP_PASSCODE_MD5=
# 站点标题,会显示在浏览器标签页上
REACT_APP_TITLE_SITE=
# 站点名称,会显示在页面头部
REACT_APP_TITLE_HEADER=
# Gemini API 密钥
REACT_APP_GEMINI_API_KEY=
# 逐字输出 Gemini 回应
# 默认值:true
REACT_APP_GEMINI_API_SSE=
# 自定义 Gemini API 地址
# Default: <空>
REACT_APP_GEMINI_API_URL=

5.构建项目

npm run build

然后把build目录复制到网站跟目录就可以了,当然共享主机也能用。或者直接本地电脑上访问也可以。

  1. sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg
  2. curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  3. NODE_MAJOR=20
  4. echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
  1. sudo apt-get update && sudo apt-get install nodejs -y

如果出现 鉴于仓库 'https://deb.nodesource.com/node_20.x nodistro InRelease' 不支持 'i386' 体系

  1. nano /etc/apt/sources.list.d/nodesource.list
  2. 把原来的修改成 deb [signed-by=/etc/apt/keyrings/nodesource.gpg, arch=amd64] https://deb.nodesource.com/node_20.x nodistro main
  3. sudo apt-get install nodejs

我的手机,电脑充电器全天几乎不拔一直插在电源插座上。这导致,今天同时烧坏了一个1A2C口充电器,一个绿联单C口充电器和一个小米魔方插座。

原因分析,可能今天风大,电网电压不稳导致的。