<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux归档 - Liao&#039;s blog</title>
	<atom:link href="https://www.laobaiblog.top/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.laobaiblog.top/category/linux/</link>
	<description>路漫漫其修远兮，吾将上下而求索</description>
	<lastBuildDate>Tue, 01 Apr 2025 13:40:41 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.laobaiblog.top/wp-content/uploads/2022/01/cropped-tyuu-32x32.png</url>
	<title>Linux归档 - Liao&#039;s blog</title>
	<link>https://www.laobaiblog.top/category/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Ubuntu安装Ollama,Huggingface下载GGUF大模型手动导入Ollama</title>
		<link>https://www.laobaiblog.top/2025/04/01/ollama-gguf/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 01 Apr 2025 07:57:35 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[huggingface]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ollama]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=546</guid>

					<description><![CDATA[<p>在 Ubuntu 24.04 上部署 Ollama + DeepSeek，可以构建一个安全、可控的本 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2025/04/01/ollama-gguf/">Ubuntu安装Ollama,Huggingface下载GGUF大模型手动导入Ollama</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  在 Ubuntu 24.04 上部署 Ollama + DeepSeek，可以构建一个安全、可控的本地 AI 知识库系统，适用于企业文档管理、个人学习助手等场景。本教程将详细介绍安装配置步骤，帮助用户快速搭建属于自己的 AI 知识库，实现高效信息检索与智能交互。
</p></blockquote>
<h3>一、Ollama 下载与部署</h3>
<p>Ollama 是一个开源项目，可以使用官网推荐的脚本方式安装，也可以直接访问 github 下载 release 包后进行手动安装。我这里选择手动安装<code>ollama-linux-amd64.tgz</code></p>
<h4>1. 自动安装</h4>
<pre><code class="language-shell line-numbers">curl -fsSL https://ollama.com/install.sh | sh
</code></pre>
<h4>2. 手动安装</h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_f15c1e22299dd452b3c75bd3294b5074.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_f15c1e22299dd452b3c75bd3294b5074.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#最新版本在github上查看
wget https://github.com/ollama/ollama/releases/download/v0.6.3/ollama-linux-amd64.tgz
#可以使用以下命令进行解压缩并拷贝到系统目录中：
sudo tar -C /usr -zxvf ollama-linux-amd64.tgz
#这样就直接部署完成了
ollama -v
#显示 ollama version is 0.6.3 查看安装版本进行验证。
</code></pre>
<h4>3. 创建 Ollama 用户及系统服务</h4>
<p>出于安全性、隔离性和系统管理的考虑，需要创建 ollama 用户，执行以下命令：</p>
<pre><code class="language-shell line-numbers"># 新增用户
sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama
# 修改用户信息
sudo usermod -a -G ollama <span class="katex math inline">(whoami)
创建系统服务 service 文件：

# 编辑文件
sudo vi /etc/systemd/system/ollama.service
# 文件内容
[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=</span>PATH"
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_ORIGINS=*"

[Install]
WantedBy=default.target
</code></pre>
<h4>4. 配置重载及开机自启</h4>
<pre><code class="language-shell line-numbers"># 重载配置
sudo systemctl daemon-reload
# 启动服务
sudo systemctl start ollama.service
# 查看服务状态
sudo systemctl status ollama.service
# 设置服务开机自启动
sudo systemctl enable ollama.service
</code></pre>
<h3>二、Huggingface模型下载</h3>
<p><a class="wp-editor-md-post-content-link" href="https://huggingface.co/">Huggingface官网下载（科学上网）</a></p>
<ol>
<li>ollama因为网络不稳定的原因，所以在这里没有ollama pull XXX模型，在这里根据自身显卡规格选择想要运行的模型，用这两个模型作为参考：</li>
</ol>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://huggingface.co/unsloth/DeepSeek-R1-Distill-Qwen-32B-GGUF/tree/main">unsloth/DeepSeek-R1-Distill-Qwen-32B-GGUF</a></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_cf5a1b7c1d1cd29251b246290255c3cf.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_cf5a1b7c1d1cd29251b246290255c3cf.jpg" alt="" /></a></p>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://huggingface.co/Qwen/QwQ-32B-GGUF">Qwen/QwQ-32B-GGUF</a></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_8add52e0c967508a9cc7032be3132d8c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_8add52e0c967508a9cc7032be3132d8c.jpg" alt="" /></a></p>
<p>下载并上传到服务器<code>/data/models/XXX</code>模型目录下</p>
<pre><code class="language-shell line-numbers">#参数解析
DeepSeek：DeepSeek 发布的模型文件
R1：深度思考模型
Distill：模型蒸馏
Qwen：与阿里巴巴推出的通义千问系列模型相关
32B：32 Billion，即 320 亿参数的版本
Q4：4-bit 量化
K：量化分组，是量化算法中的一种优化技术
M：中等量化粒度
gguf：GPT-Generated Unified Format，是一种专为大型模型设计的二进制文件存储格式
</code></pre>
<h3>三、Ollama手动加载模型运行</h3>
<p>把<strong><code>DeepSeek-R1-Distill-Qwen-32B-Q4_K_M.gguf</code></strong>及<strong><code>qwq-32b-q4_k_m.gguf</code></strong>两个模型文件放到对应的<strong><code>deepseek</code></strong>及<strong><code>qwq</code></strong>目录下。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_84e92d9b67262d046758b6409a1d931c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_84e92d9b67262d046758b6409a1d931c.jpg" alt="" /></a></p>
<h5>1. 在DeepSeek模型文件同级目录下创建文件<code>ollama-deepseek</code>并写入以下内容：</h5>
<pre><code class="language-shell line-numbers">FROM ./DeepSeek-R1-Distill-Qwen-32B-Q4_K_M.gguf
</code></pre>
<pre><code class="language-shell line-numbers">#然后在模型文件目录执行以下命令导入模型文件：
ollama create DeepSeek-R1-Distill-Qwen-32B-GGUF -f ./ollama-deepseek
</code></pre>
<h5>2. 在Qwq模型文件同级目录下创建文件<code>ollama-qwq</code>并写入以下内容：</h5>
<pre><code class="language-shell line-numbers">FROM ./qwq-32b-q4_k_m.gguf
</code></pre>
<pre><code class="language-shell line-numbers">#然后在模型文件目录执行以下命令导入模型文件：
ollama create QwQ-32B-GGUF -f ./ollama-qwq
</code></pre>
<h3>四、查看模型与运行模型</h3>
<p>可以使用命令<code>ollama list</code>查看已加载的模型列表：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_53dcc1feda2e1a8c640041ba809b3a1b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_53dcc1feda2e1a8c640041ba809b3a1b.jpg" alt="" /></a></p>
<p>然后通过命令<code>ollama run &lt;model-name&gt;</code>就可以运行指定的模型了</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_83e2136af7bdf2b143a48fc317a9d51a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_83e2136af7bdf2b143a48fc317a9d51a.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2025/04/01/ollama-gguf/">Ubuntu安装Ollama,Huggingface下载GGUF大模型手动导入Ollama</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Docker compose安装配置向量数据库Milvus，配置可视化Attu</title>
		<link>https://www.laobaiblog.top/2025/04/01/docker-compose%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%90%91%e9%87%8f%e6%95%b0%e6%8d%ae%e5%ba%93milvus%ef%bc%8c%e9%85%8d%e7%bd%ae%e5%8f%af%e8%a7%86%e5%8c%96attu/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 01 Apr 2025 06:49:19 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[docker compose]]></category>
		<category><![CDATA[milvus]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[向量数据库]]></category>
		<category><![CDATA[开源]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=544</guid>

					<description><![CDATA[<p>介绍Milvus向量数据库的安装过程，包括创建工作目录、下载docker-compose.yml文件 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2025/04/01/docker-compose%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%90%91%e9%87%8f%e6%95%b0%e6%8d%ae%e5%ba%93milvus%ef%bc%8c%e9%85%8d%e7%bd%ae%e5%8f%af%e8%a7%86%e5%8c%96attu/">Docker compose安装配置向量数据库Milvus，配置可视化Attu</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  介绍Milvus向量数据库的安装过程，包括创建工作目录、下载docker-compose.yml文件、配置attu可视化面板和修改安全设置。
</p></blockquote>
<h3>环境准备</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_5f5908886322910b08bd5deb0f4862ee.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_5f5908886322910b08bd5deb0f4862ee.jpg" alt="" /></a></p>
<ul>
<li>docker版本：28.0.4</li>
<li>docker compose版本：v2.34.0</li>
</ul>
<h3>Milvus向量数据库简介</h3>
<p><strong>Milvus是一款开源的向量数据库，它专为AI应用设计，用于管理和检索海量的特征向量</strong>。Milvus的优势主要包括：</p>
<ul>
<li>高效的向量检索性能：Milvus采用了多种先进的索引算法，如IVF, HNSW, ANNOY等，能够在大规模数据集上实现高效的近似最近邻搜索。</li>
<li>易于扩展和维护：Milvus支持水平和垂直扩展，能够适应不断增长的数据规模和查询需求。它的分布式架构使得数据存储和计算能力可以灵活扩展。</li>
<li>多种数据持久化选项：Milvus支持SSD, HDD等多种存储介质，并且可以与多种持久化存储解决方案集成，如MinIO, S3等。</li>
<li>丰富的数据接口：Milvus提供了Python, Java, RESTful等多种语言的SDK，方便开发者在不同的应用场景中使用。</li>
<li>强大的可扩展性和兼容性：支持各种大小和类型的向量数据，可以与现有的数据处理和机器学习工作流程无缝集成。</li>
<li>容器化和云原生支持：支持Docker和Kubernetes，方便在云环境中部署和管理。</li>
<li>开源社区支持：作为一个开源项目，Milvus拥有活跃的社区，不断有新的功能和改进被加入。</li>
</ul>
<p>Milvus适用于各种需要高效向量检索的应用场景，如推荐系统、图像检索、自然语言处理等。由于其高效、易用和可扩展的特性，Milvus在AI应用开发中越来越受欢迎。</p>
<h3>安装Milvus</h3>
<p><strong>1. 创建工作目录（自定义）</strong></p>
<pre><code class="language-shell line-numbers"># 切换到root目录
cd /root
# 新建一个名为milvus的目录用于存放数据 目录名称可以自定义
mkdir milvus
# 进入到新建的目录
cd milvus
</code></pre>
<p><strong>2. 下载并编辑docker-compose.yml</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://github.com/milvus-io/milvus/releases/download/v2.5.7/milvus-standalone-docker-compose-gpu.yml">Github查看最新版本</a>，选择带有GPU的yml配置文件下载（<strong>nvidia显卡</strong>）。也可以借鉴<a class="wp-editor-md-post-content-link" href="https://milvus.io/docs/zh/install_standalone-docker-compose.md">官网指南</a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_6f59b57bfdf0a0011b6760617fe0f3a4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_6f59b57bfdf0a0011b6760617fe0f3a4.jpg" alt="" /></a></p>
<p><span id="more-544"></span><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_0eeb45cac25f24508d7879025e257bfb.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_0eeb45cac25f24508d7879025e257bfb.jpg" alt="" /></a></p>
<p><strong>3. 下载milvus.yml文件</strong></p>
<p>该文件是milvus的配置文件，容器中内置，但如果要修改配置，需要单独下载，这里为了做访问控制，就需要修改配置。</p>
<pre><code class="language-shell line-numbers"># 注意改成自己对应的milvus版本号
wget https://raw.githubusercontent.com/milvus-io/milvus/v2.5.7/configs/milvus.yaml
</code></pre>
<p>下载好后，确保该文件位于milvus工作目录下，然后编辑该文件，<strong>找到其中的<code>common &gt; security &gt; authorizationEnabled</code>并将其设置为<code>true</code></strong>。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_f74e87dac045cf2c7493aaa799ff253e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_f74e87dac045cf2c7493aaa799ff253e.jpg" alt="" /></a></p>
<p><strong>3. 下载milvus-standalone-docker-compose-gpu.yml文件，在其中添加attu可视化面板的容器。并修改docker-compose.yml做资源映射</strong></p>
<pre><code class="language-shell line-numbers">version: '3.5'
services:
  etcd:
    container_name: milvus-etcd
    image: quay.io/coreos/etcd:v3.5.18
    environment:
      - ETCD_AUTO_COMPACTION_MODE=revision
      - ETCD_AUTO_COMPACTION_RETENTION=1000
      - ETCD_QUOTA_BACKEND_BYTES=4294967296
      - ETCD_SNAPSHOT_COUNT=50000
    volumes:
      - <span class="katex math inline">{DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
    command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
    healthcheck:
      test: ["CMD", "etcdctl", "endpoint", "health"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio:
    container_name: milvus-minio
    image: minio/minio:RELEASE.2023-03-20T20-16-18Z
    environment:
      MINIO_ACCESS_KEY: minioadmin
      MINIO_SECRET_KEY: minioadmin
    ports:
      - "9001:9001"
      - "9000:9000"
    volumes:
      -</span>{DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
    command: minio server /minio_data --console-address ":9001"
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  standalone:
    container_name: milvus-standalone
    image: milvusdb/milvus:v2.5.7-gpu
    command: ["milvus", "run", "standalone"]
    security_opt:
    - seccomp:unconfined
    environment:
      ETCD_ENDPOINTS: etcd:2379
      MINIO_ADDRESS: minio:9000
    volumes:
      - <span class="katex math inline">{DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
      # 新增下面这一行来实现配置文件的映射
      -</span>{DOCKER_VOLUME_DIRECTORY:-.}/milvus.yaml:/milvus/configs/milvus.yaml
    ports:
      - "19530:19530"
      - "9091:9091"
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              capabilities: ["gpu"]
              device_ids: ["0"]
    depends_on:
      - "etcd"
      - "minio"

# 在原docker-compose文件的这个位置添加下面这个attu容器，注意版本号和行前空格。
  attu:
    container_name: attu
    image: zilliz/attu:v2.5.6
    environment:
      MILVUS_URL: milvus-standalone:19530
    ports:
      - "8000:3000"  # 外部端口8000可以自定义
    depends_on:
      - "standalone"

networks:
  default:
    name: milvus
</code></pre>
<h3>启动Mlivus</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_e450eccd322cd2343c926939c6f070e3.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_e450eccd322cd2343c926939c6f070e3.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers"># 安装目录下运行命令
# 拉取镜像
docker-compose pull
# 启动容器
docker-compose up -d
# 查看启动状态（健康状态）
docker-compose ps -a
# 停止容器
docker-compose down
</code></pre>
<p>放开端口：连接数据库需要放开19530端口，这是milvus的默认端口，可在docker-compose.yml中修改。访问可视化面板放开8000端口（刚才自己设置的）做反向代理的话可以不用放开此端口。</p>
<h3>验证效果</h3>
<p>访问可视化面板并修改密码：<strong>http://ip:8000</strong></p>
<p><strong>默认账号：root<br />
默认密码：Milvus</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_bb1b7a1216bf2fd642e12ed929bf989c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/04/wp_editor_md_bb1b7a1216bf2fd642e12ed929bf989c.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2025/04/01/docker-compose%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae%e5%90%91%e9%87%8f%e6%95%b0%e6%8d%ae%e5%ba%93milvus%ef%bc%8c%e9%85%8d%e7%bd%ae%e5%8f%af%e8%a7%86%e5%8c%96attu/">Docker compose安装配置向量数据库Milvus，配置可视化Attu</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Ubuntu24.04 TLS桌面版安装Nvidia显卡驱动</title>
		<link>https://www.laobaiblog.top/2025/03/31/ubuntu24-04-tls%e6%a1%8c%e9%9d%a2%e7%89%88%e5%ae%89%e8%a3%85nvidia%e6%98%be%e5%8d%a1%e9%a9%b1%e5%8a%a8/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Mon, 31 Mar 2025 09:58:58 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[deepseek]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=525</guid>

					<description><![CDATA[<p>在经历无数次重装系统以及网上教程参差不齐的踩坑之路之后，终于找到了行之有效的方法。 一、硬件环境 硬 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2025/03/31/ubuntu24-04-tls%e6%a1%8c%e9%9d%a2%e7%89%88%e5%ae%89%e8%a3%85nvidia%e6%98%be%e5%8d%a1%e9%a9%b1%e5%8a%a8/">Ubuntu24.04 TLS桌面版安装Nvidia显卡驱动</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  在经历无数次重装系统以及网上教程参差不齐的踩坑之路之后，终于找到了行之有效的方法。
</p></blockquote>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/03/wp_editor_md_5a6cc48511a7c1850a7735fdc8e6ba96.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/03/wp_editor_md_5a6cc48511a7c1850a7735fdc8e6ba96.jpg" alt="" /></a></p>
<h3>一、硬件环境</h3>
<table>
<thead>
<tr>
<th>硬件</th>
<th>型号</th>
</tr>
</thead>
<tbody>
<tr>
<td>CPU</td>
<td>i7-14700K</td>
</tr>
<tr>
<td>显卡</td>
<td>七彩虹5090D ADOC 32G</td>
</tr>
<tr>
<td>内存</td>
<td>金士顿 128G</td>
</tr>
</tbody>
</table>
<h3>二、软件环境</h3>
<table>
<thead>
<tr>
<th>规格</th>
<th>版本</th>
</tr>
</thead>
<tbody>
<tr>
<td>系统</td>
<td><a class="wp-editor-md-post-content-link" href="https://cn.ubuntu.com/download">Ubuntu24.04 TLS 桌面版</a></td>
</tr>
<tr>
<td><strong>内核版本</strong></td>
<td><strong>6.13.8-061308-generic</strong></td>
</tr>
<tr>
<td><strong>gcc版本</strong></td>
<td><strong>gcc 14.2.0</strong> (Ubuntu 14.2.0-4ubuntu2~24.04)</td>
</tr>
</tbody>
</table>
<h3>2.1内核升级</h3>
<h4>2.1.1  在进行内核升级之前，建议更新系统中的所有软件包，以确保兼容性：</h4>
<pre><code class="language-shell line-numbers">sudo apt update
sudo apt upgrade -y
</code></pre>
<h4>2.1.2 下载内核包 原装6.11内核版本必须升级到6.13版本以上，gcc版本升级到14</h4>
<ul>
<li><strong>下载地址</strong>：</li>
<li><a class="wp-editor-md-post-content-link" href="https://kernel.ubuntu.com/mainline/v6.13.8/amd64/">kernel.ubuntu.com</a>，<strong>需要科学上网</strong>。</p>
</li>
<li>
<p><a class="wp-editor-md-post-content-link" href="https://pan.quark.cn/s/e79b0f21c268">夸克网盘：<strong>rmuW</strong></a></p>
</li>
</ul>
<pre><code class="language-shell line-numbers">1. linux-headers-6.13.8-061308_6.13.8-061308.202503222044_all.deb
2. linux-headers-6.13.8-061308-generic_6.13.8-061308.202503222044_amd64.deb
3. linux-image-unsigned-6.13.8-061308-generic_6.13.8-061308.202503222044_amd64.deb
4. linux-modules-6.13.8-061308-generic_6.13.8-061308.202503222044_amd64.deb
</code></pre>
<h4>2.1.3 安装内核包</h4>
<pre><code class="language-shell line-numbers">sudo dpkg -i linux-headers-6.13.8-061308_6.13.8-061308.202503222044_all.deb
sudo dpkg -i linux-headers-6.13.8-061308-generic_6.13.8-061308.202503222044_amd64.deb
sudo dpkg -i linux-modules-6.13.8-061308-generic_6.13.8-061308.202503222044_amd64.deb
sudo dpkg -i linux-image-unsigned-6.13.8-061308-generic_6.13.8-061308.202503222044_amd64.deb


#安装过程中，如果遇到依赖问题，可以运行以下命令进行修复
sudo apt --fix-broken install

#更新Grub并重启系统,安装内核后，需要更新Grub引导配置，以确保新内核能够被引导。执行以下命令
sudo update-grub
#完成Grub更新后，重启系统以加载新内核
sudo reboot

#验证内核升级
uname -r
#6.13.8-061308-generic
</code></pre>
<h3>2.2 gcc升级14.2</h3>
<h4>2.2.1 检查当前GCC版本</h4>
<pre><code class="language-shell line-numbers">gcc --version
</code></pre>
<h4>2.2.2 使用APT工具自动安装</h4>
<p>Ubuntu的APT包管理工具可以方便地安装GCC，但默认安装的可能是最新版本。要安装特定版本，可以使用以下命令：</p>
<pre><code class="language-shell line-numbers">sudo apt update
sudo apt install gcc-&lt;version&gt; g++-&lt;version&gt;

#例如，要安装GCC 14.2.0版本，可以输入：
sudo apt install gcc-14 g++-14
</code></pre>
<h3>三、安装NVIDIA驱动</h3>
<table>
<thead>
<tr>
<th>Distribution</th>
<th>$distro</th>
<th>$arch</th>
<th>$arch_ext</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ubuntu 24.04 LTS</td>
<td>ubuntu2404</td>
<td>x86_64</td>
<td>amd64</td>
</tr>
</tbody>
</table>
<p>执行安装前准备工作。当前正在运行的内核的内核头文件和开发包可以通过以下方式安装：</p>
<pre><code class="language-shell line-numbers">apt install linux-headers-$(uname -r)
</code></pre>
<h4>3.1 下载 NVIDIA 驱动程序：</h4>
<pre><code class="language-shell line-numbers">wget https://developer.download.nvidia.com/compute/nvidia-driver/<span class="katex math inline">version/local_installers/nvidia-driver-local-repo-</span>distro-<span class="katex math inline">version_</span>arch_ext.deb
#根据系统版本及驱动版，替换相应参数，即真实地址：
https://developer.download.nvidia.com/compute/nvidia-driver/570.124.06/local_installers/nvidia-driver-local-repo-ubuntu2404-570.124.06_1.0-1_amd64.deb
#NVIDIA 驱动程序版本 $version
</code></pre>
<h4>3.2 安装Nvidia驱动：</h4>
<pre><code class="language-shell line-numbers">dpkg -i nvidia-driver-local-repo-ubuntu2404-570.124.06_1.0-1_amd64.deb
apt update
注册临时公有 GPG 密钥：
cp /var/nvidia-driver-local-repo-ubuntu2404-570.124.06/nvidia-driver-*-keyring.gpg /usr/share/keyrings/
</code></pre>
<h4>3.3 Network Repository 安装</h4>
<p>安装新的 cuda-keyring 软件包：</p>
<pre><code class="language-shell line-numbers">wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb
dpkg -i cuda-keyring_1.1-1_all.deb
apt update
</code></pre>
<h4>3.4 启动驱动程序安装</h4>
<pre><code class="language-shell line-numbers"># Open Kernel Modules
apt install nvidia-open
# Proprietary Kernel Modules
apt install cuda-drivers
# 重启系统
reboot
</code></pre>
<h3>四、验证效果</h3>
<pre><code class="language-shell line-numbers">nvidia-smi
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2025/03/wp_editor_md_a7a70e297505c94abc9093406fc8d7a4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2025/03/wp_editor_md_a7a70e297505c94abc9093406fc8d7a4.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://docs.nvidia.com/datacenter/tesla/driver-installation-guide/index.html">官网参考地址</a>：https://docs.nvidia.com/datacenter/tesla/driver-installation-guide/index.html</p>
<p><a href="https://www.laobaiblog.top/2025/03/31/ubuntu24-04-tls%e6%a1%8c%e9%9d%a2%e7%89%88%e5%ae%89%e8%a3%85nvidia%e6%98%be%e5%8d%a1%e9%a9%b1%e5%8a%a8/">Ubuntu24.04 TLS桌面版安装Nvidia显卡驱动</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>使用docker部署pgsql，构建容灾高可用集群</title>
		<link>https://www.laobaiblog.top/2024/09/19/dockerpgbk/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Thu, 19 Sep 2024 07:04:30 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pgpool]]></category>
		<category><![CDATA[pgsql]]></category>
		<category><![CDATA[集群]]></category>
		<category><![CDATA[高可用]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=504</guid>

					<description><![CDATA[<p>postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换)，在pos &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/09/19/dockerpgbk/">使用docker部署pgsql，构建容灾高可用集群</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换)，在postgresql官网看了<a class="wp-editor-md-post-content-link" href="https://www.pgpool.net/mediawiki/index.php/Documentation">pgpool-II的文档</a>，发现部署比较麻烦，为了方便快捷还是使用docker部署。
</p></blockquote>
<h1>一、简介</h1>
<p><code>bitnami/postgresql-repmgr</code>是<code>PostgreSQL HA</code>对应的docker镜像，<code>PostgreSQL HA</code> 是 PostgreSQL 集群解决方案，其中包括 PostgreSQL 复制管理器，这是一个用于管理 PostgreSQL 集群上的复制和故障转移的开源工具。</p>
<p><code>bitnami/pgpool</code>是<code>Pgpool-II</code> 对应的docker镜像，是 PostgreSQL 代理。它位于 PostgreSQL 服务器和它们的客户端之间，提供连接池、负载平衡、自动故障转移和复制。</p>
<h1>二、部署环境</h1>
<ul>
<li>系统：CentOS Linux release 7.9.2009 (Core)</li>
<li>postgresql Version：postgresql-repmgr:14</li>
<li>pgpool Version：latest</li>
<li>Docker Version：20.10.21</li>
</ul>
<h3>1. 拉取docker镜像</h3>
<p>稳妥起见，这里选用了postgresql 14版本，其次如果遭遇docker镜像拉取网络问题，可以参考我的这篇博文<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/16/docker%e4%bb%93%e5%ba%93%e9%95%9c%e5%83%8f%e4%bb%a3%e7%90%86%e6%89%93%e9%80%a0%e5%b1%9e%e4%ba%8e%e8%87%aa%e5%b7%b1%e7%9a%84docker-hub/">打造属于自己的Docker Hub镜像代理网站</a>，或者在镜像前加入私有镜像站。</p>
<pre><code class="language-shell line-numbers">docker pull bitnami/postgresql-repmgr:14
docker pull bitnami/pgpool:latest

#私有镜像站eg
docker pull hub-mirror.c.163.com/bitnami/postgresql-repmgr:14
docker pull hub-mirror.c.163.com/bitnami/pgpool:latest
</code></pre>
<h3>2. 启动pgsql数据库</h3>
<ol>
<li>创建文件夹并授权</li>
</ol>
<pre><code class="language-shell line-numbers">cd /
mkdir data
cd data
mkdir repmgr1
mkdir repmgr2
chmod 777 /data/repmgr1
chmod 777 /data/repmgr2
</code></pre>
<ol start="2">
<li>创建docker网络</li>
</ol>
<pre><code class="language-shell line-numbers">docker network create pg-network
</code></pre>
<ol start="3">
<li>启动数据库<br />
为了数据持久化，我们把/bitnami/postgresql目录挂载到/data/repmgr1目录下。以下两条命令可以自行做成bash脚本启动。</li>
</ol>
<pre><code class="language-shell line-numbers">#pg-0数据库启动
docker run -v /data/repmgr1:/bitnami/postgresql --detach --restart always --name pg-0 -p 30350:5432 --network pg-network --env REPMGR_PARTNER_NODES=pg-0,pg-1 --env REPMGR_NODE_NAME=pg-0 --env REPMGR_NODE_NETWORK_NAME=pg-0 --env REPMGR_PRIMARY_HOST=pg-0 --env REPMGR_PASSWORD=123456 --env POSTGRESQL_PASSWORD=123456 bitnami/postgresql-repmgr:14
</code></pre>
<pre><code class="language-shell line-numbers">#pg-1数据库启动
docker run -v /data/repmgr2:/bitnami/postgresql --detach --restart always --name pg-1 -p 30351:5432 --network pg-network --env REPMGR_PARTNER_NODES=pg-0,pg-1 --env REPMGR_NODE_NAME=pg-1 --env REPMGR_NODE_NETWORK_NAME=pg-1 --env REPMGR_PRIMARY_HOST=pg-0 --env REPMGR_PASSWORD=123456 --env POSTGRESQL_PASSWORD=123456 bitnami/postgresql-repmgr:14
</code></pre>
<ol start="4">
<li>查看启动状态</li>
</ol>
<pre><code class="language-shell line-numbers">docker ps
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_53c9eb917a6049470cd79aaad78f45c2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_53c9eb917a6049470cd79aaad78f45c2.jpg" alt="" /></a></p>
<h3>3. 启动Pgpool</h3>
<p>注意，这里的<code>--add-host</code>参数对应的IP是你<strong>本地的宿主机IP</strong>，请自行修改。</p>
<pre><code class="language-shell line-numbers">docker run --detach --restart always --name pgpool -p 9999:5432 \
  --env PGPOOL_BACKEND_NODES=0:pg-0:30350,1:pg-1:30351 \
  --env PGPOOL_SR_CHECK_USER=postgres \
  --env PGPOOL_SR_CHECK_PASSWORD=123456 \
  --env PGPOOL_ENABLE_LDAP=no \
  --env PGPOOL_POSTGRES_USERNAME=postgres \
  --env PGPOOL_POSTGRES_PASSWORD=123456 \
  --env PGPOOL_ADMIN_USERNAME=postgres \
  --env PGPOOL_ADMIN_PASSWORD=123456 \
  --add-host=pg-0:192.168.1.204 \
  --add-host=pg-1:192.168.1.204 \
  bitnami/pgpool:latest
</code></pre>
<p>启动成功后，查看pgpool日志，通过pgpool可以实现数据库的负载均衡和读写分离。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_1665dd6bb789f5d7a5650c91028b8746.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_1665dd6bb789f5d7a5650c91028b8746.jpg" alt="" /></a></p>
<h3>4. 测试验证</h3>
<ol>
<li>navicat连接pgpool，创建user表并插入数据，看看<code>pg-0</code>及<code>pg-1</code>是否同步插入。</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_08857131284d85b7fd726fb0d4a5c480.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_08857131284d85b7fd726fb0d4a5c480.jpg" alt="" /></a></p>
<hr />
<p><code>pgpool</code>创建<code>user</code>表，插入数据</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_d61298966092bba2948e0fc3b46626da.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_d61298966092bba2948e0fc3b46626da.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_fb9a7662185c7a42dc7b0ed10ab8928d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_fb9a7662185c7a42dc7b0ed10ab8928d.jpg" alt="" /></a></p>
<ol start="2">
<li>验证：<code>pg-0</code>、<code>pg-1</code>同步插入</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_b71f72be299bfc3ae3136718e6abe34e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/09/wp_editor_md_b71f72be299bfc3ae3136718e6abe34e.jpg" alt="" /></a></p>
<p>以上方法非常简单，最后程序直接访问9999端口即可实现读写分离。</p>
<p><strong>缺点：<br />
只能再一个宿主机上执行，不能跨主机。Pgpool和Pgsql有更多的高可用方法，后续还可以深入，多服务器部署及新增组件等。</strong></p>
<p>参考地址：<br />
<a class="wp-editor-md-post-content-link" href="https://www.pgpool.net/mediawiki/index.php/Documentation">官网WIKI</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/applerosa/p/13160566.html">postgresql + pgpool 构建容灾高可用集群(数据同步流复制/主备自动切换)</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/hacker-linner/p/16173012.html">pgpool-II 4.3 中文手册</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/qgdtq/p/17106567.html">Postgresql通过docker进行高可用部署<br />
</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/eternityCulture/p/17528840.html">使用docker部署pg集群（postgresql+postgis+pgrouting+pgpool）</a></p>
<p><a href="https://www.laobaiblog.top/2024/09/19/dockerpgbk/">使用docker部署pgsql，构建容灾高可用集群</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Docker仓库镜像代理打造属于自己的Docker Hub</title>
		<link>https://www.laobaiblog.top/2024/07/16/docker%e4%bb%93%e5%ba%93%e9%95%9c%e5%83%8f%e4%bb%a3%e7%90%86%e6%89%93%e9%80%a0%e5%b1%9e%e4%ba%8e%e8%87%aa%e5%b7%b1%e7%9a%84docker-hub/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 16 Jul 2024 07:22:31 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[Cldouflare]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[Docker Hub]]></category>
		<category><![CDATA[Pages]]></category>
		<category><![CDATA[Workers]]></category>
		<category><![CDATA[国内访问Docker镜像]]></category>
		<category><![CDATA[镜像代理]]></category>
		<category><![CDATA[镜像加速]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=491</guid>

					<description><![CDATA[<p>本博文基于原博CMLiussss Blog编写，旨在中转对 Docker 官方镜像仓库，帮助国内用户 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/07/16/docker%e4%bb%93%e5%ba%93%e9%95%9c%e5%83%8f%e4%bb%a3%e7%90%86%e6%89%93%e9%80%a0%e5%b1%9e%e4%ba%8e%e8%87%aa%e5%b7%b1%e7%9a%84docker-hub/">Docker仓库镜像代理打造属于自己的Docker Hub</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<blockquote><p>
  本博文基于<a class="wp-editor-md-post-content-link" href="https://blog.090227.xyz/p/CF-Workers-docker.io/">原博CMLiussss Blog</a>编写，旨在中转对 Docker 官方镜像仓库，帮助国内用户访问被墙的Docker hub，只建议私人或公司内部使用，不推荐使用该项目搭建公共服务。使用你自己的域名搭建公共服务有可能会遭受<strong>污染、反诈或被墙</strong>，推荐小规模自用即可。
</p></blockquote>
<h3>环境准备</h3>
<ul>
<li><strong><a class="wp-editor-md-post-content-link" href="https://github.com/login">GitHub账号</a></strong></li>
<li><strong><a class="wp-editor-md-post-content-link" href="https://dash.cloudflare.com/login">Cloudflare账号</a></strong></li>
<li><strong>一个属于自己的域名</strong></li>
</ul>
<hr />
<h3>一、Docker代理工具介绍</h3>
<p><strong><a class="wp-editor-md-post-content-link" href="https://github.com/cmliu/CF-Workers-docker.io">本项目</a>是一个基于 <a class="wp-editor-md-post-content-link" href="https://github.com/cmliu/CF-Workers-docker.io">Cloudflare Workers 的 Docker 镜像代理工具</a>，旨在中转对 Docker 官方镜像仓库的请求，解决访问限制并加速访问。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_54e68b1d728e37cc1b057801abf85a92.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_54e68b1d728e37cc1b057801abf85a92.jpg" alt="" /></a></p>
<h4>为什么需要这个工具？</h4>
<p>由于<strong>神秘原因</strong>，国内用户逐渐无法访问Docker Hub仓库。这对于我们开发者来说是个不小的难题。<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_c53beb24b163c998a0165abb6f568c6d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_c53beb24b163c998a0165abb6f568c6d.jpg" alt="" /></a></p>
<hr />
<h3>二、GitHub Fork本项目</h3>
<p><strong>点击 <a class="wp-editor-md-post-content-link" href="https://github.com/cmliu/CF-Workers-docker.io">Github项目</a>中的<code>Fork</code>到本地自己的仓库即可。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_0e00ec03a8460fa925fa682908356f15.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_0e00ec03a8460fa925fa682908356f15.jpg" alt="" /></a></p>
<hr />
<h3>三、登录Cloudflare创建Pages自动化</h3>
<p><strong>登录 <a class="wp-editor-md-post-content-link" href="https://dash.cloudflare.com/login">cloudflare</a> ，点击<code>Works和Pages并创建</code>，选择<code>Pages</code>再连接到刚才我们Fork到Github本地仓库的项目</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_76dad882587baf9cc54c944df2618a9e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_76dad882587baf9cc54c944df2618a9e.jpg" alt="" /></a></p>
<hr />
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a34eaf7dcacdd2a28d70807887cb2942.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a34eaf7dcacdd2a28d70807887cb2942.jpg" alt="" /></a></p>
<hr />
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_86ba8012e8339c2a42b9409ddfedc8ab.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_86ba8012e8339c2a42b9409ddfedc8ab.jpg" alt="" /></a></p>
<hr />
<h3>四、开始部署设置</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_e74f76e3b13e8fb90924dd6c42b6ed77.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_e74f76e3b13e8fb90924dd6c42b6ed77.jpg" alt="" /></a></p>
<p><strong>部署完成后可以进入Pages里的自动化项目，给它设置一个自定义域名。假如我有一个顶级域名：<code>laobaiblog.top</code>，那我可以再自定义域名中配置一个：<code>docker.laobaiblog.top</code>作为我的Docker代理域名。</strong></p>
<hr />
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_7bf1740f0ea23278e45d721a9670e861.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_7bf1740f0ea23278e45d721a9670e861.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_cbb717c6ddab71dc8f27120b9f7fb026.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_cbb717c6ddab71dc8f27120b9f7fb026.jpg" alt="" /></a></p>
<p><strong>选择DNS解析，在域名解析中添加上Cloudflare生成给你的<code>CNAME记录</code>。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_5f933d2a167bf8dee77028eef8dc2e44.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_5f933d2a167bf8dee77028eef8dc2e44.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_9b62328b1e2623cae1dd08273937c5cd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_9b62328b1e2623cae1dd08273937c5cd.jpg" alt="" /></a></p>
<p><strong>在你自己的域名解析管理中，添加CNAME记录，填入<code>主机记录</code>及<code>记录值</code>参数，等待5分钟后检查DNS记录。完成后访问代理域名会发现自动跳转为官网Docker Hub，且无需翻墙就说明已经实现了docker镜像代理。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_831105c29803556dddd33044e0c27f87.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_831105c29803556dddd33044e0c27f87.jpg" alt="" /></a></p>
<h4>地址栏输入你的自定义域名搜索镜像查询，毫无压力。</h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_fde65cd2e8d255a3d7be1a361546fb15.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_fde65cd2e8d255a3d7be1a361546fb15.jpg" alt="" /></a></p>
<hr />
<h3>五、配置验证</h3>
<p><strong>在国内服务器上拉取镜像发现无法拉取，一直显示等待连接，各个大厂的镜像源都无法使用或仅内部使用。</strong></p>
<pre><code class="language-shell line-numbers">docker pull nginx
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_c42c15e2933dbf64781e4dde383a515d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_c42c15e2933dbf64781e4dde383a515d.jpg" alt="" /></a></p>
<hr />
<p><strong>拉取镜像时加上自己代理的域名。拉取镜像仓库的命令 <code>docker pull docker.laobaiblog.top/nginx</code> 即可拉取镜像。</strong></p>
<pre><code class="language-shell line-numbers">docker pull docker.laobaiblog.top/nginx
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_8dfc141d01a9a43a184d395b3e677dd0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_8dfc141d01a9a43a184d395b3e677dd0.jpg" alt="" /></a></p>
<p><strong>你甚至可以将你的域名配置在<code>daemon.json</code>中，即可直接使用<code>docker pull nginx</code>无需再加上域名的前缀。在这里也提供了一些大佬无私分享的代理域名。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a3cf47fc63957e428b02f1a13124bd95.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a3cf47fc63957e428b02f1a13124bd95.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#编辑daemon.json
vim /etc/docker/daemon.json
:wq

#重启daemon配置
systemctl daemon-reload

#重启docker
systemctl restart docker.service

</code></pre>
<hr />
<table>
<thead>
<tr>
<th>DockerHub 镜像仓库</th>
<th>镜像地址</th>
</tr>
</thead>
<tbody>
<tr>
<td>bestcfipas镜像服务</td>
<td>https://docker.registry.cyou</td>
</tr>
<tr>
<td></td>
<td>https://docker-cf.registry.cyou</td>
</tr>
<tr>
<td>zero_free镜像服务</td>
<td>https://docker.jsdelivr.fyi</td>
</tr>
<tr>
<td></td>
<td>https://dockercf.jsdelivr.fyi</td>
</tr>
<tr>
<td></td>
<td>https://dockertest.jsdelivr.fyi</td>
</tr>
<tr>
<td>docker proxy</td>
<td>https://dockerpull.com</td>
</tr>
<tr>
<td></td>
<td>https://dockerproxy.cn</td>
</tr>
<tr>
<td>Docker镜像加速站</td>
<td>https://hub.uuuadc.top</td>
</tr>
<tr>
<td></td>
<td>https://docker.1panel.live</td>
</tr>
<tr>
<td></td>
<td>https://hub.rat.dev</td>
</tr>
</tbody>
</table>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2022/01/18/centos7%e5%ae%89%e8%a3%85docker%e5%b9%b6%e6%9b%b4%e6%94%b9%e9%bb%98%e8%ae%a4%e5%ad%98%e5%82%a8%e6%96%87%e4%bb%b6%e4%bd%8d%e7%bd%ae/" title="Centos7安装Docker并更改默认存储文件位置">Centos7安装Docker并更改默认存储文件位置</a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2022/02/23/centos7%e7%a6%bb%e7%ba%bf%e5%ae%89%e8%a3%85docker-ce/" title="CentOS7离线安装docker-ce">CentOS7离线安装docker-ce</a></p>
<p><a href="https://www.laobaiblog.top/2024/07/16/docker%e4%bb%93%e5%ba%93%e9%95%9c%e5%83%8f%e4%bb%a3%e7%90%86%e6%89%93%e9%80%a0%e5%b1%9e%e4%ba%8e%e8%87%aa%e5%b7%b1%e7%9a%84docker-hub/">Docker仓库镜像代理打造属于自己的Docker Hub</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS7 Openssh离线升级至9.8p1，OpenSSL升级至1.1.1w</title>
		<link>https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 09 Jul 2024 07:02:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[openssl]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=481</guid>

					<description><![CDATA[<p>Openssh经过一段时间的等保测试，看来又得重新升级。略微删减了一下脚本，在离线环境中使用。 相关 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh离线升级至9.8p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>Openssh经过一段时间的等保测试，看来又得重新升级。略微删减了一下脚本，在离线环境中使用。</em></p>
<h3>相关环境</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_b07c39eeaf26c7ab4682643f5f4515e4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_b07c39eeaf26c7ab4682643f5f4515e4.jpg" alt="" /></a></p>
<ul>
<li>系统：CentOS Linux release 7.9.2009 (Core)</li>
<li><a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/">OpenSSH版本</a> : 7.4p1 &#8212;> <a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/">9.8p1</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/old/1.1.1/index.html">OpenSSL版本</a> ：1.0.2k &#8212;> <a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/openssl-1.1.1w.tar.gz">1.1.1w</a></li>
<li>zlib版本(需要外网下载，根据需要更换版本)：<a class="wp-editor-md-post-content-link" href="http://www.zlib.net/zlib-1.3.1.tar.gz">1.3.1</a></li>
</ul>
<h3>Openssh离线安装升级</h3>
<ul>
<li><strong><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/i0vwY23zevab">蓝奏云下载</a></strong> (离线安装包也已经整理好相关脚本依赖，防止CSDN白嫖党，解压密码：laobai)</li>
</ul>
<p>文中常用命令：</p>
<pre><code class="language-shell line-numbers">#查看Linux信息
[root@asdasd ~] uname -a
Linux ZKHY 3.10.0-1160.62.1.el7.x86_64 1 SMP Tue Apr 5 16:57:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
#查看centos版本
[root@asdasd ~] cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
#查看ssh版本
[root@adasd ~] ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
#创建脚本安装目录
[root@asdasd ~]mkdir -p /root/OpenSSH
</code></pre>
<h4><strong>1. 将脚本解压放到<code>/root/OpenSSH</code>下。</strong></h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a0e52f483aa36d9df645ad23c70ef4b5.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_a0e52f483aa36d9df645ad23c70ef4b5.jpg" alt="" /></a></p>
<h4><strong>2. 授权脚本运行升级Openssh及Openssl,静待升级即可。</strong></h4>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_eaade98e038fc094bb60fa7bd0141f7b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_eaade98e038fc094bb60fa7bd0141f7b.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#进入安装目录
[root@asdasd ~]# cd /root/OpenSSH/
[root@asdasd OpenSSH]# ll
total 13024
-rw-r--r-- 1 root root 1910393 Jul  9 14:38 openssh-9.8p1.tar.gz
-rw-r--r-- 1 root root 9893384 Jul  9 14:38 openssl-1.1.1w.tar.gz
drwxr-xr-x 3 root root    4096 Jul  9 14:38 packages
-rw-r--r-- 1 root root    5590 Jul  9 14:38 UpdateOpenSSH.sh
-rw-r--r-- 1 root root 1512791 Jul  9 14:38 zlib-1.3.1.tar.gz
#授权脚本执行权限
[root@asdasd OpenSSH]# chmod a+x UpdateOpenSSH.sh
#运行升级脚本
[root@asdasd OpenSSH]# ./UpdateOpenSSH.sh
</code></pre>
<h3>升级效果</h3>
<pre><code class="language-shell line-numbers">#输入命令查看升级效果
ssh -V
OpenSSH_9.8p1, OpenSSL 1.1.1w  11 Sep 2023
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_1365d8240319cd0ef00abd7fdb36661b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/07/wp_editor_md_1365d8240319cd0ef00abd7fdb36661b.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh离线升级至9.8p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>使用Nginx转发代理ChatGpt接口，Java调用实现多轮对话</title>
		<link>https://www.laobaiblog.top/2024/01/15/%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91%e4%bb%a3%e7%90%86chatgpt%e6%8e%a5%e5%8f%a3%ef%bc%8cjava%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%bd%ae%e5%af%b9%e8%af%9d/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Mon, 15 Jan 2024 07:50:02 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[域名]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=462</guid>

					<description><![CDATA[<p>一、理论概述 ChatGpt接口目前只能在国外互联网环境中使用，国内想要使用相关服务的话可以寻求代理 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2024/01/15/%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91%e4%bb%a3%e7%90%86chatgpt%e6%8e%a5%e5%8f%a3%ef%bc%8cjava%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%bd%ae%e5%af%b9%e8%af%9d/">使用Nginx转发代理ChatGpt接口，Java调用实现多轮对话</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h3>一、理论概述</h3>
<p>ChatGpt接口目前只能在国外互联网环境中使用，国内想要使用相关服务的话可以寻求代理，在这里使用的是一台国外服务器安装Nginx服务进行相关代理。</p>
<h3>二、环境要求</h3>
<ul>
<li>一台拥有公网IP的国外服务器</li>
<li>一个域名及免费ssl证书（可在腾讯云免费申请ssl证书）</li>
<li>一个ChatGpt账号及相关的<a class="wp-editor-md-post-content-link" href="https://platform.openai.com/api-keys">APIkey</a></li>
</ul>
<p>以上就是所有需要用到的环境，<strong><em>请注意，如要使用接口还需要<a class="wp-editor-md-post-content-link" href="https://platform.openai.com/account/billing/overview">充值API</a>额度</em></strong>。除此之外还需要将你的域名解析到公网IP上。完成准备工作后进行以下操作。</p>
<h3>三、Nginx转发</h3>
<ol>
<li>在服务器中安装nginx，这里使用的是docker服务，根据以往博文中可自行安装Docker服务。</li>
</ol>
<pre><code class="language-shell line-numbers">#服务器中新建一个nginx目录，下级目录新建conf.d、logs、ssl三个目录
mkdir -p nginx/conf.d
mkdir -p nginx/logs
mkdir -p nginx/ssl

#在nginx目录中新建start.sh脚本
vim start.sh

docker stop nginx
docker rm nginx
docker run  -p 80:80  -p 443:443 --name nginx --net=host  --restart=always  --privileged=true \
    -v `pwd`/conf.d/:/etc/nginx/conf.d \
    -v `pwd`/logs/:/var/log/nginx  \
    -v `pwd`/ssl/:/var/ssl \
    -e TZ="Asia/Shanghai" \
    nginx:latest

#输入 :wq 保存后授权并执行即可
chmod a+x start.sh
./start.sh
</code></pre>
<ol start="2">
<li>将域名ssl证书放置在ssl目录下后，编辑nginx转发代理，执行<code>start.sh</code>脚本重启nginx服务。</li>
</ol>
<pre><code class="language-shell line-numbers">vim conf.d/gpt.conf

#填入域名信息
server {
        listen       443 ssl;
        server_name  域名;
        ssl_certificate /var/ssl/域名.crt;     #配置证书位置
        ssl_certificate_key /var/ssl/域名.key; #配置秘钥位置】

        ssl_session_timeout 5m;
        ssl_protocols SSLv2 SSLv3 TLSv1.2;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers on;

        underscores_in_headers on;
        charset utf-8;

        location /v1/ {
             proxy_ssl_server_name on;
             proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
             proxy_pass https://api.openai.com;
        }
}
</code></pre>
<p>以上便完成了针对chatgpt接口地址 <strong><em><code>api.openai.com</code></em></strong> 的转发工作，转发后的地址既是你的域名。</p>
<h3>四、Java实例调用实现多轮对话</h3>
<ol>
<li>新建Maven项目ChatGPTClient，在<code>pom.xml</code>中添加后续用到的依赖，重构后拉取。</li>
</ol>
<pre data-language=XML><code class="language-markup line-numbers">&lt;dependency&gt;
            &lt;groupId&gt;com.squareup.okhttp3&lt;/groupId&gt;
            &lt;artifactId&gt;okhttp&lt;/artifactId&gt;
            &lt;version&gt;4.9.3&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
            &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
            &lt;artifactId&gt;gson&lt;/artifactId&gt;
            &lt;version&gt;2.8.9&lt;/version&gt; &lt;!-- 使用最新的可用版本 --&gt;
&lt;/dependency&gt;
</code></pre>
<ol start="2">
<li>java代码</li>
</ol>
<pre><code class="language-shell line-numbers">import okhttp3.*;
import com.google.gson.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ChatGPTClient {
    private final String apiKey;
    private final OkHttpClient client;
    private final List&lt;Message&gt; messages;
    private final Gson gson;
    private int tokenCount = 0;
    private int inputTokenCount = 0;
    private int outputTokenCount = 0;

    public ChatGPTClient(String apiKey) {
        this.apiKey = apiKey;
        this.client = new OkHttpClient();
        this.messages = new ArrayList&lt;&gt;();
        this.gson = new Gson();
    }

    public String sendMessage(String message) throws IOException {
        updateTokenCount(message, true);

        messages.add(new Message("system", "user", message));
//model模型选择可以有gpt-3.5-turbo、gpt-4、gpt-4-turbo价格以此类推
        RequestBody body = RequestBody.create(
                MediaType.get("application/json; charset=utf-8"),
                "{\"model\": \"gpt-3.5-turbo\", \"messages\": " + gson.toJson(messages) + "}"
        );

        Request request = new Request.Builder()
                .url("https://你的域名地址/v1/chat/completions")
                .addHeader("Authorization", "Bearer " + this.apiKey)
                .addHeader("Content-Type", "application/json")
                .post(body)
                .build();

        try (Response response = client.newCall(request).execute()) {
            JsonObject respJson = JsonParser.parseString(response.body().string()).getAsJsonObject();
            JsonArray choices = respJson.getAsJsonArray("choices");
            if (choices != null &amp;&amp; choices.size() &gt; 0) {
                JsonObject firstChoice = choices.get(0).getAsJsonObject();
                String aiResponse = firstChoice.getAsJsonObject("message").get("content").getAsString();

                updateTokenCount(aiResponse, false);

                messages.add(new Message("system", "assistant", aiResponse));

                System.out.println("输入的 Token 数: " + inputTokenCount);
                System.out.println("输出的 Token 数: " + outputTokenCount);
                System.out.println("总使用的 Token 数: " + tokenCount);

                return aiResponse;
            }
        }
        return "无法获取响应。";
    }

    private void updateTokenCount(String text, boolean isInput) {
        int count = 0;
        for (char c : text.toCharArray()) {
            count += (String.valueOf(c).matches("[\\u0000-\\u00ff]") ? 1 : 4);
        }
        int tokens = (int) Math.ceil(count / 4.0);
        tokenCount += tokens;
        if (isInput) {
            inputTokenCount += tokens;
        } else {
            outputTokenCount += tokens;
        }
    }

    private static class Message {
        String role;
        String content;

        public Message(String type, String role, String content) {
            this.role = role;
            this.content = content;
        }
    }

    public static void main(String[] args) throws IOException {
        ChatGPTClient client = new ChatGPTClient("YOUR-API-KEY");

        Scanner scanner = new Scanner(System.in, "UTF-8");
        String input;
        while (true) {
            System.out.print("输入消息（输入 'bye' 结束对话）: ");
            input = scanner.nextLine();
            if ("bye".equalsIgnoreCase(input)) {
                break;
            }
            String response = client.sendMessage(input);
            System.out.println("ChatGPT 回应: " + response);
        }
    }
}

</code></pre>
<p>在以上代码中，增加了每次对话后所使用的token值，以便查询核对接口使用费。可在官网查询相关定价。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_7ca6ffab890759733ec128bda9db6a20.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_7ca6ffab890759733ec128bda9db6a20.jpg" alt="" /></a></p>
<h3>五、运行结果</h3>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_86a520f2c97f583072037ca931be6455.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2024/01/wp_editor_md_86a520f2c97f583072037ca931be6455.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2024/01/15/%e4%bd%bf%e7%94%a8nginx%e8%bd%ac%e5%8f%91%e4%bb%a3%e7%90%86chatgpt%e6%8e%a5%e5%8f%a3%ef%bc%8cjava%e8%b0%83%e7%94%a8%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%bd%ae%e5%af%b9%e8%af%9d/">使用Nginx转发代理ChatGpt接口，Java调用实现多轮对话</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS7 Openssh升级至9.5p1，OpenSSL升级至1.1.1w</title>
		<link>https://www.laobaiblog.top/2023/11/22/centos7-openssh%e5%8d%87%e7%ba%a7%e8%87%b39-5p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 22 Nov 2023 06:08:25 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[zlib]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=439</guid>

					<description><![CDATA[<p>前言：近期等保出现了openssh相关漏洞，所以改了一下之前的在线升级脚本，将Openssh升级至9 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2023/11/22/centos7-openssh%e5%8d%87%e7%ba%a7%e8%87%b39-5p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh升级至9.5p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>前言：近期等保出现了openssh相关漏洞，所以改了一下之前的在线升级脚本，将Openssh升级至9.5p1，OpenSSL升级至1.1.1w，已测试放心食用。</em></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">已更新最新OpenSSH9.8p1</a></p>
<h3>相关环境</h3>
<ul>
<li>系统：CentOS Linux release 7.9.2009 (Core)</li>
<li>OpenSSH版本: <a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz">9.5p1</a></li>
<li>OpenSSL版本：<a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/openssl-1.1.1w.tar.gz">1.1.1w</a></li>
<li>zlib版本(需要外网下载，根据需要更换版本)：<a class="wp-editor-md-post-content-link" href="http://www.zlib.net/zlib-1.3.1.tar.gz">1.2.12</a></li>
</ul>
<h3>联网升级安装</h3>
<p><strong><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/igONT1flluxc">脚本蓝奏云下载</a></strong>（离线安装包也已经整理好相关脚本依赖，防止CSDN白嫖党，解压密码：laobai）</p>
<pre><code class="language-shell line-numbers">#创建安装目录
mkdir -p /root/OpenSSH/zlib/
</code></pre>
<p><strong>将zlib-1.2.12.tar.gz依赖包上传至/root/OpenSSH/zlib/目录下运行压缩包中的脚本即可</strong></p>
<pre><code class="language-shell line-numbers">#将脚本放入/root/OpenSSH目录下
cd /root/OpenSSH

#将下段代码复制粘贴后授权运行即可
chmod a+x UpdateOpenSSH.sh
./UpdateOpenSSH.sh
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/iOH1o1flp0oh"><strong>脚本下载</strong></a>（网页可能会有符号替换，不建议复制）</p>
<pre><code class="language-shell line-numbers">#!/bin/bash

clear
echo ------------------------------------------
echo        CentOS7 openssh升级到9.5p1
echo              <span class="katex math inline">(date +%F-%T)
echo         注意环境，使用前请做好测试！！！
echo ------------------------------------------
sleep 3s
clear
echo 安装进程开始  3
sleep 1s
clear
echo 安装进程开始  3  2
sleep 1s
clear
echo 安装进程开始  3  2  1
sleep 1s
clear
echo 刷新yum元数据缓存
sleep 2s

yum makecache
sleep 3s
clear
echo 检测安装telnet服务
sleep 1s
echo 尝试启动telnet服务
sleep 1s
cp /etc/securetty /etc/securetty.bak
grep  "pts/0"  /etc/securetty ||  echo 'pts/0' >> /etc/securetty
grep  "pts/1"  /etc/securetty ||  echo 'pts/1' >> /etc/securetty
systemctl restart telnet.socket &&  systemctl restart xinetd
ps -ef |grep xinetd | egrep -v grep > /dev/null
if [</span>? -eq 0 ]
then
    echo 检测到telnet服务已启动……
    systemctl enable telnet.socket
    systemctl enable xinetd
        sleep 2s
else
    echo 未检测到telnet服务，开始安装服务……
    sleep 2s
    yum -y install xinetd telnet-server
    sleep 2s
    clear
    echo 安装telnet服务结束，启动服务……
    systemctl restart telnet.socket &&  systemctl restart xinetd
    systemctl enable telnet.socket
    systemctl enable xinetd
    sleep 1s
fi
clear
echo 关闭SElinux及防火墙并禁用……
sleep 2s
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
cat /etc/selinux/config
systemctl stop firewalld.service
systemctl disable firewalld.service
sleep 2s
clear
echo 安装程序依赖包……
sleep 2s
#yum -y localinstall ls packages/*.rpm
yum -y install gcc gcc-c++ make pam pam-devel openssl-devel pcre-devel perl zlib-devel
sleep 1s
clear
echo 停止并卸载原有ssh
sleep 3s
systemctl stop sshd
cp -r /etc/ssh /etc/ssh.old
cp -r /etc/init.d/ssh /etc/init.d/ssh.old
rpm -qa | grep openssh
sleep 1s
rpm -e `rpm -qa | grep openssh` --nodeps
rpm -qa | grep openssh
sleep 1s
clear

echo 判断是否需要安装wget
WGET=`rpm -qa | grep wget`
if [<span class="katex math inline">WGET -z ];then
    yum install -y wget
fi
echo 准备文件和参数
echo ################################################################
echo 服务器无法联网下载的可以将所需要的升级包放到/root/OpenSSH目录下
echo ################################################################
file=/root/OpenSSH
#zlib=http://www.zlib.net/zlib-1.2.12.tar.gz
openssl=https://www.openssl.org/source/openssl-1.1.1w.tar.gz
openssh=https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz 
echo 创建目录
mkdir -p</span>file/zlib
mkdir -p <span class="katex math inline">file/openssl
mkdir -p</span>file/openssh
echo 联网通过wget下载安装包
cd <span class="katex math inline">file
#echo 开始下载zlib
#wget</span>zlib
echo 开始下载openssl
wget --no-check-certificate <span class="katex math inline">openssl
echo 开始下载openssh
wget --no-check-certificate</span>openssh
###安装相关依赖包###
yum install -y gcc make perl zlib zlib-devel pam pam-devel

echo 安装zlib
sleep 2s
tar -xzf zlib*.tar.gz -C <span class="katex math inline">file/zlib 
sleep 2s
cd</span>file/zlib/zlib*
./configure --prefix=/usr/local/zlib && make && make install
ls -l /usr/local/zlib
cd ..
sleep 1s
clear
echo 配置zlib
grep  "/usr/local/zlib/lib"  /etc/ld.so.conf.d/zlib.conf ||  echo '/usr/local/zlib/lib' >> /etc/ld.so.conf.d/zlib.conf
ldconfig -v
sleep 1s
clear
echo 安装openssl
sleep 5s
mv -f /usr/bin/openssl /usr/bin/openssl.old
mv -f /usr/include/openssl /usr/include/openssl.old
mv -f /usr/lib64/openssl /usr/lib64/openssl.old
rm -rf /usr/local/ssl
cd <span class="katex math inline">file
tar -xzf openssl*.tar.gz -C</span>file/openssl
cd <span class="katex math inline">file/openssl/openssl*
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib && make && make install
cd ..
sleep 5s
clear
echo 配置openssl
sleep 5s
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
grep  "/usr/local/ssl/lib"  /etc/ld.so.conf.d/ssl.conf ||  echo '/usr/local/ssl/lib' >> /etc/ld.so.conf.d/ssl.conf
grep  "/usr/local/lib"  /etc/ld.so.conf.d/ssl.conf ||  echo '/usr/local/lib' >> /etc/ld.so.conf.d/ssl.conf
ldconfig -v
openssl version -a
sleep 5s
clear
echo 安装openssh
sleep 5s
rm -rf /etc/ssh
cd</span>file
tar -xzf openssh*.tar.gz -C <span class="katex math inline">file/openssh
cd</span>file/openssh/openssh*
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl   --with-zlib --with-md5-passwords
make
sleep 5s
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
make install
cd ..
pwd
sleep 5s
clear
echo 配置openssh
sleep 10s
echo "PasswordAuthentication yes"   >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo 'Banner /etc/issue' >> /etc/ssh/sshd_config
cp -p openssh-9.5p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
chkconfig --add sshd
chkconfig sshd on
systemctl restart sshd
sleep 10s
clear
systemctl status sshd
if [ $? -eq 0 ]
then
    clear
    echo SSH安装并运行成功，开始关闭并禁用telnet
    sleep 1s
    systemctl stop telnet.socket &&  systemctl stop xinetd
    systemctl disable telnet.socket &&  systemctl disable xinetd
    sleep 1s
    echo 升级完成,安装ssh2扩展支持
    sleep 5s
    yum install libssh2 -y
    clear
    echo 安装进程结束
    sleep 5s
else
    echo SSH未成功安装或配置，安装进程即将退出，请检查日志……
    sleep 5s
fi

</code></pre>
<h3>升级成功</h3>
<pre><code class="language-shell line-numbers">#输入命令查看升级效果
ssh -V
OpenSSH_9.5p1, OpenSSL 1.1.1w  11 Sep 2023
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/11/wp_editor_md_4c74046be04e58d1cfd0c80ae1ed264d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/11/wp_editor_md_4c74046be04e58d1cfd0c80ae1ed264d.jpg" alt="" /></a></p>
<ul>
<li>这是我之前的博文：<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2022/04/01/centos-7-%e7%a6%bb%e7%ba%bf%e6%9b%b4%e6%96%b0%e5%8d%87%e7%ba%a7-openssh-8-8p1/">CentOS 7 离线更新升级 openSSH 8.8p1</a></li>
<li>另附手动升级博文：<a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/simendavid/archive/2023/10/27/17792570.html#!comments">湖南馒头:CentOS7 OpenSSL升级1.1.1w；OpenSSH 升级 9.5p1 保姆级教程 </a></li>
</ul>
<p><a href="https://www.laobaiblog.top/2023/11/22/centos7-openssh%e5%8d%87%e7%ba%a7%e8%87%b39-5p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS7 Openssh升级至9.5p1，OpenSSL升级至1.1.1w</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ChatGPT Java实例接入</title>
		<link>https://www.laobaiblog.top/2023/02/21/chatgpt%e6%8e%a5%e5%85%a5%e5%ae%9e%e4%be%8b/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 21 Feb 2023 06:51:06 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[openAi]]></category>
		<category><![CDATA[人工智能]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=385</guid>

					<description><![CDATA[<p>前言：ChatGPT因为国内的各种原因，官网目前已经提高了原生IP的访问门槛。 现状 应该有很多人和 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2023/02/21/chatgpt%e6%8e%a5%e5%85%a5%e5%ae%9e%e4%be%8b/">ChatGPT Java实例接入</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>前言：ChatGPT因为国内的各种原因，官网目前已经提高了原生IP的访问门槛。</em></p>
<h2>现状</h2>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_05555a3648930d6f79441546e9b1d2d4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_05555a3648930d6f79441546e9b1d2d4.jpg" alt="" /></a></p>
<p>应该有很多人和我一样，之前能在<a class="wp-editor-md-post-content-link" href="https://chat.openai.com/chat">官网</a>直接使用<a class="wp-editor-md-post-content-link" href="https://chat.openai.com/chat">ChatGPT</a>，现在因为节点IP不够纯正而被限制访问，不过好在<strong>官网提供的API接口是正常使用的</strong>，所以曲线救国思路就是：</p>
<ul>
<li>申请官网API keys</p>
</li>
<li>
<p>查看官网实例调用ChatGPT</p>
</li>
<li>
<p>API调用额度查看</p>
</li>
</ul>
<h4>申请API keys</h4>
<p>前文：<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2022/12/08/chatgpt%e6%b3%a8%e5%86%8c%e4%bd%bf%e7%94%a8%e7%b3%bb%e5%88%97%e4%b8%80/">ChatGPT注册使用系列一</a>文中，注册好账号后，在<a class="wp-editor-md-post-content-link" href="https://platform.openai.com/account/api-keys">个人页</a>创建自己的<strong>API keys</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8fced2b62d0e7686a5329f9aac7e7c0e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8fced2b62d0e7686a5329f9aac7e7c0e.jpg" alt="" /></a></p>
<h4>官网支持语言一览</h4>
<p><a class="wp-editor-md-post-content-link" href="https://platform.openai.com/docs/libraries/community-libraries">官网</a>中可以看到ChatGPT已经支持很多语言接入了。</p>
<p><a class="wp-editor-md-post-content-link" href="https://github.com/TheoKanning/openai-java">openai-java</a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d57dfa1fcca95a80803e95b3ef67dc47.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d57dfa1fcca95a80803e95b3ef67dc47.jpg" alt="" /></a></p>
<h4>调用费用</h4>
<p>程序接入到 ChatGPT，<strong>调用接口要收费的</strong>。<br />
不过<strong>新注册的账号，前3个月免费使用，总消费额度不超过18美元</strong>。<br />
我的账号是到2023年4月1日，这期间只要调用费用不超过18美元相当于是免费使用</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_5ebb08c846a4ad8dee1ca49bcaadae83.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_5ebb08c846a4ad8dee1ca49bcaadae83.jpg" alt="" /></a></p>
<h2>官网实例接入</h2>
<p>以上准备工作及注意事项做好之后，我们就可以开始接入ChatGPT了。<br />
下面是官网给出的调用例子（只是其中一个使用场景）</p>
<pre><code class="language-shell line-numbers">curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model": "text-davinci-003", "prompt": "中国的首都是什么地方？", "temperature": 0, "max_tokens": 7}'
</code></pre>
<p><strong>重要参数解释：</strong></p>
<ul>
<li><strong>model：接入模型</strong><br />
<a class="wp-editor-md-post-content-link" href="https://platform.openai.com/docs/models/gpt-3">OpenAI API</a>提供了一系列具有不同功能和价格点的模型,其中，GPT-3是最为智能的模型，也是收费最高的，后面代码中我们将使用其中的text-davinci-003。<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6853edb2ae5e4b1cbd79af59a0cb414a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6853edb2ae5e4b1cbd79af59a0cb414a.jpg" alt="" /></a><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b937e808a676673c239b6f648d95f652.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b937e808a676673c239b6f648d95f652.jpg" alt="" /></a></li>
</ul>
<h4>使用场景</h4>
<p>官网给我们列出来很多使用<strong><a class="wp-editor-md-post-content-link" href="https://platform.openai.com/examples">场景</a></strong></p>
<ul>
<li>Answers（问答场景）<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fbc63daab97421d75e28d4c28f1b5da2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fbc63daab97421d75e28d4c28f1b5da2.jpg" alt="" /></a></p>
</li>
<li>
<p>Classification（分类场景）<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b07d4627ab63e58198215d23daaae228.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b07d4627ab63e58198215d23daaae228.jpg" alt="" /></a></p>
</li>
<li>
<p>Code(代码场景)<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8488f7a00c66e29339a3010ebb8d1d04.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8488f7a00c66e29339a3010ebb8d1d04.jpg" alt="" /></a></p>
</li>
<li>
<p>Conversation（谈话场景）<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_cd7e8e6dc56b453179e0aadba442b109.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_cd7e8e6dc56b453179e0aadba442b109.jpg" alt="" /></a></p>
</li>
<li>
<p>Translation（翻译场景）<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b5ebdd7240f8fad098e99708d6230ded.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b5ebdd7240f8fad098e99708d6230ded.jpg" alt="" /></a></p>
</li>
<li>
<p>Transformation（转换场景）<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6f99e394d7cfe6f39bdcea29263e58c2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6f99e394d7cfe6f39bdcea29263e58c2.jpg" alt="" /></a></p>
</li>
</ul>
<h3>代码实现</h3>
<p>官网有大约49种场景。代码中，我们以<strong>Answers（问答场景）</strong> 为例，只要<strong>点场景图标</strong>，就可以<strong>跳到该场景查看对应参数调用实例</strong>了。具体如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fa0e4302233c0949146cd7560d873a89.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fa0e4302233c0949146cd7560d873a89.jpg" alt="" /></a></p>
<h4>postman调用测试</h4>
<p><em>可以在github中下载对应汉化版本的 <a class="wp-editor-md-post-content-link" href="https://github.com/hlmd/Postman-cn">postman</a>，参考<a class="wp-editor-md-post-content-link" href="https://www.quanxiaoha.com/article/postman-set-cn.html">相应教程</a></em></p>
<ul>
<li><strong>选择请求方式，填入接口地址，添加自己账号创建的Token</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ad7183ad7ef3c68d755eeb4235eddb60.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ad7183ad7ef3c68d755eeb4235eddb60.jpg" alt="" /></a></p>
<ul>
<li><strong>请求头中添加Content-Type类型为json</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_7ec77d39456140b33981c109d868e937.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_7ec77d39456140b33981c109d868e937.jpg" alt="" /></a></p>
<ul>
<li><strong>拼接json格式的入参</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8b99f937d1cff8abb84c8d82f8f1609e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8b99f937d1cff8abb84c8d82f8f1609e.jpg" alt="" /></a></p>
<ul>
<li><strong>调用成功</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_cdb357d4266204eccc28d6db3927745b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_cdb357d4266204eccc28d6db3927745b.jpg" alt="" /></a></p>
<h4>Java代码调用</h4>
<ol>
<li>IDEA新建一个Maven项目：ChatGPT</li>
<li>POM添加Hutool依赖，使用Hutool工具发送http post请求，json对象封装等等。</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_02bb4f54a9babded6dda5f3ce7fbb502.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_02bb4f54a9babded6dda5f3ce7fbb502.jpg" alt="" /></a><br />
3. <strong>Java代码</strong></p>
<pre><code class="language-java line-numbers">import cn.hutool.http.*;
import cn.hutool.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class ChatGptDemo {
    public static void main(String[] args) {
        Map&lt;String,String&gt; headers = new HashMap&lt;String,String&gt;();
        headers.put("Content-Type","application/json;charset=UTF-8");

        JSONObject json = new JSONObject();
        //选择模型
        json.set("model","text-davinci-003");
        //添加我们需要输入的内容
        json.set("prompt","中国的首都在哪里？");
        json.set("temperature",0.9);
        json.set("max_tokens",2048);
        json.set("top_p",1);
        json.set("frequency_penalty",0.0);
        json.set("presence_penalty",0.6);

        HttpResponse response = HttpRequest.post("https://api.openai.com/v1/completions")
                .headerMap(headers, false)
                .bearerAuth("API keys")
                .body(String.valueOf(json))
                .timeout(5 * 60 * 1000)
                .execute();

        System.out.println(response.body());
    }
}
</code></pre>
<p>调用返回结果：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_80bc1f3014183f70417ebdfd5e72c59f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_80bc1f3014183f70417ebdfd5e72c59f.jpg" alt="" /></a></p>
<p><span id="more-385"></span></p>
<p>使用场景有很多，具体需求可以在官网实例中找到自己感兴趣的场景学习研究。目前Github上有很多优秀的基于ChatGPT二次开发的封装的项目，可以多多试验。<br />
&#8211; <a class="wp-editor-md-post-content-link" href="https://zhuanlan.zhihu.com/p/597371088#:~:text=%E7%9B%98%E7%82%B9%E8%BF%91%E6%9C%9F%E9%9D%9E%E5%B8%B8%E7%81%AB%E7%83%AD%E7%9A%84ChatGPT%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%201%20ChatGPT%20Vscode%20Plugin%202%20wechat-chatgpt,3%20ChatGPT%20for%20Google%204%20chatgpt-api%205%20awesome-chatgpt-prompts">盘点近期非常火热的ChatGPT开源项目</a></p>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://github.com/search?q=chatgpt">Github项目</a><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e0554dde3570512c0360d4849ce37c01.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e0554dde3570512c0360d4849ce37c01.jpg" alt="" /></a></li>
</ul>
<p><!--more--></p>
<p>我也根据一个<a class="wp-editor-md-post-content-link" href="https://github.com/slippersheepig/chatgpt-web">开源小项目</a>搭建了一个网页版ChatGPT<br />
https://github.com/slippersheepig/chatgpt-web</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_56fec56cbff554deb16365657736a89f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_56fec56cbff554deb16365657736a89f.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_008801e6c58082083fc00cfdbd1864e4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_008801e6c58082083fc00cfdbd1864e4.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_272b1739f0fe2ef4b1de8837ee761ad4.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_272b1739f0fe2ef4b1de8837ee761ad4.jpg" alt="" /></a></p>
<p><strong>PS：18美元的免费额度，大概能回答54000000字。每天限制调用200次</strong></p>
<p><a href="https://www.laobaiblog.top/2023/02/21/chatgpt%e6%8e%a5%e5%85%a5%e5%ae%9e%e4%be%8b/">ChatGPT Java实例接入</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>按照等保测评标准实施操作系统加固的建议和参考</title>
		<link>https://www.laobaiblog.top/2023/02/07/%e6%8c%89%e7%85%a7%e7%ad%89%e4%bf%9d%e6%b5%8b%e8%af%84%e6%a0%87%e5%87%86%e5%ae%9e%e6%96%bd%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%8a%a0%e5%9b%ba%e7%9a%84%e5%bb%ba%e8%ae%ae%e5%92%8c%e5%8f%82%e8%80%83/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 07 Feb 2023 03:16:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[安全加固]]></category>
		<category><![CDATA[等保测评]]></category>
		<category><![CDATA[身份验证]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=379</guid>

					<description><![CDATA[<p>等保测评在如今项目安全性及验收结项都是至关重要的步骤。 Windows 以服务器绝大多数为Windo &#8230;</p>
<p><a href="https://www.laobaiblog.top/2023/02/07/%e6%8c%89%e7%85%a7%e7%ad%89%e4%bf%9d%e6%b5%8b%e8%af%84%e6%a0%87%e5%87%86%e5%ae%9e%e6%96%bd%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%8a%a0%e5%9b%ba%e7%9a%84%e5%bb%ba%e8%ae%ae%e5%92%8c%e5%8f%82%e8%80%83/">按照等保测评标准实施操作系统加固的建议和参考</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>等保测评在如今项目安全性及验收结项都是至关重要的步骤。</em></p>
<h1>Windows</h1>
<p>以服务器绝大多数为Windows Server 2012 版本参考为例</p>
<h3>一、身份鉴别</h3>
<h6>1. 口令复杂度和口令更改周期</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> 账户策略 —> 密码策略</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1ed28802b101df004f62f79c3e924126.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1ed28802b101df004f62f79c3e924126.jpg" alt="" /></a></p>
<h6>2. 登录失败和空闲超时</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> 账户策略 —> 账户锁定策略</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ede9b9361fd2c479b6cb859161604eae.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ede9b9361fd2c479b6cb859161604eae.jpg" alt="" /></a></p>
<p>控制面板 —> 外观 —> 显示 —> 更改屏幕保护程序</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c8404cd48ff9d0c49b3e9b6e5ba457e1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c8404cd48ff9d0c49b3e9b6e5ba457e1.jpg" alt="" /></a></p>
<h6>3. 加密远程管理</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —> 管理模板—> Windows组件 —> 远程桌面服务 —> 远程桌面会话主机 —> 安全</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6cbde13dcc34fb411556ac067959dd50.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6cbde13dcc34fb411556ac067959dd50.jpg" alt="" /></a></p>
<p><span id="more-379"></span></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d5826d138a9dc08d0484a22158d1f267.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d5826d138a9dc08d0484a22158d1f267.jpg" alt="" /></a><br />
<!--more--><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_40e85c6152a236959311879bde4c62dc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_40e85c6152a236959311879bde4c62dc.jpg" alt="" /></a></p>
<h3>二、访问控制</h3>
<h6>1. 禁用匿名用户guest</h6>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_47fc7286ade29876066d96b1efa87a63.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_47fc7286ade29876066d96b1efa87a63.jpg" alt="" /></a></p>
<h6>2. 修改默认密码</h6>
<p>计算机管理（本地）—> 本地用户和组 —> 用户 —> Administrator —> 右键  —> 设置密码</p>
<h6>3. 禁用其他无关用户，创建多个个人用户，避免多人共用一个账户</h6>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c9dd25370f529c9d23a19dad41226cbb.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_c9dd25370f529c9d23a19dad41226cbb.jpg" alt="" /></a></p>
<h6>4. 授予管理用户所需的最小权限，实现管理用户的权限分离</h6>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8d1498306241ba3efd1a64ec6a1ea097.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_8d1498306241ba3efd1a64ec6a1ea097.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ba8bc7dd69d020d41b210fc4005d668a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ba8bc7dd69d020d41b210fc4005d668a.jpg" alt="" /></a><br />
<!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1813ec53c31f622502166044f3dfaf7d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1813ec53c31f622502166044f3dfaf7d.jpg" alt="" /></a><br />
<!--more--><br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fea37aba9d4eaa000467ba872fecd3f2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fea37aba9d4eaa000467ba872fecd3f2.jpg" alt="" /></a></p>
<h3>三、安全审计</h3>
<h6>1. 开启安全审计</h6>
<p>Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> 本地策略 —> 审核策略</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3e118ca1ed6bd00977e41262fb408241.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3e118ca1ed6bd00977e41262fb408241.jpg" alt="" /></a></p>
<h6>2.设置日志保存时间和存储空间</h6>
<p>计算机管理 —> 系统工具 —> 事件查看器 —> Windows日志 —> 应用程序、安全、系统 —> 右键 —> 属性（三个都需要设置）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e13a7c94149bec3194810bb474d79240.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e13a7c94149bec3194810bb474d79240.jpg" alt="" /></a></p>
<h3>四、入侵防范</h3>
<h6>1. 删除业务非必要的组件和应用程序</h6>
<p>控制面板 —> 所有控制面板项 —> 程序和功能</p>
<h6>2. 关闭不需要的系统服务、默认共享和高危端口</h6>
<p><strong>关闭系统服务器：</strong><br />
计算机管理 —> 服务和应用程序 —> 服务<br />
禁用非必要的系统服务（如 Print Spooler、Remote Registry Service等）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_af7bbaf19f8182e05507555d699e1d9f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_af7bbaf19f8182e05507555d699e1d9f.jpg" alt="" /></a></p>
<p><strong>关闭默认共享：</strong><br />
计算机管理 —> 系统工具 —> 共享文件夹 —> 右键 —> 停止共享<br />
关闭系统默认共享（如C、D、E）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_931ab2fe4f226c336d30817a2d86995f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_931ab2fe4f226c336d30817a2d86995f.jpg" alt="" /></a></p>
<p><strong>禁用高危端口一：</strong><br />
Win+R —> gpedit.msc —> 本地计算机策略 —>计算机配置 —>Windows设置 —> 安全设置 —> IP安全策略，在 本地计算机<br />
禁用高危端口的策略（至少包括TCP135、139、445、UDP135、137、138、445端口）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b4f0d9641fbe01b78cb35588db3a890c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b4f0d9641fbe01b78cb35588db3a890c.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_37c1a6c91d6e0cd773cf3ae8c7e1bd3a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_37c1a6c91d6e0cd773cf3ae8c7e1bd3a.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_0899a1920072f750f5440d1e43ced8a6.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_0899a1920072f750f5440d1e43ced8a6.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fff5f55a6293948110315e535b91fb9a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_fff5f55a6293948110315e535b91fb9a.jpg" alt="" /></a></p>
<p><strong>禁用高危端口二：</strong><br />
控制面板 —> 系统和安全 —> 管理工具 —> 高级安全Windows防火墙 —> 入站规则<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e69e6f91287d196c95ac0e962d21e469.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e69e6f91287d196c95ac0e962d21e469.jpg" alt="" /></a></p>
<h6>3. 设置远程桌面地址限制</h6>
<p>控制面板—>管理工具—>高级安全Windows防火墙—>入站规则—>远程桌面-用户模式（TCP-In）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6422d12b92c3cbefba4cc1cf4e4db96b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_6422d12b92c3cbefba4cc1cf4e4db96b.jpg" alt="" /></a></p>
<h6>五、恶意代码防范</h6>
<p>1、安装杀毒软件并更新病毒库（火绒安全仅为参考防病毒软件）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_23abb6ab2608f92093bdfbec87694254.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_23abb6ab2608f92093bdfbec87694254.jpg" alt="" /></a></p>
<h1>Linux</h1>
<p>说明：以下以CentOS Linux release 7.9.2009 (Core)  64位 为例，提供等保整改操作参考。</p>
<h3>一、身份鉴别</h3>
<h6>1. 口令复杂度和口令更改周期</h6>
<p><strong>口令更改周期：</strong><br />
<strong>方法一：</strong><br />
在/etc/login.defs中修改（修改原有的，并非添加）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e1c1537efdf8ec0a3c3a2daa3af605a8.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e1c1537efdf8ec0a3c3a2daa3af605a8.jpg" alt="" /></a><br />
（如经重启后无效或服务器不能重启，需逐一执行修改，参考方法二（无需重启））</p>
<p><strong>方法二（无需重启修改密码有效期）：</strong><br />
查看某个用户的密码设置情况：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_df5c68d5c04a607852280cf851235ef3.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_df5c68d5c04a607852280cf851235ef3.jpg" alt="" /></a><br />
强制root用户下次登陆时修改密码（-d 0），并且设置密码最低有效期0（-m 1）和最高有限期90（-M 90），提前7天发警报提示-W 7 （root为用户名，可改成需要修改的用户）<br />
<code>chage -d 0 -m 1 -M 90 -W 7 root</code></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_06012c4fe40e5f7b44da7f634d0f193c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_06012c4fe40e5f7b44da7f634d0f193c.jpg" alt="" /></a></p>
<p><strong>口令复杂度配置：</strong><br />
在/etc/pam.d/system-auth中找到</p>
<pre><code class="language-shell line-numbers">password requisite pam_pwquality.so try_first_pass local_users_only
</code></pre>
<p>然后在其后面添加以下配置</p>
<pre><code class="language-shell line-numbers">retry=3 authtok_type= minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 enforce_for_root
</code></pre>
<p>配置后：</p>
<pre><code class="language-shell line-numbers">password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= minlen=8 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 enforce_for_root
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_390daa1840450e721c26899f33957b38.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_390daa1840450e721c26899f33957b38.jpg" alt="" /></a><br />
配置参数说明：<br />
retry=3 尝试三次<br />
minlen=8 密码最小长度为8个字符。<br />
lcredit=-1 密码应包含的小写字母的至少一个<br />
ucredit=-1 密码应包含的大写字母至少一个<br />
dcredit=-1 将密码包含的数字至少为一个<br />
ocredit=-1 设置其他符号的最小数量，例如@，＃、! $％等，至少要有一个<br />
enforce_for_root 确保即使是root用户设置密码，也应强制执行复杂性策略</p>
<h6>2. 登录失败和空闲超时</h6>
<p><strong>登录失败处理功能：（配置三个文件方可全方位生效）</strong><br />
在 <strong>/etc/pam.d/system-auth</strong> 文件加入以下配置 <strong>（请找到相应的对应区域，且必须按以下命令顺序）</strong><br />
在 <strong>/etc/pam.d/system-auth</strong> 下首行#%PAM-1.0下增加找到相应位置并添加：</p>
<pre><code class="language-shell line-numbers">auth  required  pam_tally2.so onerr=fail deny=5 unlock_time=300 even_deny_root  root_unlock_time=60
</code></pre>
<p><strong>onerr=fail</strong> 表示连续登录失败，<strong>deny=5</strong> 表示超过5次登录失败即锁定，<strong>unlock_time=300</strong>表示普通用户锁定300秒，<strong>even_deny_root</strong> 表示对root账户生效，<strong>root_unlock_time=60</strong>表示root用户锁定60秒。<br />
配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d7e7abfa412c6e626f53fbd13b225b7d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d7e7abfa412c6e626f53fbd13b225b7d.jpg" alt="" /></a></p>
<p>在 <strong>/etc/pam.d/sshd</strong> 和 <strong>/etc/pam.d/login</strong>中在首行#%PAM-1.0下增加：</p>
<pre><code class="language-shell line-numbers">auth  required  pam_tally2.so deny=5 unlock_time=300 even_deny_root root_unlock_time=60
</code></pre>
<p><strong>/etc/pam.d/sshd</strong> 配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg" alt="" /></a></p>
<p><strong>/etc/pam.d/login</strong> 配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b385674ef4dc2748d1b08c8cff21dd67.jpg" alt="" /></a></p>
<p><strong>/etc/pam.d/login</strong> 配置如下：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b1c623a18a58699f233fbfb91c2a6622.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b1c623a18a58699f233fbfb91c2a6622.jpg" alt="" /></a></p>
<p><strong>注意：</strong><br />
1）注意上面命令行写在文件的顺序，没配置正确有可能root都无法登录。<br />
2）如果想锁住root用户，在pam_tally2.so 条目里添加 even_deny_root 选项</p>
<p><strong>解锁方法：</strong><br />
查询密码错误情况：pam_tally2<br />
在root权限下：</p>
<pre><code class="language-shell line-numbers">pam_tally2  –user=root  --reset  #解锁某一个用户（root）
pam_tally2  --reset  #解锁所有用户
</code></pre>
<p>在普通用户权限下：</p>
<pre><code class="language-shell line-numbers">sudo  pam_tally2  –user=root  --reset  #解锁某一个用户（root）
sudo  pam_tally2  --reset  #解锁所有用户
</code></pre>
<p>空闲超时自动退出：<br />
在 /etc/profile末尾添加：</p>
<pre><code class="language-shell line-numbers">export TMOUT=600
</code></pre>
<p>说明：0代表永不自动退出，600代表600秒自动退出。<br />
执行命令source /etc/profile使配置生效</p>
<h6>3. 加密远程管理</h6>
<p>使用 <strong>netstat -ntpl | grep LISTEN</strong>查看是否有开启23端口（telnet服务）<br />
一般情况下，默认是使用ssh服务（22端口）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d337d079e02f3dbb3d2d73f562dd9478.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_d337d079e02f3dbb3d2d73f562dd9478.jpg" alt="" /></a></p>
<h3>二、访问控制</h3>
<h6>1. 禁用多余用户（禁用所有非必要的用户）</h6>
<p>修改 <strong>/etc/passwd</strong>文件中用户登录的shell，添加<strong>nologin</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_53e5cfcdd3a08c713472aa34b8241007.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_53e5cfcdd3a08c713472aa34b8241007.jpg" alt="" /></a></p>
<h6>2. 创建多个个人用户，避免多人通用一个账户</h6>
<p>为每个用户创建一个独立的账户，避免用户都使用一个管理用户root</p>
<pre><code class="language-shell line-numbers">#创建新用户命令：
adduser user1 #添加一个名为user1的用户
#修改（添加）新用户密码：
Passwd user1
#输入两次密码即可
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_aa629bb1569e207fe4648878e9ee085f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_aa629bb1569e207fe4648878e9ee085f.jpg" alt="" /></a></p>
<h6>3. 修改默认口令</h6>
<p>修改默认口令，既修改默认账户root的默认口令，Centos 8在安装的时候创建root账户时，口令就不能为默认口令且要求具有复杂度要求，所以不存在默认口令。以下提供修改口令的命令供参考：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_f946045db052c3be8ecbec50d2871f3a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_f946045db052c3be8ecbec50d2871f3a.jpg" alt="" /></a></p>
<h6>4. 授予管理用户所需的最小权限，实现管理用户的权限分离</h6>
<p>操作系统暂难实现三权分立，只需根据业务需求分配权限即可</p>
<h6>5. 关闭root账户直接远程登录</h6>
<p>在 <strong>/etc/ssh/sshd_config</strong>中修改“<strong>PermitRootLogin</strong>”参数为“no”<br />
<strong>注意：</strong> 修改前请确认具有普通用户，或创建一个可供远程管理的普通用户！！！</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_5080388e88162b3abdf127c80e207c44.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_5080388e88162b3abdf127c80e207c44.jpg" alt="" /></a></p>
<p>配置后，用户不能用root账户直接远程登录系统，需用普通账户远程登录，然后su切换到root账户<br />
随后<strong>重启ssh服务</strong>即可：</p>
<pre><code class="language-shell line-numbers">systemctl restart sshd.service
</code></pre>
<h6>6. 应对重要主体和客体设置安全标记，并控制主体对有安全标记信息资源的访问</h6>
<p>将 <strong>/etc/selinux/config</strong>中<strong>SELINUX</strong>参数默认为<strong>enforcing</strong>（强制模式）</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e5637a2527ba98844e6e21f3a571c9e2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_e5637a2527ba98844e6e21f3a571c9e2.jpg" alt="" /></a></p>
<h3>三、安全审计</h3>
<h6>1. 开启安全审计和审计保护进程</h6>
<p>查看auditd和rsyslogd进程的状态（默认是开启状态）：</p>
<pre><code class="language-shell line-numbers">service auditd status 或
systemctl status auditd.service
service rsyslog status 或
systemctl status rsyslog.service
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d7952e7813c0aef476915bff715caad.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d7952e7813c0aef476915bff715caad.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_67136bf145ef112fe46cd7b14a29ecc7.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_67136bf145ef112fe46cd7b14a29ecc7.jpg" alt="" /></a></p>
<p>如果没有开启auditd和rsyslog服务，使用以下命令开启（重启）：</p>
<pre><code class="language-shell line-numbers">service auditd restart 或
systemctl restart auditd.service
service rsyslog restart 或
systemctl restart rsyslog.service
</code></pre>
<p>设置auditd和rsyslog服务开机启动：</p>
<pre><code class="language-shell line-numbers">systemctl enable auditd
systemctl enable rsyslog
</code></pre>
<h6>2. 设置日志保存时间</h6>
<p>在 <strong>/etc/logrotate.conf</strong>文件修改<strong>rotate</strong>参数：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3a03f44337db2f4973c72b86226467cd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_3a03f44337db2f4973c72b86226467cd.jpg" alt="" /></a></p>
<p>默认情况下，以周为单位，修改rotate参数为26，26周为26*7=182天，满足180天以上要求。</p>
<p>使用ll /var/log/ 命令查看实际日志是否满足要求：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_bf08c96ed2844079e0121a3b84cf88c1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_bf08c96ed2844079e0121a3b84cf88c1.jpg" alt="" /></a></p>
<p>日志时间满足180天，如需确认可查看以上文件进行确认。</p>
<h6>4. 设置审计记录备份（配置日志服务器）</h6>
<p><strong>注：</strong> 该项配置暂未有统一加固整改建议（需根据每个系统的部署情况而定）<br />
查看 <strong>/etc/rsyslog.conf</strong>文件是否配置日志服务器或日志审计<strong>设备IP</strong>：</p>
<h3>四、入侵防范</h3>
<h6>1. 删除业务非必要的组件和应用程序</h6>
<p>使用<strong>yum list installed</strong>命令查看已安装的软件</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1e6dd75ced6b9c35a4a261c2806c9234.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_1e6dd75ced6b9c35a4a261c2806c9234.jpg" alt="" /></a></p>
<h6>2. 关闭不必要的系统服务和高危端口</h6>
<p><strong>方法一：</strong><br />
使用<strong>netstat -ntlp | grep LISTEN</strong>命令查看开放端口状态以及对应的服务：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_7961d1e2b6cc2cf22a4dd778d5483acc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_7961d1e2b6cc2cf22a4dd778d5483acc.jpg" alt="" /></a></p>
<p>上图可以看到系统打开了<strong>cupsd服务（打印服务）</strong>，属于不必要的系统服务，使用以下命令进行关闭（举例说明，其他不必要的系统服务请自行判断后进行关闭）</p>
<pre><code class="language-shell line-numbers">systemctl stop cups
#并设置重启不启用cups服务
systemctl disable cups
#查看cups服务状态，确保cups服务已成关闭
systemctl status cups
</code></pre>
<p><strong>方法二：</strong><br />
使用 <strong>Nmap工具</strong>进行端口扫描（自身扫描或通过管理终端扫描）：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b27d94d160de6a99e0555132dc901f3c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b27d94d160de6a99e0555132dc901f3c.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_65ce0eb06d788fa80051667c63cc1192.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_65ce0eb06d788fa80051667c63cc1192.jpg" alt="" /></a></p>
<h6>3. 设置远程管理接入地址限制（限制SSH登录地址）</h6>
<p>这里<strong>Centos7</strong>有两种方法配置地址限制</p>
<p>第一种：通过 <strong>/etc/hosts.allow</strong>和 <strong>hosts.deny</strong>配置地址限制。<br />
<strong>/etc/hosts.allow</strong>配置如下：（<strong>允许IP地址ssh</strong>）</p>
<pre><code class="language-shell line-numbers">sshd:192.168.110.129:allow          #允许单个IP地址ssh
sshd:192.168.110.1:allow       #允许一个28掩码网络段ssh
sshd:192.168.110.0/28:allow       #允许一个28掩码网络段ssh
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_467ba704da2909779a523dc7ec5edbd5.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_467ba704da2909779a523dc7ec5edbd5.jpg" alt="" /></a></p>
<p><strong>/etc/hosts.deny</strong>配置如下：(禁止所有IP地址ssh)</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_081e30d1680c568cacfce053e106d229.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_081e30d1680c568cacfce053e106d229.jpg" alt="" /></a></p>
<p>重启ssh服务</p>
<pre><code class="language-shell line-numbers">Systemctl restart sshd
</code></pre>
<p>以上就是 <strong>白名单机制，Linux</strong>的检查策略是先看 <strong>/etc/hosts.allow</strong>中是否允许，如果允许直接放行；如果没有，则再看 <strong>/etc/hosts.deny</strong>中是否禁止，如果禁止那么就禁止连入。</p>
<p>第二种：采用防火墙规则配置地址限制（Firewalld）<br />
查看Firewalld状态：</p>
<pre><code class="language-shell line-numbers">systemctl status firewalld.service
firewall-cmd --state
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ec8f86c1f0632553bd36ab73bfc8ca6b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_ec8f86c1f0632553bd36ab73bfc8ca6b.jpg" alt="" /></a></p>
<p><!--more--></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b5867fdb2ed5c571f1728c5373dacece.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_b5867fdb2ed5c571f1728c5373dacece.jpg" alt="" /></a></p>
<p>防火墙 <strong>Firewall</strong>的状态是<strong>开启的</strong>，这样子在防火墙配置的策略才会<strong>有效</strong>，如果防火墙是关闭的，则配置的策略为无效。</p>
<p>在配置防火墙策略之前，得先了解一下配置的一个思路，就拿配置限制SSH登录地址举例。先有一个白名单机制的思维，白名单机制就是除允许名单外的所有名单都是被拒绝访问的，如果一个服务全开放，白名单则毫无意义。所以要限制SSH登录地址，先确认SSH是否为开放服务，先查看当前配置的防火墙规则：</p>
<pre><code class="language-shell line-numbers">firewall-cmd --list-all
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d0368dcac4bbfc5f91edda2a5938896.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_9d0368dcac4bbfc5f91edda2a5938896.jpg" alt="" /></a></p>
<p>可以看到这里的规则是开放了ssh服务的，意思就是全开放，所有的IP均可以通过ssh远程该系统。那么要做限制SSH登录地址，首先要先在规则上禁止掉ssh服务全开放。</p>
<pre><code class="language-shell line-numbers">firewall-cmd --permanent --remove-service=ssh    #禁止ssh服务
firewall-cmd --permanent --add-service=ssh       #开放ssh服务
</code></pre>
<p>配置完这命令后，使用查看当前配置的防火墙规则命令进行查询，ssh服务全开放依旧存在，那是因为配置了防火墙规则后，需要手动重载防火墙服务，因为后续还需配置，这里先不重载。接下来就是配置允许指定IP（段）访问制定本地端口（<strong>ssh服务，22端口</strong>）(永久生效再加上 <strong>&#8211;permanent</strong>)</p>
<pre><code class="language-shell line-numbers">firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.110.128/28" port protocol="tcp" port="22" accept'  #允许指定IP段访问制定本地端口

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.110.1" port protocol="tcp" port="22" accept'  #允许指定IP访问制定本地端口
</code></pre>
<p>配置完成后，<strong>重载防火墙</strong>（不同于重启防火墙）</p>
<pre><code class="language-shell line-numbers">firewall-cmd --reload      #重载防火墙
systemctl restart firewalld.service      #重启防火墙
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_916071081b29e6bccf5ecec20eb62231.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2023/02/wp_editor_md_916071081b29e6bccf5ecec20eb62231.jpg" alt="" /></a></p>
<p>以上防火墙（<strong>Firewall</strong>）规则就已经实现<strong>限制SSH登录地址</strong>限制，<strong>仅允许192.168.110.129/28网络段</strong>和<strong>192.168.110.1</strong>访问该系统的 <strong>ssh服务（22端口）</strong>。</p>
<h3>五、恶意代码防范</h3>
<h6>1. 安装杀毒软件并更新病毒库（ClamAV）或安装其他终端检测软件</h6>
<p>安装方法请根据具体的系统版本进行百度或联系相关安全设备管家进行沟通安装。<br />
<a class="wp-editor-md-post-content-link" href="https://www.jianshu.com/p/c9b5d87d8335">安装ClamAV参考</a>：https://www.jianshu.com/p/c9b5d87d8335</p>
<p><a href="https://www.laobaiblog.top/2023/02/07/%e6%8c%89%e7%85%a7%e7%ad%89%e4%bf%9d%e6%b5%8b%e8%af%84%e6%a0%87%e5%87%86%e5%ae%9e%e6%96%bd%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e5%8a%a0%e5%9b%ba%e7%9a%84%e5%bb%ba%e8%ae%ae%e5%92%8c%e5%8f%82%e8%80%83/">按照等保测评标准实施操作系统加固的建议和参考</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>ChatGPT注册使用系列一</title>
		<link>https://www.laobaiblog.top/2022/12/08/chatgpt%e6%b3%a8%e5%86%8c%e4%bd%bf%e7%94%a8%e7%b3%bb%e5%88%97%e4%b8%80/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Thu, 08 Dec 2022 09:53:50 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[ChatGPT]]></category>
		<category><![CDATA[openAi]]></category>
		<category><![CDATA[人工智能]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=354</guid>

					<description><![CDATA[<p>ChatGPT 是什么？ 这个问题，由ChatGPT 亲自回答：:satisfied: ChatGP &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/12/08/chatgpt%e6%b3%a8%e5%86%8c%e4%bd%bf%e7%94%a8%e7%b3%bb%e5%88%97%e4%b8%80/">ChatGPT注册使用系列一</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h2>ChatGPT 是什么？</h2>
<p><strong>这个问题，由ChatGPT 亲自回答：</strong>:satisfied:</p>
<blockquote><p>
  ChatGPT 是一种自然语言生成模型，它用来自然地生成与人类语言交互。这是一种机器学习技术，它可以通过对大量文本数据进行学习，然后利用这些学习结果来生成新的文本。这种技术可以用来改善人机交互，提高聊天机器人的效率。-ChatGPT<br />
  <!---->
</p></blockquote>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_7a347ec149313ab6e8d8f1a2559b1fa9.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_7a347ec149313ab6e8d8f1a2559b1fa9.jpg" alt="" /></a></p>
<h2>OpenAI 又是什么？</h2>
<p><strong>如是说：</strong></p>
<blockquote><p>
  OpenAI 是一家人工智能研究和开发公司，它的目标是通过研究和开发人工智能技术来解决全球最重要的问题。OpenAI 是由一群技术领袖和慈善家共同创立的，包括 Elon Musk 和 Sam Altman 等。该公司的研究领域包括人工智能、机器学习、神经网络等。OpenAI 也开发了许多技术产品，例如 GPT-3、Dactyl 等。-ChatGPT
</p></blockquote>
<h5>以下是维基百科关于 ChatGPT 的相关介绍：</h5>
<blockquote><p>
  ChatGPT是由OpenAI开发的一个人工智能聊天机器人程序，于2022年11月30日推出。该程序使用基于GPT-3.5架构的大型语言模型并通过强化学习进行训练。ChatGPT 使用基于人类反馈的强化学习进行训练，这种方法通过人类干预以增强机器学习的效果，从而获得更为逼真的结果。其使用基于GPT-3.5架构的语言模型。在训练过程中，人类训练师扮演着用户与人工智能助手的角色。模型在Microsoft Azure的超级计算机上训练，并通过近端策略优化算法（proximal policy optimization）进行微调。这种策略优化算法比信任域策略优化（trust region policy optimization）算法更为高效。
</p></blockquote>
<h2>如何注册 ChatGPT</h2>
<p>要注册使用 ChatGPT，你需要做好以下准备：</p>
<ul>
<li>全局代理（推荐美国节点）</p>
</li>
<li>
<p>一个邮箱用于注册（Gmail, Outlook 均可）</p>
</li>
<li>
<p>一个国外手机号用于接收验证码（Google Voice 虚拟号码不行）</p>
</li>
<li>
<p>一个浏览器（建议使用无痕模式）</p>
</li>
</ul>
<p>关于第1个准备，本文就不做介绍了，这种内容不能写在文章里，懂的都懂。第2和第4个准备应该没什么问题，本文会详细介绍第3个准备步骤。</p>
<h5>ChatGPT 具体注册步骤如下：</h5>
<ol>
<li><strong>在你的设备上开启全局代理。</strong><br />
建议使用美国地区的节点。</p>
</li>
<li>
<p><strong>访问 ChatGPT 登录页开始注册。</strong><br />
ChatGPT 登录页为 https://chat.openai.com/auth/login。点击 Sign up 根据提示进行创建一个 OpenAI 账号；输入你的电子邮箱继续。如果你有 Gmail，你也可以点击下方的 Continue with Google 按钮直接以 Google 账号注册。</p>
</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_f1b760fa61d92871613eb716a22d629e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_f1b760fa61d92871613eb716a22d629e.jpg" alt="" /></a></p>
<ol start="3">
<li><strong>根据屏幕指示操作。</strong><br />
完善你的姓名，机构名称可不填，点击下方的 Continue 按钮后，你会来到验证手机号码界面：</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_89f68fb4e988517d20d997e4c1cdcfbf.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_89f68fb4e988517d20d997e4c1cdcfbf.jpg" alt="" /></a><br />
先停在这个界面；接下来我们需要准备一个手机号码接收验证码。</p>
<ol start="4">
<li><strong>前往接码平台租用一个海外手机号</strong><br />
我们只需要一个临时的海外手机号来接收 OpenAI 的验证码即可，不需要购买海外的实体手机卡。<br />
推荐在 <a class="wp-editor-md-post-content-link" href="https://sms-activate.org/cn">sms-activate.org</a> 上花 $0.2 买一个印度尼西亚的手机号接收验证码。具体操作步骤如下：<br />
1) 前往 sms-activate.org 并注册账号；注册完成后登录账号。<br />
注：如果英文界面看不懂，可以切换语言为中文。<br />
)2 点击右上角下方的金额，然后选择开始充值：</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_a8d0d1e9bf9cc5e7d18c5e797015a1e2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_a8d0d1e9bf9cc5e7d18c5e797015a1e2.jpg" alt="" /></a><br />
3) 下滑屏幕找到 Alipay 并点击，在弹出的窗口中输入你要充值的金额。充值0.2美元即可。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_0f21e0ec9e15cb0cb77c0d43ffcefcce.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_0f21e0ec9e15cb0cb77c0d43ffcefcce.jpg" alt="" /></a><br />
4) 充值完毕后，返回首页；在左侧边栏的搜索框内，输入 openai 找到 OpenAI 服务，并点击：</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_60c226957d487a6898e2de4e501741e9.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_60c226957d487a6898e2de4e501741e9.jpg" alt="" /></a><br />
点击 Indonesia 右侧的购物车按钮，你会得到一个62开头的印度尼西亚手机号码。<br />
5) 将这个手机号码复制并粘贴至步骤3中的验证手机号码界面，然后点击 Send code via SMS。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_b29aaa995ba0e4b2105dc17228a1e595.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_b29aaa995ba0e4b2105dc17228a1e595.jpg" alt="" /></a><br />
留意 sms-activate.org 页面，很快将会收到来自 OpenAI API 的验证码；将验证码填入 OpenAI 页面的验证码输入框，即可完成验证。</p>
<ol start="5">
<li><strong>选择你注册 OpenAI 的主要用途</strong><br />
此处选择“I’m exploring personal feature” 即可。</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_42b08a56e887c0ce4780bacd9334e3c0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_42b08a56e887c0ce4780bacd9334e3c0.jpg" alt="" /></a></p>
<ol start="6">
<li><strong>开始使用 ChatGPT</strong><br />
接下来，只需点击顶部的 Try it，然后使用前面注册的 OpenAI 账号登录，就可以开始与 ChatGPT 聊天啦！</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_02e08441064e5d7d5318a27d46a27a99.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_02e08441064e5d7d5318a27d46a27a99.jpg" alt="" /></a></p>
<ol start="7">
<li><strong>在底部输入框内输入你想要问的问题，开始与 ChatGPT 进行互动。</strong></li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_ae80d4b3775a1ace6f333ec44fcd8c77.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_ae80d4b3775a1ace6f333ec44fcd8c77.jpg" alt="" /></a></p>
<ol start="8">
<li><strong>随堂测试</strong></li>
</ol>
<p><strong>我还写什么代码！直接描述。</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_81129c7a40b00243c2b225a7dd1ba270.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_81129c7a40b00243c2b225a7dd1ba270.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_b8c8dc474036c1ccc3dc899f99306444.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_b8c8dc474036c1ccc3dc899f99306444.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_a598d50b83e1c713c9a6eb396417dd1b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_a598d50b83e1c713c9a6eb396417dd1b.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_eabf9b99f14d5619760d5dd4491f338a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_eabf9b99f14d5619760d5dd4491f338a.jpg" alt="" /></a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_41be113a0bc660f660526381b45c7702.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_41be113a0bc660f660526381b45c7702.jpg" alt="" /></a></p>
<ol start="9">
<li><strong>ChatGPT现状</strong><br />
目前公开接口部分大致实现了文本、图像、文件等，搭建了一个本地环境，但因为请求网络的原因暂时没法完全研究它的功能模块，但我相信那一天不会遥远！</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_7d497c01d915d9d92ea43a3658f07a78.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/12/wp_editor_md_7d497c01d915d9d92ea43a3658f07a78.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2022/12/08/chatgpt%e6%b3%a8%e5%86%8c%e4%bd%bf%e7%94%a8%e7%b3%bb%e5%88%97%e4%b8%80/">ChatGPT注册使用系列一</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Docker安装nps实现[OpenWrt]内网穿透</title>
		<link>https://www.laobaiblog.top/2022/11/02/docker%e5%ae%89%e8%a3%85nps%e5%ae%9e%e7%8e%b0openwrt%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 02 Nov 2022 06:36:43 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nps]]></category>
		<category><![CDATA[openwrt]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[内网穿透]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=334</guid>

					<description><![CDATA[<p>一、NPS 概述 NPS 是一款轻量级、功能强大的内网穿透代理服务器。支持 tcp、udp 流量转发 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/11/02/docker%e5%ae%89%e8%a3%85nps%e5%ae%9e%e7%8e%b0openwrt%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f/">Docker安装nps实现[OpenWrt]内网穿透</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h3>一、NPS 概述</h3>
<p>NPS 是一款轻量级、功能强大的内网穿透代理服务器。支持 tcp、udp 流量转发，支持内网 http 代理、内网 socks5 代理，同时支持 snappy 压缩、站点保护、加密传输、多路复用、header 修改等。支持 web 图形化管理，集成多用户模式。管理系统比 FRP 方便很多，更容易上手。</p>
<h3>二、配置要求</h3>
<ul>
<li>一台拥有公网 IP 的服务器。</li>
<li>开放端口例如：(8080,8024,80,443）等可以不是这些端口，nps可以配置任意端口，实现与其它服务共存。</li>
</ul>
<h3>三、相关文档</h3>
<ul>
<li>NPS 配置文档：https://ehang-io.github.io/nps/#/</li>
<li>NPS 安装包：https://github.com/ehang-io/nps/releases</li>
<li>NPS 源码：https://github.com/ehang-io/nps</li>
</ul>
<h3>四、环境说明</h3>
<ul>
<li>服务器端是我的Ubuntu(arm)云服务器；</li>
<li><strong>客户端是本地N1盒子Openwrt系统的nps插件（无需安装客户端）</strong>。</li>
</ul>
<h3>五、演示安装</h3>
<h4>1. 服务端</h4>
<ul>
<li><strong>Docker拉取Nps镜像</strong></li>
</ul>
<pre><code class="language-shell line-numbers">#拉取nps镜像
docker pull ffdfgdfg/nps
#创建nps配置文件目录
mkdir -p /root/nps/conf
</code></pre>
<ul>
<li>github下载配置文件，<strong>将nps-master下的conf文件拷贝至服务器上的/root/nps/conf目录下</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_265c4dd6295be6b20c0ebbaea52b7f2f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_265c4dd6295be6b20c0ebbaea52b7f2f.jpg" alt="" /></a></p>
<p><span id="more-334"></span></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_5f324c40e1444e06a3980f7f451b335a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_5f324c40e1444e06a3980f7f451b335a.jpg" alt="" /></a></p>
<ul>
<li><strong>修改nps.conf配置</strong></li>
</ul>
<pre><code class="language-shell line-numbers">#编辑nps.conf
vim /root/nps/conf/nps.conf

#nps.conf
appname = nps
runmode = dev

http_proxy_ip=0.0.0.0
http_proxy_port=19000
https_proxy_port=19001
https_just_proxy=true

https_default_cert_file=conf/server.pem
https_default_key_file=conf/server.key

bridge_type=tcp
bridge_port=19002
bridge_ip=0.0.0.0

public_vkey=123

log_level=7

web_host=a.o.com
web_username=admin
web_password=123
web_port = 19003
web_ip=0.0.0.0
web_base_url=
web_open_ssl=false
web_cert_file=conf/server.pem
web_key_file=conf/server.key
auth_crypt_key =1234567887654321
allow_user_login=false
allow_user_register=false
allow_user_change_username=false
allow_flow_limit=false
allow_rate_limit=false
allow_tunnel_num_limit=false
allow_local_proxy=false
allow_connection_num_limit=false
allow_multi_ip=false
system_info_display=false
http_cache=false
http_cache_length=100
http_add_origin_header=false[object Object]


</code></pre>
<ul>
<li><strong>docker启动nps，注意防火墙是否开放相关端口</strong></li>
</ul>
<pre><code class="language-shell line-numbers">#启动nps，端口开放19000-19010
docker run -d -p 19000-19010:19000-19010 -v /root/nps/conf:/conf --name=nps --restart=always ffdfgdfg/nps
</code></pre>
<ul>
<li><strong>访问Nps后台：http://IP:19003 默认账号密码是配置文件中的admin/123(可自行更改)。</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_dc27a065af42956f136ee1424fd069e9.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_dc27a065af42956f136ee1424fd069e9.jpg" alt="" /></a></p>
<ul>
<li><strong>创建nps客户端及tcp隧道</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_1f47862aa69dd09a9dd397316ba0d9cc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_1f47862aa69dd09a9dd397316ba0d9cc.jpg" alt="" /></a></p>
<p><!--more--></p>
<p>创建客户端，点击客户端详情查看 <strong>-server/-key</strong> 两个参数。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_3e67ef83c08e03524f834e442df1a1a9.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_3e67ef83c08e03524f834e442df1a1a9.jpg" alt="" /></a></p>
<h4>2. 客户端</h4>
<ul>
<li><strong>进入内网OpenWrt，打开nps插件，输入server及key参数保存，在服务端即可发现客户端已连接。</strong></li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_fa3e4010917fd1997f207478acc8c24f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_fa3e4010917fd1997f207478acc8c24f.jpg" alt="" /></a></p>
<h4>3. 配置转发</h4>
<ul>
<li><strong>查看客户端状态</strong></li>
</ul>
<p>此处可以看到一个客户端ID为6，连接状态为在线。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_701405fdb3565a5c8c329c7b615ee226.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_701405fdb3565a5c8c329c7b615ee226.jpg" alt="" /></a></p>
<ul>
<li><strong>添加tcp隧道转发</strong></li>
</ul>
<p>如下配置表示<strong>将服务端的1XXX6端口转发到局域网内192.168.50.1/3的80/5244等端口</strong>。其他的UDP、SOCKS、HTTP也是类似的配置不再赘述。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_7a46b904fdeb607003c0270434ee4951.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/11/wp_editor_md_7a46b904fdeb607003c0270434ee4951.jpg" alt="" /></a></p>
<h4>4. 总结</h4>
<p>NPS及OpenWrt的配置安装都很便捷，如果你有一台自己的VPS云服务器，可以尝试一下，将你的家庭本地电脑映射到外网服务器。<strong>访问公网IP+对应1XXXX端口即可访问到内网对应服务。</strong></p>
<h4>5. 参考文章</h4>
<p>不同的安装环境可以看看其他博文：</p>
<p>超详细openwrt内网穿透-nps小白教程：https://vpsxb.net/419/<br />
软路由openwrt之nps内网穿透插件服务：https://www.vjsun.com/424.html<br />
nps实现内网穿透，电脑免费变云服务器：https://tangly1024.com/article/nps-centos-nat-traversal<br />
N1盒子op系统nps内网穿透对接腾讯云傻妞：https://blog.csdn.net/hebine7/article/details/122373365<br />
docker安装nps实现内网穿透：https://5616760.com/docker/nps/2021/08/09/docker-nps.html</p>
<p><a href="https://www.laobaiblog.top/2022/11/02/docker%e5%ae%89%e8%a3%85nps%e5%ae%9e%e7%8e%b0openwrt%e5%86%85%e7%bd%91%e7%a9%bf%e9%80%8f/">Docker安装nps实现[OpenWrt]内网穿透</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>远程连接Centos7桌面功能</title>
		<link>https://www.laobaiblog.top/2022/09/05/%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5centos7%e6%a1%8c%e9%9d%a2%e5%8a%9f%e8%83%bd/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Mon, 05 Sep 2022 10:03:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Xfce]]></category>
		<category><![CDATA[远程桌面]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=277</guid>

					<description><![CDATA[<p>突如其来的疫情让人措手不及，愿疫情早日过去&#8230; 因为要是实现居家办公，公司的服务器有些工作 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/09/05/%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5centos7%e6%a1%8c%e9%9d%a2%e5%8a%9f%e8%83%bd/">远程连接Centos7桌面功能</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>突如其来的疫情让人措手不及，愿疫情早日过去&#8230;</em><br />
<em>因为要是实现居家办公，公司的服务器有些工作需要桌面化才能满足日常使用要求</em></p>
<h1>远程连接CentOS7桌面方案</h1>
<p><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouy.com/it82e0b3pseh">MobaXterm工具蓝奏云下载</a></p>
<h3>SSH + X11桌面远程</h3>
<p>Linux的远程桌面一般采用VNC，很少提到SSH + X11做转发，下面介绍多种SSH + X11；</p>
<ul>
<li>安装Xfce桌面</li>
</ul>
<pre><code class="language-shell line-numbers">#安装Xfce
yum -y groupinstall "X Window System" "Xfce"
#启动桌面
startxfce4
</code></pre>
<ul>
<li>MobaXterm转发X11</li>
</ul>
<ol>
<li>MobaXterm功能非常全，内建X server，可远程运行X窗口程序，支持VNC/RDP/Xdmcp等远程桌面；</p>
</li>
<li>
<p>在SSH服务器中配置X11转发服务<br />
在/etc/ssh/sshd_config文件中将 X11Forwarding 设置成 yes</p>
</li>
</ol>
<p><code>X11Forwarding yes</code></p>
<p>重启ssh相关命令</p>
<pre><code class="language-shell line-numbers">#查看ssh服务状态
systemctl status sshd.service

#开启ssh服务
systemctl start sshd.service

#设置ssh服务开机自启
systemctl enable sshd.service
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_3ddb2904cb3a4ae54ea3402ad19b3bb0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_3ddb2904cb3a4ae54ea3402ad19b3bb0.jpg" alt="" /></a></p>
<ol start="3">
<li>配置MobaXterm登录信息(Remote environment注意CentOS的桌面类型 )</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b6667f76c9b7497a0f69fdc484f3cff3.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_b6667f76c9b7497a0f69fdc484f3cff3.jpg" alt="" /></a></p>
<ol start="4">
<li>MobaXterm连接到服务器<br />
X11-forwarding 和 DISPLAY 都打钩表示配置正常</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_20e20ee8af40a31abb81d48990ff287b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_20e20ee8af40a31abb81d48990ff287b.jpg" alt="" /></a></p>
<h3>远程效果</h3>
<p>这样就可以很方便的使用内网应用了</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_708ff87ef5c2eed595989189ca7eacdc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/09/wp_editor_md_708ff87ef5c2eed595989189ca7eacdc.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2022/09/05/%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5centos7%e6%a1%8c%e9%9d%a2%e5%8a%9f%e8%83%bd/">远程连接Centos7桌面功能</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS Docker环境部署Nessus漏洞扫描 系列一</title>
		<link>https://www.laobaiblog.top/2022/08/31/centos-docker%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2nessus%e6%bc%8f%e6%b4%9e%e6%89%ab%e6%8f%8f-%e7%b3%bb%e5%88%97%e4%b8%80/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 31 Aug 2022 04:14:00 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nessus]]></category>
		<category><![CDATA[漏洞扫描]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=271</guid>

					<description><![CDATA[<p>一、Docker部署Nessus 部署环境 操作系统版本：CentOS Linux release  &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/08/31/centos-docker%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2nessus%e6%bc%8f%e6%b4%9e%e6%89%ab%e6%8f%8f-%e7%b3%bb%e5%88%97%e4%b8%80/">CentOS Docker环境部署Nessus漏洞扫描 系列一</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h1>一、Docker部署Nessus</h1>
<h2>部署环境</h2>
<ul>
<li>操作系统版本：CentOS Linux release 7.9.2009 (Core)</li>
<li>Docker版本：Docker Server Version: 20.10.17</li>
<li>Nessus版本： 10.3.0 （#80） Linux</li>
</ul>
<h2>部署Nessus</h2>
<pre><code class="language-shell line-numbers">#搜索nessus相关镜像
docker search nessus
#pull nessus最新镜像
docker pull tenableofficial/nessus
#启动docker镜像，同时配置用户名和口令、不启动自动更新
docker run -it -d -p8834:8834 --name nessus -e USERNAME=Nessus -e AUTO_UPDATE=no -e PASSWORD=HDuUNO1XzDEq2Ls tenableofficial/nessus
</code></pre>
<pre><code class="language-shell line-numbers">#进入nessus容器
docker exec -it nessus bash
#启动nessus服务
/opt/scripts/configure_scanner.py

</code></pre>
<h2>访问nessus界面</h2>
<p><strong><code>https://localhost:8834</code></strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg" alt="" /></a></p>
<p><strong>用户名和口令为创建nessus容器时配置的用户名和口令</strong></p>
<pre><code class="language-shell line-numbers">username:Nessus
password:HDuUNO1XzDEq2Ls
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_c582b125111664a9c6b32a7822448b6b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_c582b125111664a9c6b32a7822448b6b.jpg" alt="" /></a></p>
<h1>二、官方注册插件库和激活码</h1>
<p><a class="wp-editor-md-post-content-link" href="https://plugins.nessus.org/v2/offline.php">官网插件库地址</a>：<br />
https://plugins.nessus.org/v2/offline.php</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ada4e589a08b061fb9cc269bc159a4bd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ada4e589a08b061fb9cc269bc159a4bd.jpg" alt="" /></a></p>
<h4>获取第一个值Challenge code</h4>
<pre><code class="language-shell line-numbers">#进入Nessus容器
docker exec -it nessus bash
#生成匹配Challenge code
/opt/nessus/sbin/nessuscli fetch --challenge
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_53f7bd59813c35b6213db9c1f36f484c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_53f7bd59813c35b6213db9c1f36f484c.jpg" alt="" /></a></p>
<p><strong>Challenge code: be86f8bde86494e544d6bad87c2ea9122f8b012d</strong></p>
<h4>获取第二个值激活码Activation Code</h4>
<p>进入<a class="wp-editor-md-post-content-link" href="https://zh-cn.tenable.com/products/nessus/nessus-essentials?tns_redirect=true">官网</a>，邮箱注册获取激活码，填写邮箱接收邮件<br />
https://zh-cn.tenable.com/products/nessus/nessus-essentials?tns_redirect=true</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2e284d8c7dda8752214f442a95eb0fa8.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2e284d8c7dda8752214f442a95eb0fa8.jpg" alt="" /></a></p>
<p>获取激活码</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2dedf9fed1be758a698876ce8209394c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_2dedf9fed1be758a698876ce8209394c.jpg" alt="" /></a></p>
<p>提交获取插件下载地址和证书内容</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_57e8f77cc73b6aa8c53aefb92aabfc7a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_57e8f77cc73b6aa8c53aefb92aabfc7a.jpg" alt="" /></a></p>
<p>插件下载地址及激活码License</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_eb3ac519e7b116dbe71dc06b373ea579.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_eb3ac519e7b116dbe71dc06b373ea579.jpg" alt="" /></a></p>
<h2>更新docker中nessus插件库</h2>
<p>将下载的插件库上传至nessus容器中</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_12b65f4dbd5a4c3dc004423e6af78266.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_12b65f4dbd5a4c3dc004423e6af78266.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">#从Docker宿主机复制文件到Docker容器 all-2.0.tar.gz插件位置看个人上传宿主机目录
docker cp /data/middleware/nessus/all-2.0.tar.gz nessus:/usr/local/
#Docker容器中更新插件库
docker exec -it nessus /bin/bash
cd /usr/local
#更新插件库
/opt/nessus/sbin/nessuscli update all-2.0.tar.gz
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_78c7f20c643d7823d9d26297908c62a0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_78c7f20c643d7823d9d26297908c62a0.jpg" alt="" /></a></p>
<h2>激活Nessus</h2>
<pre><code class="language-shell line-numbers">#进入容器
docker exec -it nessus /bin/bash
cd /usr/local
#填写刚才所获得的激活码
vi nessus.license

</code></pre>
<pre data-language=XML><code class="language-markup line-numbers">-----BEGIN TENABLE LICENSE-----
aTJZK2tGL1NQY3Fad2UrR0pWeWRobFpxdjJiY1F3d0Q0cEk0OWJtR3FuYjhmOTduOUF1OUMrY0FF
SmRVTkNJUUp5dEN6WTFiY1UrTnlsMG02VEQ0eUZBNU0yVGNDNDA4MmRMZEYyZy9VelhacWYyY3JH
aXFkY29kdnRhUzJtNytBbnJpUnprU21URjQva21kT3VwRWNVYmlHb0QzaXFUekNtZnZITnJaVldx
Wmh1eEFxYU9Pb2cwQW5GZXVRTWFsS1ZOODRBaXBGbFNJWjRrUi9XUUtGYWZZTmY1RGplZjZWVE1F
aUgzUDJnRmxSazJ2WFI4ZVcyazBPVEQ4R3JuTlpIaUZnNVZKdkZqdHJLZ1lYNlBRcU4zTWhIdzZF
Z2ZlajZqaG5QeUpWSkhSVFlTaHcvdzB3OEZUVXRZNU1TZmttRWlpT1lEOHcxejM2STlha1BCSGFB
dERETmFxN3l6SXJ4QTQ3ekRlY3FiS0lLYUhwWUMyeFpPbGNoV3VXZloxNGRvSXRySnFGVXB6MXRP
TERDUkNGQ2lHSHIrYUtjMUM1SUpqWTZKcFRiSHIrZm5wU3k2VDMrY1NzeU1JV3VyUmw1cUNFVWVs
WkJudUxXNkg4R0pwd3gvZEdHYi9TUjNpVjV2dzFoQUpGWG91K2NqM04zTktKVE5VcUp2Zi9URUth
SHNKTy9uWW9ZeXpGck9IUGtzWmxpdVdnMzR6U3V1MGpEamZZYVFsK3Y2ZkRlUHp5dU4vZjhhREdw
MUpSQTN4NGYwUTl3dzg0aXdKd0Zyb0Z1L3ltZE9ValIrbGR2cWFpemp3b0k3cnVCckpiNXlJb0tw
bXR3NDF4OWx5aXFPczM5d056bEkrUlN1UlpRV1BJNDJjUStFN2dwOVA4dUhndzVuZmNXK2RySzA9
DQp7ImFjdGl2YXRpb25fY29kZSI6IkdSQTctMkxVRC1EUENOLTg1WEQtWE1CTSIsInVwZGF0ZV9w
YXNzd29yZCI6ImY4MjM0OTFlYzExYjIxMGI0ODczYTllM2YxMzVlMDE3IiwicGVuZG9fYXBpX2tl
eSI6ImE3YzhkNWM0LWI2YWUtNDg2Ny03ZGFiLTY5YTkyYTA4NDdlMSIsIm5hbWUiOiJOZXNzdXMg
SG9tZSIsInR5cGUiOiJob21lIiwiZXhwaXJhdGlvbl9kYXRlIjoxODE5NTkzMzkwLCJjdXN0b21l
cl9pZCI6MCwiaXBzIjoxNiwidXBkYXRlX2xvZ2luIjoiMDdhOGZhNGZkYmYzNGIxNzU5NGZhNGUw
YTc1NmM2ZTAiLCJkcm0iOiJjMDUyOGZkOWQyNGIyZGQ0MDExMmZjZTNlM2I2NzY1MiJ9
-----END TENABLE LICENSE-----
</code></pre>
<h4>激活</h4>
<pre><code class="language-shell line-numbers">/opt/nessus/sbin/nessuscli fetch --register-offline nessus.license
#重启nessus
/opt/scripts/configure_scanner.py

</code></pre>
<p>等待加载插件库后访问nessus界面</p>
<p><code>https://localhost:8834</code></p>
<pre><code class="language-shell line-numbers">username:Nessus
password:HDuUNO1XzDEq2Ls
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_48afaed8f27d566dfcd378d912ee0f8f.jpg" alt="" /></a></p>
<p>插件正常加载</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_772a469666fb869bbe65c533211c309e.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_772a469666fb869bbe65c533211c309e.jpg" alt="" /></a></p>
<h1>三、Nessus破解修改限制</h1>
<pre><code class="language-shell line-numbers">#nessus初始化完成后Hosts显示为"0 of 16 used”，修改其限制
docker exec -it nessus /bin/bash
#复制插件到容器根目录
cp -r /opt/nessus/lib/nessus/plugins/ /
#查看plugins插件库复制是否成功，若不成功则重新复制
du -h /plugins/
#删除重新复制
rm -rf /plugins
cp -r /opt/nessus/lib/nessus/plugins/ /

</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_f1c564b79bbfc14f7b63e656daab9dcc.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_f1c564b79bbfc14f7b63e656daab9dcc.jpg" alt="" /></a></p>
<ul>
<li>查看plugin_feed_info.inc文件位置</li>
</ul>
<pre><code class="language-shell line-numbers">[root@7b287c8f02b0 /]# find / -name "plugin_feed_info.inc"
/opt/nessus/var/nessus/plugin_feed_info.inc
/opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
</code></pre>
<ul>
<li>备份plugin_feed_info.inc</li>
</ul>
<pre><code class="language-shell line-numbers">mkdir /pluginsinc
cp /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc /pluginsinc/plugin_feed_info.inc.libinc
cp /opt/nessus/var/nessus/plugin_feed_info.inc /pluginsinc/plugin_feed_info.inc.varinc
</code></pre>
<ul>
<li>将plugin_feed_info.inc内容修改为专业版，PLUGIN_SET序号号为Policy Template Version=202208301606或其后序号</li>
</ul>
<pre><code class="language-shell line-numbers">vi /pluginsinc/plugin_feed_info.inc
PLUGIN_SET = "202208301606";
PLUGIN_FEED = "ProfessionalFeed (Direct)";
PLUGIN_FEED_TRANSPORT = "Tenable Network Security Lightning";
</code></pre>
<ul>
<li>关闭Nessus服务</li>
</ul>
<pre><code class="language-shell line-numbers">supervisorctl stop nessusd
rm -f /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
cp /pluginsinc/plugin_feed_info.inc /opt/nessus/var/nessus/plugin_feed_info.inc
</code></pre>
<ul>
<li>重启Nessus服务</li>
</ul>
<pre><code class="language-shell line-numbers">supervisorctl start nessusd
du -h /opt/nessus/lib/nessus/plugins/
more /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
more /opt/nessus/var/nessus/plugin_feed_info.inc
</code></pre>
<ul>
<li>访问Nessus并更新规则库，此过程特慢需放置等待</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ca43e3cfd0153a5b5649895b972084a2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/08/wp_editor_md_ca43e3cfd0153a5b5649895b972084a2.jpg" alt="" /></a></p>
<ul>
<li>查看状态</li>
</ul>
<pre><code class="language-shell line-numbers">du -h /opt/nessus/lib/nessus/plugins/
more /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
more /opt/nessus/var/nessus/plugin_feed_info.inc
#若状态异常，重新执行插件删除程序
rm -rf /opt/nessus/lib/nessus/plugins/
cp -r /plugins /opt/nessus/lib/nessus/
supervisorctl stop nessusd
rm -f /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
cp /pluginsinc/plugin_feed_info.inc /opt/nessus/var/nessus/plugin_feed_info.inc
supervisorctl start nessusd
</code></pre>
<h4>重置启动</h4>
<p>因服务重启时unlimited失效，根据状态异常操作步骤重新操作，编写nessus_start.sh代替service nessusd start，因为命令执行过程较长且Nessus需要重新加载插件，启动过程慢是正常现象。</p>
<pre><code class="language-shell line-numbers">vi /root/nessus_start.sh

#!/bin/bash
rm -rf /opt/nessus/lib/nessus/plugins/
cp -r /plugins /opt/nessus/lib/nessus/
supervisorctl stop nessusd
rm -f /opt/nessus/lib/nessus/plugins/plugin_feed_info.inc
cp /pluginsinc/plugin_feed_info.inc /opt/nessus/var/nessus/plugin_feed_info.inc
supervisorctl start nessusd

chmod +x /root/nessus_start.sh
</code></pre>
<p>手动执行脚本</p>
<pre><code class="language-shell line-numbers">/root/nessus_start.sh
</code></pre>
<p><a href="https://www.laobaiblog.top/2022/08/31/centos-docker%e7%8e%af%e5%a2%83%e9%83%a8%e7%bd%b2nessus%e6%bc%8f%e6%b4%9e%e6%89%ab%e6%8f%8f-%e7%b3%bb%e5%88%97%e4%b8%80/">CentOS Docker环境部署Nessus漏洞扫描 系列一</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>N1盒子刷入OpenWrt设置旁路由实现科学上网</title>
		<link>https://www.laobaiblog.top/2022/07/26/n1%e7%9b%92%e5%ad%90%e5%88%b7%e5%85%a5openwrt%e8%ae%be%e7%bd%ae%e6%97%81%e8%b7%af%e7%94%b1%e5%ae%9e%e7%8e%b0%e7%a7%91%e5%ad%a6%e4%b8%8a%e7%bd%91/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 26 Jul 2022 07:44:31 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[N1]]></category>
		<category><![CDATA[openwrt]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=249</guid>

					<description><![CDATA[<p>N1盒子我在前文刷入了joyo1大神的安卓盒子及蓝光播放机双系统 感兴趣可以看看之前的博文 安装环境 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/07/26/n1%e7%9b%92%e5%ad%90%e5%88%b7%e5%85%a5openwrt%e8%ae%be%e7%bd%ae%e6%97%81%e8%b7%af%e7%94%b1%e5%ae%9e%e7%8e%b0%e7%a7%91%e5%ad%a6%e4%b8%8a%e7%bd%91/">N1盒子刷入OpenWrt设置旁路由实现科学上网</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>N1盒子我在前文刷入了joyo1大神的安卓盒子及蓝光播放机双系统<br />
感兴趣可以看看之前的<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2022/05/18/idea2021-%e8%bf%85%e9%9b%b7%e7%a0%b4%e8%a7%a3%e7%89%88-n1%e7%9b%92%e5%ad%90%e5%a4%9a%e7%b3%bb%e7%bb%9f%e5%9b%ba%e4%bb%b6%e5%8c%85%e5%88%86%e4%ba%ab/">博文</a></em></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_1bad57895b84bc5293210c56b931867d.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_1bad57895b84bc5293210c56b931867d.jpg" alt="" /></a></p>
<hr />
<h1>安装环境</h1>
<ol>
<li><a class="wp-editor-md-post-content-link" href="https://pan.baidu.com/s/15b1OWLXcmpJjqdaYFKvIlg?pwd=6nc4">镜像包百度云下载</a> 提取码：6nc4</p>
</li>
<li><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouj.com/iVWrX0nfkstg">烧录U盘工具</a></p>
</li>
<li><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouy.com/i24FH08fslbe">U盘启动工具</a></p>
</li>
<li>
<p>N1盒子</p>
</li>
</ol>
<p>在这里我用的是<a class="wp-editor-md-post-content-link" href="https://www.right.com.cn/forum/thread-4076037-1-1.html">恩山论坛</a>flippy大神编译最新的+O 版本镜像包。<br />
（原博排版及知识量对于新入手的玩家来说不是太友好）</p>
<p><strong>+O：代表已经装好各类插件</strong></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_078692b2a3642f180c18ae0b39d5efe2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_078692b2a3642f180c18ae0b39d5efe2.jpg" alt="" /></a></p>
<h1>刷机教程</h1>
<ol>
<li><a class="wp-editor-md-post-content-link" href="https://www.bilibili.com/video/av331820870/">B站视频教程</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://www.youtube.com/watch?v=8j8-BDTHKAM&#038;t=3s">Youtube视频完整教程</a></li>
</ol>
<h1>注意事项</h1>
<p>（1）在烧录U盘过程中，如果安装失败可以更换U盘多试几次。</p>
<p><strong>（2）刷机完成之后有可能遇到N1盒子无法联通网络问题。</strong><br />
在ShadowSocksRPlus+插件中，测试百度无法链接，在这里我们需要在防火墙中设置几条参数。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_6d0014314376d1330e924912e580fba1.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_6d0014314376d1330e924912e580fba1.jpg" alt="" /></a></p>
<ol>
<li>设置N1中的DNS服务</li>
</ol>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_80f823c3aa289dce0a2099383ef6d608.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_80f823c3aa289dce0a2099383ef6d608.jpg" alt="" /></a></p>
<ol start="2">
<li>添加防火墙规则</li>
</ol>
<pre><code class="language-shell line-numbers">iptables -t nat -I POSTROUTING -j MASQUERADE
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_14b798a3cde62a292ed6238e873b6a31.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_14b798a3cde62a292ed6238e873b6a31.jpg" alt="" /></a></p>
<ol start="3">
<li>调整防火墙网关</li>
</ol>
<p>进入TTYD终端，输入命令添加默认192.168.50.1网关</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_2ddfb35785e1e860d818d89a82977402.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_2ddfb35785e1e860d818d89a82977402.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">root@OpenWrt:~# route
root@OpenWrt:~# route add default gw 192.168.50.1
</code></pre>
<p>最后终于可以ping通外网了</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_8608826dabc256e5b56dbb762306b0b2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_8608826dabc256e5b56dbb762306b0b2.jpg" alt="" /></a></p>
<h1>成品展示</h1>
<p>系统概览</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_5fb4aac38398a02cebc10fb40c61c755.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_5fb4aac38398a02cebc10fb40c61c755.jpg" alt="" /></a></p>
<hr />
<p>网络联通测试</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_0f8ef06ef0fdf0d628bdc0489e1a1295.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_0f8ef06ef0fdf0d628bdc0489e1a1295.jpg" alt="" /></a></p>
<hr />
<p><a class="wp-editor-md-post-content-link" href="http://www.fast.com">外网网速测试</a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_6a693eb45560884da0bb92aef9b6ce03.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_6a693eb45560884da0bb92aef9b6ce03.jpg" alt="" /></a></p>
<p><span id="more-249"></span></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_a5e9e6574b534340ab987f3b3aa3be27.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_a5e9e6574b534340ab987f3b3aa3be27.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2022/07/26/n1%e7%9b%92%e5%ad%90%e5%88%b7%e5%85%a5openwrt%e8%ae%be%e7%bd%ae%e6%97%81%e8%b7%af%e7%94%b1%e5%ae%9e%e7%8e%b0%e7%a7%91%e5%ad%a6%e4%b8%8a%e7%bd%91/">N1盒子刷入OpenWrt设置旁路由实现科学上网</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Linux系统网络安全检查方案汇总记录</title>
		<link>https://www.laobaiblog.top/2022/07/22/linux%e7%b3%bb%e7%bb%9f%e7%bd%91%e7%bb%9c%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5%e6%96%b9%e6%a1%88%e6%b1%87%e6%80%bb%e8%ae%b0%e5%bd%95/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Fri, 22 Jul 2022 09:27:16 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[安全]]></category>
		<category><![CDATA[网络安全]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=244</guid>

					<description><![CDATA[<p>记录一下日常可能用到的系统检测方案及命令 1. 服务器是否被暴力破解 Debian 和 Ubuntu &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/07/22/linux%e7%b3%bb%e7%bb%9f%e7%bd%91%e7%bb%9c%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5%e6%96%b9%e6%a1%88%e6%b1%87%e6%80%bb%e8%ae%b0%e5%bd%95/">Linux系统网络安全检查方案汇总记录</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><em>记录一下日常可能用到的系统检测方案及命令</em></p>
<h5>1.  服务器是否被暴力破解</h5>
<pre><code class="language-shell line-numbers">Debian 和 Ubuntu 存储在 /var/log/auth.log
RedHat 和 CentOS 存储在 /var/log/secure

1.查看 root 用户登录成功的IP及次数看看是否有不熟悉的 IP 地址

grep "Accepted password for root" /var/log/secure | awk '{print <span class="katex math inline">11}' | sort | uniq -c | sort -nr | more

2.查看尝试暴力破解 root 账户的IP及次数
 grep "Failed password for root" /var/log/secure | awk '{print</span>11}' | sort | uniq -c | sort -nr | more

3.查看尝试暴力破解用户名的IP及次数
grep "Failed password for invalid user" /var/log/secure | awk '{print $13}' | sort | uniq -c | sort -nr | more
</code></pre>
<h5>2.  隐藏系统信息</h5>
<p>默认情况下，登录提示信息包括Linux发行版的名称、版本、内核版本和主机名等信息，这些信息对于黑客入侵是很有帮助的，因此，出于服务器的安全考虑，需要将这些信息修改或注释掉。应该只显示一个“login:”提示符。<br />
操作时删除 <code>/etc/issue和/etc/issue.net</code> 文件中的内容即可。</p>
<pre><code class="language-shell line-numbers">[root@localhost ~]# vim  /etc/issue   issue文件是用户从本地登录时看到的提示(注释或删除内容)

[root@localhost ~]# vim  /etc/issue.net   issue.net文件是用户从网络登录（如telnet、ssh）系统时看到的登录提示(注释或删除内容)。

</code></pre>
<h5>3.  禁ping设置</h5>
<p>在 <code>/etc/rc.d/rc.local</code> 文件增加：<code>echo 1 &gt; /proc/sys/net/ipv4/icmp_echo_ignore_all</code> ，防止别人ping自己的系统，从而增加系统的安全性。</p>
<pre><code class="language-shell line-numbers">echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
</code></pre>
<h5>4.  防止IP欺骗</h5>
<p>在 <code>/etc/host.conf</code> 文件增加一行：<code>nospoof on</code>，防止IP欺骗。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_f94e94c7b8dce4fe34952100dc97e7db.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_f94e94c7b8dce4fe34952100dc97e7db.jpg" alt="" /></a></p>
<h5>5.  使用以下命令对系统进行系统安全检查。</h5>
<pre><code class="language-shell line-numbers"># Whoami           当前用户？
# W                所有登录用户包括网络登录的？
# Who              所有登录用户包括网络登录的？
# history          历史命令记录
# clear            清屏
# last             曾经登录的用户
# top              活动进程
# netstat          查看网络状态

</code></pre>
<h5>6. 定期检查系统中的日志</h5>
<p>（1）<code>/var/log/messages</code> 日志文件。检查 <code>/var/log/messages</code> 日志文件，查看外部用户的登录情况。</p>
<p>（2）history文件。检查用户主目录 <code>/home/username</code> 下的历史文件，即 <code>.history</code> 文件。</p>
<h5>7. 分区保护</h5>
<p>在Linux系统中，可以将不同的应用安装在不同的分区上，每个分区分别进行不同的配置，可以将关键分区设置为只读，这样可以大大提高Linux文件系统的安全。Linux文件系统可以分为几个主要的分区，一般情况下至少需要建立 <code>/boot、/lib、/sbin、/usr/local、/var和/home</code> 等分区。</p>
<p><code>/usr</code> 可以安装成只读，并且可以被认为是不可修改的，如果 <code>/usr</code> 中有任何文件发生了改变，那么系统将立即发出安全报警。</p>
<p><code>/boot、/lib和/sbin</code> 的安装和设置也一样，在安装时尽量将它们设为只读。<br />
不过有些分区是不能设为只读的，比如 <code>/var</code>。</p>
<pre><code class="language-shell line-numbers">[root@localhost /]# chattr +i  /usr 加i属性使得root用户也不能在/BIN 创建改变文件

[root@localhost /]# lsattr -d  /usr 验证i属性加成功否？
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_2fbb72e741e89b20c8d7a98bc23280a0.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_2fbb72e741e89b20c8d7a98bc23280a0.jpg" alt="" /></a></p>
<h5>8. 用户管理</h5>
<pre><code class="language-shell line-numbers">查看用户列表：cat /etc/passwd
查看组列表：cat /etc/group

userdel sync
userdel shutdown
# 需要删除的多余用户共有：sync shutdown halt uucp operator games gopher
groupdel adm
groupdel games
# 需要删除的多余用户组共有：adm lp games dip
</code></pre>
<p>Linux中的帐号和口令是依据 /etc/passwd 、/etc/shadow、 /etc/group 、/etc/gshadow 这四个文档的，所以需要更改其权限提高安全性：</p>
<pre><code class="language-shell line-numbers">chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshado
</code></pre>
<p>如果还原，<strong>把 +i 改成 -i</strong> ,再执行一下上面四条命令。</p>
<p><strong>注：i属性：不允许对这个文件进行修改，删除或重命名，设定连结也无法写入或新增数据！只有 root 才能设定这个属性。</strong></p>
<h5>9. 查看当前网络通信IP</h5>
<pre><code class="language-shell line-numbers">#当前网络IP及请求连接数

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

#当前80端口通信IP，排查是否CC攻击

netstat -an|grep ':80' -c

#端口抓包分析
tcpdump -nn port 80 or port 443

</code></pre>
<h5>10. CentOS7防⽕墙放⾏或限制指定IP和端⼝（firewall）</h5>
<pre><code class="language-shell line-numbers">CentOS7默认没有安装iptables，可以⼿动安装iptables；也可以通过CentOS7已带的firewall配置防⽕墙。
1.查看firewalld.service服务状态
systemctl status firewalld

2.查看firewall运⾏状态
firewall-cmd --state

3.⼿动启动/停⽌/重启firewalld.service服务
# 启动firewalld
service firewalld start
# 停⽌firewalld
service firewalld stop
# 重启firewalld
service firewalld restart

4.展⽰当前配置的firewall规则
firewall-cmd --list-all

5.端⼝（端⼝段）的查询/开放
# 查询端⼝是否开放
firewall-cmd --query-port=8080/tcp
# 新建永久规则，开放8080端⼝（TCP协议）
firewall-cmd --permanent --add-port=8080/tcp
# 移除上述规则
firewall-cmd --permanent --remove-port=8080/tcp
# 新建永久规则，批量开放⼀段端⼝（TCP协议）
firewall-cmd --permanent --add-port=9001-9100/tcp

6.IP（IP段）的开放
# 新建永久规则，开放192.168.1.1单个源IP的访问
firewall-cmd --permanent --add-source=192.168.1.1
# 新建永久规则，开放192.168.1.0/24整个源IP段的访问
firewall-cmd --permanent --add-source=192.168.1.0/24
# 移除上述规则
firewall-cmd --permanent --remove-source=192.168.1.1

7.系统服务的开放
# 开放http服务
firewall-cmd --permanent --add-service=http
# 移除上述规则
firewall-cmd --permanent --remove-service=http

8.⾃定义复杂规则（注意是否与已有规则冲突）
# 允许指定IP访问本机8080端⼝

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.1" port protocol="tcp" port="8080" accept'

# 允许指定IP段访问本机8080-8090端⼝

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="8080-8090" accept'

# 禁⽌指定IP访问本机8080端⼝

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.1" port protocol="tcp" port="8080" reject'

9.任何修改操作，配置完成后，需要重新装载firewall。可重新启动firewalld服务。
firewall-cmd --reload
service firewalld restart
</code></pre>
<p>持续更新&#8230;..</p>
<p><a href="https://www.laobaiblog.top/2022/07/22/linux%e7%b3%bb%e7%bb%9f%e7%bd%91%e7%bb%9c%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5%e6%96%b9%e6%a1%88%e6%b1%87%e6%80%bb%e8%ae%b0%e5%bd%95/">Linux系统网络安全检查方案汇总记录</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS7.9安装Nodejs爬坑</title>
		<link>https://www.laobaiblog.top/2022/07/19/centos7-9%e5%ae%89%e8%a3%85nodejs%e7%88%ac%e5%9d%91/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Tue, 19 Jul 2022 07:02:15 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[npm]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=238</guid>

					<description><![CDATA[<p>引用博文 前言：在安装Nodejs过程中出现了如下报错 node: relocation error &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/07/19/centos7-9%e5%ae%89%e8%a3%85nodejs%e7%88%ac%e5%9d%91/">CentOS7.9安装Nodejs爬坑</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><a class="wp-editor-md-post-content-link" href="https://www.jianshu.com/p/990a093e9e1d?u_atoken=c9da25e6-e1a0-474a-8f75-7b59306bc804&#038;u_asession=01xpruQfmpwzKf05qj9yoM__R1IbJ1flBDVWVw5kWNhDYzWWnvk0PXjbN8ZJf0Hcd4X0KNBwm7Lovlpxjd_P_q4JsKWYrT3W_NKPr8w6oU7K9oXnVffIuJgR38HvyHdZ5lPpcarp92QKzyJKyYjREPlmBkFo3NEHBv0PZUm6pbxQU&#038;u_asig=05ReNMps794XZLa2116BvqUbqDZRKP9BxA0TKKMDGuUvcz-jm-bt9qct8mQ75BKIuBnWqBdZoR6bfDE76CL4sAi0SY3k-konqsqzun1p2m36FkaC7PWoG3eQjXiVMlUzZv0c3YB6hOBdchQ0YEkR0IXQ-oMoNm16aE933hN47KEAr9JS7q8ZD7Xtz2Ly-b0kmuyAKRFSVJkkdwVUnyHAIJzcMTDxdrEpkmF-Oh34m5Dc41MqkdD2Eu1Ij6iItBcYzCWPRPQyB_SKrj-61LB_f61u3h9VXwMyh6PgyDIVSG1W8IN89uV4tqg0ewrf7Gv3TDXsc5ggf623lX74vpg8_18VOzw7_0TmEGwkZ8XryrdyrvMMJF8I4XcLixaby12wqSmWspDxyAEEo4kbsryBKb9Q&#038;u_aref=HWFn0mHZBymIuPLmHken%2F8KbQms%3D">引用博文</a></p>
<p><em>前言：在安装Nodejs过程中出现了如下报错</em></p>
<pre><code class="language-shell line-numbers">node: relocation error: /lib64/libnode.so.93: symbol FIPS_selftest, version OPENSSL_1_1_0g not defined in file libcrypto.so.1.1 with link time reference
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_36af827772014031e2aa245079c6ee76.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_36af827772014031e2aa245079c6ee76.jpg" alt="" /></a></p>
<p>在升级了Openssl，Openssh无果之后，在百度/Google检索，很少有见到这类问题的解决办法，只能尝试上文中提到的降级方式，刚好我的服务器也是<strong>glibc2.17</strong>版本。</p>
<p><code>ldd --version</code></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_8fe256df50092f4d761bd06fe5a241bd.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_8fe256df50092f4d761bd06fe5a241bd.jpg" alt="" /></a></p>
<h1>安装</h1>
<p><a class="wp-editor-md-post-content-link" href="https://nodejs.org/en/about/previous-releases">下载历史NodeJs版本</a></p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_d95d1b19675aced5767a5b4edc971cac.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_d95d1b19675aced5767a5b4edc971cac.jpg" alt="" /></a></p>
<p>安装配置NodeJs</p>
<pre><code class="language-shell line-numbers">yum install gcc gcc-c++

tar -xvf node-v12.19.1-linux-x64.tar.gz

mv node-v12.19.1-linux-x64 node

#配置环境变量
vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=<span class="katex math inline">NODE_HOME/bin:</span>PATH
source /etc/profile

</code></pre>
<h1>验证</h1>
<pre><code class="language-shell line-numbers">node -v
npm -v
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_bc32bc428c87c774e0bf8e0d8da9dc3a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/07/wp_editor_md_bc32bc428c87c774e0bf8e0d8da9dc3a.jpg" alt="" /></a></p>
<p><em>ps:记录一次爬坑,升级openssh/l可以看以往博文<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">CentOS 7 离线更新升级 openSSH 9.8p1</a></em></p>
<p><a href="https://www.laobaiblog.top/2022/07/19/centos7-9%e5%ae%89%e8%a3%85nodejs%e7%88%ac%e5%9d%91/">CentOS7.9安装Nodejs爬坑</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CentOS 7 离线更新升级 openSSH 8.8p1</title>
		<link>https://www.laobaiblog.top/2022/04/01/centos-7-%e7%a6%bb%e7%ba%bf%e6%9b%b4%e6%96%b0%e5%8d%87%e7%ba%a7-openssh-8-8p1/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Fri, 01 Apr 2022 06:22:32 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=173</guid>

					<description><![CDATA[<p>简述：最近2022年一季度收到网安漏洞扫描，基本上重复出现的漏洞都是openssh版本过低问题。就着 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/04/01/centos-7-%e7%a6%bb%e7%ba%bf%e6%9b%b4%e6%96%b0%e5%8d%87%e7%ba%a7-openssh-8-8p1/">CentOS 7 离线更新升级 openSSH 8.8p1</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>简述：最近2022年一季度收到网安漏洞扫描，基本上重复出现的漏洞都是openssh版本过低问题。就着手准备升级ssh，需要注意的是升级ssh或许会导致远程服务器失联，升级之前记得打开telnet连接方式。</p>
<p><strong><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/2024/07/09/centos7-openssh%e7%a6%bb%e7%ba%bf%e5%8d%87%e7%ba%a7%e8%87%b39-8p1%ef%bc%8copenssl%e5%8d%87%e7%ba%a7%e8%87%b31-1-1w/">更新：升级最新的OpenSSH9.8p1版本</a></strong></p>
<h1>一、环境准备</h1>
<p><a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouu.com/ihl0u02f2x1e">openSSH 8.8p1离线升级包</a></p>
<p>查看系统版本</p>
<pre><code class="language-shell line-numbers">[root@izpv301ot71ucbyplf9wz1z ~]# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)
[root@izpv301ot71ucbyplf9wz1z ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

</code></pre>
<h1>二、升级准备</h1>
<ol>
<li>创建路径 <strong>/root/OpenSSH</strong> 并授权，同时创建/root/OpenSSH/packages</p>
</li>
<li>服务器联网，如果不能联网手动下载安装包<br />
1) <a class="wp-editor-md-post-content-link" href="https://www.zlib.net/zlib-1.3.1.tar.gz">zlib-1.2.12.tar.gz</a><br />
2) <a class="wp-editor-md-post-content-link" href="https://www.openssl.org/source/openssl-1.1.1m.tar.gz">openssl-1.1.1m.tar.gz</a><br />
3) <a class="wp-editor-md-post-content-link" href="https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz">openssh-8.8p1.tar.gz</a><br />
4) 依赖包需要：<a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouu.com/iAgMM02esasd">蓝奏云地址</a>，也可以在下面的网站搜索下载<a class="wp-editor-md-post-content-link" href="http://rpm.pbone.net/index.php">RPM Search</a>（有版本号比较好检索下载），将下载的rpm包拷贝到 <strong>/root/OpenSSH/packages</strong> 即可。<br />
软件包 gcc-4.8.5-44.el7.x86_64<br />
软件包 gcc-c++-4.8.5-44.el7.x86_64<br />
软件包 1:make-3.82-24.el7.x86_64<br />
软件包 pam-1.1.8-23.el7.x86_64<br />
软件包 pam-devel-1.1.8-23.el7.x86_64<br />
软件包 1:openssl-devel-1.0.2k-22.el7_9.x86_64<br />
软件包 pcre-devel-8.32-17.el7.x86_64<br />
软件包 4:perl-5.16.3-299.el7_9.x86_64<br />
软件包 zlib-devel-1.2.7-19.el7_9.x86_64</p>
</li>
</ol>
<h1>三、开始升级</h1>
<p>将下面的脚本（UpdateOpenSSH.sh）上传至/root/OpenSSH目录，并给定执行权限<code>chmod a+x UpdateOpenSSH.sh</code>。执行./UpdateOpenSSH.sh，等待升级完毕。<br />
<a class="wp-editor-md-post-content-link" href="https://mrliao.lanzouu.com/iTTNO02et2kd">UpdateOpenSSH.sh 蓝奏云地址</a></p>
<pre><code class="language-shell line-numbers">#!/bin/bash

clear
echo ------------------------------------------
echo        CentOS7 openssh升级到8.8p1
echo              <span class="katex math inline">(date +%F-%T)
echo         注意环境，使用前请做好测试！！！
echo ------------------------------------------
sleep 3s
clear
echo 安装进程开始  3
sleep 1s
clear
echo 安装进程开始  3  2
sleep 1s
clear
echo 安装进程开始  3  2  1
sleep 1s
clear
echo 刷新yum元数据缓存
sleep 2s

yum makecache
sleep 3s
clear
echo 检测安装telnet服务
sleep 1s
echo 尝试启动telnet服务
sleep 1s
cp /etc/securetty /etc/securetty.bak
grep  "pts/0"  /etc/securetty ||  echo 'pts/0' >> /etc/securetty
grep  "pts/1"  /etc/securetty ||  echo 'pts/1' >> /etc/securetty
systemctl restart telnet.socket &&  systemctl restart xinetd
ps -ef |grep xinetd | egrep -v grep > /dev/null
if [</span>? -eq 0 ]
then
    echo 检测到telnet服务已启动……
    systemctl enable telnet.socket
    systemctl enable xinetd
        sleep 2s
else
    echo 未检测到telnet服务，开始安装服务……
    sleep 2s
    yum -y install xinetd telnet-server
    sleep 2s
    clear
    echo 安装telnet服务结束，启动服务……
    systemctl restart telnet.socket &&  systemctl restart xinetd
    systemctl enable telnet.socket
    systemctl enable xinetd
    sleep 1s
fi
clear
echo 关闭SElinux及防火墙并禁用……
sleep 2s
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
cat /etc/selinux/config
systemctl stop firewalld.service
systemctl disable firewalld.service
sleep 2s
clear
echo 安装程序依赖包……
sleep 2s
yum -y install gcc gcc-c++ make pam pam-devel openssl-devel pcre-devel perl zlib-devel
sleep 1s
clear
echo 停止并卸载原有ssh
sleep 3s
systemctl stop sshd
cp -r /etc/ssh /etc/ssh.old
cp -r /etc/init.d/ssh /etc/init.d/ssh.old
rpm -qa | grep openssh
sleep 1s
rpm -e <code>rpm -qa | grep openssh</code> --nodeps
rpm -qa | grep openssh
sleep 1s
clear

echo 判断是否需要安装wget
WGET=<code>rpm -qa | grep wget</code>
if [<span class="katex math inline">WGET -z ];then
    yum install -y wget
fi
echo 准备文件和参数
echo ################################################################
echo 服务器无法联网下载的可以将所需要的升级包放到/root/OpenSSH目录下
echo ################################################################
file=/root/OpenSSH
zlib=http://www.zlib.net/zlib-1.2.12.tar.gz
openssl=https://www.openssl.org/source/openssl-1.1.1m.tar.gz
openssh=https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz
echo 创建目录
mkdir -p</span>file/zlib
mkdir -p <span class="katex math inline">file/openssl
mkdir -p</span>file/openssh
echo 联网通过wget下载安装包
cd <span class="katex math inline">file
echo 开始下载zlib
#wget</span>zlib
echo 开始下载openssl
#wget --no-check-certificate <span class="katex math inline">openssl
echo 开始下载openssh
#wget --no-check-certificate</span>openssh
###安装相关依赖包###
yum install -y gcc make perl zlib zlib-devel pam pam-devel

echo 安装zlib
sleep 2s
tar -xzf zlib*.tar.gz -C <span class="katex math inline">file/zlib 
sleep 2s
cd</span>file/zlib/zlib*
./configure --prefix=/usr/local/zlib && make && make install
ls -l /usr/local/zlib
cd ..
sleep 1s
clear
echo 配置zlib
grep  "/usr/local/zlib/lib"  /etc/ld.so.conf.d/zlib.conf ||  echo '/usr/local/zlib/lib' >> /etc/ld.so.conf.d/zlib.conf
ldconfig -v
sleep 1s
clear
echo 安装openssl
sleep 5s
mv -f /usr/bin/openssl /usr/bin/openssl.old
mv -f /usr/include/openssl /usr/include/openssl.old
mv -f /usr/lib64/openssl /usr/lib64/openssl.old
rm -rf /usr/local/ssl
cd <span class="katex math inline">file
tar -xzf openssl*.tar.gz -C</span>file/openssl
cd <span class="katex math inline">file/openssl/openssl*
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib && make && make install
cd ..
sleep 5s
clear
echo 配置openssl
sleep 5s
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
grep  "/usr/local/ssl/lib"  /etc/ld.so.conf.d/ssl.conf ||  echo '/usr/local/ssl/lib' >> /etc/ld.so.conf.d/ssl.conf
grep  "/usr/local/lib"  /etc/ld.so.conf.d/ssl.conf ||  echo '/usr/local/lib' >> /etc/ld.so.conf.d/ssl.conf
ldconfig -v
openssl version -a
sleep 5s
clear
echo 安装openssh
sleep 5s
rm -rf /etc/ssh
cd</span>file
tar -xzf openssh*.tar.gz -C <span class="katex math inline">file/openssh
cd</span>file/openssh/openssh*
./configure --prefix=/usr --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl   --with-zlib --with-md5-passwords
make
sleep 5s
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
make install
cd ..
pwd
sleep 5s
clear
echo 配置openssh
sleep 10s
echo "PasswordAuthentication yes"   >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo 'Banner /etc/issue' >> /etc/ssh/sshd_config
cp -p openssh-8.8p1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod +x /etc/init.d/sshd
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
sudo chmod 600 /etc/ssh/ssh_host_ecdsa_key
sudo chmod 600 /etc/ssh/ssh_host_ed25519_key
chkconfig --add sshd
chkconfig sshd on
systemctl restart sshd
sleep 10s
clear
systemctl status sshd
if [ $? -eq 0 ]
then
    clear
    echo SSH安装并运行成功，开始关闭并禁用telnet
    sleep 1s
    systemctl stop telnet.socket &&  systemctl stop xinetd
    systemctl disable telnet.socket &&  systemctl disable xinetd
    sleep 1s
    echo 升级完成,安装ssh2扩展支持
    sleep 5s
    yum install libssh2 -y
    clear
    echo 安装进程结束
    sleep 5s
else
    echo SSH未成功安装或配置，安装进程即将退出，请检查日志……
    sleep 5s
fi

</code></pre>
<p>查看升级情况<code>ssh -V</code></p>
<pre><code class="language-shell line-numbers">[root@izpv301ot71ucbyplf9wz1z ~]# ssh -V
OpenSSH_8.8p1, OpenSSL 1.1.1m  14 Dec 2021
[root@izpv301ot71ucbyplf9wz1z ~]# 
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/04/wp_editor_md_42e27f1596d8fccdff6a2546b70e06ca.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/04/wp_editor_md_42e27f1596d8fccdff6a2546b70e06ca.jpg" alt="" /></a></p>
<p><a href="https://www.laobaiblog.top/2022/04/01/centos-7-%e7%a6%bb%e7%ba%bf%e6%9b%b4%e6%96%b0%e5%8d%87%e7%ba%a7-openssh-8-8p1/">CentOS 7 离线更新升级 openSSH 8.8p1</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Docker-compose安装部署ELK并集成SpringBoot</title>
		<link>https://www.laobaiblog.top/2022/03/30/docker-compose%e5%ae%89%e8%a3%85%e9%83%a8%e7%bd%b2elk%e5%b9%b6%e9%9b%86%e6%88%90springboot/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Wed, 30 Mar 2022 08:32:29 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=164</guid>

					<description><![CDATA[<p>原文地址：https://www.cnblogs.com/zys2019/p/14816634.ht &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/03/30/docker-compose%e5%ae%89%e8%a3%85%e9%83%a8%e7%bd%b2elk%e5%b9%b6%e9%9b%86%e6%88%90springboot/">Docker-compose安装部署ELK并集成SpringBoot</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/zys2019/p/14816634.html">原文地址</a>：<a href="https://www.cnblogs.com/zys2019/p/14816634.html">https://www.cnblogs.com/zys2019/p/14816634.html</a></p>
<h1>一、概述</h1>
<h2>1.1 定义</h2>
<p>对于大规模的日志，需要集中化的管理。而ELK提供了一整套解决方案，并且都是开源软件，之间互相配合使用，完美衔接，高效的满足了很多场合的应用。ELK是三种技术产品的简称，包括Elasticsearch、Logstash、Kibana，可在项目中作为日志框架使用。</p>
<h2>1.2 功能说明</h2>
<ul>
<li>Elasticsearch是个开源分布式搜索引擎，提供搜集、分析、存储数据三大功能。</p>
</li>
<li>Logstash 主要是用来日志的搜集、分析、过滤日志的工具，支持大量的数据获取方式。</p>
</li>
<li>Kibana 也是一个开源和免费的工具，Kibana可以为 Logstash 和 ElasticSearch 提供的日志分析友好的 Web 界面，可以帮助汇总、分析和搜索重要数据日志。</p>
</li>
</ul>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_831e7c63fb031c5a9c701ed93dd67da2.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_831e7c63fb031c5a9c701ed93dd67da2.jpg" alt="" /></a></p>
<p>简单来说，应用服务生产日志，通过Logger产生日志并输出；Logstash通过http接收应用服务产生的日志；Elasticsearch为日志提供全文检索功能；kibana为Elasticsearch提供图形化界面。</p>
<h1>二、部署ELK</h1>
<p>部署环境</p>
<ul>
<li>CentOS Linux release 7.9.2009 (Core)</li>
<li>Docker Version: 20.10.12</li>
<li>Docker Compose version v2.3.4</li>
</ul>
<h2>2.1 创建目录及配置文件</h2>
<h3>1) 创建elasticsearch数据目录及插件目录</h3>
<pre><code class="language-shell line-numbers">mkdir -p /home/middleware/elk/elasticsearch/data
mkdir -p /home/middleware/elk/elasticsearch/plugins
//elasticsearch数据文件夹授权，保障docker容器中读写权限
chmod 777 /home/middleware/elk/elasticsearch/data
</code></pre>
<h3>2) 创建kibana目录，以便后续汉化操作</h3>
<pre><code class="language-shell line-numbers">mkdir -p /home/middleware/elk/kibana/config
touch /home/middleware/elk/kibana/config/kibana.yml
</code></pre>
<p>配置kibana汉化</p>
<pre><code class="language-shell line-numbers">vim /home/middleware/elk/kibana/config/kibana.yml

#
# ** THIS IS AN AUTO-GENERATED FILE **
#

# Default Kibana configuration for docker target
server.host: "0.0.0.0"
server.shutdownTimeout: "5s"
# 注意你的本地IP
elasticsearch.hosts: [ "http://本地IP:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
#汉化
i18n.locale: "zh-CN"
</code></pre>
<h3>3) 创建logstash.conf配置文件</h3>
<pre><code class="language-shell line-numbers">mkdir -p /home/middleware/elk/logstash.conf配置文件/conf.d/
touch /home/middleware/elk/logstash/conf.d/logstash.conf
</code></pre>
<p>编辑配置logstash.conf，其内容如下</p>
<pre><code class="language-shell line-numbers">vim /home/middleware/elk/logstash/conf.d/logstash.conf

input {
  tcp {
    mode => "server"
    host => "0.0.0.0"
    port => 4560
    codec => json
  }
}
output {
  elasticsearch {
    hosts => "es:9200"
    index => "logstash-%{+YYYY.MM.dd}"
  }
}

</code></pre>
<p>在这里指定了输入的日志的端口是<strong>4560，那么下面对外暴露的端口也必须是4560。</strong></p>
<h3>4) 创建docker-compose.yml文件</h3>
<pre><code class="language-shell line-numbers">touch /home/middleware/elk/docker-compose.yml
</code></pre>
<h2>2.2 配置docker-compose并启动</h2>
<pre><code class="language-shell line-numbers">cd /home/middleware/elk
vim docker-compose.yml
</code></pre>
<p>配置内容如下：</p>
<pre><code class="language-shell line-numbers">
version: '3.7'
services:
  elasticsearch:
    image: elasticsearch:7.17.1
    container_name: elasticsearch
    privileged: true
    user: root
    environment:
      #设置集群名称为elasticsearch
      - cluster.name=elasticsearch 
      #以单一节点模式启动
      - discovery.type=single-node 
      #设置使用jvm内存大小
      - ES_JAVA_OPTS=-Xms512m -Xmx512m 
    volumes:
      - /home/middleware/elk/elasticsearch/plugins:/usr/share/elasticsearch/plugins
      - /home/middleware/elk/elasticsearch/data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300

  logstash:
    image: logstash:7.17.1
    container_name: logstash
    ports:
       - 4560:4560
    privileged: true
    environment:
      - TZ=Asia/Shanghai
    volumes:
      #挂载logstash的配置文件
      - /home/middleware/elk/logstash/conf.d/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
    depends_on:
      - elasticsearch 
    links:
      #可以用es这个域名访问elasticsearch服务
      - elasticsearch:es 

  kibana:
    image: kibana:7.17.1
    container_name: kibana
    ports:
        - 5601:5601
    privileged: true
    links:
      #可以用es这个域名访问elasticsearch服务
      - elasticsearch:es 
    depends_on:
      - elasticsearch 
    environment:
      #设置访问elasticsearch的地址
      - elasticsearch.hosts=http://elasticsearch:9200
    volumes:
      - /home/middleware/elk/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
</code></pre>
<p>这里使用privileged设置为true是赋予这个容器root权限。然后启动</p>
<h3>5) docker-compose启动elk</h3>
<p>完整目录结构如下图</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_697d1448cd339c91baf5ef946f3fc7b5.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_697d1448cd339c91baf5ef946f3fc7b5.jpg" alt="" /></a></p>
<pre><code class="language-shell line-numbers">cd /home/middleware/elk
docker-compose up -d
</code></pre>
<p>若启动报错，需要先关闭并删除容器后再重新启动。关闭删除命令：</p>
<pre><code class="language-shell line-numbers">docker-compose down
</code></pre>
<h2>2.3 打开kibana</h2>
<p>输入http://192.168.1.104:5601/app/home，访问Kibana web界面。点击左侧设置，进入Management界面</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_8c540c1591ac09e4715e0156ee8ef83a.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_8c540c1591ac09e4715e0156ee8ef83a.jpg" alt="" /></a></p>
<h1>三、日志收集</h1>
<p>本文通过SpringBoot架构把日志信息记录到logstash。</p>
<h2>3.1 环境准备</h2>
<ul>
<li>IntelliJ IDEA 2019.3.5</li>
<li>Spring-boot</li>
</ul>
<h3>3.1.1 创建springboot项目</h3>
<p>1) 打开IDEA，新建File -&gt; New -&gt; Project -&gt; Spring Initializr</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_6cde4d7e8db1e1940005665eed2dfd96.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_6cde4d7e8db1e1940005665eed2dfd96.jpg" alt="" /></a></p>
<p>2) 创建springelk测试项目</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_9f9188d9e9126b034b187397ddfacbc3.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_9f9188d9e9126b034b187397ddfacbc3.jpg" alt="" /></a></p>
<p>3) 新建一个springboot的项目，在 <strong>pom.xml</strong> 下导入以下web的依赖</p>
<pre data-language=XML><code class="language-markup line-numbers">&lt;!--集成logstash开始--&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;net.logstash.logback&lt;/groupId&gt;
            &lt;artifactId&gt;logstash-logback-encoder&lt;/artifactId&gt;
            &lt;version&gt;6.6&lt;/version&gt;
        &lt;/dependency&gt;
&lt;!--集成logstash结束--&gt;
</code></pre>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_0a07ffb6365c8ced5d856181133980f7.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_0a07ffb6365c8ced5d856181133980f7.jpg" alt="" /></a></p>
<h3>3.1.2 使用logback记录日志</h3>
<p>logback是SpringBoot自带的日志，只要导入了web的依赖即可使用。<br />
1) 在测试包下新建一个测试类和测试方法</p>
<pre><code class="language-java line-numbers">import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 *
 * @author lkh
 * date:2022-03-30
 */

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringElkTest.class)
public class SpringElkTest {
//创建log对象

    Logger logger = LogManager.getLogger(this.getClass());

    @Test
    public void logback() {
        logger.info("这是一个logback日志Info信息");
        logger.error("这是一个logback日志Error信息");
    }

}
</code></pre>
<p>2）在resources目录新建logback-spring.xml</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_bb30d6ef508543d6e5656a89dccec62b.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_bb30d6ef508543d6e5656a89dccec62b.jpg" alt="" /></a></p>
<p><strong>写入以下内容</strong></p>
<pre data-language=XML><code class="language-markup line-numbers">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE configuration&gt;
&lt;configuration&gt;
    &lt;include resource="org/springframework/boot/logging/logback/defaults.xml"/&gt;
    &lt;include resource="org/springframework/boot/logging/logback/console-appender.xml"/&gt;
    &lt;!--应用名称--&gt;
    &lt;property name="APP_NAME" value="springboot-logback-elk-demo"/&gt;
    &lt;!--日志文件保存路径--&gt;
    &lt;property name="LOG_FILE_PATH" value="<span class="katex math inline">{LOG_FILE:-</span>{LOG_PATH:-<span class="katex math inline">{LOG_TEMP:-</span>{java.io.tmpdir:-/tmp}}}/logs}"/&gt;
    &lt;contextName&gt;<span class="katex math inline">{APP_NAME}&lt;/contextName&gt;
    &lt;!--每天记录日志到文件appender--&gt;
    &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
        &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
            &lt;fileNamePattern&gt;</span>{LOG_FILE_PATH}/<span class="katex math inline">{APP_NAME}-%d{yyyy-MM-dd}.log&lt;/fileNamePattern&gt;
            &lt;maxHistory&gt;30&lt;/maxHistory&gt;
        &lt;/rollingPolicy&gt;
        &lt;encoder&gt;
            &lt;pattern&gt;</span>{FILE_LOG_PATTERN}&lt;/pattern&gt;
        &lt;/encoder&gt;
    &lt;/appender&gt;
    &lt;!--输出到logstash的appender--&gt;
    &lt;appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender"&gt;
        &lt;!--可以访问的logstash日志收集端口--&gt;
        &lt;destination&gt;192.168.1.104:4560&lt;/destination&gt;
        &lt;encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/&gt;
    &lt;/appender&gt;
    &lt;root level="INFO"&gt;
        &lt;appender-ref ref="CONSOLE"/&gt;
        &lt;appender-ref ref="FILE"/&gt;
        &lt;appender-ref ref="LOGSTASH"/&gt;
    &lt;/root&gt;
&lt;/configuration&gt;

</code></pre>
<p>3) 然后启动测试方法，查看控制台日志。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_3e7061093009107d38fc59820470d5fb.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_3e7061093009107d38fc59820470d5fb.jpg" alt="" /></a></p>
<p>4) 返回kibana页面，创建索引，已自动搜索展示出来</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_dc2e378315f7f5fa5f3b3634cef41929.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_dc2e378315f7f5fa5f3b3634cef41929.jpg" alt="" /></a></p>
<p>5) 选择Discover,可以看到刚才打印的日志已经反馈到kibana中</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_122ec43f890c49e8e8d7698615723d79.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_122ec43f890c49e8e8d7698615723d79.jpg" alt="" /></a></p>
<p>查看信息时，建议在左侧Available fields中筛选出&quot;message&quot;信息，&quot;host&quot;字段可选。筛选的字段在左侧也可以看到，右侧看到的信息就比较清晰。</p>
<p>需要注意的是，在这些日志中，时间是logstash收集日志时的创建时间，并不是原始日志的记录时间。</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_1a8d6fc8d9d646b64088f388ef33b065.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_1a8d6fc8d9d646b64088f388ef33b065.jpg" alt="" /></a></p>
<h3>3.1.3 使用log4j2记录日志</h3>
<p>要使用log4j2，则必须排除SpringBoot自带的日志。<br />
1) pom.xml中排除logback并导入log4j2依赖</p>
<pre data-language=XML><code class="language-markup line-numbers">&lt;!--集成log4j2开始--&gt;
                &lt;dependency&gt;
                    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                    &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
                    &lt;exclusions&gt;
                        &lt;!-- 引入log4j日志时需去掉默认的logback --&gt;
                &lt;exclusion&gt;
                    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                    &lt;artifactId&gt;spring-boot-starter-logging&lt;/artifactId&gt;
                &lt;/exclusion&gt;
            &lt;/exclusions&gt;
        &lt;/dependency&gt;

        &lt;!-- 日志管理log4j2 --&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
            &lt;artifactId&gt;spring-boot-starter-log4j2&lt;/artifactId&gt;
            &lt;version&gt;2.1.0.RELEASE&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;!--集成log4j2结束 --&gt;
</code></pre>
<p>在资源目录下新建log4j2.xml</p>
<pre data-language=XML><code class="language-markup line-numbers">&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;configuration status="info"&gt;
    &lt;Properties&gt;
        &lt;!-- 声明日志文件存储的目录 --&gt;
        &lt;Property name="LOG_HOME"&gt;E:\logs&lt;/Property&gt;
        &lt;Property name="LOG_PATTERN"
                  value="%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%thread][%class{36}:%line] - %msg%n"&gt;&lt;/Property&gt;
    &lt;/Properties&gt;

    &lt;Appenders&gt;
        &lt;!--输出控制台的配置--&gt;
        &lt;Console name="Console" target="SYSTEM_OUT"&gt;
            &lt;!--控制台只输出level及以上级别的信息（onMatch），其他的直接拒绝（onMismatch）--&gt;
            &lt;ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/&gt;
            &lt;!-- 输出日志的格式--&gt;
            &lt;PatternLayout pattern="<span class="katex math inline">{LOG_PATTERN}"/&gt;
        &lt;/Console&gt;

        &lt;!--这输出日志到文件的配置，每次大小超过size，则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩，作为存档--&gt;
        &lt;RollingFile name="RollingFile" fileName="</span>{LOG_HOME}\app_<span class="katex math inline">{date:yyyy-MM-dd}.log"
                     filePattern="</span>{LOG_HOME}\<span class="katex math inline">{date:yyyy-MM}\app_%d{yyyy-MM-dd}_%i.log"&gt;
            &lt;ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/&gt;
            &lt;!-- 输出日志的格式--&gt;
            &lt;PatternLayout pattern="</span>{LOG_PATTERN}"/&gt;
            &lt;!-- 日志文件大小 --&gt;
            &lt;SizeBasedTriggeringPolicy size="20MB"/&gt;
            &lt;!-- 最多保留文件数 --&gt;
            &lt;DefaultRolloverStrategy max="30"/&gt;
        &lt;/RollingFile&gt;

        &lt;!--输出到logstash的appender--&gt;
        &lt;Socket name="Socket" host="192.168.1.104" port="4560" protocol="TCP"&gt;
            &lt;!--输出到logstash的日志格式--&gt;
            &lt;PatternLayout pattern="${LOG_PATTERN}"/&gt;
        &lt;/Socket&gt;
    &lt;/Appenders&gt;

    &lt;!--然后定义Logger，只有定义了Logger并引入的Appender，Appender才会生效。Root中level配置了日志级别，可配置其他级别--&gt;
    &lt;Loggers&gt;
        &lt;Root level="info"&gt;
            &lt;AppenderRef ref="Console"/&gt;
            &lt;AppenderRef ref="RollingFile"/&gt;
            &lt;AppenderRef ref="Socket"/&gt;
        &lt;/Root&gt;
    &lt;/Loggers&gt;

&lt;/configuration&gt;
</code></pre>
<p><strong>注意需要指定logstash服务的ip和记录日志的端口。</strong></p>
<p>3) 新建测试类及方法</p>
<pre><code class="language-java line-numbers">import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 *
 * @author lkh
 * date:2022-03-30
 */

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringElkTest.class)
public class SpringElkTest {
//创建log对象

    Logger logger = LogManager.getLogger(this.getClass());

    /*@Test
    public void logback() {
        logger.info("这是一个logback日志Info信息test1111");
        logger.error("这是一个logback日志Error信息test1111");
    }*/

    @Test
    public void log4j2() {
        logger.info("这是一个log4j2日志Info信息");
        logger.error("这是一个log4j2日志Error信息");
    }

}

</code></pre>
<p>4) 启动测试方法</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_83ab167ef424ca6cd2900b81541a575c.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_83ab167ef424ca6cd2900b81541a575c.jpg" alt="" /></a></p>
<p>查看kibana的日志信息</p>
<p><a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_12275b9ef3163f16cefa472441d40565.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_12275b9ef3163f16cefa472441d40565.jpg" alt="" /></a></p>
<p>查看信息时，建议在左侧Available fields中筛选出&quot;message&quot;信息，&quot;thread_name&quot;，&quot;host&quot;字段可选。筛选的字段在左侧也可以看到，右侧看到的信息就比较清晰，包含了日志本身的时间，这是是配置日志配置的。</p>
<p><a href="https://www.laobaiblog.top/2022/03/30/docker-compose%e5%ae%89%e8%a3%85%e9%83%a8%e7%bd%b2elk%e5%b9%b6%e9%9b%86%e6%88%90springboot/">Docker-compose安装部署ELK并集成SpringBoot</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Nginx不停服务热升级</title>
		<link>https://www.laobaiblog.top/2022/03/24/nginx%e4%b8%8d%e5%81%9c%e6%9c%8d%e5%8a%a1%e7%83%ad%e5%8d%87%e7%ba%a7/</link>
		
		<dc:creator><![CDATA[大白]]></dc:creator>
		<pubDate>Thu, 24 Mar 2022 07:27:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[分享]]></category>
		<guid isPermaLink="false">https://www.laobaiblog.top/?p=160</guid>

					<description><![CDATA[<p>原博地址：软件老王 1. 场景描述 在线上环境下，为了最小化影响服务的正常使用，在这里采用不停服务对 &#8230;</p>
<p><a href="https://www.laobaiblog.top/2022/03/24/nginx%e4%b8%8d%e5%81%9c%e6%9c%8d%e5%8a%a1%e7%83%ad%e5%8d%87%e7%ba%a7/">Nginx不停服务热升级</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><a class="wp-editor-md-post-content-link" href="https://www.cnblogs.com/ruanjianlaowang/p/12058113.html">原博地址：软件老王</a></p>
<h2>1. 场景描述</h2>
<p>在线上环境下，为了最小化影响服务的正常使用，在这里采用不停服务对nginx进行热升级，也一定程度保障nginx不会出现旧版本安全漏洞。</p>
<h2>2. 升级</h2>
<p>官网下载：<a href="http://nginx.org/en/download.html">http://nginx.org/en/download.html</a><br />
nginx 1.9.9升级至nginx 1.20.2<br />
<a class="wp-editor-md-post-content-link" href="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_131e07f31dedcf3ba8285d898c9f3767.jpg"><img decoding="async" src="https://www.laobaiblog.top/wp-content/uploads/2022/03/wp_editor_md_131e07f31dedcf3ba8285d898c9f3767.jpg" alt="" /></a></p>
<h2>3. 整体备份</h2>
<pre><code class="language-shell line-numbers">[root@laobai ~]# whereis nginx
nginx: /usr/local/nginx
[root@laobai ~]# cd /usr/local
[root@laobai ~]# cp  -rf nginx nginx20220324
</code></pre>
<h2>4. 升级</h2>
<pre><code class="language-shell line-numbers">[root@laobai ~]# cd   /usr/local
[root@laobai ~]# tar zxvf  nginx-1.20.2.tar.gz
[root@laobai ~]# cd nginx-1.20.2/
[root@laobai ~]# ./configure --prefix=/usr/local/nginx
[root@laobai ~]# make
----切记不要执行make install，该命令是命令是安装，会覆盖原有文件夹

---升级重点就是这一行命令
[root@laobai ~]# cp -rf /usr/local/nginx-1.20.2/objs/nginx /usr/local/nginx/sbin/
[root@laobai ~]# make upgrade
</code></pre>
<p><strong>说明</strong></p>
<ul>
<li>切记不要执行make install，该命令是安装，会覆盖原有文件夹</li>
<li>升级nginx，其实是升级的nginx的二进制文件，以下命令是重点：</li>
</ul>
<pre><code class="language-shell line-numbers">[root@laobai ~]# cp -rf /usr/local/nginx-1.20.2/objs/nginx /usr/local/nginx/sbin/
</code></pre>
<h2>5. 验证</h2>
<pre><code class="language-shell line-numbers">[root@laobai ~]# cd /usr/local/nginx
[root@laobai ~]# cd sbin/
[root@laobai ~]# ./nginx -v
nginx version: nginx/1.20.2
</code></pre>
<p><a href="https://www.laobaiblog.top/2022/03/24/nginx%e4%b8%8d%e5%81%9c%e6%9c%8d%e5%8a%a1%e7%83%ad%e5%8d%87%e7%ba%a7/">Nginx不停服务热升级</a>最先出现在<a href="https://www.laobaiblog.top">Liao&#039;s blog</a>。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
