一、搭建DHCP服務(wù),為局域網(wǎng)內(nèi)用戶提供10.1.1.0/24網(wǎng)段的IP,且租約期默認(rèn)為48小時(shí)
1.安裝軟件包:yum install -y dhcp*
2.配置服務(wù):
為德宏州等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及德宏州網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)、德宏州網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
[root@localhost dhcp]# vim dhcpd.conf
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 172800;
max-lease-time 172800;
log-facility local7;
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.100 10.1.1.200;
3.啟動(dòng)服務(wù)并驗(yàn)證:
systemctl start dhcp
dhclient -d
二、在上述實(shí)驗(yàn)基礎(chǔ)上,實(shí)現(xiàn)DHCP中繼:
# 開(kāi)啟路由轉(zhuǎn)發(fā)功能
vim /etc/sysctl.conf
net.ipv4.ip-forward=1
sysctl -p
# 啟動(dòng)dhcp中繼服務(wù)
dhcrelay dhcp_server_ip
中繼服務(wù)實(shí)際使用中,基本沒(méi)有必要使用。其他網(wǎng)絡(luò)的主機(jī)另外新建一個(gè)dhcp服務(wù)就好,沒(méi)有必要非得使用中繼
三、借助Ansible Playbook自動(dòng)化搭建LNMP環(huán)境(可借助yum)
1.實(shí)驗(yàn)主機(jī):
ansible主機(jī):172.20.10.6
webservers:172.20.10.3
appservers:172.20.10.4
2.ansible主機(jī)免密鑰認(rèn)證
(1)
[root@localhost playbooks]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:LFUqZ3zNLyVoJzwgIo+LzGwHhd2YCnKh7kOl6IZQcZ4 root@localhost
The key's randomart image is:
+---[RSA 2048]----+
| *o* . . . |
|ooo@ + o = + |
|+o+.E . * B = . |
|*++. * o + + |
|=B.. . S . . |
|B . . . |
|.= |
|. . |
| |
+----[SHA256]-----+
(2)
[root@localhost] ssh-copy-id 172.20.10.3
[root@localhost]# ssh-copy-id 172.20.10.4
3.ansible配置文件
[webservers]
172.20.10.3
[appservers]
172.20.10.4
4.定義playbook劇本:
[root@localhost playbooks]# vim lnmp.yml
---
- hosts: webservers
remote_user: root
tasks:
- name: install nginx
yum: name=nginx
- name: config
copy: src=/data/nginx.conf dest=/etc/nginx/nginx.conf
tags: conf
notify: restart nginx
- name: start nginx
service: name=nginx state=started enabled=yes
handlers:
- name: restart nginx
service: name=nginx state=restarted
- hosts: appservers
remote_user: root
tasks:
- name: install services
yum: name={{ item }}
with_items:
- mariadb
- mariadb-server
- php
- php-fpm
- php-MySQL
- name: php-fpm config
copy: src=/data/www.conf dest=/etc/php-fpm.d/www.conf
notify: restart php-fpm
- name: start php-fpm
service: name=php-fpm state=started enabled=yes
- name : start mysql
service: name=mariadb state=started enabled=yes
- name : config mysql
shell: mysqladmin -uroot password "centos"
- name: config php-index-file
copy: src=/data/index.php dest=/var/www/html/
- name: config php-mysql-file
copy: src=/data/mysql.php dest=/var/www/html/
handlers:
- name: restart php-fpm
service: name=php-fpm state=restart
(5)執(zhí)行結(jié)果:
(6)測(cè)試:
四、采用Ansible Role方式自動(dòng)化搭建LNMP
1.實(shí)驗(yàn)主機(jī):
ansible主機(jī):172.20.10.6
webservers:172.20.10.3
appservers:172.20.10.4
2.ansible主機(jī)roles目錄:
3.執(zhí)行結(jié)果為:
4.訪問(wèn)測(cè)試為:
文章名稱:dhcp和ansible
網(wǎng)頁(yè)網(wǎng)址:http://muchs.cn/article16/jpshgg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供建站公司、關(guān)鍵詞優(yōu)化、網(wǎng)站維護(hù)、企業(yè)建站、網(wǎng)站排名、軟件開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
移動(dòng)網(wǎng)站建設(shè)知識(shí)