19.1、LNMP一体机的数据库分离成独立的数据库:

1、根据以上学习过的方法在db01服务器上安装独立的mysql数据库软件:

2、在web01服务器上导出原先的数据库:

[root@web01 tools]# mysqldump -uroot -p123456 -R --single-transaction --master-data=1 -F -B wordpress | gzip>bak.sql.gz

#-A: 备份所有的库,也可以单独指定库;

3、拷贝导出的数据库到db01服务器上:

[root@web01 tools]# scp -P22 bak.sql.gz root@172.16.1.51:/tmp/

4、在db01数据库上还原在web01上导出的数据库:

[root@db01 tmp]# gzip -d bak.sql.gz

[root@db01 tmp]# mysql -uroot -p123456 </tmp/bak.sql

[root@db01 tmp]# mysql -uroot -p123456 -e "show databases;"

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

| Database |

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

| information_schema |

| mysql |

| performance_schema |

| test |

| wordpress |

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

[root@db01 tmp]# mysql -uroot -p123456 -e "use wordpress;show tables;"

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

| Tables_in_wordpress |

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

| lc_commentmeta |

| lc_comments |

| lc_links |

| lc_options |

| lc_postmeta |

| lc_posts |

| lc_term_relationships |

| lc_term_taxonomy |

| lc_termmeta |

| lc_terms |

| lc_usermeta |

| lc_users |

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

5、为worpress数据库设置管理用户和访问的网段:

[root@db01 tmp]# mysql -uroot -p123456

mysql> grant all on wordpress.* to wordpress@'172.16.1.%' identified by '123456';

6、关闭web01服务器上的数据库,关闭开机自启动功能:

[root@web01 tools]# /etc/init.d/mysqld stop

Shutting down MySQL.. [确定]

[root@web01 tools]# chkconfig mysqld off

[root@web01 tools]# chkconfig --list mysqld

mysqld 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭

7、更改wb01服务器上nginx中php的配置:

[root@web01 tools]# cd /application/nginx/html/php/

[root@web01 php]# vim wp-config.php

/** MySQL主机 */

define('DB_HOST', '172.16.1.51');

8、访问网页:

9、查看数据库中的内容:

[root@db01 tmp]# mysql -uroot -p123456

mysql> use wordpress; #切换用户管理的库;

Database changed

mysql> select * from lc_posts\G; #\G代表进行竖行显示;

*************************** 1. row ***************************

ID: 1

post_author: 1

post_date: 2018-11-22 14:31:27

post_date_gmt: 2018-11-22 06:31:27

post_content: 欢迎使用WordPress。这是您的第一篇文章。编辑或删除它,然后开始写作吧!

post_title: 世界,您好!

post_excerpt:

post_status: trash

comment_status: open

ping_status: open

post_password:

post_name: hello-world__trashed

to_ping:

pinged:

post_modified: 2018-11-22 21:49:16

post_modified_gmt: 2018-11-22 13:49:16

post_content_filtered:

post_parent: 0

guid: http://www.php.com/?p=1

menu_order: 0

post_type: post

post_mime_type:

comment_count: 1

19.2、将lnmp,web01服务器的上传目录独立分离到nfs服务器上,这样就可以保证访问任何一台web服务器都能够访问到相同的资源:

1、需要注意的是nfs目录和nginx,php目录的虚拟用户要保持一致性;

[root@web01 ~]# id nginx

uid=889(nginx) gid=889(nginx) 组=889(nginx)

[root@nfs01 ~]# cat /etc/exports

/data 172.16.1.0/24(rw,sync,all_squash,anonuid=889,anongid=889)

[root@nfs01 ~]# useradd -u 889 -Ms /sbin/nginx nginx

[root@nfs01 ~]# id nginx

uid=889(nginx) gid=889(nginx) 组=889(nginx)

[root@nfs01 ~]# chown -R nginx:nginx /data/

[root@nfs01 ~]# ls -ld /data

drwxr-xr-x 3 nginx nginx 4096 11月 2 15:29 /data

[root@nfs01 ~]# /etc/init.d/nfs reload

2、挂载nfs共享存储:

[root@web01 ~]# rpm -qa rpcbind nfs-utils

nfs-utils-1.2.3-78.el6.x86_64

rpcbind-0.2.0-16.el6.x86_64

[root@web01 ~]# chkconfig --list rpcbind

rpcbind 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭

[root@web01 ~]# showmount -e 172.16.1.31

Export list for 172.16.1.31:

/data 172.16.1.0/24

[root@web01 ~]# cd /application/nginx/html/php/wp-content/uploads

[root@web01 uploads]# ls

2018

[root@web01 uploads]# mv 2018/ /tmp/ #导出原来的图片

[root@web01 uploads]# mount -t nfs 172.16.1.31:/data/ /application/nginx/html/php/wp-content/uploads/

[root@web01 uploads]# df -h

172.16.1.31:/data/ 57G 1.7G 53G 4% /application/nginx-1.8.1/html/php/wp-content/uploads

3、把挂载nfs共享存储加入到开机自启中:

[root@web01 /]# vim /etc/rc.local

mount -t nfs 172.16.1.31:/data/ /application/nginx/html/php/wp-content/uploads/

提示:另外 下面两个需要加入到开机自启动之中:

/application/nginx/sbin/nginx #启动nginx

/application/php/sbin/php-fpm #启动php

4、测试:

图片没有了:

5、还原图片

[root@web01 uploads]# cp -av /tmp/2018/ .#

刷新页面:

6、查看用户上传的图片和文件:

[root@nfs01 11]# pwd

/data/2018/11

[root@nfs01 11]# ls -l

-rw-r--r-- 1 nginx nginx 42545 11月 22 21:56 323415-1024x576.jpg

-rw-r--r-- 1 nginx nginx 55651 11月 22 21:56 323415-1200x675.jpg

-rw-r--r-- 1 nginx nginx 3715 11月 22 21:56 323415-150x150.jpg

-rw-r--r-- 1 nginx nginx 6668 11月 22 21:56 323415-300x169.jpg

-rw-r--r-- 1 nginx nginx 26806 11月 22 21:56 323415-768x432.jpg

-rw-r--r-- 1 nginx nginx 457776 11月 22 21:56 323415.jpg

[root@web01 11]# pwd

/application/nginx/html/php/wp-content/uploads/2018/11

[root@web01 11]# ls -l

-rw-r--r-- 1 nginx nginx 42545 11月 22 21:56 323415-1024x576.jpg

-rw-r--r-- 1 nginx nginx 55651 11月 22 21:56 323415-1200x675.jpg

-rw-r--r-- 1 nginx nginx 3715 11月 22 21:56 323415-150x150.jpg

-rw-r--r-- 1 nginx nginx 6668 11月 22 21:56 323415-300x169.jpg

-rw-r--r-- 1 nginx nginx 26806 11月 22 21:56 323415-768x432.jpg

-rw-r--r-- 1 nginx nginx 457776 11月 22 21:56 323415.jpg

19、lnmp_mysql、nfs组件分离的更多相关文章

  1. 第19讲- UI组件之_Button、checkbox、radio

    第19讲 UI组件之_Button.checkbox.radio 四.按钮Button Button继承自TextView,间接继承自View.当用户对按钮进行操作的时候,触发相应事件,如点击,触摸. ...

  2. 记录一次vxworks下使用NFS组件的过程

    问题:有三块CPU都运行vxworks6.9,现在想要CPU3做server,CPU1-2通过NFS访问CPU3上的文件 补充:使用防火墙可能会影响NFS访问,目前我还没有找到解决办法... 下面是过 ...

  3. React 设计模式 --- Container and Presentational pattern(容器和展示组件分离)

    在React开发中,一个典型的React组件通常会混杂着逻辑操作部分和展示部分.逻辑操作部分指的是和页面UI无关的内容,如API的调用,数据的处理,事件处理函数. 展示部分则指的是创建页面UI 的内容 ...

  4. 19,django组件之contenttype(一)

    django组件之contenttype(一) 方式1:适用于1张表和另一张表要关联的时候. 1.路飞学成表设计: 2.将2个价格策略表合并1张表. 3.如果再加一张表,那价格策略表的表结构会发生改变 ...

  5. HarmonyOS三方件开发指南(19)-BGABadgeView徽章组件

    目录: 1.引言 2.功能介绍 3.BGABadgeView 使用指南 4.BGABadgeView 开发指南 5.<HarmonyOS三方件开发指南>系列文章合集 引言 现在很多的APP ...

  6. SpringBootSecurity学习(19)前后端分离版之OAuth2.0 token的存储和管理

    内存中存储token 我们来继续授权服务代码的下一个优化.现在授权服务中,token的存储是存储在内存中的,我们使用的是 InMemoryTokenStore : 图中的tokenStore方法支持很 ...

  7. 网站集群架构(LVS负载均衡、Nginx代理缓存、Nginx动静分离、Rsync+Inotify全网备份、Zabbix自动注册全网监控)--技术流ken

    前言 最近做了一个不大不小的项目,现就删繁就简单独拿出来web集群这一块写一篇博客.数据库集群请参考<MySQL集群架构篇:MHA+MySQL-PROXY+LVS实现MySQL集群架构高可用/高 ...

  8. IoC之AutoFac(一)——简单使用和组件注册

    阅读目录 一.AutoFac简单使用 二.注册 2.1 注册方式 2.2 带参数注册 回到顶部 一.AutoFac简单使用 1 namespace AutofacDemo 2 { 3 class Pr ...

  9. Ubuntu搭建NFS

    NFS全称是Network File System,网络文件系统.它可以通过网络实现文件共享.其结构图大概是这样的: 在机器E上开启NFS服务,机器ABCD都挂载NFS,这样可以实现机器ABCD共享文 ...

随机推荐

  1. [c++] 文件包含

    当一个类用到另一个类时,有两种包含方式,在.h中包含和在.cpp中包含 用到公共类库时,在.h文件中包含(公共类库可视为不变的) 用到项目开发过程中自己或同事写的类时,在.cpp文件中包含(可能根据需 ...

  2. 寻找CPU使用率高的进程方法

    寻找CPU使用率高的进程方法 发布时间:  2017-07-13 浏览次数:  1362 下载次数:  0 问题描述 节点报CPU使用率高,甚至出现"ALM-12016 CPU使用率超过阈值 ...

  3. 855 gpu强 730 3倍

    骁龙730G的GPU规模只有骁龙835的GPU规模的一半,Adreno 618是128 ALUs,而Adreno 540是256 ALUs. 根据GFXBench的数据,对GPU负载比较大的曼哈顿3. ...

  4. 那些天,shell脚本中曾经踩过的坑

    前些天,需要实现一个需求,用脚本轮流kill服务器上的进程,观察内存变化情况,并写日志.脚本逻辑不难,但shell脚本好久不用,看过书里的语法都忘得差不多了,中间踩了不少的坑,特此记录一下,留作后续参 ...

  5. linux 修改IP, DNS -(转自fighter)

    linux下修改IP.DNS.路由命令行设置 ubuntu 版本命令行设置IP cat /etc/network/interfaces # This file describes the networ ...

  6. 【Web前端HTML5&CSS3】12-字体

    笔记来源:尚硅谷Web前端HTML5&CSS3初学者零基础入门全套完整版 目录 字体 1. 字体相关的样式 2. font-family 3. 几种字体 手写体 艺术体 乱码字体 中文字体 4 ...

  7. 企业实施CRM系统后的积极作用

    公司在发展过程中,可能会遇到各种各样的问题,尤其是来自客户的问题,是最令广大企业头痛的.这并不是一个单方面的问题,不仅涉及到员工也涉及到企业.因此,许多企业使用CRM客户管理系统来管理客户,并通过它来 ...

  8. GO学习-(33) Go实现日志收集系统2

    Go实现日志收集系统2   一篇文章主要是关于整体架构以及用到的软件的一些介绍,这一篇文章是对各个软件的使用介绍,当然这里主要是关于架构中我们agent的实现用到的内容 关于zookeeper+kaf ...

  9. GO学习-(2) 从零开始搭建Go语言开发环境

    从零开始搭建Go语言开发环境 一步一步,从零搭建Go语言开发环境. 安装Go语言及搭建Go语言开发环境 下载 下载地址 Go官网下载地址:https://golang.org/dl/ Go官方镜像站( ...

  10. MySQL 基础、安装、配置

    1. MySQL 基础 1.1 什么是数据库? 1.2 数据库的类型 1.3 关系型数据库的优点 1.4 MySQL 简介 1.5 MySQL 数据类型 1.6 Mysql 存储引擎 1.7 MySQ ...