<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>晓春花店</title>
    <link>https://xiaochuncloud.com</link>
    <description>初春夜晚盛开的蔷薇花</description>
    <atom:link href="https://xiaochuncloud.com/feed/" rel="self" type="application/rss+xml"/>
    <item>
      <title>linux deploy 使用过程</title>
      <link>https://xiaochuncloud.com/article/79</link>
      <guid>https://xiaochuncloud.com/article/79</guid>
      <pubDate>Wed, 07 May 2025 10:08:00 +0800</pubDate>
      <description><![CDATA[<h1 id="魅族手机配置linux">魅族手机配置linux</h1>
<h3 id="1更换源的操作">1、更换源的操作&#xff1a;</h3>
<pre><code class="language-sh">vim /etc/apt/sources.list

#deb http://ftp.debian.org/debian/ stable main contrib non-free
#deb-src http://ftp.debian.org/debian/ stable main contrib non-free
deb https://mirrors.163.com/debian/ stable main contrib non-free
deb-src https://mirrors.163.com/debian/ stable main contrib non-free
</code></pre>
<p>stable 是debian的一个版本&#xff0c;一般debian 10 是buster</p>
<h3 id="2安装数据库">2、安装数据库</h3>
<h5 id="21安装mariadb">2.1、安装mariadb</h5>
<p>除了ubuntu&#xff0c;debian等发行版移除了mysql&#xff0c;只能安装mariadb</p>
<pre><code class="language-sh">apt-get install mariadb-server
</code></pre>
<h5 id="22对mariadb进行初始化">2.2、对mariadb进行初始化</h5>
<pre><code class="language-sh">mysql_secure_installation
# 根据提示进行设置&#xff0c;包括设置密码等操作
</code></pre>
<h5 id="23mysql配置外网访问">2.3、mysql配置外网访问</h5>
<h6 id="231解除安卓系统网络限制">2.3.1、解除安卓系统网络限制</h6>
<p>在安卓手机安装的debian中&#xff0c;需要执行下面这行代码才能让mysql能够被外网访问</p>
<pre><code class="language-sh">usermod -aG aid_inet mysql
</code></pre>
<h6 id="232注释绑定的本地ip">2.3.2、注释绑定的本地IP</h6>
<p>在mysql配置文件/etc/mysql/mariadb.conf.d/50-server.cnf 中&#xff0c;默认绑定本地IP地址导致外网无法访问mysql&#xff0c;需注释该配置</p>
<pre><code class="language-sh"># bind-address &#61; 127.0.0.1
</code></pre>
<h6 id="233设置数据库访问权限">2.3.3、设置数据库访问权限</h6>
<pre><code class="language-sql">grant all privileges on databaseName.tableName to &#39;username&#39;&#64;&#39;localhost&#39; identified by &#39;password&#39; with grant option;
flush privileges;
-- 其中databaseName和tableName分别表示库名和表名&#xff0c;可用*表示任意库或任意表
-- username表示用户名&#xff0c;localhost指本地地址&#xff0c;可使用%表示任意地址&#xff0c;也可指定特定的IP地址
-- password 表示密码&#xff0c;flush privileges刷新对权限的修改&#xff0c;使改动立即生效
</code></pre>
<h6 id="234安装时的一些坑">2.3.4、安装时的一些坑</h6>
<pre><code class="language-sh"># 安装源
dpkg -i mysql-apt-config_0.8.15-1_all.deb 
# 卸载源
dpkg -P mysql-apt-config
</code></pre>
<h3 id="3安装gogs">3、安装gogs</h3>
<h5 id="31安装gogs之前需先安装git">3.1、安装gogs之前需先安装git</h5>
<pre><code class="language-sh">apt install git
</code></pre>
<h5 id="32下载gogs">3.2、下载gogs</h5>
<p>在<a href="https://gogs.io/docs/installation/install_from_binary.html页面选择合适的版本下载。" rel="nofollow">https://gogs.io/docs/installation/install_from_binary.html页面选择合适的版本下载。</a></p>
<p>当前在arm架构中最新的只支持armv6&#xff0c;下载后解压。</p>
<h5 id="33修改配置">3.3、修改配置</h5>
<p>gogs脚本默认以git用户启动&#xff0c;如果当前用户不是git需修改成当前用户。</p>
<pre><code class="language-sh">vim gogs/scripts/init/debian/gogs

# 将USER对应的值改为root

USER&#61;root
</code></pre>
<h5 id="34执行安装">3.4、执行安装</h5>
<pre><code class="language-sh">./gogs web
</code></pre>
<p>浏览器访问<a href="http://设备IP:3000&#xff0c;配置数据库等信息、管理员用户可不创建&#xff0c;之后注册的第一个用户&#xff08;ID&#61;1&#xff09;自动成为管理员" rel="nofollow">http://设备IP:3000&#xff0c;配置数据库等信息、管理员用户可不创建&#xff0c;之后注册的第一个用户&#xff08;ID&#61;1&#xff09;自动成为管理员</a></p>
<h5 id="35后续启动使用">3.5、后续启动使用</h5>
<pre><code class="language-sh">vim gogs/custom/conf/app.ini
#  将RUN_USER的值改为root
RUN_USER &#61; root
#  然后使用启动命令
./gogs web
</code></pre>
<h3 id="4安装kodexplorer">4、安装kodexplorer</h3>
<h5 id="41安装nginx">4.1、安装nginx</h5>
<pre><code class="language-sh">apt install nginx 
vim /etc/nginx/sites-enabled/default
#修改默认网站根目录
root /root/nginx/html;
#启用php
location ~ \.php$ {
	include snippets/fastcgi-php.conf;
	fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
# 重启nginx
service nginx restart
</code></pre>
<h5 id="42安装php">4.2、安装php</h5>
<pre><code class="language-sh">apt install php7.3-fpm php7.3-curl php7.3 php7.3-mbstring php7.3-gd php7.3-xml php7.3-common php7.3-cli
vim /etc/php/7.3/fpm/pool.d/www.conf
# 修改运行用户
;user &#61; www-data
;group &#61; www-data
user&#61;root
group&#61;root
启动php-fpm
# php7.3-fpm -R
</code></pre>
<h5 id="43部署kodexplorer">4.3、部署kodexplorer</h5>
<p>下载kodexplorer&#xff0c;将zip包解压到nginx根目录。</p>
<h3 id="5配置usb自动挂载">5、配置USB自动挂载</h3>
<p>手机无法启动udev服务&#xff0c;额&#xff0c;暂时没法使用</p>
<p><del>使用udisk2实现</del></p>
<p>自己写代码监听内核日志&#xff0c;发现usb插入、拔出日志&#xff0c;触发。</p>
<p>其他知识点&#xff1a;</p>
<p><a href="https://zixijian.github.io/2020/09/01/007.html" rel="nofollow">https://zixijian.github.io/2020/09/01/007.html</a></p>
<p><a href="https://zixijian.github.io/2021/01/15/008.html" rel="nofollow">https://zixijian.github.io/2021/01/15/008.html</a></p>
<pre><code>保持 cpu 唤醒不起作用
表现为操作卡顿、联网卡顿&#xff0c;
使用 wakelock 锁&#xff0c;shell 中输入&#xff1a;
获取 su 权限
su

保持 cpu 唤醒&#xff1a;
echo lock_me &gt; /sys/power/wake_lock

解除 wakelock 锁&#xff1a;
echo lock_me &gt; /sys/power/wake_unlock

注&#xff1a;容器内使用时命令前面加 unchroot&#xff0c;
对 /sys 分区操作时不需要&#xff08;容器挂载了 /sys 分区&#xff09;。
Wi-Fi 进入节能模式
表现为不能全速传输&#xff0c;延时高。
查询节能状态
unchroot iw dev wlan0 get power_save
关闭节能模式
unchroot iw wlan0 set power_save off 
</code></pre>
<h3 id="6解锁bl">6、解锁bl</h3>
<p>不需要官方工具&#xff0c;进入fastboot模式&#xff08;电源键&#43;音量减&#xff09;。解锁会清空数据&#xff01;&#xff01;&#xff01;</p>
<p>注意是fastboot&#xff0c;不是adb&#xff0c;需要使用扩展坞&#xff0c;电脑usb口电压不够&#xff0c;无法成功识别adb&#xff0c;或者识别后无法执行命令。</p>
<pre><code>fastboot oem unlock 111111111111111
...
(bootloader) Begin to do oem unlock ...
OKAY [  0.042s]
finished. total time: 0.044s
</code></pre>
<p>出现上面的内容&#xff0c;此时手机上出现确认界面。</p>
<h2 id="充电策略控制">充电策略控制</h2>
<p>将手机用作服务器后&#xff0c;
无用的安卓服务占据大量内存&#xff0c;
可停止安卓服务并使用 crontab 定时任务控制充电。</p>
<pre><code class="language-sh">停止安卓服务&#xff1a;
unchroot /system/bin/stop
恢复安卓服务
unchroot /system/bin/start

创建 crontab 定时任务&#xff1a;
crontab -e
*/5 * * * * /usr/chargec.sh

创建脚本文件&#xff1a;
touch /usr/chargec.sh
chmod a&#43;x /usr/chargec.sh

编辑充电控制脚本&#xff1a;
#!/bin/sh
# Android chroot charge limit controller
# author: zixijian
# website: zixijian.github.io
# co-author: Ethereal
# useage: crontab -e
#         */5 * * * * /usr/chargec.sh

# define
charge&#61;&#96;cat /sys/class/power_supply/battery/status&#96;
capacity&#61;&#96;cat /sys/class/power_supply/battery/capacity&#96;

echo Now battery is: $charge.
echo Now battery level is: $capacity.

# set max charge current 
# parameter: 800mA&#61;800000
chmod 644 /sys/class/power_supply/battery/constant_charge_current_max
echo 800000 &gt; /sys/class/power_supply/battery/constant_charge_current_max

# check max limit
if [ $capacity -ge 85 ]; then
# stop
  echo 1 &gt; /sys/class/power_supply/battery/input_suspend 
fi

# check min limit
if [ $capacity -le 35 ]; then
# start
  echo 0 &gt; /sys/class/power_supply/battery/input_suspend 
fi
红米note4x mido 充电控制文件为&#xff1a;
/sys/class/power_supply/battery/charging_enabled
禁止充电值为 0&#xff0c;开启充电值为 1。

# check max limit
if [ $capacity -ge 85 ]; then
# stop
  echo 0 &gt; /sys/class/power_supply/battery/charging_enabled
fi

# check min limit
if [ $capacity -le 35 ]; then
# start
  echo 1 &gt; /sys/class/power_supply/battery/charging_enabled
fi
</code></pre>
<h2 id="常见问题">常见问题</h2>
<ul><li>CLI 启动失败&#xff0c;无法操作内存卡&#xff08;内部存储&#xff09;
从外部修改 sshd 配置&#xff1a;
<code>UsePAM no</code>
修改 /root/.profile 最后一行为&#xff1a;
<code>tty -s &amp;&amp; mesg n || true</code>
将用户加入 <code>aid_everybody</code> 分组&#xff1a;
<code>usermod -aG aid_everybody username</code></li><li>SSH 服务启动失败
常见网络问题&#xff0c;
可尝试更换网络环境重新安装系统&#xff0c;
使用 rootfs 包安装系统。
使用 CLI 调试。</li><li>容器挂载失败
检查 SElinux 状态&#xff0c;
更换 busybox 版本&#xff0c;
更换安装方式为目录安装。</li><li>MYSQL、ping 等不能使用
将用户加入 <code>aid_inet</code> 用户组&#xff1a;
<code>usermod -aG aid_inet mysql</code>
<code>usermod -aG aid_inet root</code></li><li>按 TAB 不能自动补全路径
修改默认 shell&#xff1a;
<code>chsh</code> 输入 <code>/bin/bash</code>。</li></ul>
<p><a href="https://www.t00ls.com/articles-68635.html" rel="nofollow">https://www.t00ls.com/articles-68635.html</a></p>
]]></description>
    </item>
    <item>
      <title>node 内存溢出问题解决</title>
      <link>https://xiaochuncloud.com/article/68</link>
      <guid>https://xiaochuncloud.com/article/68</guid>
      <pubDate>Thu, 27 Mar 2025 07:07:00 +0800</pubDate>
      <description><![CDATA[<h3 id="问题报错">问题报错</h3>
<h5 id="linux-在开发rn项目时遇到几个报错记录下">linux 在开发RN项目时遇到几个报错&#xff0c;记录下</h5>
<ol><li>内存溢出</li></ol>
<pre><code class="language-shell">&lt;--- Last few GCs ---&gt;

[130124:0000021FC62BC9D0]     1795 ms: Scavenge 1762.7 (1796.8) -&gt; 1762.6 (1796.8) MB, 34.4 / 0.0 ms 
 (average mu &#61; 1.000, current mu &#61; 1.000) allocation failure
[130124:0000021FC62BC9D0]     2409 ms: Mark-sweep 1922.7 (1956.8) -&gt; 1922.0 (1956.1) MB, 487.4 / 0.0 ms
  (&#43; 38.4 ms in 10 steps since start of marking, biggest step 5.0 ms, walltime since start of marking 2053 ms)
 (average mu &#61; 1.000, current mu &#61; 1.000)

&lt;--- JS stacktrace ---&gt;
</code></pre>
<ol><li>超过文件监听数量</li></ol>
<pre><code class="language-shell">ENOSPC: System limit for number of file watchers reached
</code></pre>
<h3 id="问题解决">问题解决</h3>
<ol><li>内存溢出</li></ol>
<pre><code class="language-shell">npm install -g increase-memory-limit  # 全局安装 
&#34;fix-memory-limit&#34;: &#34;cross-env LIMIT&#61;40960 increase-memory-limit&#34; # package.json 加入 然后执行
</code></pre>
<p>或者</p>
<pre><code class="language-shell">vim ~/.bashrc
# 增加以下环境变量
export NODE_OPTIONS&#61;&#34;--max-old-space-size&#61;8192&#34;
</code></pre>
<ol><li>超过文件监听数量</li></ol>
<pre><code class="language-shell">sysctl fs.inotify.max_user_watches&#61;524288
sysctl -p
</code></pre>
]]></description>
    </item>
    <item>
      <title>ubuntu 安装虚拟安卓环境并开启adb tcp</title>
      <link>https://xiaochuncloud.com/article/67</link>
      <guid>https://xiaochuncloud.com/article/67</guid>
      <pubDate>Thu, 26 Dec 2024 11:48:00 +0800</pubDate>
      <description><![CDATA[<h2 id="拉取docker镜像">拉取docker镜像</h2>
<pre><code class="language-shell">docker pull redroid/redroid:12.0.0_64only-latest
</code></pre>
<h2 id="开启虚拟化">开启虚拟化</h2>
<pre><code class="language-shell">apt install linux-modules-extra-&#96;uname -r&#96;
modprobe binder_linux devices&#61;&#34;binder,hwbinder,vndbinder&#34;
modprobe ashmem_linux
</code></pre>
<h2 id="启动容器">启动容器</h2>
<pre><code class="language-shell">docker run  --name&#61;my_phone   -itd --privileged \
-v ~/android/data:/data \
-p 5555:5555 redroid/redroid:12.0.0_64only-latest \
androidboot.redroid_width&#61;1080     \
androidboot.redroid_height&#61;2160   \
androidboot.redroid_dpi&#61;480
</code></pre>
<h2></h2>
<pre><code class="language-shell"># 连接adb 需android tool
adb connect ip:5555
# 显示连接的设备
adb devices
</code></pre>
]]></description>
    </item>
    <item>
      <title>docker 安装 Photopea 工具</title>
      <link>https://xiaochuncloud.com/article/66</link>
      <guid>https://xiaochuncloud.com/article/66</guid>
      <pubDate>Tue, 05 Nov 2024 11:25:00 +0800</pubDate>
      <description><![CDATA[<pre><code class="language-shell"># 1、 拉去镜像
docker pull registry.cn-guangzhou.aliyuncs.com/os_cmty/os_cmty:Photopea
# 2、常规启动
docker run -d --name Photopea -p 2000:2887 registry.cn-guangzhou.aliyuncs.com/os_cmty/os_cmty:Photopea
# 3、自定义参数启动
docker run --hostname&#61;9335fb9c6cfa \
--env&#61;PATH&#61;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
--volume&#61;/Users/madi/desktop/sdk/photopea/fonts:/run/photopea/www.photopea.com/rsrc/fonts \
--workdir&#61;/var/run/photopea -p 8988:2887 \
--restart&#61;no \
--runtime&#61;runc \
-d registry.cn-guangzhou.aliyuncs.com/os_cmty/os_cmty:Photopea
 
</code></pre>
]]></description>
    </item>
    <item>
      <title>解决The engine &quot;node&quot; is incompatible with this module. Expected version &quot;&gt;=18.0.0&quot;. Got &quot;16.18.1&quot;</title>
      <link>https://xiaochuncloud.com/article/65</link>
      <guid>https://xiaochuncloud.com/article/65</guid>
      <pubDate>Wed, 17 Apr 2024 02:53:00 +0800</pubDate>
      <description><![CDATA[<h2 id="the-engine-node-is-incompatible-with-this-module-expected-version-1800-got-16181">The engine &#34;node&#34; is incompatible with this module. Expected version &#34;&gt;&#61;18.0.0&#34;. Got &#34;16.18.1&#34;</h2>
<p>1,配置yarn</p>
<pre><code>yarn config set ignore-engines true
</code></pre>
<p>2&#xff0c;重试安装应该就好了</p>
]]></description>
    </item>
    <item>
      <title>yum本地源搭建</title>
      <link>https://xiaochuncloud.com/article/64</link>
      <guid>https://xiaochuncloud.com/article/64</guid>
      <pubDate>Wed, 10 Apr 2024 01:09:00 +0800</pubDate>
      <description><![CDATA[<h2 id="yum本地源搭建记录">yum本地源搭建记录</h2>
<p>参考&#xff1a;<a href="https://www.vos.cn/os/387.html" rel="nofollow">https://www.vos.cn/os/387.html</a></p>
<p><a href="https://www.wanpeng.life/1903.html" rel="nofollow">https://www.wanpeng.life/1903.html</a></p>
<h3 id="1安装工具">1、安装工具</h3>
<pre><code class="language-sh">yum install screen wget -y
yum install yum-utils createrepo -y
</code></pre>
<h3 id="2开始下载">2、开始下载</h3>
<p>安装源</p>
<pre><code class="language-sh">yum install epel-release -y
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
</code></pre>
<p>查看源列表</p>
<pre><code>yum repolist
</code></pre>
<p><img src="http://101.43.125.205:9099/65154940919739f3eaef43389b7759ac27fa3eb5" alt="image-20230928173702037" /></p>
<p>创建目录&#xff08;其实这步可以省&#xff0c;文件夹会自动创建&#xff09;</p>
<pre><code class="language-sh">mkdir -p /home/html/{base,centosplus,extras,updates}
</code></pre>
<p>下载</p>
<p>下载所有&#xff0c;不指定--repoid</p>
<pre><code class="language-sh">reposync -g -l -d -m --newest-only --download-metadata --download_path&#61;/home/html/
</code></pre>
<p>下载指定仓库&#xff1a;</p>
<pre><code class="language-sh">reposync -g -l -d -m --repoid&#61;base --newest-only --download-metadata --download_path&#61;/home/html/
reposync -g -l -d -m --repoid&#61;centosplus --newest-only --download-metadata --download_path&#61;/home/html/
reposync -g -l -d -m --repoid&#61;extras --newest-only --download-metadata --download_path&#61;/home/html/
reposync -g -l -d -m --repoid&#61;updates --newest-only --download-metadata --download_path&#61;/home/html/
reposync -g -l -d -m --repoid&#61;epel --newest-only --download-metadata --download_path&#61;/home/html/
reposync -g -l -d -m --repoid&#61;docker-ce-stable --newest-only --download-metadata --download_path&#61;/home/html/
</code></pre>
<p>-g 删除公钥校验不通过的包</p>
<p>-d 删除本地有但是远程源没有的包</p>
<p>这两个会导致很多有用的包被删除&#xff0c;比如p7zip、nethogs</p>
<h3 id="3创建仓库">3、创建仓库</h3>
<pre><code class="language-sh">cd /home/html
ls|xargs -n1 echo createrepo 
# 然后拷贝打印的命令进行执行
# base  docker-ce-stable  epel  extras  updates
#然后压缩
cd ..
tar cJvf html.tar.xz html/
# 或者轻度压缩
tar czvf html.tar.gz html/
# 或者不压缩
tar cvf html.tar html/
</code></pre>
<p>已上传到123云盘</p>
<pre><code>https://www.123pan.com/s/xMzAjv-k47dv.html提取码:ChVh
</code></pre>
<h3 id="4文件服务器">4、文件服务器</h3>
<p>启动文件服务器</p>
<p>python2&#xff08;大部分系统自带&#xff09;</p>
<pre><code>cd /home/html
python -m SimpleHTTPServer 80
</code></pre>
<p>python3</p>
<pre><code>cd /home/html
python3 -m http.server 80
</code></pre>
<h3 id="5客户端配置">5、客户端配置</h3>
<p>包含&#xff1a;base  docker-ce-stable  epel  extras  updates</p>
<pre><code class="language-ini">[base]
name&#61;base
baseurl&#61;http://192.168.31.197/base
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
[docker-ce-stable]
name&#61;docker-ce-stable
baseurl&#61;http://192.168.31.197/docker-ce-stable
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
[epel]
name&#61;epel
baseurl&#61;http://192.168.31.197/epel
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
[extras]
name&#61;extras
baseurl&#61;http://192.168.31.197/extras
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
[updates]
name&#61;updates
baseurl&#61;http://192.168.31.197/updates
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
</code></pre>
<p>可以用pyhton脚本生成</p>
<pre><code class="language-python">import os
def gen(name, addr):
    return &#39;&#39;&#39;[%s]
name&#61;%s
baseurl&#61;http://%s/%s
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_

&#39;&#39;&#39; % (name,name,addr,name)
if __name__ &#61;&#61; &#34;__main__&#34;:
    html &#61; &#34;/home/package_dir/html&#34;
    addr &#61; &#34;192.168.31.89&#34;
    content &#61; &#34;&#34;
    for d in os.listdir(html):
        if os.path.isdir(os.path.join(html, d)):
            content &#43;&#61; gen(d, addr)
    with open(&#34;/etc/yum.repos.d/local.repo&#34;, &#34;w&#34;) as f:
        f.write(content)
</code></pre>
<h3 id="6优化">6、优化</h3>
<h4 id="61裁剪体积">6.1、裁剪体积</h4>
<p>下载的源中的包&#xff0c;绝大部分是用不到的&#xff0c;可以删除一些&#xff0c;基本上rpm包大小在30M以上的&#xff0c;都可以删除&#xff08;少数除外&#xff09;&#xff0c;实际操作中&#xff0c;30M以上的&#xff0c;只保留了这几个&#xff1a;</p>
<pre><code class="language-json">[
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/g/golang-bin-1.19.10-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;golang-bin-1.19.10-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 112246734
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/c/chromium-116.0.5845.96-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;chromium-116.0.5845.96-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 78721720
    },
    {
        &#34;path&#34;: &#34;/home/html/mysql56-community/mysql-community-server-5.6.51-2.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;mysql-community-server-5.6.51-2.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 69836204
    },
    {
        &#34;path&#34;: &#34;/home/html/mysql56-community/mysql-community-embedded-devel-5.6.51-2.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;mysql-community-embedded-devel-5.6.51-2.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 69255060
    },
    {
        &#34;path&#34;: &#34;/home/html/mysql56-community/mysql-community-embedded-devel-5.6.51-2.el7.i686.rpm&#34;,
        &#34;name&#34;: &#34;mysql-community-embedded-devel-5.6.51-2.el7.i686.rpm&#34;,
        &#34;size&#34;: 65964768
    },
    {
        &#34;path&#34;: &#34;/home/html/mysql56-community/mysql-community-test-5.6.51-2.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;mysql-community-test-5.6.51-2.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 60873572
    },
    {
        &#34;path&#34;: &#34;/home/html/updates/Packages/kernel-3.10.0-1160.99.1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;kernel-3.10.0-1160.99.1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 54174680
    },
    {
        &#34;path&#34;: &#34;/home/html/base/Packages/kernel-3.10.0-1160.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;kernel-3.10.0-1160.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 52709940
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/c/chromium-headless-116.0.5845.96-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;chromium-headless-116.0.5845.96-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 49613116
    },
    {
        &#34;path&#34;: &#34;/home/html/mysql-tools-community/mysql-shell-8.0.34-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;mysql-shell-8.0.34-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 40307744
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/r/rust-doc-1.72.1-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;rust-doc-1.72.1-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 40136368
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/a/apptainer-1.2.3-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;apptainer-1.2.3-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 39570249
    },
    {
        &#34;path&#34;: &#34;/home/html/docker-ce-stable/Packages/containerd.io-1.6.24-3.1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;containerd.io-1.6.24-3.1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 35551084
    },
    {
        &#34;path&#34;: &#34;/home/html/updates/Packages/java-1.8.0-openjdk-headless-1.8.0.382.b05-1.el7_9.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;java-1.8.0-openjdk-headless-1.8.0.382.b05-1.el7_9.x86_64.rpm&#34;,
        &#34;size&#34;: 34752068
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/r/rust-std-static-1.72.1-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;rust-std-static-1.72.1-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 34294892
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/p/python36-cryptography-vectors-2.3-1.el7.noarch.rpm&#34;,
        &#34;name&#34;: &#34;python36-cryptography-vectors-2.3-1.el7.noarch.rpm&#34;,
        &#34;size&#34;: 32090756
    },
    {
        &#34;path&#34;: &#34;/home/html/epel/Packages/r/rust-1.72.1-1.el7.x86_64.rpm&#34;,
        &#34;name&#34;: &#34;rust-1.72.1-1.el7.x86_64.rpm&#34;,
        &#34;size&#34;: 31779556
    }
]
</code></pre>
<p>其实这里面有几个也不需要保留</p>
<h4 id="62新增mysql">6.2、新增mysql</h4>
<p>之前下载的时候没有添加mysql源&#xff0c;后面补上</p>
<pre><code class="language-sh">wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-release-el7-5.noarch.rpm
# 重新下载&#xff08;增量下载&#xff09;
reposync -l -m --newest-only --download-metadata --download_path&#61;/home/html/
# 重新创建库
cd /home/html
ls|xargs -n1 createrepo
</code></pre>
<h3 id="7定制特定软件的源">7、定制特定软件的源</h3>
<pre><code>yum install screen wget -y
yum install yum-utils createrepo -y
</code></pre>
<pre><code>mkdir source
cd source
</code></pre>
<pre><code class="language-sh">yumdownloader --resolve --alldeps --destdir&#61;./ docker-ce docker-ce-cli
yumdownloader --resolve --alldeps  --destdir&#61;./ rpcbind 
yumdownloader --resolve --alldeps  --destdir&#61;./ nfs-utils 
yumdownloader --resolve --alldeps  --destdir&#61;./ ipvsadm 
yumdownloader --resolve --alldeps  --destdir&#61;./ ipset 
yumdownloader --resolve --alldeps  --destdir&#61;./ sysstat 
yumdownloader --resolve --alldeps  --destdir&#61;./ conntrack-tools
yumdownloader --resolve --alldeps  --destdir&#61;./ libseccomp 
</code></pre>
<p>不要一起下载&#xff0c;一起下载时没有对应的源没法下载的包会被忽略。实测&#xff0c;在kylin v10上有 --alldeps选项&#xff08;下载所有依赖&#xff0c;即使已安装&#xff09;&#xff0c;centos7上没有&#xff0c;所以centos7使用yumdownloader可能会漏包</p>
<p>使用<strong>repotrack</strong> 参考&#xff1a;<a href="https://zhuanlan.zhihu.com/p/662529601" rel="nofollow">https://zhuanlan.zhihu.com/p/662529601</a></p>
<pre><code>  113  repotrack -p ./  docker-ce docker-ce-cli
  118  repotrack -p ./  rpcbind
  119  repotrack -p ./  nfs-utils 
  120  repotrack -p ./  ipvsadm
  121  repotrack -p ./ ipset
  122  repotrack -p ./ sysstat
  123  repotrack -p ./ conntrack
  124  repotrack -p ./ libseccomp
  126  repotrack -p ./ conntrack-tools
</code></pre>
<p>创建索引</p>
<pre><code class="language-sh">createrepo ./
tar czvf ../centos7-rpms-amd64.tar.gz ./*
</code></pre>
]]></description>
    </item>
    <item>
      <title>误操作 将/usr/lib 恢复</title>
      <link>https://xiaochuncloud.com/article/63</link>
      <guid>https://xiaochuncloud.com/article/63</guid>
      <pubDate>Mon, 11 Mar 2024 03:31:00 +0800</pubDate>
      <description><![CDATA[<p>1&#xff0c;由于误操作 cp 执行成了 mv 将/usr/lib 移动导致所有终端命令无法使用</p>
<pre><code class="language-shell"># 首先找到移动后的lib目录
x86_64-linux-gnu
# 然后
./ld-linux-x86-64.so.2 --library-path /libswp/lib/x86_64-linux-gnu/ /usr/bin/mv /usr/lib_bak /usr/lib
</code></pre>
<p>应该就解决了&#xff0c;要是找不到 x86_64-linux-gnu 目录可以在另外一台相同的服务器搜索一下</p>
]]></description>
    </item>
    <item>
      <title>docker 设置独立centos 容器（独立IP）</title>
      <link>https://xiaochuncloud.com/article/62</link>
      <guid>https://xiaochuncloud.com/article/62</guid>
      <pubDate>Thu, 07 Mar 2024 13:59:00 +0800</pubDate>
      <description><![CDATA[<p>###创建自定义docker 网络</p>
<pre><code class="language-shell">docker network create -d macvlan --subnet&#61;192.168.1.0/16 --gateway&#61;192.168.1.1 -o parent&#61;eth0 mynet
</code></pre>
<ol><li>macvlan 模式 subnet(网段)&#xff0c;gateway(网关) parent(指定物理网卡)</li><li>macvlan 模式会独占物理网卡&#xff0c;一个物理网卡只能开启个macvlan 模式</li></ol>
<p>###创建centos 容器</p>
<pre><code class="language-shell">docker run -itd --name centos7 \
--net mynet \
--ip 192.168.1.13 \
--mac-address 11:11:11:11:12 \
--privileged&#61;true centos:7 /usr/sbin/init
</code></pre>
<ol><li>centos7 存在bug&#xff0c;所以需要-privileged&#61;true 特殊授权和 /usr/sbin/init</li><li>容器资源是共享宿主机资源</li></ol>
<h3 id="迁移-docker">迁移 docker</h3>
<pre><code class="language-shell">systemctl stop docker 

cp -avx  /var/lib/docker /home/username/docker

vim /usr/lib/systemd/system/docker.service

# 在合适位置加上这个
ExecStart&#61;/usr/bin/dockerd --graph&#61;/home/username/docker

# 重新加载配置
systemctl daemon-reload
# 重启 Docker 引擎
systemctl restart docker

docker info  查看 root dir 是否已经更新

</code></pre>
]]></description>
    </item>
    <item>
      <title>ubuntu22 安装 xrdp</title>
      <link>https://xiaochuncloud.com/article/61</link>
      <guid>https://xiaochuncloud.com/article/61</guid>
      <pubDate>Sun, 18 Feb 2024 05:55:00 +0800</pubDate>
      <description><![CDATA[<ol><li>安装xrdp服务</li></ol>
<pre><code class="language-shell">sudo apt install -y  xrdp 
</code></pre>
<p>2.把xrdp用户添加证书用户组</p>
<pre><code class="language-shell">adduser xrdp ssl-cert
</code></pre>
<p>3.修改/etc/xrdp/startwm.sh 追加配置&#xff08;解决ubuntu22 连接闪退问题&#xff09;</p>
<pre><code>unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
</code></pre>
<p>4.增加 GNOME-ubuntu 配置&#xff0c;获取原生体验</p>
<pre><code class="language-shell"># 创建.xsessionrc 文件
vim ~/.xsessionrc
# 写入
export GNOME_SHELL_SESSION_MODE&#61;ubuntu
export XDG_CURRENT_DESKTOP&#61;ubuntu:GNOME
export XDG_CONFIG_DIRS&#61;/etc/xdg/xdg-ubuntu:/etc/xdg
</code></pre>
<p>5.远程桌面连接时&#xff0c;主机需要注销要登陆的用户&#xff0c;否则远程会黑屏&#xff0c;同理在主机需要登陆时&#xff0c;远程桌面需要注销登陆的用户</p>
<p>6.笔记本合盖休眠问题</p>
<p>6.1. 修改logind.cof 文件</p>
<pre><code class="language-shell"># 编辑操作动作
vim /etc/systemd/logind.conf
# 将原内容&#xff0c;修改为下面的
HandleLidSwitch&#61;lock
HandleLidSwitchExternalPower&#61;lock
HandleLidSwitchDocked&#61;ignore
</code></pre>
<p>6.2. WiFi休眠</p>
<pre><code class="language-shell">vim /etc/ppp/options

# 注释下面内容
lcp-echo-interval
lcp-echo-failure

iwconfig

iwconfig 网卡 power off
</code></pre>
<p>6.3 系统休眠</p>
<pre><code class="language-shell"># 查看 sleep.target 状态
systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target

# 禁用休眠
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

# 开启休眠
systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target
</code></pre>
]]></description>
    </item>
    <item>
      <title>docker 安装 mysql8</title>
      <link>https://xiaochuncloud.com/article/60</link>
      <guid>https://xiaochuncloud.com/article/60</guid>
      <pubDate>Sat, 17 Feb 2024 09:21:00 +0800</pubDate>
      <description><![CDATA[<pre><code class="language-shell">sudo docker run -p 8306:3306 --name mysql_8 \
--privileged&#61;true \
--restart&#61;always \
-v /data/data_mate/mysql/mysql-files:/var/lib/mysql-files \
-v /data/data_mate/mysql/conf:/etc/mysql \
-v /data/data_mate/mysql/logs:/var/log/mysql \
-v /data/data_mate/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD&#61;123456\!\! \
-d mysql:8.0.20

</code></pre>
]]></description>
    </item>
    <item>
      <title>docker  导入、导出、启动容器</title>
      <link>https://xiaochuncloud.com/article/59</link>
      <guid>https://xiaochuncloud.com/article/59</guid>
      <pubDate>Tue, 16 Jan 2024 12:06:00 +0800</pubDate>
      <description><![CDATA[<pre><code class="language-shell"># 导出 docker export -o 容器名.tar 容器名
docker export -o linux.tar linux

# 导入 docker import 容器名.tar 自定义镜像名:自定义版本
docker import linux.tar linux:v1

# 导出 docker save &gt; 镜像名.tar  镜像名
docker save &gt; ./redroid.tar.gz redroid/redroid:12.0.0_64only-latest

# 导入 docker load -i  镜像.tar
docker load -i redroid.tar.gz

# 启动容器
1. docker ps -a --no-trunc 查看 command 信息

2. docker run -it -v /xx/xx:/xx/xx -p 80:80 --name linuxnew linux:v1 command信息
</code></pre>
<p>注意&#xff1a;启动容器时要调出先前容器的 command 信息&#xff0c;不然会报错&#xff0c;command信息拼再后面即可&#xff0c;其他参数可与之前启动容器加的参数&#xff0c;酌情修改。</p>
<pre><code class="language-shell">docker run -d --name dzzoffice -v /opt/dzzoffice:/var/www/html/data -p 8282:80 imdevops/dzzoffice:latest

docker run -i -t -d -p 8383:80 --name onlyoffice --restart&#61;always onlyoffice/documentserver:7.1.1

</code></pre>
]]></description>
    </item>
    <item>
      <title>oracle安装及使用</title>
      <link>https://xiaochuncloud.com/article/58</link>
      <guid>https://xiaochuncloud.com/article/58</guid>
      <pubDate>Mon, 15 Jan 2024 04:40:00 +0800</pubDate>
      <description><![CDATA[<h1 id="oracle安装及使用">oracle安装及使用</h1>
<h2 id="1docker安装oracle">1、docker安装oracle</h2>
<pre><code class="language-shell">docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
</code></pre>
<pre><code class="language-shell">docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g
</code></pre>
<h2 id="2配置oracle环境变量">2、配置oracle环境变量</h2>
<pre><code class="language-shell">docker exec -it oracle11 bash
</code></pre>
<p>vi /etc/profile</p>
<pre><code class="language-shell"> export ORACLE_HOME&#61;/home/oracle/app/oracle/product/11.2.0/dbhome_2
 export ORACLE_SID&#61;helowin
 export PATH&#61;$ORACLE_HOME/bin:$PATH
</code></pre>
<pre><code class="language-shell">source /etc/profile
</code></pre>
<p>这里设置的ORACLE_SID将作为登录的服务名</p>
<p><img src="/media/editor/0071q2ergy1h6brgvrzboj30eg07qwfl_20240115124456694378.jpg" alt="" /></p>
<h2 id="3配置数据库">3、配置数据库</h2>
<pre><code class="language-sql">sqlplus /nolog   --登录
conn /as sysdba  --
alter user system identified by system;--修改system用户账号密码&#xff1b;
alter user sys identified by system;--修改sys用户账号密码&#xff1b;
create user test identified by test; -- 创建内部管理员账号密码&#xff1b;
grant connect,resource,dba to test; --将dba权限授权给内部管理员账号和密码&#xff1b;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED; --修改密码规则策略为密码永不过期&#xff1b;&#xff08;会出现坑&#xff0c;后面讲解&#xff09;
alter system set processes&#61;1000 scope&#61;spfile; --修改数据库最大连接数据&#xff1b;
</code></pre>
<h2 id="4重启">4、重启</h2>
<pre><code class="language-shell">conn /as sysdba
shutdown immediate; --关闭数据库
startup; --启动数据库
exit&#xff1a;退出
</code></pre>
<h2 id="5开启日志归档">5、开启日志归档</h2>
<pre><code>sqlplus /nolog   --登录
conn /as sysdba  --
</code></pre>
<pre><code>archive log list;
</code></pre>
<p><img src="/media/editor/0071q2ergy1h6brmoh7zdj30b402ymya_20240115124507382546.jpg" alt="" />
查看日志归档设置状态&#xff0c;发现未开启日志归档。</p>
<pre><code class="language-sql">alter system set db_recovery_file_dest_size &#61; 10G;
alter system set db_recovery_file_dest &#61; &#39;/opt/oracle/oradata/recovery_area&#39; scope&#61;spfile;
</code></pre>
<p>需要手动创建/opt/oracle/oradata/recovery_area目录&#xff0c;注意授权</p>
<pre><code class="language-shell">mkdir -p /opt/oracle/oradata/recovery_area
chown -R oracle:root /opt/oracle/
chmod -R 0777 /opt/oracle
</code></pre>
<p>重启&#43;启动归档日志&#43;查看归档日志状态</p>
<pre><code class="language-sql">shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
archive log list;
</code></pre>
<p><img src="/media/editor/0071q2ergy1h6bry8e6qwj30b903kgmv_20240115124558277519.jpg" alt="" />
更详细配置&#xff1a;</p>
<p><a href="https://github.com/ververica/flink-cdc-connectors/blob/master/docs/content/connectors/oracle-cdc.md" rel="nofollow">https://github.com/ververica/flink-cdc-connectors/blob/master/docs/content/connectors/oracle-cdc.md</a></p>
<h2 id="6flink-cdc">6、flink-cdc</h2>
<p>导入依赖</p>
<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;com.ververica&lt;/groupId&gt;
    &lt;artifactId&gt;flink-connector-oracle-cdc&lt;/artifactId&gt;
    &lt;version&gt;2.2.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
    &lt;artifactId&gt;flink-table-api-java-bridge_${scala.binary.version}&lt;/artifactId&gt;
    &lt;version&gt;${flink.version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.flink&lt;/groupId&gt;
    &lt;artifactId&gt;flink-clients_${scala.binary.version}&lt;/artifactId&gt;
    &lt;version&gt;${flink.version}&lt;/version&gt;
    &lt;scope&gt;provided&lt;/scope&gt;
&lt;/dependency&gt;
</code></pre>
<p>flink版本是1.13.6&#xff0c;scala版本是2.11&#xff0c;oracle-cdc版本是2.2.1</p>
<p>示例代码&#xff1a;</p>
<pre><code class="language-java">Properties properties &#61; new Properties();
properties.put(&#34;database.tablename.case.insensitive&#34;,&#34;false&#34;);
SourceFunction&lt;String&gt; sourceFunction &#61; OracleSource.&lt;String&gt;builder()
    .hostname(&#34;192.168.31.219&#34;)
    .port(1521)
    .database(&#34;helowin&#34;) // monitor XE database
    .schemaList(&#34;TEST&#34;) // monitor inventory schema
    .tableList(&#34;TEST.DEMO&#34;) // monitor products table
    .username(&#34;system&#34;)
    .password(&#34;system&#34;)
//                .startupOptions(StartupOptions.latest())
    .debeziumProperties(properties)
    .deserializer(new JsonDebeziumDeserializationSchema()) // converts SourceRecord to JSON String
    .build();
StreamExecutionEnvironment env &#61; StreamExecutionEnvironment.getExecutionEnvironment();
env.addSource(sourceFunction)
    .print().setParallelism(1); // use parallelism 1 for sink to keep message ordering
env.execute();
</code></pre>
<p>必须加 properties.put(&#34;database.tablename.case.insensitive&#34;,&#34;false&#34;); 否则会报错&#xff1a;</p>
<pre><code>io.debezium.DebeziumException: Supplemental logging not configured for table HELOWIN.TEST.demo.  Use command: ALTER TABLE TEST.demo ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS
</code></pre>
<p>大小写导致的问题&#xff1a;需要注明的是&#xff0c;对于 database.tablename.case.insensitive 参数&#xff0c;Debezium 目前仅对 Oracle 11g 默认设置为 true&#xff0c;对其余 Oracle 版本均默认设置为 false。所以读者如果使用的不是 Oracle 11g 版本&#xff0c;可无需修改该参数&#xff0c;但仍需显式指定大写的表名。</p>
<h1 id="踩坑">踩坑</h1>
<p>oracle用docker安装后过去了12天&#xff0c;今天连接是发现报错**archiver error. Connect internal only, until freed.**google后猜测大概意思是&#xff0c;归档错误&#xff0c;只允许内部连接&#xff0c;直到被清理。看网上的说法应该是归档日志满了&#xff0c;不清理日志&#xff0c;外网无法连接。</p>
<pre><code class="language-shell">docker exec -it oracle11g /bin/bash
</code></pre>
<pre><code class="language-shell">sqlplus /nolog
</code></pre>
<p>报错&#xff0c;</p>
<p><img src="/media/editor/0071q2ergy1h6q3rbohb1j30f502z0uj_20240115124647349135.jpg" alt="" /></p>
<pre><code class="language-shell">source /etc/profile
sqlplus /nolog
</code></pre>
<pre><code class="language-sql">conn /as sysdba;
</code></pre>
<p>查询日志归档使用情况</p>
<pre><code class="language-sql"> select * from V$FLASH_RECOVERY_AREA_USAGE;
</code></pre>
<p><img src="/media/editor/0071q2ergy1h6q3tw1xkmj30dj0hhtcy_20240115124733929354.jpg" alt="" /></p>
<p>archived log 为99.99。确定是日志满了。</p>
<pre><code class="language-shell">exit  --退出sqlplus
rman -- 进入rman
connect target /
crosscheck archivelog all;  -- 检查日志
delete expired archivelog all;  -- 删除过期日志
DELETE ARCHIVELOG ALL COMPLETED BEFORE &#39;SYSDATE-7&#39;; -- 删除7天前的日志
</code></pre>
<p>再次查询日志&#xff0c;发现只有0.62了&#xff0c;连接oracle也可以连接了。</p>
<p>还有就是将日志空间设置大一点&#xff08;未测试&#xff09;</p>
<pre><code class="language-sql">alter system set DB_RECOVERY_FILE_DEST_SIZE&#61;10g
</code></pre>
<p>不确定是在sqlplus中执行还是在rman中执行</p>
<h2 id="补充日志和归档日志">补充日志和归档日志</h2>
<p>归档日志&#xff08;Archive Log&#xff09;和补充日志&#xff08;Supplemental Logging&#xff09;是Oracle数据库中两个不同的日志机制&#xff0c;用于不同的目的。</p>
<ol><li>归档日志&#xff08;Archive Log&#xff09;&#xff1a;
<ul><li>归档日志是用于数据库备份和恢复的一种机制。</li><li>当数据库处于归档日志模式时&#xff0c;数据库会将已提交的事务日志写入归档日志文件中&#xff0c;而不仅仅是写入在线重做日志文件。</li><li>归档日志文件可以用于在数据库发生故障时进行恢复&#xff0c;以保证数据的完整性和一致性。</li><li>归档日志对于数据恢复和灾难恢复非常重要&#xff0c;但对于实时数据捕获&#xff08;如CDC&#xff09;并不是必需的。</li></ul>
</li><li>补充日志&#xff08;Supplemental Logging&#xff09;&#xff1a;
<ul><li>补充日志是一种用于捕获数据库更改操作的机制。</li><li>当启用补充日志后&#xff0c;数据库会将更改操作的详细信息记录到重做日志中&#xff0c;包括修改的表、列和行的信息。</li><li>补充日志对于实时数据捕获&#xff08;如CDC&#xff09;非常重要&#xff0c;因为它提供了更详细的更改信息&#xff0c;使应用程序能够准确地捕获和处理这些更改。</li></ul>
</li></ol>
<p>对于使用CDC&#xff08;Change Data Capture&#xff09;的情况&#xff0c;你需要启用补充日志。补充日志记录了数据库中的更改操作&#xff0c;使CDC工具&#xff08;如Flink CDC&#xff09;能够捕获这些更改并将其传递给其他应用程序进行处理。</p>
<p>总结&#xff1a;</p>
<ul><li>归档日志用于备份和恢复数据库&#xff0c;保证数据的完整性和一致性。</li><li>补充日志用于实时数据捕获&#xff08;如CDC&#xff09;&#xff0c;记录数据库的更改操作&#xff0c;以便其他应用程序可以捕获和处理这些更改。</li></ul>
<p>之前搞的是归档日志&#xff0c;这里开启补充日志</p>
<pre><code>ALTER DATABASE ARCHIVELOG 命令用于开启Oracle数据库的归档日志模式&#xff0c;而不是补充日志&#xff08;Supplemental Logging&#xff09;。
补充日志是一种用于捕获数据库更改操作的机制&#xff0c;以便其他应用程序&#xff08;如Flink CDC&#xff09;可以监听和处理这些更改。要在Oracle数据库中启用补充日志&#xff0c;你需要执行以下步骤&#xff1a;
确保你具有适当的权限&#xff0c;例如sysdba权限。
使用sys用户登录到Oracle数据库。
执行以下命令来启用补充日志&#xff1a;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
这将在数据库级别启用补充日志&#xff08;在当前数据库中启用补充日志&#xff09;。
如果你只想为特定表启用补充日志&#xff0c;可以执行以下命令&#xff1a;
ALTER TABLE ORCL.TEST.TEST1 ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
这将为ORCL.TEST.TEST1表启用补充日志&#xff0c;并为所有列配置补充日志。
请注意&#xff0c;启用补充日志可能会增加数据库的负载和存储需求。确保在启用补充日志之前评估其对系统性能和资源的影响。
</code></pre>
<p>参考&#xff1a;<a href="https://github.com/ververica/flink-cdc-connectors/blob/master/docs/content/connectors/oracle-cdc.md" rel="nofollow">https://github.com/ververica/flink-cdc-connectors/blob/master/docs/content/connectors/oracle-cdc.md</a></p>
]]></description>
    </item>
    <item>
      <title>docker 安装达梦数据库</title>
      <link>https://xiaochuncloud.com/article/57</link>
      <guid>https://xiaochuncloud.com/article/57</guid>
      <pubDate>Thu, 11 Jan 2024 06:53:00 +0800</pubDate>
      <description><![CDATA[<p>1&#xff0c;下载docker 镜像 <a href="https://eco.dameng.com/download/?_blank" rel="nofollow">https://eco.dameng.com/download/?_blank</a></p>
<p>2&#xff0c;安装步骤 <a href="https://eco.dameng.com/document/dm/zh-cn/start/dm-install-docker.html" rel="nofollow">https://eco.dameng.com/document/dm/zh-cn/start/dm-install-docker.html</a></p>
<pre><code class="language-shell"># 导入镜像
docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar
# 创建容器并启动
docker run -d -p 30236:5236 --restart&#61;always \
--name dm8_test --privileged&#61;true \
-e PAGE_SIZE&#61;16 -e LD_LIBRARY_PATH&#61;/opt/dmdbms/bin \
-e EXTENT_SIZE&#61;32 -e BLANK_PAD_MODE&#61;1 -e LOG_SIZE&#61;1024 \
-e UNICODE_FLAG&#61;1 -e LENGTH_IN_CHAR&#61;1 \
-e INSTANCE_NAME&#61;dm8_test -v /data/dm8_test:/opt/dmdbms/data dm8_single:dm8_20230808_rev197096_x86_rh6_64

# 容器配置
# 30236 是映射到宿主机的端口
# --privileged&#61;true 是容器获取宿主机root权限
# /data/dm8_test 是映射到宿主机目录&#xff0c;存储的是数据库文件

# 数据库初始化配置&#xff0c;后续无法修改
# page_size 数据文件使用的页大小&#xff0c;可以为 4 KB、8 KB、16 KB 或 32 KB 之一&#xff0c;选择的页大小越大&#xff0c;则 DM 支持的元组长度也越大&#xff0c;但同时空间利用率可能下降&#xff0c;缺省使用 8 KB。
# extent_size 指数据文件使用的簇大小&#xff0c;即每次分配新的段空间时连续的页数。只能是 16 页或 32 页或 64 页之一&#xff0c;缺省使用 16 页。
# UNICODE_FLAG 字符集 0&#xff1a;GB18030 1&#xff1a;UTF-8 2&#xff1a;EUC-KR
# LOG_SIZE 日志大小
# LENGTH_IN_CHAR VARCHAR类型长度是否以字符为单位(N)&#xff0c;可选值&#xff1a;Y/N&#xff0c;1/0
# BLANK_PAD_MODE 设置字符串比较时&#xff0c; 结尾空格填充模式是否兼容 ORACLE。 取值&#xff1a; 1 兼容&#xff1b; 0 不兼容。默认为 0。可选参数。

# 查看日志
docker logs -f  dm8_test
----------------------------------------------------------------------------日志-----------------------
create dm database success. 2024-01-11 09:32:07
initdb V8
db version: 0x7000c
Init DM success!
Start DmAPService...
Starting DmAPService:                                      [ OK ]
/opt/dmdbms/conf/dm.ini does not exist, use default dm.ini
Start DMSERVER success!
Dmserver is running.
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
DM Database is not OK, please wait...
 * Starting periodic command scheduler cron
   ...done.
2023-07-27 19:57:51.680 [INFO] database P0000023431 T0000000000000023435  rfil_close_low set main rfil[../datatest/DAMENG/DAMENG01.log]&#39;s sta to inactive, l_next_seq &#61; 4788, g_next_seq &#61; 4788, clsn &#61; 38842, handle &#61; 7, free&#61;8720896, len&#61;268435456
2023-07-27 19:57:51.681 [INFO] database P0000023431 T0000000000000023435  os_sema2_free, sema_id:3309591, sema_value:1!
2023-07-27 19:57:51.691 [INFO] database P0000023431 T0000000000000023435  shutdown MAL subsystem...
2023-07-27 19:57:51.797 [INFO] database P0000023431 T0000000000000023435  global inject hint deinit
2023-07-27 19:57:51.797 [INFO] database P0000023431 T0000000000000023435  global stat cache deinit
2023-07-27 19:57:51.803 [INFO] database P0000023431 T0000000000000023435  fil_sys_destroy
2023-07-27 19:57:52.812 [INFO] database P0000023431 T0000000000000023435  close lsnr socket
2023-07-27 19:57:52.815 [INFO] database P0000023431 T0000000000000023435  [for dem]SYSTEM SHUTDOWN SUCCESS.
2023-07-27 19:57:52.815 [INFO] database P0000023431 T0000000000000023435  DM Database Server shutdown successfully.
2023-07-27 19:57:52.815 [INFO] database P0000023431 T0000000000000023435  nsvr_notify_exit wakeup main thread to exit

</code></pre>
<p>注意</p>
<ol><li>如果使用 docker 容器里面的 disql&#xff0c;进入容器后&#xff0c;先执行 source /etc/profile 防止中文乱码。</li><li>新版本 Docker 镜像中数据库默认用户名/密码为 SYSDBA/SYSDBA001。</li><li>容器创建后&#xff0c;构建数据库需要一些时间初始化&#xff0c;需要耐心等待</li></ol>
]]></description>
    </item>
    <item>
      <title>设置静态IP</title>
      <link>https://xiaochuncloud.com/article/53</link>
      <guid>https://xiaochuncloud.com/article/53</guid>
      <pubDate>Sat, 02 Dec 2023 11:53:00 +0800</pubDate>
      <description><![CDATA[<h2 id="设置静态ip">设置静态IP</h2>
<h3 id="1centos7">1、centos7</h3>
<ol><li>打开终端并以root用户身份登录。</li><li>编辑网络配置文件。使用以下命令打开网络配置文件&#xff1a;</li></ol>
<pre><code>   vi /etc/sysconfig/network-scripts/ifcfg-eth0
</code></pre>
<p>注意&#xff1a;如果您的网络接口不是eth0&#xff0c;请相应地更改文件名。</p>
<ol><li>在文件中&#xff0c;找到并修改以下行&#xff1a;</li></ol>
<pre><code>   BOOTPROTO&#61;static
   ONBOOT&#61;yes
</code></pre>
<p>将BOOTPROTO的值更改为static&#xff0c;将ONBOOT的值更改为yes。</p>
<ol><li>添加以下行来定义您的IP地址、子网掩码、网关和DNS服务器&#xff1a;</li></ol>
<pre><code>   IPADDR&#61;your_ip_address
   NETMASK&#61;your_netmask
   GATEWAY&#61;your_gateway
   DNS1&#61;your_dns_server1
   DNS2&#61;your_dns_server2
</code></pre>
<p>将&#34;your_ip_address&#34;替换为您想要设置的固定IP地址&#xff0c;将&#34;your_netmask&#34;替换为子网掩码&#xff0c;将&#34;your_gateway&#34;替换为网关的IP地址&#xff0c;将&#34;your_dns_server1&#34;和&#34;your_dns_server2&#34;替换为您的DNS服务器的IP地址。</p>
<ol><li>保存并关闭文件。</li><li>重启网络服务以使更改生效。使用以下命令重启网络服务&#xff1a;</li></ol>
<pre><code>   systemctl restart network
</code></pre>
<p>现在您的CentOS 7系统应该已经设置了固定IP地址。</p>
<p>请注意&#xff0c;这些步骤假设您正在使用以太网接口eth0。如果您使用的是其他网络接口&#xff0c;请相应地更改文件名和接口名称。</p>
<p>脚本自动修改</p>
<pre><code class="language-python">#!/usr/bin/env python
# -*- coding:utf8 -*-

import os
import re

local_ipv4_checker &#61; re.compile(
    &#34;(?:(?:10(?:(?:\\.1[0-9][0-9])|(?:\\.2[0-4][0-9])|(?:\\.25[0-5])|(?:\\.[1-9][0-9])|(?:\\.[0-9])))|(?:172(&#34;
    &#34;?:\\.(?:1[6-9])|(?:2[0-9])|(?:3[0-1])))|(?:192\\.168))(?:(?:\\.1[0-9][0-9])|(?:\\.2[0-4][0-9])|(?:\\.25[&#34;
    &#34;0-5])|(?:\\.[1-9][0-9])|(?:\\.[0-9])){2}&#34;)


def configure_ifcfg_ens33():
    # 获取本机以192开头的IP地址
    def get_local_ip():
        ips &#61; os.popen(&#34;ip -o -f inet addr show | awk &#39;$4 ~ /192/ {print $4}&#39;&#34;).readlines()
        return ips[0].strip().split(&#39;/&#39;)[0]

    ip &#61; get_local_ip()
    ip_prefix &#61; ip[:ip.rfind(&#34;.&#34;) &#43; 1]
    if IP is not None:
        ip &#61; ip_prefix &#43; IP
    if not local_ipv4_checker.match(ip):
        print(&#34;IP地址不合法&#xff1a;%s&#xff0c;放弃修改&#34; % ip)
        return
    backup_file &#61; &#34;/etc/sysconfig/network-scripts/ifcfg-%s.bak&#34; % interface_name
    exist &#61; os.path.exists(backup_file)
    if exist and not force:
        print(&#34;备份文件已存在&#xff0c;不再执行&#34;)
        return
    if not exist:
        # 备份原始文件
        os.system(&#34;cp /etc/sysconfig/network-scripts/ifcfg-%s %s&#34; % (interface_name, backup_file))
        print(&#34;备份成功&#xff0c;原始文件已保存为%s&#34; % backup_file)
    # 读取原始文件内容
    with open(backup_file, &#34;r&#34;) as f:
        content &#61; f.read()
    # 修改BOOTPROTO为static
    content &#61; re.sub(r&#34;BOOTPROTO&#61;dhcp&#34;, &#34;BOOTPROTO&#61;static&#34;, content)
    # 追加IPADDR、NETMASK、GATEWAY和DNS1
    content &#43;&#61; &#34;\nIPADDR&#61;%s\n&#34; % ip
    content &#43;&#61; &#34;NETMASK&#61;255.255.255.0\n&#34;
    content &#43;&#61; &#34;GATEWAY&#61;%s.1\n&#34; % ip_prefix
    content &#43;&#61; &#34;DNS1&#61;%s.1\n&#34; % ip_prefix
    content &#43;&#61; &#34;DNS2&#61;223.5.5.5\n&#34;

    # 修改文件内容
    with open(&#34;/etc/sysconfig/network-scripts/ifcfg-ens33&#34;, &#34;w&#34;) as f:
        f.write(content)
    print(&#34;修改成功&#xff0c;修改后的文件为/etc/sysconfig/network-scripts/ifcfg-%s&#34; % interface_name)


if __name__ &#61;&#61; &#34;__main__&#34;:
    IP &#61; None
    force &#61; False
    interface_name &#61; &#34;ens33&#34;
    configure_ifcfg_ens33()
    print(&#34;配置网卡成功&#34;)
    if os.system(&#34;service  network restart&#34;):
        print(&#34;重启网络服务失败&#34;)
    else:
        print(&#34;重启网络服务成功&#34;)

</code></pre>
<h3 id="2ubuntu">2、ubuntu</h3>
<p>测试使用的是ubuntu 20.04.6</p>
<p>研究了半天&#xff0c;ubuntu使用netplan管理网络</p>
<p>参考&#xff1a;</p>
<p><a href="https://ubuntu.com/server/docs/network-configuration" rel="nofollow">https://ubuntu.com/server/docs/network-configuration</a></p>
<p><a href="https://www.51cto.com/article/721393.html" rel="nofollow">https://www.51cto.com/article/721393.html</a></p>
<p>先备份原来的设置</p>
<pre><code class="language-sh">mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak
</code></pre>
<p>创建新的配置</p>
<pre><code class="language-sh">cat &gt;/etc/netplan/99_config.yaml &lt;&lt;&#39;EOF&#39;
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:   # 注意这个是网卡名称
      addresses:
        - 192.168.31.90/24
      routes:
        - to: default
          via: 192.168.31.1
      nameservers:
              #search: [mydomain, otherdomain]
          addresses: [114.114.114.114, 192.168.31.1]
EOF
</code></pre>
<p>原文中有个search字段&#xff0c;我不知道是啥&#xff0c;就注释了&#xff0c;感觉也没影响</p>
<p>然后执行</p>
<pre><code class="language-sh">sudo netplan apply
</code></pre>
<p>生效&#xff01;一开始&#xff0c;我没有移除原有的配置&#xff0c;执行后网卡获取到了两个IP。</p>
]]></description>
    </item>
    <item>
      <title>gradle安装记录</title>
      <link>https://xiaochuncloud.com/article/52</link>
      <guid>https://xiaochuncloud.com/article/52</guid>
      <pubDate>Thu, 16 Nov 2023 07:37:00 +0800</pubDate>
      <description><![CDATA[<h2 id="gradle安装记录">gradle安装记录</h2>
<h3 id="1下载">1、下载</h3>
<p><a href="https://gradle.org/releases/" rel="nofollow">https://gradle.org/releases/</a></p>
<p>gradle是java写的&#xff0c;跨平台通用</p>
<h3 id="2环境变量">2、环境变量</h3>
<pre><code class="language-sh">#!/bin/bash
source /etc/profile
source /root/.bash_profile

sh_dir&#61;/home/apps/jpom/projects/intelligence-center-apm/package

export GRADLE_HOME&#61;${sh_dir}/gradle-7.6.3
export GRADLE_USER_HOME&#61;${GRADLE_HOME}/localRepository
export PATH&#61;$GRADLE_HOME/bin:$PATH
gradle -v
</code></pre>
<p>GRADLE_USER_HOME是定义本地仓库目录的</p>
<h3 id="3配置国内镜像">3、配置国内镜像</h3>
<p>gradle默认从国外拉取依赖&#xff0c;有时网络不通。</p>
<pre><code class="language-sh">mkdir -p ${GRADLE_USER_HOME}/.gradle
cat &gt; ${GRADLE_USER_HOME}/.gradle/init.gradle &lt;&lt;&#39;EOF&#39;
allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL &#61; &#39;https://maven.aliyun.com/repository/public&#39;
        def ALIYUN_JCENTER_URL &#61; &#39;https://maven.aliyun.com/repository/public&#39;
        def ALIYUN_GOOGLE_URL &#61; &#39;https://maven.aliyun.com/repository/google&#39;
        def ALIYUN_GRADLE_PLUGIN_URL &#61; &#39;https://maven.aliyun.com/repository/gradle-plugin&#39;
        all { ArtifactRepository repo -&gt;
            if(repo instanceof MavenArtifactRepository){
                def url &#61; repo.url.toString()
                if (url.startsWith(&#39;https://repo1.maven.org/maven2/&#39;)) {
                    project.logger.lifecycle &#34;Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL.&#34;
                    remove repo
                }
                if (url.startsWith(&#39;https://jcenter.bintray.com/&#39;)) {
                    project.logger.lifecycle &#34;Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL.&#34;
                    remove repo
                }
                if (url.startsWith(&#39;https://dl.google.com/dl/android/maven2/&#39;)) {
                    project.logger.lifecycle &#34;Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL.&#34;
                    remove repo
                }
                if (url.startsWith(&#39;https://plugins.gradle.org/m2/&#39;)) {
                    project.logger.lifecycle &#34;Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL.&#34;
                    remove repo
                }
            }
        }
        maven { url ALIYUN_REPOSITORY_URL }
        maven { url ALIYUN_JCENTER_URL }
        maven { url ALIYUN_GOOGLE_URL }
        maven { url ALIYUN_GRADLE_PLUGIN_URL }
    }
}
EOF
</code></pre>
]]></description>
    </item>
    <item>
      <title>自动监控MySQL表结构变更脚本</title>
      <link>https://xiaochuncloud.com/article/51</link>
      <guid>https://xiaochuncloud.com/article/51</guid>
      <pubDate>Tue, 14 Nov 2023 01:22:00 +0800</pubDate>
      <description><![CDATA[<pre><code class="language-python">
import datetime
import hashlib
import difflib

import mysql.connector as mdb
from celery import shared_task
from django.core.mail import EmailMessage
from django.template.loader import render_to_string

from auditdb.settings import EMAIL_FROM


&#64;shared_task
def schema_modify_monitor(**kwargs):
    check_time &#61; datetime.datetime.now().strftime(&#34;%Y-%m-%d %H:%M:%S&#34;)
    conn &#61; connect_db(**kwargs)
    cursor &#61; conn.cursor(dictionary&#61;True)

    query_info &#61; &#34;select table_schema,table_name,group_concat(COLUMN_NAME) as column_name,&#34; \
                 &#34;group_concat(COLUMN_DEFAULT) as column_default,group_concat(IS_NULLABLE) as is_nullable,&#34; \
                 &#34;group_concat(DATA_TYPE) as data_type,group_concat(CHARACTER_MAXIMUM_LENGTH) as char_length,&#34; \
                 &#34;group_concat(COLUMN_TYPE) as column_type,group_concat(COLUMN_COMMENT) as column_comment &#34; \
                 &#34;from columns where table_schema&#61;&#39;{schema}&#39; &#34; \
                 &#34;group by table_schema,table_name&#34;.format(schema&#61;kwargs[&#39;schema&#39;])

    cursor.execute(query_info)

    source_info &#61; []
    table_list &#61; []
    diff_old_data &#61; &#39;&#39;
    diff_new_data &#61; &#39;&#39;
    table_change_data &#61; []

    for row in cursor.fetchall():
        table_schema &#61; row[&#39;table_schema&#39;]
        table_name &#61; row[&#39;table_name&#39;]

        md5_source &#61; &#39;&#39;.join(str(row.values()))
        md5_sum &#61; hashlib.md5(md5_source.encode(&#39;utf8&#39;)).hexdigest()
        source_info.append({&#39;table_schema&#39;: table_schema, &#39;table_name&#39;: table_name, &#39;md5_sum&#39;: md5_sum})
        table_list.append(table_name)

    # 如果当前库没有记录&#xff0c;则进行初始化全量同步
    if MonitorSchema.objects.filter(table_schema&#61;kwargs[&#39;schema&#39;]).first() is None:
        for row in source_info:
            table_schema &#61; row[&#39;table_schema&#39;]
            table_name &#61; row[&#39;table_name&#39;]

            query_table_stru &#61; &#34;show create table {}&#34;.format(&#39;.&#39;.join((table_schema, table_name)))
            cursor.execute(query_table_stru)
            for i in cursor:
                table_stru &#61; i[&#39;Create Table&#39;]
                row[&#39;table_stru&#39;] &#61; str(table_stru)
                MonitorSchema.objects.create(**row)
    else:
        # 如果存在&#xff0c;开始核验数据
        old_data &#61; list(MonitorSchema.objects.filter(table_schema&#61;kwargs[&#39;schema&#39;]).values_list(&#39;table_name&#39;, flat&#61;True))
        new_data &#61; table_list

        # 找出已删除的表&#xff0c;并处理
        table_remove &#61; list(set(old_data).difference(set(new_data)))
        if table_remove:
            table_change_data.append({&#39;remove&#39;: table_remove})
            # 从本地库中删除该表的记录
            MonitorSchema.objects.filter(table_schema&#61;kwargs[&#39;schema&#39;]).filter(table_name__in&#61;table_remove).delete()

        # 找出新增的表&#xff0c;并处理
        table_add &#61; list(set(new_data).difference(set(old_data)))
        if table_add:
            for i in table_add:
                for j in source_info:
                    if i in j.values():
                        table_change_data.append({&#39;add&#39;: j})
                        table_schema &#61; j[&#39;table_schema&#39;]
                        table_name &#61; j[&#39;table_name&#39;]
                        query_table_stru &#61; &#34;show create table {}&#34;.format(&#39;.&#39;.join((table_schema, table_name)))
                        cursor.execute(query_table_stru)
                        for x in cursor:
                            table_stru &#61; x[&#39;Create Table&#39;]
                            j[&#39;table_stru&#39;] &#61; str(table_stru)
                            MonitorSchema.objects.create(**j)

        # 找出相同的表&#xff0c;并核验表结构
        table_intersection &#61; list(set(old_data).intersection(set(new_data)))
        for row in source_info:
            table_schema &#61; row[&#39;table_schema&#39;]
            table_name &#61; row[&#39;table_name&#39;]
            new_md5_sum &#61; row[&#39;md5_sum&#39;]

            if table_name in table_intersection:
                old_table &#61; MonitorSchema.objects.get(table_schema&#61;table_schema, table_name&#61;table_name)
                if new_md5_sum !&#61; old_table.md5_sum:
                    query_table_stru &#61; &#34;show create table {}&#34;.format(&#39;.&#39;.join((table_schema, table_name)))
                    cursor.execute(query_table_stru)
                    for i in cursor:
                        table_stru &#61; i[&#39;Create Table&#39;]
                        diff_old_data &#43;&#61; old_table.table_stru &#43; &#39;\n&#39;*3
                        diff_new_data &#43;&#61; table_stru &#43; &#39;\n&#39;*3
                        # 更新新表表结构到本地
                        MonitorSchema.objects.update_or_create(table_schema&#61;table_schema, table_name&#61;table_name,
                                                               defaults&#61;{&#39;table_stru&#39;: table_stru,
                                                                         &#39;md5_sum&#39;: new_md5_sum})

    if (diff_old_data and diff_new_data) or table_change_data:
        html_data &#61; &#39;&#39;
        if diff_old_data and diff_new_data:
            diff_data &#61; difflib.HtmlDiff(tabsize&#61;2)
            old_table_stru &#61; list(diff_old_data.split(&#39;\n&#39;))
            new_table_stru &#61; list(diff_new_data.split(&#39;\n&#39;))
            html_data &#61; diff_data.make_file(old_table_stru, new_table_stru, &#39;旧表-表结构&#39;, &#39;新表-表结构&#39;, context&#61;False,
                                            numlines&#61;5)

        email_html_body &#61; render_to_string(&#39;_monitor_table.html&#39;, {&#39;html_data&#39;: html_data, &#39;table_change_data&#39;: table_change_data})
        title &#61; &#39;{db}库表变更[来自:{host},检测时间:{check_time}]&#39;.format(db&#61;kwargs[&#39;schema&#39;], host&#61;kwargs[&#39;describle&#39;], check_time&#61;check_time)
        msg &#61; EmailMessage(subject&#61;title,
                           body&#61;email_html_body,
                           from_email&#61;EMAIL_FROM,
                           to&#61;kwargs[&#39;receiver&#39;].split(&#39;,&#39;),
                           )
        msg.content_subtype &#61; &#34;html&#34;
        msg.send()
    cursor.close()
    conn.close()

</code></pre>
<p><a href="https://developer.aliyun.com/article/241553" rel="nofollow">转载自https://developer.aliyun.com/article/241553</a></p>
]]></description>
    </item>
    <item>
      <title>使用docker安装fastdfs</title>
      <link>https://xiaochuncloud.com/article/50</link>
      <guid>https://xiaochuncloud.com/article/50</guid>
      <pubDate>Mon, 06 Nov 2023 01:58:00 +0800</pubDate>
      <description><![CDATA[<h1 id="fastdfs">fastdfs</h1>
<h2 id="1使用docker安装fastdfs">1、使用docker安装fastdfs</h2>
<pre><code class="language-sh">docker run -dti \
--network&#61;host \
--name tracker \
-v /opt/fastdfs/tracker:/var/fdfs \
-v /etc/localtime:/etc/localtime \
delron/fastdfs tracker

docker run -dti  \
--network&#61;host \
--name storage \
-e TRACKER_SERVER&#61;&#34;0.0.0.0:22122&#34; \
-v /opt/fastdfs/storage:/var/fdfs  \
-v /etc/localtime:/etc/localtime  \
delron/fastdfs storage
</code></pre>
<p>TRACKER_SERVER为tracker的地址</p>
<p>/etc/localtime同步时间</p>
<p>运行后&#xff0c;使用的端口为&#xff1a;</p>
<p>fdfs_storaged&#xff1a;23000</p>
<p>fdfs_trackerd&#xff1a; 22122</p>
<h2 id="2java操作fastdfs">2、java操作fastdfs</h2>
<h3 id="21引入依赖">2.1、引入依赖</h3>
<p>先运行&#xff1a;</p>
<pre><code class="language-sh">mvn install:install-file                           \
-Dfile&#61;&#34;lib\fastdfs-client-java-1.27-SNAPSHOT.jar&#34; \
-Dpackaging&#61;jar                                    \
-DgroupId&#61;org.csource                              \
-DartifactId&#61;fastdfs-client-java                   \
-Dversion&#61;1.27
</code></pre>
<p>再在pom.xml中添加&#xff1a;</p>
<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.csource&lt;/groupId&gt;
    &lt;artifactId&gt;fastdfs-client-java&lt;/artifactId&gt;
    &lt;version&gt;1.27&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>
<p>此依赖通过远程仓库无法加载</p>
<h3 id="22配置初始化">2.2、配置初始化</h3>
<p>初始化方式有多种</p>
<h4 id="221配置文件初始化">2.2.1、配置文件初始化</h4>
<pre><code class="language-java">String tracker &#61; GmallManageWebApplicationTests.class.getResource(&#34;/tracker.conf&#34;).getPath();// 配置文件路径
ClientGlobal.init(tracker);
</code></pre>
<p>tracker.conf&#xff1a;</p>
<pre><code class="language-ini"># tracker服务器的地址&#xff0c;注意端口不是访问文件端口是通讯端口
tracker_server&#61;192.168.2.128:22122
# 连接超时时间&#xff0c;针对socket套接字函数connect&#xff0c;默认为30秒
connect_timeout&#61;30000
# 网络通讯超时时间&#xff0c;默认是60秒
network_timeout&#61;60000
</code></pre>
<h4 id="222properties初始化">2.2.2、Properties初始化</h4>
<pre><code class="language-java">Properties properties &#61; new Properties();
properties.setProperty(&#34;fastdfs.connect_timeout_in_seconds&#34;, &#34;30&#34;);
properties.setProperty(&#34;fastdfs.network_timeout_in_seconds&#34;, &#34;60&#34;);
properties.setProperty(&#34;fastdfs.tracker_servers&#34;, &#34;192.168.18.188:22122&#34;);
ClientGlobal.initByProperties(properties);
</code></pre>
<p>初始化参数中&#xff0c;tracker_server是必须的&#xff0c;其他是可选的。tracker_server的格式要是&#xff1a;    host:port</p>
<h3 id="22获取storageclient对象">2.2、获取StorageClient对象</h3>
<pre><code class="language-java">TrackerClient trackerClient &#61; new TrackerClient();
// 获得一个trackerServer的实例
TrackerServer trackerServer &#61; trackerClient.getConnection();
// 通过tracker获得一个Storage链接客户端
StorageClient storageClient &#61; new StorageClient(trackerServer,null);
</code></pre>
<p>StorageClient对象可以进行上传下载删除修改等操作</p>
<p>2.3、工具类</p>
<pre><code class="language-java">import org.csource.common.MyException;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

&#64;Configuration
&#64;ConfigurationProperties(&#34;fastdfs&#34;)
public class FastdfsUtil {
    private String trackerServer;
    private String networkTimeoutInSeconds;
    private String connectTimeoutInSeconds;
    private static String accessPath;

    public void setAccessPath(String accessPath) {
        FastdfsUtil.accessPath &#61; accessPath;
    }

    public void setTrackerServer(String trackerServer) {
        this.trackerServer &#61; trackerServer;
    }

    public void setNetworkTimeoutInSeconds(String networkTimeoutInSeconds) {
        this.networkTimeoutInSeconds &#61; networkTimeoutInSeconds;
    }

    public void setConnectTimeoutInSeconds(String connectTimeoutInSeconds) {
        this.connectTimeoutInSeconds &#61; connectTimeoutInSeconds;
    }

    private static StorageClient client;
    &#64;PostConstruct
    private void init() throws IOException, MyException {
        Properties properties &#61; new Properties();
        properties.setProperty(&#34;fastdfs.connect_timeout_in_seconds&#34;, connectTimeoutInSeconds);
        properties.setProperty(&#34;fastdfs.network_timeout_in_seconds&#34;, networkTimeoutInSeconds);
        properties.setProperty(&#34;fastdfs.tracker_servers&#34;, trackerServer);
        ClientGlobal.initByProperties(properties);
        TrackerClient trackerClient &#61; new TrackerClient();
        // 获得一个trackerServer的实例
        TrackerServer trackerServer &#61; trackerClient.getConnection();
        client &#61; new StorageClient(trackerServer, null);  //并发量小的时候重用StorageClient对象没啥问题&#xff0c;但他不是线程安全的&#xff01;&#xff01;
        												//解决办法是使用ThreadLocal懒加载赋值&#xff0c;或者每次使用都new一个
    }
// 以上为初始化
    //获取可操作的客户端
    public static StorageClient getClient() {
        return client;
    }
	//文件信息转地址工具
    public static String getUrl(String[] uploadInfos){
        StringBuilder url &#61; new StringBuilder(accessPath);
        for (String uploadInfo : uploadInfos) {
            url.append(&#34;/&#34;).append(uploadInfo);
        }
        return url.toString();
    }
    //根据文件地址删除文件
    public static void delete(String url) throws IOException, MyException {
        final StorageClient client &#61; FastdfsUtil.getClient();
        final Pattern compile &#61; Pattern.compile(&#34;.*(group\\d&#43;)/(.*)&#34;);
        final Matcher matcher &#61; compile.matcher(url);
        if (matcher.find()) {
            System.out.println(client.delete_file(matcher.group(1), matcher.group(2)));
        }else{
            System.out.println(&#34;未找到&#xff1a; &#34; &#43; url);
        }
    }
}
</code></pre>
<p>配置文件application.yml&#xff1a;</p>
<pre><code class="language-yml">fastdfs:
  tracker_server: 192.168.18.188:22122
  connect_timeout_in_seconds: 30
  network_timeout_in_seconds: 60
  accessPath: http://192.168.18.188:8888
</code></pre>
]]></description>
    </item>
    <item>
      <title>ssh代理与端口转发</title>
      <link>https://xiaochuncloud.com/article/49</link>
      <guid>https://xiaochuncloud.com/article/49</guid>
      <pubDate>Wed, 11 Oct 2023 12:50:00 +0800</pubDate>
      <description><![CDATA[<h2 id="ssh代理与端口转发">ssh代理与端口转发</h2>
<p><a href="https://zhuanlan.zhihu.com/p/57630633" rel="nofollow">https://zhuanlan.zhihu.com/p/57630633</a></p>
<h3 id="1正向代理">1、正向代理</h3>
<p>参数 -L</p>
<p>l应该是表示local&#xff0c;再本地开监听端口&#xff0c;将收到的流量转发到绑定端口上</p>
<p>举例</p>
<pre><code class="language-sh">ssh -L 0.0.0.0:1314:192.168.1.2:1314 root&#64;192.168.1.2
</code></pre>
<p><a href="mailto:再本地开1314端口&#xff0c;将收到的流量转发到root&#64;192.168.1.2服务器可以访问的192.168.1.2" rel="nofollow">再本地开1314端口&#xff0c;将收到的流量转发到root&#64;192.168.1.2服务器可以访问的192.168.1.2</a>:1314端口上</p>
<p><a href="mailto:可知&#xff0c;只要是root&#64;192.168.1.2能够访问的端口&#xff0c;都可以转发。" rel="nofollow">可知&#xff0c;只要是root&#64;192.168.1.2能够访问的端口&#xff0c;都可以转发。</a></p>
<p>比如&#xff0c;本机无法访问192.168.1.3:<a href="mailto:1314&#xff0c;但是本机可以访问root&#64;192.168.1.2&#xff0c;root" rel="nofollow">1314&#xff0c;但是本机可以访问root&#64;192.168.1.2&#xff0c;root</a>&#64;192.168.1.2可以访问192.168.1.3:1314&#xff0c;可以绑定端口&#xff1a;</p>
<pre><code class="language-sh">ssh -L 0.0.0.0:1314:192.168.1.3:1314 root&#64;192.168.1.2
</code></pre>
<p>这样本机的0.0.0.0:1314和本机无法访问的192.168.1.3:<a href="mailto:1314通过root&#64;192.168.1.2作为桥梁绑定到一起。" rel="nofollow">1314通过root&#64;192.168.1.2作为桥梁绑定到一起。</a></p>
<h3 id="2反向代理">2、反向代理</h3>
<p>参数 -R</p>
<p>r应该是表示remote&#xff0c;再远程机器开监听端口&#xff0c;将收到的流量转发到绑定端口上</p>
<p>举例</p>
<pre><code class="language-sh">ssh -R 192.168.1.2:1314:192.168.1.4:1314 root&#64;192.168.1.2
</code></pre>
<p><a href="mailto:在root&#64;192.168.1.2上开1314端口&#xff0c;将收到的流量转发到本机可以访问的192.168.1.4" rel="nofollow">在root&#64;192.168.1.2上开1314端口&#xff0c;将收到的流量转发到本机可以访问的192.168.1.4</a>:1314端口上</p>
<p>前面的是远程机器上要开的监听端口&#xff0c;后面是本机可访问的要暴露出去的端口</p>
<h3 id="3socks5代理">3、socks5代理</h3>
<p>参数 -D</p>
<p>d应该是dynamic&#xff0c;动态。本机开监听端口&#xff0c;将收到的流量通过远程ssh程序发出。就是一个socket代理程序。</p>
<p>举例</p>
<pre><code class="language-sh">ssh -D 0.0.0.0:1080  root&#64;192.168.1.2
</code></pre>
<p><a href="mailto:这时候&#xff0c;root&#64;192.168.1.2就成了socket5代理服务器&#xff0c;本地ssh成了客户端&#xff0c;客户端监听的端口是1080" rel="nofollow">这时候&#xff0c;root&#64;192.168.1.2就成了socket5代理服务器&#xff0c;本地ssh成了客户端&#xff0c;客户端监听的端口是1080</a></p>
<h3 id="4优化">4、优化</h3>
<pre><code class="language-sh"> ssh -CqTnN -L 0.0.0.0:PortA:HostC:PortC  user&#64;HostB
</code></pre>
<p>其中 <code>-C</code> 为压缩数据&#xff0c;<code>-q</code> 安静模式&#xff0c;<code>-T</code> 禁止远程分配终端&#xff0c;<code>-n</code> 关闭标准输入&#xff0c;<code>-N</code> 不执行远程命令。此外视需要还可以增加 <code>-f</code> 参数&#xff0c;把 ssh 放到后台运行。</p>
<h3 id="5socks5反向代理">5、socks5反向代理</h3>
<p>比如想提供socks5代理的服务端没有公网IP&#xff0c;客户端有公网IP&#xff0c;客户端想通过服务端代理上网。</p>
<p>首先&#xff0c;服务端启动socks5代理服务</p>
<pre><code class="language-sh">ssh -CqTnNf -D 127.0.0.1:1080  root&#64;127.0.0.1
</code></pre>
<p>这是服务端可以通过本地的1080端口&#xff0c;代理上网&#xff0c;自己代理自己&#xff0c;没有意义。</p>
<p>但是下面将这个代理端口绑定到客户端</p>
<p>服务端启动反向代理</p>
<pre><code class="language-sh">ssh -CqTnNf -R clientHost:1080:127.0.0.1:1080  root&#64;clientHost
</code></pre>
<p>这样&#xff0c;客户端可以通过本地的1080端口访问到服务端的1080端口&#xff0c;进而访问到服务端提供的socks5代理。</p>
]]></description>
    </item>
    <item>
      <title>离线安装docker</title>
      <link>https://xiaochuncloud.com/article/48</link>
      <guid>https://xiaochuncloud.com/article/48</guid>
      <pubDate>Tue, 10 Oct 2023 04:23:00 +0800</pubDate>
      <description><![CDATA[<h2 id="离线安装docker">离线安装docker</h2>
<p>参考&#xff1a;<a href="https://yeasy.gitbook.io/docker_practice/install/offline" rel="nofollow">https://yeasy.gitbook.io/docker_practice/install/offline</a></p>
<h3 id="1yum本地文件安装">1、yum本地文件安装</h3>
<h4 id="11过程记录">1.1、过程记录</h4>
<p>准备安装包</p>
<p>在一台有网络的机器上下载安装包</p>
<p>安装docker源</p>
<pre><code class="language-shell">wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sudo sed -i &#39;s&#43;download.docker.com&#43;mirrors.tuna.tsinghua.edu.cn/docker-ce&#43;&#39; /etc/yum.repos.d/docker-ce.repo
yum update
</code></pre>
<p>查看可用的docker版本</p>
<pre><code class="language-shell">yum list docker-ce --showduplicates|sort -r
</code></pre>
<p>下载指定版本</p>
<pre><code class="language-shell">mkdir -p /home/docker_packages/
yum install --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>执行发现系统已安装docker&#xff0c;改为执行update</p>
<pre><code class="language-shell">yum update --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>再次执行报错&#xff0c;证书过期</p>
<pre><code>https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#60 - &#34;Peer&#39;s Certificate has expired.&#34;
</code></pre>
<p>一番排查后是虚拟机时间不对</p>
<pre><code class="language-shell">yum install ntpdate -y
ntpdate -u ntp.aliyun.com
</code></pre>
<p>然后再下载</p>
<pre><code>yum update --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>报错</p>
<pre><code>[Errno -1] 软件包与预期下载的不符。建议&#xff1a;运行 yum --enablerepo&#61;docker-ce-stable clean metadata
</code></pre>
<p>执行</p>
<pre><code>yum --enablerepo&#61;docker-ce-stable clean metadata
</code></pre>
<p>再下载</p>
<pre><code>yum update --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>还是报错</p>
<p>覆盖&#xff0c;不使用清华源</p>
<pre><code class="language-sh">wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
yum update --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>下载成功。可能是之前安装的docker不是清华源安装的。所以更新的时候不匹配。</p>
<p>这个下载的只有2个文件&#xff0c;和文档不符。也许是因为之前已经安装过&#xff0c;有些已存在的依赖没有被下载。为避免意外&#xff0c;克隆一台全新的虚拟机来安装。</p>
<p>途中还是报错&#xff0c;软件包与预期下载的不符。</p>
<p>查<a href="https://blog.csdn.net/hylaking/article/details/87978819" rel="nofollow">https://blog.csdn.net/hylaking/article/details/87978819</a></p>
<p>执行</p>
<pre><code>yum clean all
yum makecache
</code></pre>
<p>还是报错&#xff0c;覆盖</p>
<pre><code class="language-sh">wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
yum clean all
yum makecache
</code></pre>
<p>再次下载</p>
<pre><code class="language-sh">mkdir -p /home/docker_packages/
yum install --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>下载完成</p>
<pre><code>-rw-r--r--. 1 root root  77K 8月  23 2019 audit-libs-python-2.8.5-4.el7.x86_64.rpm
-rw-r--r--. 1 root root 295K 11月 12 2018 checkpolicy-2.5-8.el7.x86_64.rpm
-rw-r--r--. 1 root root  34M 9月  16 07:20 containerd.io-1.6.24-3.1.el7.x86_64.rpm
-rw-r--r--. 1 root root  40K 7月   6 2020 container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm
-rw-r--r--. 1 root root  14M 7月  24 23:07 docker-buildx-plugin-0.11.2-1.el7.x86_64.rpm
-rw-r--r--. 1 root root  25M 9月  15 21:42 docker-ce-24.0.6-1.el7.x86_64.rpm
-rw-r--r--. 1 root root  14M 9月  15 21:42 docker-ce-cli-24.0.6-1.el7.x86_64.rpm
-rw-r--r--. 1 root root 9.2M 9月  15 21:42 docker-ce-rootless-extras-24.0.6-1.el7.x86_64.rpm
-rw-r--r--. 1 root root  13M 9月  15 21:42 docker-compose-plugin-2.21.0-1.el7.x86_64.rpm
-rw-r--r--. 1 root root  82K 4月  29 2020 fuse3-libs-3.6.1-4.el7.x86_64.rpm
-rw-r--r--. 1 root root  55K 4月  29 2020 fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm
-rw-r--r--. 1 root root  67K 8月  23 2019 libcgroup-0.41-21.el7.x86_64.rpm
-rw-r--r--. 1 root root 113K 11月 12 2018 libsemanage-python-2.5-14.el7.x86_64.rpm
-rw-r--r--. 1 root root 458K 4月   4 2020 policycoreutils-python-2.5-34.el7.x86_64.rpm
-rw-r--r--. 1 root root  33K 7月   4 2014 python-IPy-0.75-6.el7.noarch.rpm
-rw-r--r--. 1 root root 621K 11月 12 2018 setools-libs-3.3.8-4.el7.x86_64.rpm
-rw-r--r--. 1 root root  82K 4月  29 2020 slirp4netns-0.4.3-4.el7_8.x86_64.rpm
</code></pre>
<p>拷贝后执行安装</p>
<pre><code>rpm -Uvh *.rpm --nodeps --force
</code></pre>
<p>安装成功</p>
<h4 id="12安装流程总结">1.2、安装流程总结</h4>
<p>在一台有网且未安装docker的虚拟机上下载docker的rpm包&#xff0c;系统版本最好与要离线安装docker的系统是一致的。</p>
<pre><code class="language-sh">wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
yum clean all
yum makecache
mkdir -p /home/docker_packages/
yum install --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
</code></pre>
<p>拷贝rpm文件到离线的系统</p>
<p>执行安装</p>
<pre><code>rpm -Uvh *.rpm --nodeps --force
</code></pre>
<h3 id="2本地源安装">2、本地源安装</h3>
<h4 id="21安装过程记录">2.1、安装过程记录</h4>
<p>单纯的创建本地源&#xff0c;可以参考&#xff1a;<a href="https://www.vos.cn/os/387.html" rel="nofollow">https://www.vos.cn/os/387.html</a></p>
<p>下载Everything系统镜像&#xff08;阿里镜像&#xff0c;选择OS镜像下载&#xff09;</p>
<pre><code>https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Everything-2207-02.iso
</code></pre>
<p>虚拟机挂载</p>
<pre><code>mount /dev/cdrom /mnt
</code></pre>
<p>安装reposync</p>
<pre><code>yum install yum-utils
</code></pre>
<p>下载docker-ec源仓库</p>
<pre><code class="language-sh">wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
mkdir -p /home/html/docker-ce
reposync -r docker-ce-stable -p /home/html/docker-ce/
</code></pre>
<p>配置本地源&#xff08;可选&#xff09;</p>
<pre><code class="language-sh"># 删除其他网络源
rm -f /etc/yum.repo.d/*
# 添加本地源
cat &gt;/etc/yum.repos.d/local_files.repo&lt;&lt; EOF
[Local_Files]
name&#61;Local_Files
baseurl&#61;file:///mnt
enable&#61;1
gpgcheck&#61;0
gpgkey&#61;file:///mnt/RPM-GPG-KEY-CentOS-7
EOF
</code></pre>
<p>安装createrepo</p>
<pre><code class="language-sh">yum clean all
yum install createrepo -y
createrepo /home/html/docker-ce/

# 使用overlay报错&#xff0c;不支持底层iso的文件系统
#mkdir -p /home/html/base_upper /home/html/base_work /home/html/base
#mount -t overlay overlay -olowerdir&#61;/mnt/Packages/,upperdir&#61;/home/html/base_upper,workdir&#61;/home/html/base_work /home/html/base
mkdir -p /home/html/base
cp /mnt/Packages/* /home/html/base
createrepo /home/html/base/
</code></pre>
<p>开启http文件服务器</p>
<pre><code class="language-sh">cd /home/html
nohup python -m SimpleHTTPServer 80 &gt;./console.log 2&gt;&amp;1 &amp;
</code></pre>
<p>客户端设置</p>
<pre><code class="language-sh">rm -f /etc/yum.repo.d/*
cat &gt;/etc/yum.repos.d/local_files.repo&lt;&lt; EOF
[base]
name&#61;base
# 改成B服务器地址
baseurl&#61;http://192.168.31.197/base
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
[docker_ce]
name&#61;docker_ce
# 改成B服务器地址
baseurl&#61;http://192.168.31.197/docker-ce
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
EOF
</code></pre>
<p>安装docker</p>
<pre><code> yum install docker-ce
</code></pre>
<p>报错</p>
<pre><code>---&gt; 软件包 docker-compose-plugin.x86_64.0.2.21.0-1.el7 将被 安装
--&gt; 解决依赖关系完成
错误&#xff1a;软件包&#xff1a;3:docker-ce-24.0.6-1.el7.x86_64 (docker_ce)
          需要&#xff1a;container-selinux &gt;&#61; 2:2.74
错误&#xff1a;软件包&#xff1a;containerd.io-1.6.24-3.1.el7.x86_64 (docker_ce)
          需要&#xff1a;container-selinux &gt;&#61; 2:2.74
错误&#xff1a;软件包&#xff1a;docker-ce-rootless-extras-24.0.6-1.el7.x86_64 (docker_ce)
          需要&#xff1a;slirp4netns &gt;&#61; 0.4
错误&#xff1a;软件包&#xff1a;docker-ce-rootless-extras-24.0.6-1.el7.x86_64 (docker_ce)
          需要&#xff1a;fuse-overlayfs &gt;&#61; 0.7
</code></pre>
<p>到服务器上执行&#xff08;此时服务器用的本地文件源&#xff09;</p>
<pre><code>yum search fuse-overlayfs
</code></pre>
<p>没有这个包&#xff0c;说明Everything的iso里没有这个包</p>
<p>服务器恢复为公共网络源&#xff0c;查差的这几个包的信息</p>
<pre><code class="language-sh">yum provides fuse-overlayfs
yum provides slirp4netns
yum provides container-selinux
</code></pre>
<p>发现都来自extras源下</p>
<p>列出源列表</p>
<pre><code>yum repolist
</code></pre>
<p>下载extras源</p>
<p>参考&#xff1a;<a href="https://www.vos.cn/os/387.html" rel="nofollow">https://www.vos.cn/os/387.html</a></p>
<pre><code class="language-sh">mkdir -p /home/html/extras
reposync -g -l -d -m --repoid&#61;extras --newest-only --download-metadata --download_path&#61;/home/html/
createrepo --worker&#61;6 /home/html/extras/
</code></pre>
<p>修改客户端设置</p>
<pre><code class="language-ini">[base]
name&#61;base
# 改成B服务器地址
baseurl&#61;http://192.168.31.197/base
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_

[extras]
name&#61;extras
# 改成B服务器地址
baseurl&#61;http://192.168.31.197/extras
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_

[docker_ce]
name&#61;docker_ce
# 改成B服务器地址
baseurl&#61;http://192.168.31.197/docker-ce
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
</code></pre>
<p>安装docker</p>
<pre><code class="language-sh">yum install docker-ce
</code></pre>
<h4 id="22安装流程总结">2.2、安装流程总结</h4>
<p>找一台有网的机器</p>
<p>安装工具</p>
<pre><code>yum install yum-utils createrepo
</code></pre>
<p>下载基本软件&#xff08;阿里镜像&#xff0c;选择OS镜像&#xff0c;下载Everything系统镜像&#xff09;</p>
<pre><code>https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Everything-2207-02.iso
</code></pre>
<p>挂载Everything镜像</p>
<pre><code class="language-sh">mount /dev/cdrom /mnt
</code></pre>
<p>开始制作</p>
<pre><code class="language-sh">mkdir -p /home/html/{base,extras,docker-ce}
</code></pre>
<p>拷贝base软件</p>
<pre><code class="language-sh">cp /mnt/Packages/* /home/html/base/
createrepo --worker&#61;6 -v /home/html/base/
</code></pre>
<p>同步docker-ce源</p>
<pre><code class="language-sh">wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
mkdir -p /home/html/docker-ce
reposync -r docker-ce-stable -p /home/html/docker-ce/
createrepo /home/html/docker-ce/
</code></pre>
<p>这一步可以参考&#xff1a;<a href="https://www.vos.cn/os/387.html&#xff0c;只下载最新的&#xff08;未测试&#xff09;" rel="nofollow">https://www.vos.cn/os/387.html&#xff0c;只下载最新的&#xff08;未测试&#xff09;</a></p>
<pre><code class="language-sh">reposync -g -l -d -m --repoid&#61;docker-ce-stable --newest-only --download-metadata --download_path&#61;/home/html
</code></pre>
<p>说明&#xff1a;</p>
<pre><code>-g, --gpgcheck        Remove packages that fail GPG signature checking after downloading
-l, --plugins         enable yum plugin support
-d, --delete          delete local packages no longer present in repository
-m, --downloadcomps   also download comps.xml

-r REPOID, --repoid&#61;REPOID
                        specify repo ids to query, can be specified multiple
                        times (default is all enabled)

-n, --newest-only     Download only newest packages per-repo

--download-metadata   download all the non-default metadata

-p DESTDIR, --download_path&#61;DESTDIR
                        Path to download packages to: defaults to current dir
  --norepopath          Don&#39;t add the reponame to the download path. Can only
                        be used when syncing a single repository (default is
                        to add the reponame)
</code></pre>
<p>同步extras源</p>
<pre><code class="language-sh">mkdir -p /home/html/extras
reposync -g -l -d -m --repoid&#61;extras --newest-only --download-metadata --download_path&#61;/home/html/
createrepo --worker&#61;6 /home/html/extras/
</code></pre>
<p>开启http文件服务器</p>
<pre><code class="language-sh">cd /home/html
nohup python -m SimpleHTTPServer 80 &gt;./console.log 2&gt;&amp;1 &amp;
</code></pre>
<p>客户端设置</p>
<pre><code class="language-ini">[base]
name&#61;base
# 改成服务器地址
baseurl&#61;http://192.168.31.197/base
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_

[extras]
name&#61;extras
# 改成服务器地址
baseurl&#61;http://192.168.31.197/extras
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_

[docker_ce]
name&#61;docker_ce
# 改成服务器地址
baseurl&#61;http://192.168.31.197/docker-ce
enable&#61;1
gpgcheck&#61;0
proxy&#61;_none_
</code></pre>
<p>客户端安装</p>
<pre><code class="language-sh">yum install docker-ce
</code></pre>
<h3 id="3一键安装脚本">3、一键安装脚本</h3>
<pre><code class="language-sh">#!/bin/bash
source /etc/profile
# #############
# 离线服务器一键安装docker
# 需要docker_packages.7z
# 下载地址&#xff1a;
#		https://www.123pan.com/s/xMzAjv-wm7dv.html提取码:4U5d
# 实际位于123云盘&#xff1a;/linux软件包/docker_packages.tgz
# 校验 md5 a5b43193a62bca23786cd77b203030b6

# docker_packages.7z 中包含docker安装所需的rpm包&#xff0c;这个包使用以下命令,在虚拟机中生成
    #wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
    #yum clean all
    #yum makecache
    #mkdir -p /home/docker_packages/
    #yum install --downloadonly --downloaddir&#61;/home/docker_packages/ docker-ce docker-ce-cli
    #tar czvf dockerker_packages.tgz /home/docker_packages/

# 虚拟机环境&#xff1a;
# 系统&#xff1a; CentOS Linux release 7.9.2009 (Core)
# 内核&#xff1a; Linux vm0 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# glibc&#xff1a; ldd (GNU libc) 2.17
# docker版本&#xff1a; 24.0.6-1.el7.x86_64
# #############

/usr/bin/docker -v &amp;&amp; {
  echo &#34;docker 已安装&#34;
  exit 0
}
cd &#34;$(dirname &#34;$0&#34;)&#34; || exit 1
[ -f &#34;./docker_packages.tgz&#34; ] || {
  echo &#34;docker_packages.tgz未找到&#34;
  exit 2
}
[ &#96;md5sum docker_packages.tgz |awk &#39;{print $1}&#39;&#96; &#61; a5b43193a62bca23786cd77b203030b6 ]|| {
  echo &#34;docker_packages.tgz文件md5有误&#xff0c;文件可能弄错了或被篡改&#34;
  exit 3
}
tar xzvf docker_packages.tgz || {
  echo &#34;解压失败&#xff0c;请手动解压到docker_packages.tgz到当前目录&#34;
  exit 4
}
# 安装docker
cd docker_packages &amp;&amp; yum localinstall *.rpm &amp;&amp; service docker start &amp;&amp; docker -v
</code></pre>
]]></description>
    </item>
    <item>
      <title>使用bind9 配置dns服务器</title>
      <link>https://xiaochuncloud.com/article/47</link>
      <guid>https://xiaochuncloud.com/article/47</guid>
      <pubDate>Wed, 09 Aug 2023 02:33:00 +0800</pubDate>
      <description><![CDATA[<h3 id="1安装bind9">1&#xff0c;安装bind9</h3>
<pre><code class="language-shell">sudo apt-get update
apt-get install bind9
</code></pre>
<h3 id="2配置bind9-解析">2&#xff0c;配置bind9 解析</h3>
<pre><code class="language-shell">cd /etc/bind


vim named.conf.zones

# 写入
zone &#34;exp.top&#34;{
        type master;
        file &#34;/etc/bind/db.exp.top&#34;;
};

vim db.exp.top

# 写入
;
; BIND data file for local loopback interface
;
$TTL    604800
&#64;       IN      SOA     exp.top. root.exp.top. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
&#64;       IN      NS      exp.top.
&#64;       IN      A       192.168.31.219
&#64;       IN      AAAA    ::1
</code></pre>
<h3 id="重启启动bind9">重启&#xff0c;启动bind9</h3>
<pre><code class="language-shell">systemctl restart bind9
</code></pre>
]]></description>
    </item>
  </channel>
</rss>
