<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title><![CDATA[云笔记]]></title> 
<atom:link href="https://host-vps.de/rss.php" rel="self" type="application/rss+xml" />
<description><![CDATA[云笔记]]></description>
<link>https://host-vps.de/</link>
<language>zh-cn</language>
<generator>www.emlog.net</generator>
<item>
    <title>debian 添加开机启动项</title>
    <link>https://host-vps.de/post-12.html</link>
    <description><![CDATA[<p><br></p><p style="text-align: start;">有的时候，经常有自己需要的程序，官方并没有提供添加开机启动的方法，但我们却需要让他们开机启动（比如探针类、飞机类、服务类程序等）。可能有的人会说，可以使用 <code>/etc/rc.local</code> 啊。是可以使用这个，但不是所有的系统都有 rc.local 。今天介绍一个简单的方法，实现将自己需要的程序添加到开机启动项中，并使其在<a href="https://so.csdn.net/so/search?q=%E7%B3%BB%E7%BB%9F%E5%90%AF%E5%8A%A8&amp;spm=1001.2101.3001.7020" target="_blank">系统启动</a>后自动执行。</p><p style="text-align: start;">首先，进入 <code>/etc/init.d</code> 目录中：</p><pre style="text-align: start;"><code class="language-bash">cd /etc/init.d/</code></pre><p style="text-align: start;">然后，我们使用 <code>ls</code> 命令，会发现里面有一些文件。这些文件就是在开机启动时自动运行的程序。我们现在来开始添加一个自定义的开机启动项 mytest ：</p><pre style="text-align: start;"><code class="language-bash">vim mytest</code></pre><p style="text-align: start;">设想我们需要创建一个名为 mytest 的开机启动项，并要求其在开机时在 <strong>/root/mytest.txt</strong> 文件中写入一句话：“Hello Linux World !”，根据上面的模板，我们需要修改成这个样子：</p><pre style="text-align: start;"><code class="language-bash">#!/bin/sh 
### BEGIN INIT INFO# Provides: MyTest
# Required-Start: $network $remote_fs $local_fs
# Required-Stop: $network $remote_fs $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: MyTest
# Description: MyTest Test Program
## END INIT INFO

 echo "Hello Linux World !" &gt;&gt; /root/mytest.txt 

 exit 0</code></pre><p style="text-align: start;">之后将文件保存，关闭编辑器。</p><p style="text-align: start;">接下来，我们将刚才编辑好的 <code>MyTest</code> 文件加上可执行的属性（<strong>如果不加属性，启动脚本将无法运行</strong>）：</p><pre style="text-align: start;"><code class="language-bash">chmod +x mytest</code></pre><p style="text-align: start;">然后，将这个启动脚本加入开机启动项中：</p><pre style="text-align: start;"><code class="language-bash">update-rc.d mytest defaults</code></pre><p style="text-align: start;">然后重新启动系统，或者命令行执行 <code>/etc/init.d/mytest</code> ，执行启动脚本，然后使用 <code>cat /root/mytest.txt</code>，验证文件是否正确创建。</p><p style="text-align: start;">那么，还有一个问题：那就是如何删除我们刚才创建的开机启动项呢？</p><p style="text-align: start;">答案很简单，只需要一条命令：</p><pre style="text-align: start;"><code class="language-bash">update-rc.d -f MyTest remove</code></pre><p><br></p>]]></description>
    <pubDate>Fri, 22 Dec 2023 13:02:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-12.html</guid>
</item>
<item>
    <title>file2ban安装以及使用说明</title>
    <link>https://host-vps.de/post-11.html</link>
    <description><![CDATA[<p># 检查fail2ban的启动问题</p><pre><code >fail2ban-client -x start</code></pre><p># 查看fail2ban状态</p><pre><code >fail2ban-client status</code></pre><p># 查看被 ban IP，其中 ssh-iptables 为名称，比如上面的 [ssh-iptables] 和 [nginx-dir-scan]</p><pre><code >fail2ban-client status ssh-iptables</code></pre><p># 添加白名单</p><pre><code >fail2ban-client set ssh-iptables addignoreip IP地址</code></pre><p># 删除白名单</p><pre><code >fail2ban-client set ssh-iptables delignoreip IP地址</code></pre><p># 查看日志</p><pre><code >tail /var/log/fail2ban.log</code></pre><p># 查看被禁止的 IP 地址</p><pre><code >iptables -L -n</code></pre><p><br></p>]]></description>
    <pubDate>Thu, 21 Dec 2023 13:01:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-11.html</guid>
</item>
<item>
    <title>测试</title>
    <link>https://host-vps.de/post-10.html</link>
    <description><![CDATA[<p>测试</p>]]></description>
    <pubDate>Thu, 21 Dec 2023 13:00:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-10.html</guid>
</item>
<item>
    <title>测试</title>
    <link>https://host-vps.de/post-9.html</link>
    <description><![CDATA[<p>测试</p>]]></description>
    <pubDate>Thu, 21 Dec 2023 13:00:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-9.html</guid>
</item>
<item>
    <title>Debian 12 解决 /etc/rc.local 开机启动问题</title>
    <link>https://host-vps.de/post-8.html</link>
    <description><![CDATA[<p><br></p><p style="text-align: start;">本文同样适用于 Debian 11 Bullseye, Debian 10 Buster 和 Debian 9 Strech。</p><p style="text-align: start;">由于某些软件并没有增加开启启动的服务，很多时候需要手工添加，一般我们都是推荐使用 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>systemd</code></span> 写个系统服务，但是对于一些简单的脚本或者懒人来说，添加命令到 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>/etc/rc.local</code></span> 文件更方便，但是自从 Debian 9 开始，Debian 默认不带 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>/etc/rc.local</code></span> 文件，而 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>rc.local</code></span> 服务却还是自带的：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-bash">root@debian ~ # cat /lib/systemd/system/rc-local.service
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
</code></pre><p style="text-align: start;">并且默认情况下这个服务还是关闭的状态：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-bash">root@debian ~ # systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
     Loaded: loaded (/lib/systemd/system/rc-local.service; static)
    Drop-In: /usr/lib/systemd/system/rc-local.service.d
             └─debian.conf
     Active: inactive (dead)
       Docs: man:systemd-rc-local-generator(8)
</code></pre><p style="text-align: start;">为了解决这个问题，我们需要手工添加一个 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>/etc/rc.local</code></span> 文件：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-bash">cat &lt;&lt;EOF &gt;/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
EOF
</code></pre><p style="text-align: start;">然后赋予权限：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-bash">chmod +x /etc/rc.local
</code></pre><p style="text-align: start;">接着启动 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>rc-local</code></span> 服务：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-bash">systemctl enable --now rc-local
</code></pre><p style="text-align: start;">此时可能会弹出警告：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-text">The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.
</code></pre><p style="text-align: start;">无视警告，因为这个服务没有任何依赖的系统服务，只是开机启动 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>/etc/rc.local</code></span> 脚本而已。</p><p style="text-align: start;">再次查看状态：</p><p style="text-align: start;"><br></p><pre><code class="language-hljs language-bash">root@debian ~ # systemctl status rc-local.service 
● rc-local.service - /etc/rc.local Compatibility
     Loaded: loaded (/lib/systemd/system/rc-local.service; enabled-runtime; vendor preset: enabled)
    Drop-In: /usr/lib/systemd/system/rc-local.service.d
             └─debian.conf
     Active: active (exited) since Thu 2022-01-27 18:52:43 UTC; 10s ago
       Docs: man:systemd-rc-local-generator(8)
    Process: 541 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
        CPU: 3ms

Jan 27 18:52:43 debian systemd[1]: Starting /etc/rc.local Compatibility...
Jan 27 18:52:43 debian systemd[1]: Started /etc/rc.local Compatibility.
</code></pre><p style="text-align: start;">然后你就可以把需要开机启动的命令添加到 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>/etc/rc.local</code></span> 文件，丢在 <span style="background-color: rgba(110, 118, 129, 0.4);"><code>exit 0</code></span> 前面即可，并尝试重启以后试试是否生效了。</p><p><br></p>]]></description>
    <pubDate>Thu, 21 Dec 2023 13:00:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-8.html</guid>
</item>
<item>
    <title>测试</title>
    <link>https://host-vps.de/post-7.html</link>
    <description><![CDATA[<p>测试</p>]]></description>
    <pubDate>Thu, 21 Dec 2023 12:59:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-7.html</guid>
</item>
<item>
    <title>测试</title>
    <link>https://host-vps.de/post-6.html</link>
    <description><![CDATA[<p>测试</p>]]></description>
    <pubDate>Thu, 21 Dec 2023 12:59:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-6.html</guid>
</item>
<item>
    <title>测试</title>
    <link>https://host-vps.de/post-5.html</link>
    <description><![CDATA[<p>123</p><pre><code >123</code></pre><p><br></p>]]></description>
    <pubDate>Thu, 21 Dec 2023 12:53:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-5.html</guid>
</item>
<item>
    <title>测试</title>
    <link>https://host-vps.de/post-2.html</link>
    <description><![CDATA[<p>测试</p>]]></description>
    <pubDate>Thu, 21 Dec 2023 11:25:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-2.html</guid>
</item>
<item>
    <title>docker常用命令以及docker-compose.yaml文件格式</title>
    <link>https://host-vps.de/post-4.html</link>
    <description><![CDATA[<p><br></p><pre><code >docker info       #可以查看安装的docker 比较详细的信息 相比docker version
docker search mysql      #搜素镜像
docker pull mysql:5.7     #使用docker pull 去拉取一个镜像 :后面指定拉取的版本。
docker images       # 使用docker images 查看本地所有的镜像
docker inspect 2c9028880e58       # 后面的2c9028880e58 是镜像的id 可以通过docker images查看镜像id
docker rmi docker.io/hello-world:latest        #通过名字加版本tag删除镜像
docker rmi d1165f221234       # 通过镜像id删除镜像
docker ps -a     #查看运行过的所有容器
docker rm 容器的id/名字       #删除指定的容器
docker start 容器的id/名字   #运行指定的容器
docker stop 容器的id/名字    #停止指定的容器
docker rm 容器的id/名字     #删除指定的容器
docker rm -f $(docker ps -aq)     #强制删除所有容器
docker exec -it 容器id /bin/bash        #进入容器，并打开一个容器里面的终端（命令窗口），我们可以在这个命令窗口执行命令
docker cp index.jsp 55d9d2bda967:/usr/local/tomcat/webapps     #将宿主机里面的文件复制到容器中</code></pre><pre><code class="language-xml">docker run -it -d \
    -e SECRET_KEY='dnsadmin1syn' \
    -v pda-data:/data \
    -p 9191:80 \
    --restart=always \
    ngoduykhanh/powerdns-admin:latest
    ###linux命令行创建docker镜像示例</code></pre><pre><code class="language-xml">version: '3'
services:
  mysql:
    image: mysql:8.0
    container_name: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 111111
      #MYSQL_ALLOW_EMPTY_PASSWORD: yes
      MYSQL_DATABASE: powerdns
      MYSQL_USER: powerdns
      MYSQL_PASSWORD: powerdns
    volumes:
    - ./db:/var/lib/mysql
    - ./etc/my.cnf:/etc/my.cnf
    - /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime
    ports:
    - 3306:3306
    command:
      #为了能远程登录root，所以修改了验证模块，生产中建不开启
      # - --default-authentication-plugin=mysql_native_password
      #yaml文件格式</code></pre><p><br></p>]]></description>
    <pubDate>Thu, 21 Dec 2023 11:09:00 +0800</pubDate>
    <dc:creator>lei</dc:creator>
    <guid>https://host-vps.de/post-4.html</guid>
</item></channel>
</rss>