国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

網(wǎng)站架構(gòu)演變、LNP+Mariadb數(shù)據(jù)庫(kù)分離、Web服務(wù)器集群、Keepalived高可用

這篇具有很好參考價(jià)值的文章主要介紹了網(wǎng)站架構(gòu)演變、LNP+Mariadb數(shù)據(jù)庫(kù)分離、Web服務(wù)器集群、Keepalived高可用。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

目錄

day02

深入理解程序的數(shù)據(jù)存儲(chǔ)

驗(yàn)證

配置NFS服務(wù)器

配置代理服務(wù)器

配置名稱解析


day02

深入理解程序的數(shù)據(jù)存儲(chǔ)

  • 程序?qū)⑽淖謹(jǐn)?shù)據(jù)保存到數(shù)據(jù)庫(kù)中
  • 程序?qū)⒎俏淖謹(jǐn)?shù)據(jù)(如圖片、視頻、壓縮包等)保存到相應(yīng)的文件目錄中

驗(yàn)證

  • 發(fā)一篇文章,文章內(nèi)容包含文字和圖片
  • 在數(shù)據(jù)庫(kù)中查看文字?jǐn)?shù)據(jù)。在最新的一條記錄中,可以查看到圖片的保存位置
[root@database ~]# mysql

mysql> use wordpress;

mysql> select * from wp_posts\G
  • 在文件系統(tǒng)中查看圖片文件。/usr/share/nginx/html/wp-content/uploads/是固定位置,其后的2023/01是年和月目錄。每個(gè)月上傳的圖片,都會(huì)保存到相應(yīng)的月份目錄。
[root@web1 html]# ls /usr/share/nginx/html/wp-content/uploads/2023/01/

snow.jpg

配置NFS服務(wù)器

  • 準(zhǔn)備環(huán)境

虛擬機(jī)ip與名稱:nfs 192.168.88.31

  • 配置ansible環(huán)境
[root@pubserver project01]# vim inventory 

[webservers]

web1 ansible_host=192.168.88.11

web2 ansible_host=192.168.88.12

web3 ansible_host=192.168.88.13


[dbs]

database ansible_host=192.168.88.21


[storages]

nfs ansible_host=192.168.88.31

   

[all:vars]

ansible_ssh_user=root

ansible_ssh_pass=a
  • 配置nfs服務(wù)
# 1. 配置yum

[root@pubserver project01]# ansible-playbook 01-upload-repo.yml 


# 2. 配置nfs服務(wù)

[root@pubserver project01]# vim 08-config-nfs.yml

---

- name: config nfs

  hosts: nfs

  tasks:

    - name: install nfs        # 安裝nfs

      yum:

        name: nfs-utils

        state: present


    - name: mkdir /nfs_root    # 創(chuàng)建共享目錄

      file:

        path: /nfs_root

        state: directory

        mode: "0755"


    - name: nfs share          # 修改配置文件

      lineinfile:

        path: /etc/exports

        line: '/nfs_root 192.168.88.0/24(rw)'


    - name: start service      # 循環(huán)啟動(dòng)服務(wù)

      service:

        name: "{{item}}"

        state: started

        enabled: yes

      loop:

        - rpcbind       # nfs服務(wù)依賴rpcbind服務(wù)

        - nfs-server


[root@pubserver project01]# ansible-playbook 08-config-nfs.yml


# 3. 查看共享輸出

[root@nfs ~]# showmount -e

Export list for nfs:

/nfs_root 192.168.88.0/24
  • 遷移文件至nfs共享
# 1. 重新下載web1的html目錄

[root@pubserver project01]# cp 06-fetch-web1.yml 09-fetch-web1.yml

---

- name: copy web

  hosts: web1

  tasks:

    - name: compress html        # 壓縮html目錄到/root下

      archive:

        path: /usr/share/nginx/html

        dest: /root/html2.tar.gz

        format: gz


    - name: download html

      fetch:

        src: /root/html2.tar.gz  # 下載壓縮文件

        dest: files/

        flat: yes


[root@pubserver project01]# ansible-playbook 09-fetch-web1.yml 


# 2. 釋放壓縮包到nfs服務(wù)器

[root@pubserver project01]# cp 07-deploy-web23.yml 10-deploy-nfs.yml

[root@pubserver project01]# vim 10-deploy-nfs.yml 

---

- name: deploy nfs

  hosts: nfs

  tasks:

    - name: unarchive to web     # 將控制端壓縮文件解壓到指定位置

      unarchive:

        src: files/html2.tar.gz

        dest: /nfs_root/


[root@pubserver project01]# ansible-playbook 10-deploy-nfs.yml 


# 3. 清除web服務(wù)器的html目錄

[root@pubserver project01]# vim 11-rm-html.yml

---

- name: rm html

  hosts: webservers

  tasks:

    - name: rm html

      file:

        path: /usr/share/nginx/html

        state: absent

        

    - name: create html

      file:

        path: /usr/share/nginx/html

        state: directory

        owner: apache

        group: apache

        mode: "0755"


[root@pubserver project01]# ansible-playbook 11-rm-html.yml


# 4. 掛載nfs到web服務(wù)器

[root@pubserver project01]# vim 12-mount-nfs.yml

---

- name: mount nfs

  hosts: webservers

  tasks:

    - name: install nfs

      yum:

        name: nfs-utils

        state: present

        

    - name: mount nfs

      mount:

        path: /usr/share/nginx/html

        src: 192.168.88.31:/nfs_root/html

        fstype: nfs

        state: mounted


[root@pubserver project01]# ansible-playbook 12-mount-nfs.yml

配置代理服務(wù)器

  • 準(zhǔn)備環(huán)境

虛擬機(jī)ip與名稱:haproxy1 192.168.88.5 ? haproxy2 192.168.88.6文章來源地址http://www.zghlxwxcb.cn/news/detail-829451.html

  • 配置ansible環(huán)境
[root@pubserver project01]# vim inventory 

[webservers]

web1 ansible_host=192.168.88.11

web2 ansible_host=192.168.88.12

web3 ansible_host=192.168.88.13


[dbs]

database ansible_host=192.168.88.21


[storages]

nfs ansible_host=192.168.88.31


[lb]

haproxy1 ansible_host=192.168.88.5

haproxy2 ansible_host=192.168.88.6


[all:vars]

ansible_ssh_user=root

ansible_ssh_pass=a
  • 配置高可用、負(fù)載均衡功能
# 1. 配置yum

[root@pubserver project01]# ansible-playbook 01-upload-repo.yml 


# 2. 配置調(diào)度服務(wù)器

[root@pubserver project01]# vim 13-install-lb.yml 

---

- name: install lb

  hosts: lb

  tasks:

    - name: install pkg

      yum:

        name: haproxy,keepalived

        state: present


[root@pubserver project01]# ansible-playbook 13-install-lb.yml 


# 3. 修改配置文件并啟動(dòng)服務(wù)

[root@pubserver project01]# vim 14-config-lb.yml

---

- name: config haproxy

  hosts: lb

  tasks:

    - name: rm lines

      shell: sed -i '64,$d' /etc/haproxy/haproxy.cfg


    - name: add lines

      blockinfile:

        path: /etc/haproxy/haproxy.cfg

        block: |

          listen wordpress

              bind 0.0.0.0:80

              balance roundrobin

              server web1 192.168.88.11:80 check inter 2000 rise 2 fall 5

              server web2 192.168.88.12:80 check inter 2000 rise 2 fall 5

              server web3 192.168.88.13:80 check inter 2000 rise 2 fall 5


          listen mon

            bind 0.0.0.0:1080

            stats refresh 30s

            stats uri /mon

            stats auth admin:admin


    - name: start service

      service:

        name: haproxy

        state: started

        enabled: yes


[root@pubserver project01]# ansible-playbook 14-config-lb.yml


# 4. haproxy1配置keepalived,實(shí)現(xiàn)高可用集群

[root@haproxy1 ~]# vim /etc/keepalived/keepalived.conf 

...略...

 12    router_id haproxy1   # 為本機(jī)取一個(gè)唯一的id

 13    vrrp_iptables        # 自動(dòng)開啟iptables放行規(guī)則

...略...

 20 vrrp_instance VI_1 {

 21     state MASTER        # 主服務(wù)器狀態(tài)是MASTER

 22     interface eth0

 23     virtual_router_id 51

 24     priority 100

 25     advert_int 1

 26     authentication {

 27         auth_type PASS

 28         auth_pass 1111

 29     }

 30     virtual_ipaddress {

 31         192.168.88.80       # vip地址

 32     }

 33 }

# 以下全部刪除


# 5. haproxy2配置keepalived

[root@haproxy1 ~]# scp /etc/keepalived/keepalived.conf 192.168.88.6:/etc/keepalived/

[root@haproxy2 ~]# vim /etc/keepalived/keepalived.conf 

...略...

 12    router_id haproxy2   # 為本機(jī)取一個(gè)唯一的id

 13    vrrp_iptables        # 自動(dòng)開啟iptables放行規(guī)則

...略...

 20 vrrp_instance VI_1 {

 21     state BACKUP        # 備份服務(wù)器狀態(tài)是BACKUP

 22     interface eth0

 23     virtual_router_id 51

 24     priority 80         # 備份服務(wù)器優(yōu)先級(jí)低于主服務(wù)器

 25     advert_int 1

 26     authentication {

 27         auth_type PASS

 28         auth_pass 1111

 29     }

 30     virtual_ipaddress {

 31         192.168.88.80

 32     }

 33 }

 

# 6. 啟動(dòng)服務(wù)

[root@haproxy1 ~]# systemctl enable keepalived.service --now

[root@haproxy2 ~]# systemctl enable keepalived.service --now


# 7. 驗(yàn)證。haproxy1上出現(xiàn)VIP??蛻舳嗽L問http://192.168.88.80即可

[root@haproxy1 ~]# ip a s | grep 192

    inet 192.168.88.5/24 brd 192.168.88.255 scope global noprefixroute eth0

    inet 192.168.88.80/32 scope global eth0

配置名稱解析

  • 通過本機(jī)hosts文件實(shí)現(xiàn)名稱解析
[root@myhost ~]# echo "192.168.88.80 www.danei.com" >> /etc/hosts
  • 如果客戶端是windows主機(jī),則使用記事本程序打開C:\windows\System32\drivers\etc\hosts添加名稱解析
  • 當(dāng)點(diǎn)擊http://www.danei.com頁(yè)面中任意鏈接時(shí),地址欄上的地址,都會(huì)變成192.168.88.11。通過以下方式修復(fù)它:
# 在nfs服務(wù)器上修改配置文件

[root@nfs ~]# vim /nfs_root/html/wp-config.php 

# define('DB_NAME', 'wordpress')它的上方添加以下兩行:

define('WP_SITEURL', 'http://www.danei.com');

define('WP_HOME', 'http://www.danei.com');

到了這里,關(guān)于網(wǎng)站架構(gòu)演變、LNP+Mariadb數(shù)據(jù)庫(kù)分離、Web服務(wù)器集群、Keepalived高可用的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 解剖“全球最大男性交友網(wǎng)站”,GitHub十五年數(shù)據(jù)庫(kù)架構(gòu)演進(jìn)

    解剖“全球最大男性交友網(wǎng)站”,GitHub十五年數(shù)據(jù)庫(kù)架構(gòu)演進(jìn)

    數(shù)據(jù)庫(kù)編程大賽:一條SQL計(jì)算撲克牌24點(diǎn) 近期,GitHub全面升級(jí)到了MySQL 8.0。ITPUB特別邀請(qǐng)了NineData創(chuàng)始人、資深技術(shù)專家葉正盛老師,為大家解析GitHub歷年數(shù)據(jù)庫(kù)架構(gòu)的發(fā)展歷程,以及大型網(wǎng)站何時(shí)進(jìn)行分庫(kù)分表的改造。 Hello,各位朋友!今天,我們一起來回顧GitHub,這個(gè)被程

    2024年02月03日
    瀏覽(21)
  • spring boot shardingsphere mybatis-plus druid mysql 搭建mysql數(shù)據(jù)庫(kù)讀寫分離架構(gòu)

    spring boot shardingsphere mybatis-plus druid mysql 搭建mysql數(shù)據(jù)庫(kù)讀寫分離架構(gòu)

    ##關(guān)于window mysql主從搭建簡(jiǎn)單教程 傳送門?window mysql5.7 搭建主從同步環(huán)境-CSDN博客 ##父pom.xml ##模塊pom.xml ##yml配置 ##mapper.xml ##TestMapper ##TestService ##TestController ##瀏覽器訪問 ##數(shù)據(jù)庫(kù)

    2024年01月21日
    瀏覽(26)
  • MariaDB數(shù)據(jù)庫(kù)服務(wù)器

    MariaDB數(shù)據(jù)庫(kù)服務(wù)器

    目錄 一、什么是數(shù)據(jù)庫(kù)? 二、什么是關(guān)系型數(shù)據(jù)庫(kù)? 三、數(shù)據(jù)庫(kù)字符集和排序規(guī)則是什么? 四、常用數(shù)據(jù)類型 五、Mariadb數(shù)據(jù)庫(kù)相關(guān)配置案例 一、什么是數(shù)據(jù)庫(kù)? 數(shù)據(jù)庫(kù)(DB)是以一定方式長(zhǎng)期存儲(chǔ)在計(jì)算機(jī)硬盤內(nèi),能與多個(gè)用戶共享,具有盡可能小的冗余度、與應(yīng)用程序

    2024年02月10日
    瀏覽(27)
  • Windows 安裝 MariaDB 數(shù)據(jù)庫(kù)

    Windows 安裝 MariaDB 數(shù)據(jù)庫(kù)

    之前一直使用 MySQL,使用 MySQL8.0 時(shí)候,占用內(nèi)存比較大,儲(chǔ)存空間好像也稍微有點(diǎn)大,看到 MariaDB 是用來代替 MySQL 的方案,之前用著也挺得勁,MySQL8.0 以上好像不能去導(dǎo)入低版本的 sql,或者需要改一些東西,但是用著 MariaDB 不用改就可以導(dǎo)入,所以寫一下這個(gè)的安裝 Maria

    2024年02月09日
    瀏覽(17)
  • MariaDB數(shù)據(jù)庫(kù)的主從配置

    MariaDB數(shù)據(jù)庫(kù)的主從配置

    首先準(zhǔn)備兩臺(tái)可以互相ping通的機(jī)器,兩臺(tái)機(jī)器可以互為主從,示例:10.210.23.77主服務(wù)器 10.20.84.183從服務(wù)器 在兩臺(tái)機(jī)器上各自安裝數(shù)據(jù) 解壓MariaDB安裝包; ?安裝MariaDB依賴包; ?啟動(dòng)MariaDB服務(wù) ?安全配置 # 開始安全配置 ??① 輸入當(dāng)前密碼,初次安裝后是沒有密碼的,直接回

    2024年02月04日
    瀏覽(25)
  • 使用MariaDB數(shù)據(jù)庫(kù)管理系統(tǒng)

    初始化MariaDB服務(wù) //再確認(rèn)mariadb數(shù)據(jù)庫(kù)軟件程序安裝完畢并成功啟動(dòng)后請(qǐng)不要立即使用。為了確保數(shù)據(jù)庫(kù)的安全性和正常運(yùn)轉(zhuǎn),需要做以下5個(gè)操作 1.設(shè)置root管理員在數(shù)據(jù)庫(kù)中的密碼值(該密碼并非root管理員在系統(tǒng)中的密碼,這里的密碼值默認(rèn)應(yīng)該為空) 2.設(shè)置root管理員在數(shù)據(jù)

    2024年02月19日
    瀏覽(30)
  • mariadb數(shù)據(jù)庫(kù)從入門到精通

    mariadb數(shù)據(jù)庫(kù)從入門到精通

    實(shí)驗(yàn)環(huán)境:yum倉(cāng)庫(kù)搭建好 mariadb 是當(dāng)前流行的Mysql數(shù)據(jù)庫(kù)的分支 Mysql原先SUN公司(java)被Orical收購(gòu)了 Mysql開源免費(fèi),所以企業(yè)當(dāng)中的核心數(shù)據(jù)庫(kù)是Orical,其余是Mysql mariadb是Mysql數(shù)據(jù)庫(kù)的一個(gè)分支 1.數(shù)據(jù)庫(kù)的安裝 由于數(shù)據(jù)庫(kù)的登陸不需要密碼所以不安全,我們要安全初始化。 密碼

    2024年01月21日
    瀏覽(29)
  • [MariaDB] 數(shù)據(jù)庫(kù)統(tǒng)計(jì)插件啟用和配置

    最近因?yàn)樾枰O(jiān)控?cái)?shù)據(jù)庫(kù)(MySQL/MariaDB)的登陸動(dòng)作、數(shù)據(jù)修改等,需要調(diào)研一個(gè)監(jiān)控?cái)?shù)據(jù)庫(kù)方案。經(jīng)查詢有canal等開源方案,調(diào)查過后基本也符合需求;最后查詢GPT推薦MariaDB官方插件server audit:初步閱讀文檔感覺很符合需求,故進(jìn)行部署驗(yàn)證和測(cè)試 基于CentOS7部署最新版本的

    2024年02月02日
    瀏覽(28)
  • Cpolar內(nèi)網(wǎng)穿透本地MariaDB數(shù)據(jù)庫(kù)

    Cpolar內(nèi)網(wǎng)穿透本地MariaDB數(shù)據(jù)庫(kù)

    cpolar內(nèi)網(wǎng)穿透本地MariaDB數(shù)據(jù)庫(kù),實(shí)現(xiàn)外公網(wǎng)環(huán)境下使用navicat圖形化工具遠(yuǎn)程連接本地內(nèi)網(wǎng)的MariaDB數(shù)據(jù)庫(kù) 配置MariaDB數(shù)據(jù)庫(kù) 安裝MariaDB數(shù)據(jù)庫(kù) 進(jìn)入MariaDB數(shù)據(jù)庫(kù)官網(wǎng)https://mariadb.com/downloads/community/,然后下載相應(yīng)的windows版本 下載好后點(diǎn)擊安裝,出現(xiàn)設(shè)置密碼界面設(shè)置一下密碼,mar

    2024年02月06日
    瀏覽(25)
  • 第十六章 使用MariaDB數(shù)據(jù)庫(kù)管理系統(tǒng)

    一、數(shù)據(jù)庫(kù)管理系統(tǒng) 1、數(shù)據(jù)庫(kù)介紹 數(shù)據(jù)庫(kù)是指按照某些特定結(jié)構(gòu)來存儲(chǔ)數(shù)據(jù)資料的數(shù)據(jù)倉(cāng)庫(kù)。在當(dāng)今這個(gè)大數(shù)據(jù)技術(shù)迅速崛起的年代,互聯(lián)網(wǎng)上每天都會(huì)生成海量的數(shù)據(jù)信息,數(shù)據(jù)庫(kù)技術(shù)也從最初只能存儲(chǔ)簡(jiǎn)單的表格數(shù)據(jù)的單一集中存儲(chǔ)模式,發(fā)展到了現(xiàn)如今存儲(chǔ)海量數(shù)據(jù)

    2024年02月05日
    瀏覽(16)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包