分布式搭载博客网站

2024-04-18 19:29
文章标签 网站 博客 分布式 搭载

本文主要是介绍分布式搭载博客网站,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一.运行环境:
 

IP主机名系统服务
192.168.118.128Server-WebLinuxWeb
192.168.118.131Server-NFS-DNSLinuxNFS/DNS

二.基础配置

1. 配置主机名,hosts映射
[root@server ~]# hostnamectl set-hostname Server-Web
[root@server ~]# hostname
Server-Web
[root@server ~]#vim /etc/hosts
        127.0.0.1   Server-Web
        192.168.118.128 Server-Web
        192.168.118.131 Server-NFS-DNS
[root@server ~]# reboot


[root@node ~]# hostnamectl set-hostname Server-NFS-DNS
[root@node ~]# hostname
Server-NFS-DNS
[root@node ~]# reboot
[root@Server-NFS-DNS ~]# vim /etc/hosts
127.0.0.1 Server-NFS-DNS
192.168.118.128 Server-Web
        192.168.118.131 Server-NFS-DNS
2. 开启防火墙并配置
相同操作:
[root@Server-NFS-DNS ~]# systemctl start firewalld
[root@Server-NFS-DNS ~]# systemctl enable firewalld
3. 服务器之间使用同 ntp.aliyun.com 进行时间同步
相同操作:
vim  /etc/chrony.conf
server ntp.aliyun.com iburst 
systemctl restart chronyd
chronyc sources -v
timedatectl status
4. 服务器之间实现 SSH 免密登录
Server-Web:

[root@Server-Web ~]# 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:kNDhoYpfc4CEb5NVN+WC39+sPbE2FausptyEzk5qs0s root@Server-Web
The key's randomart image is:
+---[RSA 3072]----+
| .. .o+.o..      |
|.. ..+.= o       |
| ..oo = . .      |
| .=. . o o     . |
|....o . S .     o|
| . . o    .. o...|
|  .    E o .o ++ |
|      .o* o. ==  |
|      .+=*ooo..o |
+----[SHA256]-----+
[root@Server-Web ~]# ssh-copy-id 192.168.118.131
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.118.131 (192.168.118.131)' can't be established.
ED25519 key fingerprint is SHA256:OXWoro2/b049fk8uPMIfR4b5nj0v8M3PoMq+75B1jaM.
This key is not known by any other names
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

Authorized users only. All activities may be monitored and reported.
root@192.168.118.131's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.118.131'"
and check to make sure that only the key(s) you wanted were added.

[root@Server-Web ~]# ssh 192.168.118.131

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Last login: Wed Apr 17 11:39:31 2024 from 192.168.118.1


Welcome to 5.10.0-182.0.0.95.oe2203sp3.x86_64

System information as of time:     2024年 04月 17日 星期三 11:44:11 CST

System load:     0.00
Processes:     193
Memory used:     10.4%
Swap used:     0%
Usage On:     12%
IP address:     192.168.118.131
Users online:     2


[root@Server-NFS-DNS ~]# exit
注销
Connection to 192.168.118.131 closed.
[root@Server-Web ~]#

Server-NFS-DNS:

[root@Server-NFS-DNS ~]# ssh-keygen -t rsa
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:gwX4W59iAtyPksBTA6D0gKYuPvi2LDgkTbeysPG1pzU root@Server-NFS-DNS
The key's randomart image is:
+---[RSA 3072]----+
|o+.. ..          |
|+.o +  .         |
|+. + +  .        |
|. = + oo.        |
|.o + +.=S. .     |
|=oo = + +.o      |
|B= + oEo .       |
|*++ ....         |
| ==..o           |
+----[SHA256]-----+
[root@Server-NFS-DNS ~]# ssh-copy-id 192.168.118.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/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

Authorized users only. All activities may be monitored and reported.
root@192.168.118.128's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.118.128'"
and check to make sure that only the key(s) you wanted were added.

[root@Server-NFS-DNS ~]# ssh 192.168.118.128

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Last login: Wed Apr 17 11:39:22 2024 from 192.168.118.1


Welcome to 5.10.0-182.0.0.95.oe2203sp3.x86_64

System information as of time:     2024年 04月 17日 星期三 11:48:15 CST

System load:     0.00
Processes:     195
Memory used:     10.2%
Swap used:     0%
Usage On:     12%
IP address:     192.168.118.128
Users online:     2


[root@Server-Web ~]# exit
注销
Connection to 192.168.118.128 closed.
[root@Server-NFS-DNS ~]# 

三.环境搭建:

Server-Web: yum install nginx mariadb-server php* -y

Server-NFS-DNS:wordpress上传到Server-NFS-DNS)端的/目录下

[root@Server-NFS-DNS ~]# cd /
[root@Server-NFS-DNS /]# ls
afs   dev   lib         media  proc  sbin  tmp  wordpress-6.1-zh_CN.zip
bin   etc   lib64       mnt    root  srv   usr
boot  home  lost+found  opt    run   sys   var
[root@Server-NFS-DNS /]# unzip wordpress-6.1-zh_CN.zip

[root@Server-NFS-DNS /]# ls
afs   dev   lib         media  proc  sbin  tmp  wordpress
bin   etc   lib64       mnt    root  srv   usr  wordpress-6.1-zh_CN.zip
boot  home  lost+found  opt    run   sys   var
[root@Server-NFS-DNS /]# cd wordpress
[root@Server-NFS-DNS wordpress]# ls
index.php             wp-config-sample.php  wp-mail.php
license.txt           wp-content            wp-settings.php
readme.html           wp-cron.php           wp-signup.php
wp-activate.php       wp-includes           wp-trackback.php
wp-admin              wp-links-opml.php     xmlrpc.php
wp-blog-header.php    wp-load.php
wp-comments-post.php  wp-login.php

四.Server-NFS-DNS端的/wordpress 目录共享给 Server-Web

[root@Server-NFS-DNS wordpress]# yum install rpcbind nfs-utils -y

[root@Server-NFS-DNS wordpress]# cd ~
[root@Server-NFS-DNS ~]# vim /etc/exports
[root@Server-NFS-DNS ~]# chmod -Rf 777 /wordpress

         /wordpress 192.168.118.128(rw,sync,all_squash)

防火墙开启权限:

[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=mountd
success
[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=rpc-bind
success
[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=nfs
success
[root@Server-NFS-DNS ~]# firewall-cmd --reload
success

启动服务:

[root@Server-NFS-DNS ~]# systemctl start rpcbind
[root@Server-NFS-DNS ~]# systemctl start nfs-server
 

五.Server-web设置:

[root@Server-Web ~]#yum install rpcbind nfs-utils -y

[root@Server-Web ~]# showmount -e 192.168.118.131
Export list for 192.168.118.131:
192.168.118.128(rw,sync,all_squash) *
/wordpress                          *
[root@Server-Web ~]# mkdir /wp
[root@Server-Web ~]# mount  -t nfs 192.168.118.131:/wordpress /wp
[root@Server-Web ~]# ls
anaconda-ks.cfg
[root@Server-Web ~]# cd /wp
[root@Server-Web wp]# ls
index.php             wp-config-sample.php  wp-mail.php
license.txt           wp-content            wp-settings.php
readme.html           wp-cron.php           wp-signup.php
wp-activate.php       wp-includes           wp-trackback.php
wp-admin              wp-links-opml.php     xmlrpc.php
wp-blog-header.php    wp-load.php
wp-comments-post.php  wp-login.php

六.Nginx设置:

[root@Server-Web ~]#  firewall-cmd --permanent --zone public --add-service=http
success
[root@Server-Web ~]#  firewall-cmd --reload
success
[root@Server-Web ~]# vim /etc/nginx/nginx.conf

七.修改wordpress配置文件

[root@Server-Web /]# cd wp
[root@Server-Web wp]# ls
index.php             wp-config-sample.php  wp-mail.php
license.txt           wp-content            wp-settings.php
readme.html           wp-cron.php           wp-signup.php
wp-activate.php       wp-includes           wp-trackback.php
wp-admin              wp-links-opml.php     xmlrpc.php
wp-blog-header.php    wp-load.php
wp-comments-post.php  wp-login.php
[root@Server-Web wp]# cp wp-config-sample.php wp-config.php
[root@Server-Web wp]# vim wp-config.php 

        define( 'DB_NAME', 'wordpress' );

        /** Database username */
        define( 'DB_USER', 'LYY' );

        /** Database password */
        define( 'DB_PASSWORD', '123456' );

八.数据库设置

[root@Server-Web ~]# systemctl start mariadb
[root@Server-Web ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.22-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> create user 'LYY'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> grant all on wordpress.* to 'LYY'@'localhost';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit

Bye
[root@Server-Web ~]# systemctl restart mariadb
[root@Server-Web ~]# systemctl restart nginx
 

九.windows设置

十.Server-NFS-DNS端配置DNS

[root@Server-NFS-DNS ~]# cd ~
[root@Server-NFS-DNS ~]# yum install bind -y

[root@Server-NFS-DNS ~]# firewall-cmd --permanent --zone public --add-service=dns
success
[root@Server-NFS-DNS ~]# firewall-cmd --reload
success
[root@Server-NFS-DNS ~]# systemctl start named
[root@Server-NFS-DNS ~]# vim /etc/named.conf 
[root@Server-NFS-DNS ~]# vim /etc/named.rfc1912.zones
        zone "openlab.com" IN {
                type master;
                file "openlab.com.zone";
                allow-update { none; };
        };

[root@Server-NFS-DNS ~]# cd /var/named/
[root@Server-NFS-DNS named]# cp -a named.localhost openlab.com.zone
[root@Server-NFS-DNS named]# vim openlab.com.zone
        $TTL 1D
        @       IN SOA  openlab.com.    admin.openlab.com.  (
                                                0       ; serial
                                                1D      ; refresh
                                                1H      ; retry
                                               1W      ; expire
                                                3H )    ; minimum
                        NS      ns.openlab.com.
        ns      IN      A       192.168.118.128
        www     IN      A       192.168.118.128
        bbs     IN      A       192.168.118.128

[root@Server-NFS-DNS named]# systemctl restart named

Server-Web 端的 DNS 改为 192.168.118.131

十一.完成,输入域名访问

这篇关于分布式搭载博客网站的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/915651

相关文章

Golang使用etcd构建分布式锁的示例分享

《Golang使用etcd构建分布式锁的示例分享》在本教程中,我们将学习如何使用Go和etcd构建分布式锁系统,分布式锁系统对于管理对分布式系统中共享资源的并发访问至关重要,它有助于维护一致性,防止竞... 目录引言环境准备新建Go项目实现加锁和解锁功能测试分布式锁重构实现失败重试总结引言我们将使用Go作

Redis分布式锁使用及说明

《Redis分布式锁使用及说明》本文总结了Redis和Zookeeper在高可用性和高一致性场景下的应用,并详细介绍了Redis的分布式锁实现方式,包括使用Lua脚本和续期机制,最后,提到了RedLo... 目录Redis分布式锁加锁方式怎么会解错锁?举个小案例吧解锁方式续期总结Redis分布式锁如果追求

集中式版本控制与分布式版本控制——Git 学习笔记01

什么是版本控制 如果你用 Microsoft Word 写过东西,那你八成会有这样的经历: 想删除一段文字,又怕将来这段文字有用,怎么办呢?有一个办法,先把当前文件“另存为”一个文件,然后继续改,改到某个程度,再“另存为”一个文件。就这样改着、存着……最后你的 Word 文档变成了这样: 过了几天,你想找回被删除的文字,但是已经记不清保存在哪个文件了,只能挨个去找。真麻烦,眼睛都花了。看

速盾高防cdn是怎么解决网站攻击的?

速盾高防CDN是一种基于云计算技术的网络安全解决方案,可以有效地保护网站免受各种网络攻击的威胁。它通过在全球多个节点部署服务器,将网站内容缓存到这些服务器上,并通过智能路由技术将用户的请求引导到最近的服务器上,以提供更快的访问速度和更好的网络性能。 速盾高防CDN主要采用以下几种方式来解决网站攻击: 分布式拒绝服务攻击(DDoS)防护:DDoS攻击是一种常见的网络攻击手段,攻击者通过向目标网

开源分布式数据库中间件

转自:https://www.csdn.net/article/2015-07-16/2825228 MyCat:开源分布式数据库中间件 为什么需要MyCat? 虽然云计算时代,传统数据库存在着先天性的弊端,但是NoSQL数据库又无法将其替代。如果传统数据易于扩展,可切分,就可以避免单机(单库)的性能缺陷。 MyCat的目标就是:低成本地将现有的单机数据库和应用平滑迁移到“云”端

49个权威的网上学习资源网站

艺术与音乐 Dave Conservatoire — 一个完全免费的音乐学习网站,口号是“让每一个人都可以接受世界级的音乐教育”,有视频,有练习。 Drawspace — 如果你想学习绘画,或者提高自己的绘画技能,就来Drawspace吧。 Justin Guitar — 超过800节免费的吉他课程,有自己的app,还有电子书、DVD等实用内容。 数学,数据科学与工程 Codecad

BT天堂网站挂马事件后续:“大灰狼”远控木马分析及幕后真凶调查

9月初安全团队披露bt天堂网站挂马事件,该网站被利用IE神洞CVE-2014-6332挂马,如果用户没有打补丁或开启安全软件防护,电脑会自动下载执行大灰狼远控木马程序。 鉴于bt天堂电影下载网站访问量巨大,此次挂马事件受害者甚众,安全团队专门针对该木马进行严密监控,并对其幕后真凶进行了深入调查。 一、“大灰狼”的伪装 以下是10月30日一天内大灰狼远控的木马样本截图,可以看到该木马变种数量不

PHP抓取网站图片脚本

方法一: <?phpheader("Content-type:image/jpeg"); class download_image{function read_url($str) { $file=fopen($str,"r");$result = ''; while(!feof($file)) { $result.=fgets($file,9999); } fclose($file); re

laravel框架实现redis分布式集群原理

在app/config/database.php中配置如下: 'redis' => array('cluster' => true,'default' => array('host' => '172.21.107.247','port' => 6379,),'redis1' => array('host' => '172.21.107.248','port' => 6379,),) 其中cl

基于MySQL实现的分布式锁

概述 在单机时代,虽然不需要分布式锁,但也面临过类似的问题,只不过在单机的情况下,如果有多个线程要同时访问某个共享资源的时候,我们可以采用线程间加锁的机制,即当某个线程获取到这个资源后,就立即对这个资源进行加锁,当使用完资源之后,再解锁,其它线程就可以接着使用了。例如,在JAVA中,甚至专门提供了一些处理锁机制的一些API(synchronize/Lock等)。 但是到了分布式系统的时代,这种