1、环境 2、解析 3、密码
SSH免密登陆 ping 4、查看项目文件 5、源码包地址 6、下载源码包
bao.yml 空运行 7、编写主机变量文件 pei.yml文件 8、编写源码安装apache文件
install.yml文件 验证语法 空运行 执行playbook文件 9、在浏览器用HTTP主机IP访问 10、总结:源码安装apache
1、环境
| 服务 | ip |
| — | — |
| ansible | 192.168.129133 |
| httpd | 192.168.129.135 |
2、解析
[root@ansible ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.129.133 httpd
3、密码
SSH免密登陆
[root@ansible ~]# ssh-keygen -t rsa #生成密钥,指定加密方式 ,下面默认一路回车即可
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory ‘/root/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:m9UgEbkFLID4MnlRrsmn76K0ARRhb6NEScTM1etAfEM root@ansible
The key’s randomart image is:
±–[RSA 3072]----+
|*O=+=E .++ |
|+==+ +. o… |
| =.=o o…o. |
|*.=+… … o |
|.=+ + S . . |
|. o . + |
| o. o |
|. +. |
|.o oo |
±—[SHA256]-----+
[root@ansible ~]# ssh-copy-id root@httpd #传递公钥
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”
The authenticity of host ‘httpd (192.168.129.133)’ can’t be established.
ECDSA key fingerprint is SHA256:+wH81RHiBmLpbkuk2OWGZxVRziiaNwJ9KAVjGtEM8zs.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keys
root@httpd’s password:
Number of key(s) added: 1
Now try logging into the machine, with: “ssh ‘root@httpd’”
and check to make sure that only the key(s) you wanted were added.
ping
[root@ansible playbook]# ansible all -m ping
192.168.129.135 | SUCCESS => {
“ansible_facts”: {
“discovered_interpreter_python”: “/usr/libexec/platform-python”
},
“changed”: false,
“ping”: “pong”
}
4、查看项目文件
[root@ansible playbook]# tree
.
├── bao.yml
├── install.yml
└── pei.yml
5、源码包地址
wget https://mirrors.bfsu.edu.cn/apache/apr/apr-1.7.0.tar.gz
wget https://mirrors.bfsu.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
wget https://mirrors.bfsu.edu.cn/apache/httpd/httpd-2.4.48.tar.gz
6、下载源码包
bao.yml
[root@ansible playbook]# cat bao.yml
hosts: httpd
tasks:
name: httpd
get_url:
url: https://mirrors.bfsu.edu.cn/apache/httpd/httpd-2.4.48.tar.gz
dest: /opt
name: apr
get_url:
url: https://mirrors.bfsu.edu.cn/apache/apr/apr-1.7.0.tar.gz
dest: /opt
name: apr-util
get_url:
url: https://mirrors.bfsu.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
dest: /opt
空运行
[root@ansible playbook]# ansible-playbook -C bao.yml
PLAY [httpd] ********************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************
ok: [192.168.129.135]
TASK [httpd] ********************************************************************************************************************************************************
changed: [192.168.129.135]
TASK [apr] **********************************************************************************************************************************************************
changed: [192.168.129.135]
TASK [apr-util] *****************************************************************************************************************************************************
changed: [192.168.129.135]
PLAY RECAP **********************************************************************************************************************************************************
192.168.129.135 : ok=4 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
7、编写主机变量文件 pei.yml文件
[root@ansible playbook]# cat pei.yml
dell: gcc,gcc-c++,perl,perl-devel,expat-devel,pcre-devel,pcre
apr_install: " cd /root/apr-1.7.0/ && ./configure --prefix=/usr/local/apr && make && make install "
apr_util_install: “cd /root/apr-util-1.6.1/ && ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make && make install”
httpd_install: " cd /root/httpd-2.4.48/ && ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util && make && make install "
8、编写源码安装apache文件
install.yml文件
[root@ansible playbook]# cat install.yml
hosts: httpd
vars_files:
/opt/playbook/pei.yml
tasks:
name: stop and disabled firewalld
service:
name: firewalld
state: stopped
enabled: no
name: disabled selinux
lineinfile:
path: /etc/selinux/config
regexp: “^SELINUX=”
line: “SELINUX=disabled”
state: present
name: install tools
yum:
name: “{{ dell }}”
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Java)
言尽于此,完结
无论是一个初级的 coder,高级的程序员,还是顶级的系统架构师,应该都有深刻的领会到设计模式的重要性。
第一,设计模式能让专业人之间交流方便,如下:
程序员A:这里我用了XXX设计模式
程序员B:那我大致了解你程序的设计思路了
第二,易维护
项目经理:今天客户有这样一个需求…
程序员:明白了,这里我使用了XXX设计模式,所以改起来很快
第三,设计模式是编程经验的总结
程序员A:B,你怎么想到要这样去构建你的代码
程序员B:在我学习了XXX设计模式之后,好像自然而然就感觉这样写能避免一些问题
第四,学习设计模式并不是必须的
程序员A:B,你这段代码使用的是XXX设计模式对吗?
程序员B:不好意思,我没有学习过设计模式,但是我的经验告诉我是这样写的
从设计思想解读开源框架,一步一步到Spring、Spring5、SpringMVC、MyBatis等源码解读,我都已收集整理全套,篇幅有限,这块只是详细的解说了23种设计模式,整理的文件如下图一览无余!
搜集费时费力,能看到此处的都是真爱! 程序员B:那我大致了解你程序的设计思路了
第二,易维护
项目经理:今天客户有这样一个需求…
程序员:明白了,这里我使用了XXX设计模式,所以改起来很快
第三,设计模式是编程经验的总结
程序员A:B,你怎么想到要这样去构建你的代码
程序员B:在我学习了XXX设计模式之后,好像自然而然就感觉这样写能避免一些问题
第四,学习设计模式并不是必须的
程序员A:B,你这段代码使用的是XXX设计模式对吗?
程序员B:不好意思,我没有学习过设计模式,但是我的经验告诉我是这样写的
[外链图片转存中…(img-Wu3Mvcvm-1711655580922)]
从设计思想解读开源框架,一步一步到Spring、Spring5、SpringMVC、MyBatis等源码解读,我都已收集整理全套,篇幅有限,这块只是详细的解说了23种设计模式,整理的文件如下图一览无余!
[外链图片转存中…(img-WHqE5rzC-1711655580923)]
搜集费时费力,能看到此处的都是真爱!
参考文章
发表评论