私有云基础架构

基础配置

使用 VMWare Workstation 创建三台 2 CPU、8G内存、100 GB硬盘 的虚拟机

主机

IP

安装服务

web01

192.168.184.110

Apache、PHP

database

192.168.184.111

MariaDB

web02

192.168.184.112

Apache、PHP

由于 openEuler 22.09 系统已经停止维护了,所以我们需要修改 yum 源为官方 Archive 的 yum 源

打开 /etc/yum.repos.d/openEuler.repo 文件,将下面所有涉及到 http://repo.openeuler.org/ 的部分改成 https://archives.openeuler.openatom.cn/

在三台机器上

[root@controller ~]#

sed -i 's|http://repo.openeuler.org/|https://archives.openeuler.openatom.cn/|g' /etc/yum.repos.d/openEuler.repo

# 然后更新 yum 源

[root@controller ~]# dnf update

关闭防火墙等

在三台机器上

        # 关闭防火墙

[root@web01 ~]# systemctl disable --now firewalld              

# 关闭 SELinux

[root@web01 ~]# vi /etc/selinux/config

# 修改以下内容

SELINUX=disabled

修改hosts

在三台机器上

[root@web01 ~]# cat >> /etc/hosts << EOF

192.168.184.110 web01

192.168.184.111 database

192.168.184.112 web02

EOF

此时最好重启一下机器,以便应用刚才关闭的 SELinux

安装数据库

数据库需要安装在 Controller 节点,这里我们选用 MariaDB 作为我们的数据库

首先安装 MariaDB

[root@controller ~]# dnf install mysql-config mariadb mariadb-server python3-PyMySQL -y

新增配置文件 /etc/my.cnf.d/openstack.cnf 内容如下所示

[root@controller ~]# vi /etc/my.cnf.d/openstack.cnf

[mysqld]

bind-address = 192.168.184.110

default-storage-engine = innodb

innodb_file_per_table = on

max_connections = 4096

collation-server = utf8_general_ci

character-set-server = utf8

然后启动服务器

[root@controller ~]# systemctl start mariadb

然后初始化数据库

[root@controller ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

haven't set the root password yet, you should just press enter here.

# 这里输入密码,由于我们是初始化MariaDB,直接回车就行

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody

can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

# 这里根据提示输入N

Switch to unix_socket authentication [Y/n] n

 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

# 输入Y,修改密码

Change the root password? [Y/n] y

# 这里输入两次密码

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

# 输入Y,删除匿名用户

Remove anonymous users? [Y/n] y

 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

# 输入Y,关闭root远程登录权限

Disallow root login remotely? [Y/n] y

 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

# 输入Y,删除test数据库

Remove test database and access to it? [Y/n] y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

# 输入Y,重载配置

Reload privilege tables now? [Y/n] y

 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

然后我们来验证一下

[root@controller ~]# mysql -uroot -p

# 输入密码

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 11

Server version: 10.5.16-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)]>

1传统架构下的应用部署

    1. 安装Apache服务

首先安装服务

[root@web01 ~]# dnf install -y httpd

[root@web01 ~]# dnf install -y php php-cli php-common php-fpm

然后启动服务

[root@web01 ~]# systemctl enable --now httpd

查看版本

[root@web01 ~]# apachectl -v

Server version: Apache/2.4.51 (Unix)

Server built:   Sep  7 2022 00:00:00

到浏览器输入http://192.168.184.110/地址进行Apache访问测试

    1. 安装PHP服务

首先安装PHP及其模块

[root@web01 ~]# dnf -y install php php-common php-cli php-gd php-pdo php-devel php-xml php-mysqlnd

然后编写测试界面文件

[root@web01 ~]# vi /var/www/html/php-test.php

<?php

phpinfo();

?>

重启Apache服务,并到浏览器中访问 http://192.168.184.110/php-test.php

[root@web01 ~]# systemctl restart httpd

    1. 安装配置数据库

首先安装MariaDB服务

[root@web01 ~]# dnf -y install mariadb mariadb-server

[root@web01 ~]# systemctl enable --now mariadb.service

由于我们上面已经初始化完数据库了,这里就不初始化了

然后创建数据库

[root@web01 ~]# mysql -uroot -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 10.5.16-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)]> GRANT ALL PRIVILEGES ON wordpress.* to root@'%' IDENTIFIED BY '000000';

Query OK, 0 rows affected (0.047 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit;

Bye

    1. 安装WordPress

下载 wordpress-6.7.1-zh_CN.zip 到根目录

[root@web01 ~]# wget https://cn.wordpress.org/wordpress-6.7.2-zh_CN.tar.gz

然后解压到Apache网页文件夹里

[root@web01 ~]# tar -zxf wordpress-6.7.2-zh_CN.tar.gz -C /var/www/html/

对解压出来的wordpress文件夹赋予权限

设置http根目录/var/www/的所有组为apache

[root@web01 ~]# chown -R :apache /var/www/

设置http根目录/var/www的所有者为apache

[root@web01 ~]# chown -R apache /var/www/

设置http根目录/var/www的组下的所有用户具有读写权限

[root@web01 ~]# chmod -R 775 /var/www/

[root@web01 ~]# systemctl restart httpd

在浏览器中访问http://192.168.184.110/wordpress/界面查看

接下来,输入数据库相关配置信息即可完成数据库连接

数据库连接成功后,单击“运行安装程序”继续安装

自定义站点相关的表单,例如登录用户名及密码等

至此,WordPress部署成功

2集群架构下的应用部署

    1. 安装MariaDB服务

首先,在database节点安装MariaDB服务

[root@database ~]# dnf -y install mariadb mariadb-server

[root@database ~]# systemctl enable --now mariadb.service

然后初始化数据库

[root@database ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

haven't set the root password yet, you should just press enter here.

# 这里输入密码,由于我们是初始化MariaDB,直接回车就行

Enter current password for root (enter for none):

OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody

can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

# 这里根据提示输入N

Switch to unix_socket authentication [Y/n] n

 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

# 输入Y,修改密码

Change the root password? [Y/n] y

# 这里输入两次密码

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

# 输入Y,删除匿名用户

Remove anonymous users? [Y/n] y

 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

# 输入Y,关闭root远程登录权限

Disallow root login remotely? [Y/n] y

 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

# 输入Y,删除test数据库

Remove test database and access to it? [Y/n] y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

# 输入Y,重载配置

Reload privilege tables now? [Y/n] y

 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

然后授权并创建数据库

[root@database ~]# mysql -uroot -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 10.5.16-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)]> GRANT ALL PRIVILEGES ON wordpress.* to root@'%' IDENTIFIED BY '000000';

Query OK, 0 rows affected (0.047 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit

Bye

    1. 安装Apache服务

Web 02节点进行如下操作

首先安装Apache

[root@web02 ~]# dnf install -y httpd

[root@web02 ~]# dnf install -y php php-cli php-common php-fpm

然后启动服务

[root@web02 ~]# systemctl enable --now httpd

查看版本

[root@web02 ~]# apachectl -v

Server version: Apache/2.4.51 (Unix)

Server built:   Sep  7 2022 00:00:00

2.3 安装PHP服务

Web 02节点进行如下操作

首先安装PHP服务

[root@web02 ~]# dnf -y install php php-common php-cli php-gd php-pdo php-devel php-xml php-mysqlnd php-mysqli

然后编写测试界面文件

[root@web01 ~]# vi /var/www/html/php-test.php

<?php

phpinfo();

?>

重启Apache服务,并到浏览器中访问 http://192.168.184.112/php-test.php

[root@web01 ~]# systemctl restart httpd

    1. 安装WordPress
Web 01节点

下载 wordpress-6.7.1-zh_CN.zip 到根目录

[root@web01 ~]# wget https://cn.wordpress.org/wordpress-6.7.2-zh_CN.tar.gz

然后解压到Apache网页文件夹里

[root@web01 ~]# tar -zxf wordpress-6.7.2-zh_CN.tar.gz -C /var/www/html/

对解压出来的wordpress文件夹赋予权限

设置http根目录/var/www/的所有组为apache

[root@web01 ~]# chown -R :apache /var/www/

设置http根目录/var/www的所有者为apache

[root@web01 ~]# chown -R apache /var/www/

设置http根目录/var/www的组下的所有用户具有读写权限

[root@web01 ~]# chmod -R 775 /var/www/

[root@web01 ~]# systemctl restart httpd

在浏览器中访问http://192.168.184.110/wordpress/界面查看

接下来,输入数据库相关配置信息即可完成数据库连接

数据库主机填写database节点的IP: 192.168.184.111

数据库连接成功后,单击“运行安装程序”继续安装

自定义站点相关的表单,例如登录用户名及密码等

至此,WordPress部署成功

Web 02节点

下载 wordpress-6.7.2zh_CN.zip 到根目录

[root@web01 ~]# wget https://cn.wordpress.org/wordpress-6.7.2-zh_CN.tar.gz

然后解压到Apache网页文件夹里

[root@web02 ~]# dnf install -y tar

[root@web01 ~]# tar -zxf wordpress-6.7.2-zh_CN.tar.gz -C /var/www/html/

对解压出来的wordpress文件夹赋予权限

设置http根目录/var/www/的所有组为apache

[root@web01 ~]# chown -R :apache /var/www/

设置http根目录/var/www的所有者为apache

[root@web01 ~]# chown -R apache /var/www/

设置http根目录/var/www的组下的所有用户具有读写权限

[root@web01 ~]# chmod -R 775 /var/www/

[root@web01 ~]# systemctl restart httpd

在浏览器中访问http://192.168.184.112/wordpress/界面查看

这里的数据库主机也是和Web01节点一样,都是填写database的IP: 192.168.184.111

       然后会提示已经安装过WordPress了,这说明Web02节点已经连接上了database节点的MariaDB数据库

Web02节点验证成功,直接单击“登录”便可以正常访问站点

即使把Web01节点的Apache服务关闭,Web02节点的WordPress仍然正常工作

[root@web01 ~]# systemctl stop httpd

2.4 Database节点验证

在database节点,登录MariaDB数据库,查看数据库列表信息

[root@database ~]# mysql -uroot -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 43

Server version: 10.5.16-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)]>  SHOW DATABASES;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| wordpress          |

+--------------------+

4 rows in set (0.000 sec)

MariaDB [(none)]> USE wordpress;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [wordpress]> SELECT * FROM wp_users;

+----+------------+------------------------------------+---------------+-------------------+----------------------------------+---------------------+---------------------+-------------+--------------+

| ID | user_login | user_pass                          | user_nicename | user_email        | user_url                         | user_registered     | user_activation_key | user_status | display_name |

+----+------------+------------------------------------+---------------+-------------------+----------------------------------+---------------------+---------------------+-------------+--------------+

|  1 | admin      | $P$B9CXb1jGD1hWsdcP63t1cYQNjZSnQN. | admin         | 2215916850@qq.com | http://192.168.184.110/wordpress | 2025-03-03 06:08:27 |                     |           0 | admin        |

+----+------------+------------------------------------+---------------+-------------------+----------------------------------+---------------------+---------------------+-------------+--------------+

1 row in set (0.000 sec)

MariaDB [wordpress]> exit;

Bye

[root@database ~]#

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/28189.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

记忆化搜索与动态规划:原理、实现与比较

记忆化搜索和动态规划是解决优化问题的两种重要方法&#xff0c;尤其在处理具有重叠子问题和最优子结构性质的问题时非常有效。 目录 1. 记忆化搜索&#xff08;Memoization&#xff09; 定义&#xff1a; 实现步骤&#xff1a; 示例代码&#xff08;斐波那契数列&#xff0…

Spring Boot 自动装配深度解析与实践指南

目录 引言&#xff1a;自动装配如何重塑Java应用开发&#xff1f; 一、自动装配核心机制 1.1 自动装配三大要素 1.2 自动装配流程 二、自定义自动配置实现 2.1 创建自动配置类 2.2 配置属性绑定 2.3 注册自动配置 三、条件注解深度应用 3.1 常用条件注解对比 3.2 自定…

关于常规模式下运行VScode无法正确执行“pwsh”问题

前言&#xff1a; pwsh在系统环境中正确配置&#xff0c;且可以运行在cmd&#xff0c; powshell&#xff08;5.1&#xff09;--- 都需要在管理员权限下运行 &#xff08;打开setting&#xff09; 打开setting.json &#xff08;在vscode中添加 powershell 7 路径&…

Ubuntu20.04双系统安装及软件安装(一):系统安装

Ubuntu20.04双系统安装及软件安装&#xff08;一&#xff09;&#xff1a;系统安装 Ubuntu系统卸载Ubuntu20.04安装BIOS进入系统安装 许久没写博客了&#xff0c;今天开始重新回归了。首先记录我在双系统上重装Ubuntu20.04的安装过程记录以及个人见解。 Ubuntu系统卸载 参考双…

基于CURL命令封装的JAVA通用HTTP工具

文章目录 一、简要概述二、封装过程1. 引入依赖2. 定义脚本执行类 三、单元测试四、其他资源 一、简要概述 在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具&#xff0c;可以说是一款很强大的http命令行工具。它支持文件的上传和下载&#xff0c;是综合传输工具&…

开发博客系统

前言 准备工作 数据库表分为实体表和关系表 第一&#xff0c;建数据库表 然后导入前端页面 创建公共模块 就是统一返回值&#xff0c;异常那些东西 自己造一个自定义异常 普通类 mapper 获取全部博客 我们只需要返回id&#xff0c;title&#xff0c;content&#xff0c;us…

uniapp+vue3搭建项目

工具使用&#xff1a; Pinia Vue 3 官方推荐的状态管理库&#xff0c;比 Vuex 更轻量&#xff0c;支持模块化&#xff0c;结合 persistedstate 插件可以持久化存储数据。uView-plus 专为 UniApp 设计&#xff0c;支持 App、小程序、H5。UnoCSS 更轻量&#xff0c;比 TailwindCS…

如何通过rust实现自己的web登录图片验证码

在进行web系统开发时&#xff0c;为保障系统登录安全&#xff0c;登录页面中的验证码必不可少。在java中&#xff0c;我们可以利用相应的2D图像库快速生成图形验证码&#xff0c;而对于rust&#xff0c;我们没有合适的标准库进行图像验证码的生成。今天&#xff0c;我们通过使用…

Unity NGUI新手向几个问题记录

1.点Button没反应 制作Button组件时&#xff0c;不光要挂载Button脚本&#xff0c;还有挂载BoxCollider BoxCollider 接收事件 2.Button点击事件的增加与删除 使用.onClick.add增加事件&#xff0c;使用.onClick.Remove,.onClick.RemoveAt,onClick.RemoveRang,onClick.Clear移…

基于SpringBoot的“扶贫助农系统”的设计与实现(源码+数据库+文档+PPT)

基于SpringBoot的“扶贫助农系统”的设计与实现&#xff08;源码数据库文档PPT) 开发语言&#xff1a;Java 数据库&#xff1a;MySQL 技术&#xff1a;SpringBoot 工具&#xff1a;IDEA/Ecilpse、Navicat、Maven 系统展示 系统功能结构图 局部E-R图 系统首页界面 系统注册…

Rust编程实战:初探WebAssembly

WebAssembly: 网页应用的性能革命 ​互联网技术日新月异&#xff0c;Web应用已经从简单的网页跃升为功能丰富的平台。然而&#xff0c;JavaScript作为Web的主力语言&#xff0c;在处理计算密集型任务时仍然存在性能瓶颈。今天&#xff0c;我们来聊一聊可能改变Web格局的技术—…

蓝桥杯4T平台(串口打印电压值)

知识点&#xff1a;串口(单片机发送数据)按键ADC 题目 配置 代码 adc.c uint16_t getadc2(void) {uint16_t adc0;HAL_ADC_Start(&hadc2);adcHAL_ADC_GetValue(&hadc2);return adc; } adc.h uint16_t getadc2(void); main.c #include "lcd.h" #include…

【异常解决】Unable to start embedded Tomcat Nacos 启动报错

Unable to start embedded Tomcat Nacos 启动报错解决方案 一、背景描述二、原因分析三、解决方案 一、背景描述 Windows 本地启动 Nacos&#xff08;2.2.0&#xff09; 服务&#xff0c;控制台报错 Unable to start embedded Tomcat。 报错信息&#xff1a;Unable to star…

Spark核心之02:RDD、算子分类、常用算子

spark内存计算框架 一、目标 深入理解RDD弹性分布式数据集底层原理掌握RDD弹性分布式数据集的常用算子操作 二、要点 ⭐️1. RDD是什么 RDD&#xff08;Resilient Distributed Dataset&#xff09;叫做**弹性分布式数据集&#xff0c;是Spark中最基本的数据抽象&#xff0c…

Machine Learning 初探

前置知识 pandas 读取文件&#xff1a;read_csv查看信息 describe&#xff1a;查看整体信息&#xff0c;包括每列的平均值、最大最小值、标准差等head&#xff1a;输出头部几行数据columns&#xff1a;输出所有列名loc&#xff1a;查询数据&#xff0c;或是根据索引取对应的数…

linux第四讲----基础开发工具vim

1.软件安装 这里以ubuntu为例&#xff0c;安装sl软件,输入这个命令即可自动安装~ 使用一下&#xff0c;输入sl&#xff0c;屏幕上会出现一个移动的小火车 之后不想要了准备卸载就输入&#xff1a; 注意&#xff1a;1&#xff09;下载软件时也可以进行搜索~ 2&#xff09;cento…

【Wireshark 02】抓包过滤方法

一、官方教程 Wireshark 官网文档 &#xff1a; Wireshark User’s Guide 二、显示过滤器 2.1、 “数据包列表”窗格的弹出过滤菜单 例如&#xff0c;源ip地址作为过滤选项&#xff0c;右击源ip->prepare as filter-> 选中 点击选中完&#xff0c;显示过滤器&#…

在 macOS 使用 .pem 私钥免密登录腾讯云服务器

前言 在腾讯云上创建服务器时&#xff0c;如果选择了「密钥对」的登录方式&#xff0c;就会得到一个 .pem 文件作为私钥。很多小伙伴在使用 macOS 系统时&#xff0c;可能不清楚如何使用这个私钥文件来 SSH 免密登录远程服务器。本文将详细介绍如何在本地配置 .pem 私钥文件并…

Android U 分屏——SystemUI侧处理

WMShell相关的dump命令 手机分屏启动应用后运行命令&#xff1a;adb shell dumpsys activity service SystemUIService WMShell 我们可以找到其中分屏的部分&#xff0c;如下图所示&#xff1a; 分屏的组成 简图 分屏是由上分屏(SideStage)、下分屏(MainStage)以及分割线组…