<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>莉莉の旋转小木屋</title><link>http://www.lilybug.cn/</link><description>莉莉の旋转小木屋</description><item><title>ansible核心模块介绍及使用说明</title><link>http://www.lilybug.cn/post/67.html</link><description>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h2 id=&quot;h2-ansible-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;ansible核心模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;ansible核心模块&lt;/h2&gt;&lt;h3 id=&quot;h3-u6A21u5757u4ECBu7ECD&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;模块介绍&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;模块介绍&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;模块分类&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;ansible-doc -l 显示所有模块名&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;命令和脚本模块&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;command模块   默认的模块  执行简单命令，不支持特殊符号&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;shell模块  执行命令，支持特殊符号&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;script模块  分发脚本并执行&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;文件&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;file 创建目录，文件，软连接&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;copy 远程分发文件，修改权限，所有者，备份&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;服务&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;systemd 服务管理&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;service 服务管理（了解）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;软件包&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;yum源  yum_repository&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;yum 命令&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;get_url 下载软件&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;系统管理&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;mount模块   挂载&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;cron模块      定时任务&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;用户管理&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;group模块   管理用户组&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;user模块      管理用户&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;其他可以研究&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;压缩解压（unarchive），rsync模块（synchronize），数据库模块（mysql_db，mysql_user）……&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;其他&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;ansible管理docker  k8s   zabbix  grafana  ……&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;用于调试模块&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;ping 模块检查ansible与其他节点连通性&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;debug 模块  用于检查/显示 变量&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-u5982u4F55u67E5u8BE2u5E2Eu52A9&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;如何查询帮助&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;如何查询帮助&lt;/h3&gt;&lt;h4 id=&quot;h4-u901Au8FC7u547Du4EE4&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;通过命令&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;通过命令&lt;/h4&gt;&lt;p&gt;&lt;code&gt;ansible-doc  -s   模块名&lt;/code&gt;&lt;/p&gt;
&lt;h4 id=&quot;h4-u901Au8FC7u5B98u7F51&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;通过官网&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;通过官网&lt;/h4&gt;&lt;p&gt;&lt;a href=&quot;https://docs.ansible.com/ansible/latest/&quot;&gt;https://docs.ansible.com/ansible/latest/&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;h3-ans-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;ans-命令与脚本类模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;ans-命令与脚本类模块&lt;/h3&gt;&lt;p&gt;ansible中的颜色：&lt;br&gt;    &lt;font color=&quot;green&quot;&gt;绿色&lt;/font&gt;表示正常&lt;br&gt;    &lt;font color=&quot;yellow&quot;&gt;黄色&lt;/font&gt;表示执行正常，状态变化&lt;br&gt;    &lt;font color=&quot;red&quot;&gt;红色&lt;/font&gt;表示错误，输出错误信息&lt;br&gt;    &lt;font color=&quot;violet&quot;&gt;紫色&lt;/font&gt;表示警告，建议排查对应问题&lt;/p&gt;
&lt;h4 id=&quot;h4-1-command-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1）command模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1）command模块&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# 仅支持简单命令，不支持特殊符号，如管道符、星号等等……
# 这个模块时默认模块，ansible不加上模块，默认使用这个模块
ansible    all   -m   command  -a '命令'
ansible    all   -a '命令'
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-2-shell-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2）shell模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2）shell模块&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# 与command模块类似，shell模块支持特殊符号
ansible    all   -m   shell   -a '命令'
例如：
ansible all -m shell  -a  'ip a s eth0|sed -n 3p'
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3-script-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3）script模块-传输脚本到被管理端并执行&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3）script模块-传输脚本到被管理端并执行&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;# 传输脚本
# 执行脚本
ansible db -m script -a '脚本的绝对路径'
例如：
安装ipvsadm
#yum.sh内容
yum install -y ipvsadm

ansible db -m script -a '/data/software/shell/yum.sh'
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-4-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;4）命令与脚本模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;4）命令与脚本模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;含义&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;应用&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;command模块&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;执行命令&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;简单命令，不含特殊符号，默认的模块  ansible  all  -a  ‘hostname’&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;shell模块&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;执行命令或脚本&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;执行含有特殊符号的命令，或执行脚本（脚本需要在被管理端）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;script模块&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;先传输脚本，然后运行脚本&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;一般用于执行脚本&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-ans-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Ans-文件与目录管理模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Ans-文件与目录管理模块&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;file 创建文件，目录
copy 远程传输文件，目录，类似于scp
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-1-file-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1）file模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1）file模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;file模块中的选项&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;path&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;路径（目录，文件）必须要写&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;src&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;源文件  一般用于link（创建软连接模式）用于指定源文件&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;state&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;状态（模式），state=directory  创建目录，state=file（默认）   更新文件，如果文件不存在也不创建，state=link 创建软连接，state=touch  创建文件，state=absent 删除&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5-u521Bu5EFAu76EEu5F55&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;创建目录&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;创建目录&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible all -m file  -a 'path=/oldboy state=directory'
ansible all -a 'ls -ld /oldboy'
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5-u521Bu5EFAu6587u4EF6&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;创建文件&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;创建文件&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible all -m file -a 'path=/oldboy/oldbboy.txt  state=touch'
ansible all -a 'ls -l /lodboy'
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5-u521Bu5EFAu8F6Fu8FDEu63A5&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;创建软连接&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;创建软连接&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible all -m file -a 'src=/oldboy/oldboy.txt  path=/tmp/oldboy.txt.soft state=link'
ansible all -a 'ls -l /tmp/oldboy.txt.soft
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5--&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;删除目录/文件/软连接&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;删除目录/文件/软连接&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible all -m file  -a  'path=/oldboy state=absent'  #删除目录
ansible all -m file  -a  'path=/oldboy/oldboy.txt state=absent' #删除文件
ansible all -m file  -a  'path=/tmp/oldboy.txt.soft state=absent' #删除软连接
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5--tmp-oldboy-txt-root-root-755&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;创建文件/tmp/oldboy.txt, 所有者root  用户组root  权限755&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;创建文件/tmp/oldboy.txt, 所有者root  用户组root  权限755&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible all -m file  -a  'path=/tmp/oldboy.txt  owner=root  group=root  mode=755  state=touch'
ansible all -a 'ls -l /tmp/oldboy.txt.soft
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-2-copy-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2）copy远程传输模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2）copy远程传输模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;copy模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;src&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;source 源文件&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;dest&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;destination 目标&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;backup&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;backup=yes 则会在覆盖前进行备份&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;mode&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;修改权限&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;owner&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;修改为指定所有者&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;group&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;修改为指定用户组&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5--etc-hosts-etc-hosts&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;传输/etc/hosts文件到/etc/hosts&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;传输/etc/hosts文件到/etc/hosts&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible  all  -m  copy  -a  'src=/etc/hosts  dest=/etc/hosts'
ansible  all  -a  'tail  -2  /etc/hosts'
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-ans-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Ans-服务管理模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Ans-服务管理模块&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;systemctl  命令
启动/关闭/重启服务
开机自启动/开机不自启动
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-1-systemd&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1）systemd&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1）systemd&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;systemd模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;name&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;用于指定服务名称&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;enabled&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;yes开机自启动&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;state&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;表示服务开，关，重启… ,state=started 开启, state=stopped 关闭, state=reloaded 重读配置文件（服务支持） 很少支持，如sshd,nfs支持, state=restarted 重启（关闭再开启）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;daemon_reload&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;yes 是否重新加载对应的服务的管理配置文件&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5--firewalld&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;关闭firewalld&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;关闭firewalld&lt;/h5&gt;&lt;blockquote&gt;
&lt;p&gt;关闭正在运行的&lt;br&gt;关闭开机自启动&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible  all  -m  systemd  -a  'name=firewalld  enabled=no  state=stopped'
ansible  all  -a  'systemctl  status  firewalld'
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5--sshd-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;开启sshd服务&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;开启sshd服务&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible  all  -m  systemd  -a  'name=sshd  enabled=yes  state=started'
ansible  all  -a  'systemctl  status  sshd'
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5--backup-rsync-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;重启backup这台机器上面的rsync服务&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;重启backup这台机器上面的rsync服务&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible  backup  -m  systemd  -a  'name=rsyncd  state=restarted'
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-2-service-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2）service （了解&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2）service （了解&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;服务管理模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;systemd模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;service模块&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;开机自启动&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;enabled&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;enabled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;服务名称&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;name&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;name&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;服务开关重启&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;state&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;运行级别&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;无&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;runlevel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;重启加载systemctl配置&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;daemon_reload=yes  或者  systemctl  daemon-reload&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;无&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h4 id=&quot;h4-3-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3）服务管理模块小结&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3）服务管理模块小结&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;systemd&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;管理linux  红帽7以上推荐使用，Ubuntu等……&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;service&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;6及以下&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id=&quot;h3-ans-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Ans-软件包管理模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Ans-软件包管理模块&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;yum_repository（管理yum源）
yum（yum命令）
get_url（wget命令）
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-1-yum-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1）yum源配置管理模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1）yum源配置管理模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;yum源模块 yum_repository&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;yum源配置文件内容&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;name&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;[epel]&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;yum源中名字 （中括号里面的名字即可）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;description&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;name=xxxxxx&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;yum源的注释说明  对应的  是name的内容&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;baseurl&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;baserurl=&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;yum源中下载地址的地址（可以访问到repodata目录）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;enabled=yes或no&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;enabled=1或0&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;是否启动这个源  yes/no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;gpgcheck=yes或no&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;gpgcheck=0&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;是否启动gpgcheck功能  no&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;file（可以不加)&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;无&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;指定yum源的文件  自动添加.repo   例如file=xxx   默认与模块名字一致&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5--nginx-yum-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;批量添加nginx-yum源&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;批量添加nginx-yum源&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;[nginx]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

ansible web -m yum_repository -a 'name=nginxdescription=&quot;nginx stable repo&quot; baseurl=&quot;http://nginx.org/packages/centos/$releasever/$basearch/&quot; gpgcheck=noenabled=yes'
# 注意未来也可以通过copy模块实现
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-2-yum-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2）yum模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2）yum模块&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;通过yum命令安装软件
&lt;/code&gt;&lt;/pre&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;yum模块&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;name&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;指定软件包名字&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;state&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;installed  安装（present）, removed删除（absent）, latest安装或更新&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5--lrzsz&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;安装lrzsz&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;安装lrzsz&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible   all   -m  yum  -a  'name=lrzsz  state=installed'
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5-u5B89u88C5u591Au4E2A&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;安装多个&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;安装多个&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible  web  -m  yum -a  'name=sl,cowsay,aalib  state=installed'
    sl --命令sl  跑火车
    cowsay --命令animalsay &quot;文字&quot;  动物字符画
    aalib --命令aafire  火焰
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-3-get_url-wget-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;3）get_url模块（wget）&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;3）get_url模块（wget）&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;get_url下载功能&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;url&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;指定要下载的地址&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;dest&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;下载到哪个目录&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5--tengine-server-tools-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;下载tengine源码包到/server/tools/(不存在)⽬录下&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;下载tengine源码包到/server/tools/(不存在)⽬录下&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible web -m file -a 'path=/server/tools/  state=directory'
ansible web -m get_url -a 'url=https://tengine.taobao.org/download/tengine-2.3.3.tar.gz  dest=/server/tools/'
ansible web -a 'tree /server/tools/'
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-ans-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Ans-系统管理模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Ans-系统管理模块&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;mount 挂载nfs模块
cron 管理定时任务
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-1-mount-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1）mount模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1）mount模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;mount&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;fstype&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;指定文件系统&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;src&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;源地址（nfs地址 eg: 192.168.26.103/data）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;path&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;挂载点（要把源挂载到哪里）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;state&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;参考下表&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;mount模块的state参数可使用的值&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;absent&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;卸载并修改fstab&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;unmounted&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;卸载不修改/etc/fstab&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;present&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;仅修改/etc/fstab 不挂载&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;&lt;strong&gt;mounted&lt;/strong&gt;&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;挂载（mount命令）并修改/etc/fstab  （永久挂载）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;remounted&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;重新挂载&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5-web01-nfs-data-web01-upload_video&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;web01 把 nfs共享的目录/data目录挂载到 web01的/upload_video&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;web01 把 nfs共享的目录/data目录挂载到 web01的/upload_video&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;步骤01 web01上创建挂载点/upload_video
    ansible web -m file  -a  'path=/upload_video  state=directory'
步骤02 挂载nfs
    ansible web -m  mount -a 'fstype=nfs  src=&quot;192.168.26.103:/data&quot; path=/upload_video state=mounted ' 
    由于nfs那台实际没有nfs共享目录，所以会挂载失败
    ansible web -a 'df -h'
ansible web -a 'tail -2 /etc/fstab'
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-2-cron-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2）cron定时任务模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2）cron定时任务模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;cron模块&lt;/th&gt;
&lt;th&gt;定时任务配置中的内容&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;name&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;#及后面的内容&lt;/td&gt;
&lt;td&gt;定时任务名字（一定要加上），对应下面注释的内容&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;minute&lt;/td&gt;
&lt;td&gt;*/2&lt;/td&gt;
&lt;td&gt;分钟 minute=”*/2”，如果没有用到不用填写即可。&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;hour&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;小时&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;day&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;日期&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;month&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;月份&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;week&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;周几&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;job&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;命令/脚本&lt;/td&gt;
&lt;td&gt;指定命令或脚本（定向到空） job=”/sbin/ntpdate  ntp1.aliyun.com &amp;amp;&amp;gt;/dev/null”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;state&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;present&lt;/strong&gt; 添加定时任务 （默认是添加）     absent 删除&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h5 id=&quot;h5--1-sync-time&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;#1 sync time&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;#1 sync time&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;*/2 * * * * /sbin/ntpdate ntp1.aliyun.com  &amp;amp;&amp;gt;/dev/null
步骤01 备份数据 
    ansible all -a 'cp /var/spool/cron/root /tmp/' a n s ibl e a l l - a ' l s -l /tmp/root' 
    ansible all -a 'ls -l /tmp/root/'
    ansible all -a 'crontab -r'
步骤02 书写定时任务 
    ansible all  -m cron -a 'name=&quot;sync time by lidao 996 20221111&quot; minute=&quot;*/2&quot; job=&quot;/sbin/ntpdate ntp1.aliyun.com  &amp;amp;&amp;gt;/dev/null&quot; state=present'
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-ans-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;Ans-用户管理模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;Ans-用户管理模块&lt;/h3&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;group 创建组模块
user  创建用户模块
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-1-user&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;1）user&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;1）user&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;user模块&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;name&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;wwww 用户名&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uid&lt;/td&gt;
&lt;td&gt;指定uid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;group&lt;/td&gt;
&lt;td&gt;指定用户组&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;shell&lt;/td&gt;
&lt;td&gt;指定命令解释器&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;create_home&lt;/td&gt;
&lt;td&gt;是否创建家目录（yes/no）&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;state&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;present 添加    absent删除&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h6 id=&quot;h6--lidao996&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;创建用户lidao996&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;创建用户lidao996&lt;/h6&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible web -m user -a 'name=lidao996'
&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5--tengine-uid-10086&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;创建虚拟用户tengine，指定uid为10086&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;创建虚拟用户tengine，指定uid为10086&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;命令解释器：/sbin/nologin
不创建家目录
ansible web -m user -a 'name=tengine uid=190086  shell=/sbin/nologin  create_home=no state=present'
&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-2-group-&quot;&gt;&lt;a class=&quot;reference-link&quot; name=&quot;2)group模块&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;2)group模块&lt;/h4&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;group&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;name&lt;/td&gt;
&lt;td&gt;指定用户组名字&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gid&lt;/td&gt;
&lt;td&gt;指定组的gid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;state&lt;/td&gt;
&lt;td&gt;present添加   absent 删除&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/body&gt;</description><pubDate>Fri, 22 Mar 2024 17:27:35 +0800</pubDate></item><item><title>clickhouse集群及zookeeper集群手动配置安装</title><link>http://www.lilybug.cn/post/66.html</link><description>&lt;h3 id=&quot;h3-u524Du7F6Eu51C6u5907&quot;&gt;&lt;a name=&quot;前置准备&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;前置准备&lt;/h3&gt;&lt;p&gt;服务器信息&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;192.168.26.101
192.168.26.102
192.168.26.103&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;下载如下软件包并传送到指定目录&lt;code&gt;/data/software/clickhouse/&lt;/code&gt;&lt;br&gt;这边采用了&lt;code&gt;clickhouse 23.4.2.11&lt;/code&gt;与&lt;code&gt;zookeeper 3.8.4&lt;/code&gt;版本。&lt;br&gt;下载地址如下：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;https://packages.clickhouse.com/rpm/stable/clickhouse-common-static-23.4.2.11.x86_64.rpm
https://packages.clickhouse.com/rpm/stable/clickhouse-server-23.4.2.11.x86_64.rpm
https://packages.clickhouse.com/rpm/stable/clickhouse-client-23.4.2.11.x86_64.rpm
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;修改系统如下配置以达到clickhouse的要求&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;##系统前置配置
sudo vim /etc/security/limits.conf
##末尾加入如下内容
* soft nofile 65535
* hard nofile 65535
* soft nproc 131072
* hard nproc 131072

sudo vim /etc/security/limits.d/20-nproc.conf
##末尾加入如下内容
* soft nofile 65535
* hard nofile 65535
* soft nproc 131072
* hard nproc 131072

##安装依赖
yum install -y libtool
yum install -y *unixODBC*&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;h2--zookeeper-&quot;&gt;&lt;a name=&quot;安装zookeeper集群&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;安装zookeeper集群&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;cd /data/software/clickhouse/
tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz  -C /data/
mv /data/apache-zookeeper-3.8.4-bin  /data/zookerper-3.8.4
mkdir /data/zookerper-3.8.4/zkData
## server对应编号 如2或其他，每台服务器不同【这边我使用了ip最后一位作为myid】
echo &amp;quot;101&amp;quot; &amp;gt; /data/zookerper-3.8.4/zkData/myid
## 配置zoo.cfg
mv /data/zookerper-3.8.4/conf/zoo_sample.cfg /data/zookerper-3.8.4/conf/zoo.cfg
vim /data/zookerper-3.8.4/conf/zoo.cfg
# 修改数据存储路径配置
dataDir=/data/zookerper-3.8.4/zkData/
## 增加集群配置如下：
################cluster##############
server.101=192.168.26.101:2888:3888
server.102=192.168.26.102:2888:3888
server.103=192.168.26.103:2888:3888

## 配置参数解读
# server.A=B:C:D
# A是一个数字，表示这个是第几号服务器，集群模式下配置一个文件myid，这个文件在dataDir目录下，这个文件里有一个数据就是A的值我这边采用ip最后一位
# zookeeper启动时读取此文件，拿到里面的数据与zoo.cfg里的配置信息比较从而判断是哪个server
# B是这个服务器的地址
# C是这个服务器follower与集群中Leader服务器交换信息的端口，默认是2888
# D是集群中Leader服务器挂了以后，用来重新进行选举通信的端口，默认是3888

##启动集群
cd /data/zookerper-3.8.4/
bin/zkServer.sh start
##查看状态
bin/zkServer.sh status

## zookeeper的zoo.cfg 没有做本地适应配置，后续可增加，集群最少需要三台服务器才能完成选举&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;h2-clickhouse-&quot;&gt;&lt;a name=&quot;clickhouse 集群安装&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;clickhouse 集群安装&lt;/h2&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;##安装rpm包
cd /data/software/clickhouse/
rpm -ivh *.rpm
##修改配置文件 
vim /etc/clickhouse-server/config.xml
#数据文件路径 &amp;lt;path&amp;gt;/var/lib/clickhouse&amp;lt;/path&amp;gt;
#日志文件路径 &amp;lt;log&amp;gt;/var/log/clickhouse-server/clickhouse-server.log&amp;lt;/log&amp;gt;
#新增集群指定配置 &amp;lt;include_from&amp;gt;/etc/clickhouse-server/config.d/metrika.xml&amp;lt;include_from&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;配置clickhouse集群&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;vim /etc/clickhouse-server/config.d/metrika.xml

&amp;lt;?xml  version=&amp;quot;1.0&amp;quot;?&amp;gt;
&amp;lt;yandex&amp;gt;
  &amp;lt;remote_servers&amp;gt;
    &amp;lt;dq_ck_servers&amp;gt; &amp;lt;!--集群名称--&amp;gt;
      &amp;lt;shard&amp;gt;     &amp;lt;!--集群的第一个分片--&amp;gt;
        &amp;lt;internal_replication&amp;gt;true&amp;lt;/internal_replication&amp;gt;
        &amp;lt;replica&amp;gt; &amp;lt;!--第一个replica是分片本体--&amp;gt;
          &amp;lt;host&amp;gt;192.168.110.53&amp;lt;/host&amp;gt;
          &amp;lt;port&amp;gt;9002&amp;lt;/port&amp;gt;
        &amp;lt;/replica&amp;gt;

        &amp;lt;replica&amp;gt; &amp;lt;!--第二个replica是分片一号副本--&amp;gt;
          &amp;lt;host&amp;gt;192.168.110.59&amp;lt;/host&amp;gt;
          &amp;lt;port&amp;gt;9002&amp;lt;/port&amp;gt;
        &amp;lt;/replica&amp;gt;

        &amp;lt;replica&amp;gt; &amp;lt;!--第三个replica是分片二号副本--&amp;gt;
          &amp;lt;host&amp;gt;192.168.110.61&amp;lt;/host&amp;gt;
          &amp;lt;port&amp;gt;9002&amp;lt;/port&amp;gt;
        &amp;lt;/replica&amp;gt;    

      &amp;lt;/shard&amp;gt;
    &amp;lt;/dq_ck_servers&amp;gt;
  &amp;lt;/remote_servers&amp;gt;

  &amp;lt;zookeeper&amp;gt;
    &amp;lt;node index=&amp;quot;53&amp;quot;&amp;gt;
      &amp;lt;host&amp;gt;192.168.110.53&amp;lt;/host&amp;gt;
      &amp;lt;port&amp;gt;2181&amp;lt;/port&amp;gt;
    &amp;lt;/node&amp;gt;
    &amp;lt;node index=&amp;quot;59&amp;quot;&amp;gt;
      &amp;lt;host&amp;gt;192.168.110.59&amp;lt;/host&amp;gt;
      &amp;lt;port&amp;gt;2181&amp;lt;/port&amp;gt;
    &amp;lt;/node&amp;gt;
    &amp;lt;node index=&amp;quot;61&amp;quot;&amp;gt;
      &amp;lt;host&amp;gt;192.168.110.61&amp;lt;/host&amp;gt;
      &amp;lt;port&amp;gt;2181&amp;lt;/port&amp;gt;
    &amp;lt;/node&amp;gt;
  &amp;lt;/zookeeper&amp;gt;

  &amp;lt;macros&amp;gt;
    &amp;lt;shard&amp;gt;01&amp;lt;/shard&amp;gt;  &amp;lt;!--不同机器放的分片数不一样，这边是只有一分片两副本所以都是01--&amp;gt;
    &amp;lt;replica&amp;gt;rep_1_2&amp;lt;/replica&amp;gt;  &amp;lt;!--不同机器放的副本数不一样，这便是一分片两副本_2和_3是副本，_1是本体--&amp;gt;
  &amp;lt;/macros&amp;gt;
   &amp;lt;networks&amp;gt;
        &amp;lt;ip&amp;gt;::/0&amp;lt;/ip&amp;gt;
    &amp;lt;/networks&amp;gt;

&amp;lt;/yandex&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;启动指令&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;systemctl start clickhouse-server
systemctl restart clickhouse-server&lt;/code&gt;&lt;/pre&gt;
</description><pubDate>Thu, 21 Mar 2024 18:11:26 +0800</pubDate></item><item><title>ansible的安装及介绍</title><link>http://www.lilybug.cn/post/65.html</link><description>&lt;h3 id=&quot;h3-u524Du8A00&quot;&gt;&lt;a name=&quot;前言&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;前言&lt;/h3&gt;&lt;blockquote&gt;
&lt;p&gt;请提前使用&lt;a href=&quot;http://www.lilybug.cn/post/64.html&quot; title=&quot;分发脚本&quot;&gt;分发脚本&lt;/a&gt;对要管理的主机进行配置免密，否则可能会导致无法按照教程一步步使用ansible管理主机&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id=&quot;h3-u51C6u5907u6B65u9AA4&quot;&gt;&lt;a name=&quot;准备步骤&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;准备步骤&lt;/h3&gt;&lt;h4 id=&quot;h4-u5B89u88C5&quot;&gt;&lt;a name=&quot;安装&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;安装&lt;/h4&gt;&lt;p&gt;centos7的简单安装方式如下&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;yum install -y epel-release
yum install -y ansible&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-u914Du7F6Eu4E3Bu673Au6E05u5355&quot;&gt;&lt;a name=&quot;配置主机清单&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;配置主机清单&lt;/h4&gt;&lt;p&gt;默认的主机清单位置在&lt;code&gt;/etc/ansible/hosts&lt;/code&gt;如无使用&lt;code&gt;-i 指定文件名&lt;/code&gt;进行指定主机清单，将会默认使用这个主机清单&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;vim   /etc/ansible/hosts
# 分组名自定义[分组名]下面几行是分组的主机ip
[oldboy]
192.168.26.101
192.168.26.102
192.168.26.103
192.168.26.104&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-u4F7Fu7528u65B9u6CD5&quot;&gt;&lt;a name=&quot;使用方法&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;使用方法&lt;/h4&gt;&lt;p&gt;[oldboy]是分组名 ping是模块名&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;ansible oldboy -m ping&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3-ansible-&quot;&gt;&lt;a name=&quot;ansible 基础说明&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;ansible 基础说明&lt;/h3&gt;&lt;h4 id=&quot;h4-ansible-&quot;&gt;&lt;a name=&quot;ansible 命令格式&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;ansible 命令格式&lt;/h4&gt;&lt;pre&gt;&lt;code&gt;ansible   主机分组  -m  指定模块
ansible   主机分组  -m  指定模块  -a  指定模块中的选项&lt;/code&gt;&lt;/pre&gt;&lt;blockquote&gt;
&lt;p&gt; 注意！批量执行与管理时不要执行交互式命令&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id=&quot;h4-ansible-&quot;&gt;&lt;a name=&quot;ansible 配置文件&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;ansible 配置文件&lt;/h4&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;/etc/ansible/ansible.cfg   # ansible的配置文件
host_key_checking = False #取消这行注释，是用来避免连接新机器时出现yes/no的确认
/etc/ansible/hosts            # ansible的默认主机清单&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;h4-ansible-&quot;&gt;&lt;a name=&quot;ansible 主机清单&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;ansible 主机清单&lt;/h4&gt;&lt;h5 id=&quot;h5-u57FAu672Cu683Cu5F0F&quot;&gt;&lt;a name=&quot;基本格式&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;基本格式&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;[oldboy]  #[分组名]
192.168.26.101
192.168.26.102
192.168.26.103
192.168.26.104&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5--&quot;&gt;&lt;a name=&quot;指定用户名，密码，端口&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;指定用户名，密码，端口&lt;/h5&gt;&lt;blockquote&gt;
&lt;p&gt;不推荐 建议使用上面的基本格式，并且做免密登录分发&lt;/p&gt;
&lt;/blockquote&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&quot;text-align:center&quot;&gt;主机清单中指定的信息&lt;/th&gt;
&lt;th style=&quot;text-align:center&quot;&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;连接的ssh端口&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;ansible_ssh_port=22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;连接的ssh用户&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;ansible_ssh_user=root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&quot;text-align:center&quot;&gt;连接的ssh密码&lt;/td&gt;
&lt;td style=&quot;text-align:center&quot;&gt;ansible_ssh_pass=’Aa142536’&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;写法如下：&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;[oldboy]  #[分组名]
192.168.26.101   ansible_ssh_port=22  ansible_ssh_user=root  ansible_ssh_pass=&amp;#39;Aa142536&amp;#39;&lt;/code&gt;&lt;/pre&gt;
&lt;h5 id=&quot;h5-u5B50u7EC4&quot;&gt;&lt;a name=&quot;子组&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;子组&lt;/h5&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;[web]
192.168.26.101
[db]
192.168.26.104
[nfs]
192.168.26.103
[backup]
192.168.26.102

[data:children] #data:children表示data是创建的子组，组里包含db，nfs，backup3个组
db
nfs
backup&lt;/code&gt;&lt;/pre&gt;
&lt;blockquote&gt;
&lt;p&gt;注：使用ansible命令时如果需要调用所有，则在分组名写all，如果需要调用单台则使用ip&lt;/p&gt;
&lt;/blockquote&gt;
</description><pubDate>Tue, 19 Mar 2024 17:57:01 +0800</pubDate></item><item><title>ssh免密登录的分发脚本</title><link>http://www.lilybug.cn/post/64.html</link><description>&lt;h3 id=&quot;h3--&quot;&gt;&lt;a name=&quot;第一步  密钥创建&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;第一步  密钥创建&lt;/h3&gt;&lt;p&gt;使用如下脚本创建密钥对&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;#!/bin/bash
echo &amp;quot;创建ssh-keygen&amp;quot;
ssh-keygen -t rsa -f /root/.ssh/id_rsa -N &amp;quot;&amp;quot; # 这边由于使用空密码，所以-N和-P都可以
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;h3--&quot;&gt;&lt;a name=&quot;第二步  分发密钥到指定主机&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;第二步  分发密钥到指定主机&lt;/h3&gt;&lt;p&gt;一般建议主机使用相同密码，如密码不同请手动更改脚本适配密码&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;#!/bin/bash

ip_list=&amp;quot;
192.168.26.101
192.168.26.102
192.168.26.103
&amp;quot;
echo &amp;quot;分发 pub key&amp;quot;

for ip in $ip_list
do
    sshpass -pAa142536 ssh-copy-id -i /root/.ssh/id_rsa.pub -o StrictHostKeyChecking=no root@${ip}
done
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;如果所有密码都不同，这边建议直接使用一一对应的命令或脚本创建&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;#!/bin/bash
echo &amp;quot;分发 pub key&amp;quot;

sshpass -p11111111 ssh-copy-id -i /root/.ssh/id_rsa.pub -o StrictHostKeyChecking=no root@192.169.26.101
sshpass -p22222222 ssh-copy-id -i /root/.ssh/id_rsa.pub -o StrictHostKeyChecking=no root@192.169.26.102
sshpass -p33333333 ssh-copy-id -i /root/.ssh/id_rsa.pub -o StrictHostKeyChecking=no root@192.169.26.103
&lt;/code&gt;&lt;/pre&gt;
</description><pubDate>Tue, 19 Mar 2024 17:44:08 +0800</pubDate></item><item><title>关于CentOS6访问https证书错误返回x509: certificate signed by unknown authority</title><link>http://www.lilybug.cn/post/63.html</link><description>&lt;h2 id=&quot;h2-u5F15u8A00&quot;&gt;&lt;a name=&quot;引言&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;引言&lt;/h2&gt;&lt;p&gt;今天突然接到一个开发反馈奇怪的报错，说访问证书返回报错&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; x509: certificate signed by unknown authority try-again: 2&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2023/05/202305181535245938717.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;h2-u6392u67E5&quot;&gt;&lt;a name=&quot;排查&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;排查&lt;/h2&gt;&lt;p&gt;一开始觉得可能是对方证书过期了，毕竟他们一开始反馈过来说是证书过期让我处理，我一看，诶证书是三月份刚换的那批，应该是没有问题的，于是我登录服务器看，发现时间是往前调的。但是调了才几天，理论上只要系统时间没有到达证书过期时间就没有事才对。&lt;/p&gt;
&lt;p&gt;因为他们是付费通配证书，理论上不应该出现这个报错，这个报错我逐字翻译了一下是“由未知权威机构签署的证书”的意思，按照常规道理来说，这个报错应该是自签证书导致，但是这个证书并非自签证书。&lt;/p&gt;
&lt;p&gt;于是我继续往下思考与寻找，直到找到这篇文章：&lt;a href=&quot;https://shagain.club/index.php/archives/462/&quot;&gt;RHEL/CentOS 7 修复 Let’s Encrypt 更改&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;原文大概意思是：&lt;br&gt;使用 Centos 7 在 2021年9月30日起环境出现异常现象是由于CA证书过期问题引起的可执行下列命令更新CA证书，CA证书过期会导致一些安全的curl SSL请求异常。&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;yum install -y ca-certificates
update-ca-trust&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;经过分析与判断，可能就是这个原因。于是我尝试执行了更新，由于系统是老的CentOS6.5的，我yum以前提前做了repo的替换，换成南开大学的yum源，然后执行上述命令。&lt;br&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2023/05/202305181543585506049.png&quot; alt=&quot;&quot;&gt;&lt;br&gt;经过安装处理后，让开发再去测试，发现已经正常了。&lt;/p&gt;
&lt;h2 id=&quot;h2-u603Bu7ED3u5206u6790&quot;&gt;&lt;a name=&quot;总结分析&quot; class=&quot;reference-link&quot; href=&quot;#&quot;&gt;&lt;/a&gt;&lt;span class=&quot;header-link octicon octicon-link&quot;&gt;&lt;/span&gt;总结分析&lt;/h2&gt;&lt;p&gt;分析原因可能是系统的CA根证书太久远，无法识别这个证书颁发者，只要更新一下CA根证书就好了。这种情况仅适用于较老的机子可能有这个问题，如果是新搭建的机子可能要分析一下是否有其它问题了。&lt;br&gt;以上就是本次事件的解决过程及分析，做个记录，希望下次不要再遇到了&lt;br&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2023/05/202305181546248384612.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
</description><pubDate>Thu, 18 May 2023 15:32:23 +0800</pubDate></item><item><title>常见python第三方库</title><link>http://www.lilybug.cn/post/61.html</link><description>&lt;h3&gt;数据分析&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Numpy：表达N维数组的最基础库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Pandas：python数据分析高层次应用库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;SciPy：数学、科学和工程计算功能库&lt;/p&gt;&lt;h3&gt;数据可视化&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Matplotlib：高质量的二维数据可视化功能库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Seaborn：统计类数据可视化功能库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Mayavi：三维科学数据可视化功能库&lt;/p&gt;&lt;h3&gt;文本处理&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;PyPDF2：用来处理PDF文件的工具集&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;NLTK：自然语言文本处理第三方库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Python-docx：创建或更新Microsoft Word文件的第三方库&lt;/p&gt;&lt;h3&gt;机器学习&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Scikit-learn：机器学习方法工具集，与数据处理相关的第三方库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;TensorFlow：AlphaGo背后的机器学习计算框架&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;MXNet：基于神经网络的深度学习计算框架&lt;/p&gt;&lt;h3&gt;爬虫&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Requests：最友好的网络爬虫功能库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Scrapy：优秀的网络爬虫框架，Python数据分析高层次应用库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pyspider：强大的Web页面爬取系统&lt;/p&gt;&lt;h3&gt;信息解析&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Beautiful Soup：HTML和XML的解析库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Re：正则表达式解析和处理功能库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Python-Goose：提取文章类型Web页面的功能库&lt;/p&gt;&lt;h3&gt;网站开发&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Django：最流行的Web应用框架&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Pyramid：规模适中的Web应用框架&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Flask：Web应用开发微框架&lt;/p&gt;&lt;h3&gt;网络应用开发&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;WeRobot：微信公众号开发框架&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;aip：百度AI开放平台接口&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;MyQR：二维码生成第三方库&lt;/p&gt;&lt;h3&gt;图形用户界面&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;PyQt5：Qt开发框架的python接口&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;wxPython：跨平台GUI开发框架&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pyGObject：使用GTK+开发的GUI的功能库（Anaconda就是用这个开发的）&lt;/p&gt;&lt;h3&gt;游戏开发&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Pygame：简单的游戏开发功能库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Panda3D（3D游戏引擎）：开源、跨平台的3D渲染和游戏开发库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;cocos2d（2d游戏框架）：构建2D游戏和图形界面交互式应用的框架&lt;/p&gt;&lt;h3&gt;虚拟现实&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;VR Zero：在树莓派上开发VR应用的python库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;pyovr：Oculus Rift针对Oculus VR设备的开发库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Vizard：基于Python的通用VR开发引擎&lt;/p&gt;&lt;h3&gt;图形艺术&lt;/h3&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;Quads：迭代的艺术|像素风&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;ascii_art：ASCII艺术库&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;turtle：海龟绘图体系（Random Art）&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Thu, 05 Aug 2021 16:55:17 +0800</pubDate></item><item><title>完蛋！服务器中毒了！该怎么办！救救孩子！</title><link>http://www.lilybug.cn/post/60.html</link><description>&lt;h1&gt;前情提要&lt;/h1&gt;&lt;p&gt;今天收到同事提醒，mysql占用了很高进程&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;http://www.lilybug.cn/zb_users/upload/2021/05/202105281622192607187381.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;仔细一看这个进程与mysql十分高仿，于是粗略判断服务器可能中毒了&lt;/p&gt;&lt;h1&gt;病毒发现&lt;/h1&gt;&lt;p&gt;对进程进行搜索，发现进程是保存在tmp目录下，那么就需要进入那个目录看下&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;http://www.lilybug.cn/zb_users/upload/2021/05/202105281622192899382275.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;在目录下看到不仅有mysqldd还有httpdd，有更多的病毒&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;ue-image&quot; src=&quot;http://www.lilybug.cn/zb_users/upload/2021/05/202105281622192947245787.png&quot;/&gt;&lt;/p&gt;&lt;h1&gt;病毒处理&lt;/h1&gt;&lt;p&gt;这边参考资料：&lt;a href=&quot;http://www.imcoder.fun/content/1583244856309&quot; target=&quot;_self&quot;&gt;记一次Linux挖矿病毒的清除与原因分析&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;进行处理及删除&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;chattr&amp;nbsp;-i&amp;nbsp;mysqldd&amp;nbsp;httpdd&amp;nbsp;nginxdd
rm&amp;nbsp;-rf&amp;nbsp;&amp;nbsp;mysqldd&amp;nbsp;httpdd&amp;nbsp;nginxdd&lt;/pre&gt;&lt;p&gt;然而只要杀死进程它就会重新生成&lt;/p&gt;&lt;p&gt;发现他们的PPID都是10391还有一个是1&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2021/05/202105281622196443376462.png&quot; alt=&quot;image.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;于是尝试使用ps来查看脚本&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;ps&amp;nbsp;-ef&amp;nbsp;|&amp;nbsp;grep&amp;nbsp;-v&amp;nbsp;&amp;quot;\[*\]&amp;quot;&lt;/pre&gt;&lt;p&gt;发现如下进程号的异常脚本及它对应的PPID号&amp;nbsp;于是一起kill掉并rm-rf删掉&lt;br/&gt;&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;kill&amp;nbsp;-9&amp;nbsp;28998&amp;nbsp;28931&amp;nbsp;28911&amp;nbsp;10391&amp;nbsp;31569
rm&amp;nbsp;-rf&amp;nbsp;&amp;nbsp;mysqldd&amp;nbsp;httpdd&amp;nbsp;nginxd&amp;nbsp;ecsgo-helper&amp;nbsp;hsperfdata_root&lt;/pre&gt;&lt;p&gt;刚以为已经没有生成的时候，一闪而过的exe进程瞬间警觉&lt;/p&gt;&lt;p&gt;可能是通过mail进行通知&lt;/p&gt;&lt;p&gt;于是关闭了系统mail提示，清空了mail&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;echo&amp;nbsp;&amp;quot;unset&amp;nbsp;MAILCHECK&amp;quot;&amp;gt;&amp;gt;&amp;nbsp;/etc/profile
source&amp;nbsp;/etc/profile
ls&amp;nbsp;-lth&amp;nbsp;/var/spool/mail/
cat&amp;nbsp;/dev/null&amp;nbsp;&amp;gt;&amp;nbsp;/var/spool/mail/root&lt;/pre&gt;&lt;p&gt;从top观察了几分钟&amp;nbsp;姑且算是恢复正常了&amp;nbsp; 后续将持续观察后续状况及后续安全问题&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2021/05/202105281622198634152530.png&quot; alt=&quot;image.png&quot;/&gt;&lt;/p&gt;</description><pubDate>Fri, 28 May 2021 17:18:03 +0800</pubDate></item><item><title>matplotlib库使用——生成折线图表</title><link>http://www.lilybug.cn/post/59.html</link><description>&lt;pre class=&quot;prism-highlight prism-language-python&quot;&gt;import&amp;nbsp;matplotlib.pyplot&amp;nbsp;as&amp;nbsp;plt

x_temp&amp;nbsp;=&amp;nbsp;[&amp;#39;这里放入纵坐标数据&amp;#39;]&amp;nbsp;&amp;nbsp;#&amp;nbsp;涉及科研数据，此处不放出完整数据，用来存放横坐标数据
y_temp1&amp;nbsp;=&amp;nbsp;[&amp;#39;此次数据的分子部分&amp;#39;]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;纵坐标的分子数据
y_temp2&amp;nbsp;=&amp;nbsp;[&amp;#39;此次数据的分母部分&amp;#39;]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;纵坐标的分母数据
y_temp=[]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;空列表&amp;nbsp;用来存放纵坐标数据
for&amp;nbsp;num&amp;nbsp;in&amp;nbsp;range(0,19):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;计算并添加纵坐标数据进空列表
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y_num&amp;nbsp;=&amp;nbsp;float(y_temp1[num])/float(y_temp2[num])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y_temp.append(y_num)
print(y_temp)

#&amp;nbsp;由于数据存在补点，需要重新排序，所以需要先绑定数据对应关系，然后进行排序
#&amp;nbsp;按排序前的顺序制作成字典，用来绑定x列表和y列表数值间的对应关系，避免后面排序后数据混乱
data&amp;nbsp;=&amp;nbsp;dict(zip(y_temp,&amp;nbsp;x_temp))
print(data)

#&amp;nbsp;通过冒泡排序对y列表进行排序
n&amp;nbsp;=&amp;nbsp;len(y_temp)
#&amp;nbsp;遍历所有数组元素
for&amp;nbsp;i&amp;nbsp;in&amp;nbsp;range(n):

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;Last&amp;nbsp;i&amp;nbsp;elements&amp;nbsp;are&amp;nbsp;already&amp;nbsp;in&amp;nbsp;place
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&amp;nbsp;j&amp;nbsp;in&amp;nbsp;range(0,&amp;nbsp;n&amp;nbsp;-&amp;nbsp;i&amp;nbsp;-&amp;nbsp;1):

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;y_temp[j]&amp;nbsp;&amp;gt;&amp;nbsp;y_temp[j&amp;nbsp;+&amp;nbsp;1]:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;y_temp[j],&amp;nbsp;y_temp[j&amp;nbsp;+&amp;nbsp;1]&amp;nbsp;=&amp;nbsp;y_temp[j&amp;nbsp;+&amp;nbsp;1],&amp;nbsp;y_temp[j]

print(&amp;quot;排序后的数组:&amp;quot;)
print(y_temp)

#按排序后的y顺序调整x顺序
y&amp;nbsp;=&amp;nbsp;y_temp
x&amp;nbsp;=&amp;nbsp;[]
for&amp;nbsp;x_num&amp;nbsp;in&amp;nbsp;range(0,19):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print(y[x_num])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x_temp_num&amp;nbsp;=&amp;nbsp;data.get(y[x_num])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.append(x_temp_num)

print(x)
#&amp;nbsp;添加的语句如下面虚线分隔起来的部分所示：
#&amp;nbsp;---------------------------------------------
ax&amp;nbsp;=&amp;nbsp;plt.gca()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;得到图像的Axes对象
plt.title(&amp;quot;幅频特性曲线&amp;quot;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;标题名称
plt.rcParams[&amp;#39;font.sans-serif&amp;#39;]&amp;nbsp;=&amp;nbsp;[&amp;#39;SimHei&amp;#39;]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;避免中文乱码
plt.rcParams[&amp;#39;axes.unicode_minus&amp;#39;]&amp;nbsp;=&amp;nbsp;False&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;避免符号乱码
plt.plot(y,&amp;nbsp;x,&amp;nbsp;color=&amp;#39;blue&amp;#39;,&amp;nbsp;linestyle=&amp;#39;solid&amp;#39;,&amp;nbsp;marker=&amp;#39;o&amp;#39;)
plt.xlabel(&amp;quot;周期比&amp;quot;,&amp;nbsp;horizontalalignment=&amp;#39;left&amp;#39;,&amp;nbsp;verticalalignment=&amp;#39;top&amp;#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;x轴名称
plt.ylabel(&amp;quot;θ/度&amp;quot;,&amp;nbsp;horizontalalignment=&amp;#39;left&amp;#39;,&amp;nbsp;verticalalignment=&amp;#39;bottom&amp;#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;y&amp;nbsp;轴名称

#&amp;nbsp;---------------------------------------------
#&amp;nbsp;如果有正负轴，则需要重新设定轴线，可以参考以下代码进行设定轴线
#&amp;nbsp;ax.spines[&amp;#39;right&amp;#39;].set_color(&amp;#39;none&amp;#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;将图像右边的轴设为透明
#&amp;nbsp;ax.spines[&amp;#39;top&amp;#39;].set_color(&amp;#39;none&amp;#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;将图像上面的轴设为透明
#&amp;nbsp;ax.xaxis.set_ticks_position(&amp;#39;bottom&amp;#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;将x轴刻度设在下面的坐标轴上
#&amp;nbsp;ax.yaxis.set_ticks_position(&amp;#39;left&amp;#39;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;将y轴刻度设在左边的坐标轴上
#&amp;nbsp;ax.spines[&amp;#39;bottom&amp;#39;].set_position((&amp;#39;data&amp;#39;,&amp;nbsp;0))&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;将两个坐标轴的位置设在数据点原点
#&amp;nbsp;ax.spines[&amp;#39;left&amp;#39;].set_position((&amp;#39;data&amp;#39;,&amp;nbsp;0))

#&amp;nbsp;画出图像
plt.savefig(&amp;#39;幅频特性曲线.png&amp;#39;,&amp;nbsp;dpi=200)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;直接保存图像，dpi=200是为了避免图像失真
plt.show()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#&amp;nbsp;如果后续还有代码，需要使用plt.close()不然会无法执行后续代码&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Sat, 22 May 2021 19:23:15 +0800</pubDate></item><item><title>关于Protected multilib versions:glib2-2.28.8-10.el6.i686 != glib2-2.28.8-5.el6.x86_64问题解决办法</title><link>http://www.lilybug.cn/post/58.html</link><description>&lt;p&gt;今天在处理一台服务器环境时，遇到了如下问题&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;yum install glib2报错如下&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2021/04/202104011617270536633764.png&quot; alt=&quot;image.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;在百度上查阅了许多资料，均说在执行命令后面加上：--setopt=protected_multilib=false&amp;nbsp;进行处理&lt;/p&gt;&lt;p&gt;但是我按照该操作进行了操作之后均会报错&lt;/p&gt;&lt;p&gt;于是参考了外网资料&lt;a href=&quot;https://cloudpack.media/3439&quot; _src=&quot;https://cloudpack.media/3439&quot;&gt;https://cloudpack.media/3439&lt;/a&gt; &lt;/p&gt;&lt;p&gt;使用yum check &amp;gt;./yum.log的方式进行check&lt;/p&gt;&lt;p&gt;出现新的报错如下&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2021/04/202104011617270664865758.png&quot; alt=&quot;image.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;根据新的报错资料，定位报错问题&lt;/p&gt;&lt;p&gt;查看外网资料，有可能是rpm数据库损坏，于是参考&lt;a href=&quot;https://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library&quot; _src=&quot;https://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library&quot;&gt;https://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library&lt;/a&gt;&lt;/p&gt;&lt;p&gt;进行了修复&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;mkdir&amp;nbsp;/var/lib/rpm/backup
cp&amp;nbsp;-a&amp;nbsp;/var/lib/rpm/__db*&amp;nbsp;/var/lib/rpm/backup/
rm&amp;nbsp;-f&amp;nbsp;/var/lib/rpm/__db.[0-9][0-9]*
rpm&amp;nbsp;--quiet&amp;nbsp;-qa
rpm&amp;nbsp;--rebuilddb
yum&amp;nbsp;clean&amp;nbsp;all&lt;/pre&gt;&lt;p&gt;重新yum install glib2依旧是一样的报错&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2021/04/202104011617270729618372.png&quot; alt=&quot;image.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;重新运行yum check &amp;gt; ./yum.log&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2021/04/202104011617270746288502.png&quot; alt=&quot;image.png&quot;/&gt;&lt;/p&gt;&lt;p&gt;可以看到check是没有报错的&lt;/p&gt;&lt;p&gt;所以排除了这个可能&lt;/p&gt;&lt;p&gt;重新查找到外网资料&lt;a href=&quot;https://serverfault.com/questions/597168/solving-multilib-version-problems&quot; _src=&quot;https://serverfault.com/questions/597168/solving-multilib-version-problems&quot;&gt;https://serverfault.com/questions/597168/solving-multilib-version-problems&lt;/a&gt;&lt;/p&gt;&lt;p&gt;给出的同时yum install glib2.x86_64&amp;nbsp; glib2.i686的方法&lt;/p&gt;&lt;p&gt;成功解决了问题&amp;nbsp;&lt;/p&gt;&lt;p&gt;根据解决问题中途遇到的问题总结&lt;/p&gt;&lt;ol class=&quot; list-paddingleft-2&quot; style=&quot;list-style-type: decimal;&quot;&gt;&lt;li&gt;&lt;p&gt;该问题是由于在系统中同时存在glib2.x86_64&amp;nbsp; glib2.i686的导致&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;如果无脑直接--setopt=protected_multilib=false有概率造成系统的rpm数据库损坏。&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;如果无法卸载多余版本，需同时升级多版本库的文件，避免造成文件损坏及系统损坏&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;参考资料：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://cloudpack.media/3439&quot; _src=&quot;https://cloudpack.media/3439&quot; style=&quot;white-space: normal;&quot;&gt;https://cloudpack.media/3439&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library&quot; _src=&quot;https://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library&quot; style=&quot;white-space: normal;&quot;&gt;https://cloudlinux.zendesk.com/hc/en-us/articles/115004075294-Fix-rpmdb-Thread-died-in-Berkeley-DB-library&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://serverfault.com/questions/597168/solving-multilib-version-problems&quot; _src=&quot;https://serverfault.com/questions/597168/solving-multilib-version-problems&quot; style=&quot;white-space: normal;&quot;&gt;https://serverfault.com/questions/597168/solving-multilib-version-problems&lt;/a&gt;&lt;/p&gt;</description><pubDate>Thu, 01 Apr 2021 17:13:36 +0800</pubDate></item><item><title>centos安装redis</title><link>http://www.lilybug.cn/post/56.html</link><description>&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    下载地址：http://redis.io/download，下载最新稳定版本
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    目前稳定版本是6.0.9 下载地址 https://download.redis.io/releases/redis-6.0.9.tar.gz
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;4674-1607384923581&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;wget https://download.redis.io/releases/redis-6.0.9.tar.gz
tar xzf redis-6.0.9.tar.gz
cd redis-6.0.9
make&lt;/pre&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    此处会报错make[1]: *** [server.o] Error 1
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608542971607710.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    有可能是gcc版本过低，可通过gcc -v查看
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
   &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608542981136365.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    redis需要gcc 5.3 以上，所以需要手动升级gcc
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;9974-1608195020171&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

#临时修改gcc版本
scl enable devtoolset-9 bash
#永久修改gcc版本
echo &amp;quot;source /opt/rh/devtoolset-9/enable&amp;quot; &amp;gt;&amp;gt;/etc/profile&lt;/pre&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    再次运行make，提示如下
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608542992816174.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    建议我们运行make test ，那我们就运行一下make test看下报错
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543001442933.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    提示我们tcl版本需要8.5以上
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    于是执行如下命令安装tcl 8.5
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;2049-1608195530429&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;wget http://mirror.centos.org/centos/7/os/x86_64/Packages/tcl-8.5.13-8.el7.x86_64.rpm
rpm -ivh tcl-8.5.13-8.el7.x86_64.rpm&lt;/pre&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    安装后已就报错如下
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543010192394.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    经过反复查询验证，最后使用参考资料（https://blog.csdn.net/ok532655221/article/details/106826822）的方式，进入报错文件tests/integration/replication.tcl修改wait_for_condition 的值为100 1000，然后重新执行make test就通过运行了
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;vim tests/integration/replication.tcl
test {Slave enters handshake} {
            wait_for_condition 100 1000 {
                [string match *handshake* [$slave role]]
            } else {
                fail &amp;quot;Replica does not enter handshake state&amp;quot;
            }
        }&lt;/pre&gt;
&lt;/div&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543024317603.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/p&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    执行完 make 命令后，redis-6.0.9 的 src 目录下会出现编译后的 redis 服务程序 redis-server，还有用于测试的客户端程序 redis-cli
&lt;/p&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    下面启动 redis 服务
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;8940-1607385004473&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;cd src
./redis-server&lt;/pre&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;image&quot; style=&quot;float: none;&quot;&gt;
   &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543036178050.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    注意这种方式启动 redis 使用的是默认配置。也可以通过启动参数告诉 redis 使用指定配置文件使用下面命令启动。
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;8270-1607385024129&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;cd src
./redis-server ../redis.conf&lt;/pre&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    redis.conf 是一个默认的配置文件。我们可以根据需要使用自己的配置文件。
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;paragraph&quot; style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    &lt;span style=&quot;font-size: 13px; color: #333333; background-color: #FFFFFF;&quot;&gt;启动 redis 服务进程后，就可以使用测试客户端程序 redis-cli 和 redis 服务交互了。&lt;/span&gt;
&lt;/div&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;5724-1607385057531&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;cd src
./redis-cli
127.0.0.1:6379&amp;gt; set foo bar
OK
127.0.0.1:6379&amp;gt; get foo
&amp;quot;bar&amp;quot;&lt;/pre&gt;
&lt;/div&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    注：如果使用ctrl+z将redis-server给stop的话，会出现cli进不去的现象
&lt;/p&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543067205877.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/p&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    这种情况是因为redis-server被stop了
&lt;/p&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543095156417.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/p&gt;
&lt;p style=&quot;white-space: pre-wrap; line-height: 1.75;&quot;&gt;
    针对这种情况，先结束掉redis的进程 然后进行如下操作：
&lt;/p&gt;
&lt;div yne-bulb-block=&quot;code&quot; id=&quot;8141-1608458701656&quot; data-theme=&quot;default&quot; data-language=&quot;javascript&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
    &lt;pre class=&quot;prism-highlight prism-language-bash&quot;&gt;解决方法一：开启server后，开辟另一个终端redis-cli即可
解决方法二：修改redis.conf文件将daemonize改成yes，并且通过redis.conf即可。
 ./redis-server ../redis.conf&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543252206122.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/p&gt;
&lt;p&gt;
    然后就可以通过redis-cli连接了
&lt;/p&gt;
&lt;p&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543346407300.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/p&gt;
&lt;p&gt;
    &lt;img src=&quot;http://www.lilybug.cn/zb_users/upload/2020/12/202012211608543389471222.png&quot; alt=&quot;image.png&quot;/&gt;
&lt;/p&gt;</description><pubDate>Mon, 21 Dec 2020 17:06:49 +0800</pubDate></item></channel></rss>