从节点的配置与主节点完全一样,为了便于区分我也修改了从节点的首页
接着我用虚拟IP进行访问,测试反向代理是否成功
cd /usr/local/tomcat8/conf #修改两台节点服务器的主配置文件
vim server.xml #跳到行尾,在Host name下新增 148
<Context path="" docBase="SLSaleSystem" reloadable="true" debug="0"></Context> #跳到行尾,在Host name下新增 日志调试信息debug为0表示信息越少,docBase指定访问目录
三 部署MySQL数据库(在主从服务器上都要部署)
这里为了节省时间我采用yum安装mariadb数据库来代替MySQL数据库,这两个数据库的功能相同,而且mariadb的配置更加简单
yum install mariadb-server mariadb -y
systemctl enable mariadb.service
systemctl start mariadb.service #开启数据库
netstat -ntap | grep 3306 #查看数据库端口
[root@localhost ~]# 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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): #这里可以直接回车,这时我还没有密码
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set 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.
Remove anonymous users? [Y/n] n #这里问是否删除匿名用户,选择no
... skipping.
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n #这里问是否拒绝管理员进行远程登录,选择no
... skipping.
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.
Remove test database and access to it? [Y/n] n #这里问是否删除默认测试数据库,选择no
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y #最后问是否现在加载权限表,选择yes
... 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!
导入slsaledb数据库
mysql -u root -p < slsaledb-2014-4-10.sql
mysql -u root -p
show databases;
MariaDB [(none)]> GRANT all ON slsaledb.* TO 'root'@'%' IDENTIFIED BY '123456'; #给root用户授权,让其可以管理slsaledb
MariaDB [(none)]> flush privileges; #重新加载数据库权限
在从数据库上进行同样的部署
以下操作在两台tomcat节点做