二、实验步骤
A、实验环境准备
1、在node2、node3、node4上安装httpd
[root@localhost ~]# yum -y install httpd 2、在node3和node4上安装php 、php-mysql
[root@localhost ~]# yum -y install php php-mysql 3、在172.18.250.193上安装mariadb,并进行配置
[root@byq ~]#yum -y install mariadb 启动数据库
[root@byq ~]#systemctl start mariadb 检查端口
[root@byq ~]#ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:3306 *:* 配置数据库相关内容
[root@byq ~]#mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database dz;
MariaDB [(none)]> grant all privileges on dz.* to 'dzadmin'@'%' identified by '123456';
MariaDB [(none)]> grant all privileges on dz.* to 'dzadmin'@'localhost' identified by '123456';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dz |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
MariaDB [(none)]> exit
Bye 远程登陆测试创建的数据库用户是否正常连接
[root@BYQ ~]#mysql -udzadmin -p123456 -h172.18.250.193
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 4、编辑node2、node3、node4中httpd的配置文件httpd.conf
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 修改添加如下内容
ServerName node2.byq.com:80
DocumentRoot "/var/www/html/upload"
ServerName node3.byq.com:80
DocumentRoot "/var/www/html/upload"
ServerName node4.byq.com:80
DocumentRoot "/var/www/html/upload"