首页 > 数据库技术 > 详细

linux运维、架构之路-数据库迁移

时间:2017-09-26 15:38:11      阅读:290      评论:0      收藏:0      [点我收藏+]

一、wordpress搭建

1、wordpress下载部署

cd /server/tools/
wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz
tar xf wordpress-4.8.1-zh_CN.tar.gz
mv wordpress/* /application/nginx/html/blog/
chown -R www.www /application/nginx/html/blog/

注意:确认hosts文件进行了解析
浏览器页面输入blog.etiantian.org/进行wordpress部署        
vim wp-config.php可以修改wordpress上的数据库连接参数信息

2、数据库创建管理wordpress用户及授权

create database wordpress;
grant all on wordpress.* to wordpress@172.16.1.% identified by 123456;
select user,host from mysql.user;
grant all on wordpress.* to wordpress@localhost identified by 123456;
flush privileges;

3、 搭建网站基本流程

①要有网站代码(向开发人员要)

wordpress Discuz DedeCMS……等开源软件

②进入到代码程序目录中,将代码信息移动到站点目录下

mv ./* /application/nginx/html/blog/

③修改站点目录权限

chown -R www.www /application/nginx/html/blog/

④进行网站初始化

create database wordpress;
grant all on wordpress.* to wordpress@172.16.1.% identified by oldboy123;
grant all on wordpress.* to wordpress@localhost identified by oldboy123;
flush privileges;

二、数据库迁移

1、备份web01数据库数据

mysqldump -uroot -p123456 --all-databases >/tmp/bak_$(date +%F).sql

2、把备份到的数据远程拷贝到独立数据库db01(172.16.1.51)上面

scp -rp /tmp/bak_2017-09-25.sql 172.16.1.51:/tmp/

3、db01导入数备份的据库信息

mysql -uroot -p123456 </tmp/bak_2017-09-25.sql
flush privileges;

4、数据库迁移完毕,修改网站连接数据库的配置文件

vi wp-config.php 
注:修改localhost为远程db01的数据库IP地址
此时web服务器的数据库就可以停止服务了,至此数据库迁移完毕

技术分享

三、站点数据迁移到NFS共享目录

1、将原有目录中的数据移出

/application/nginx/html/blog/wp-content
mkdir /tmp/wordpress_backup -p
mv uploads/* /tmp/wordpress_backup/

2、NFS服务器上面配置创建共享目录

echo "/data 172.16.1.0/24(rw,sync,all_squash)" >>/etc/exports
/etc/init.d/nfs restart
showmount -e 172.16.1.31
mount -t nfs 172.16.1.31:/data /application/nginx/html/blog/wp-content/uploads/
mv /tmp/wordpress_backup/* .

3、wordpress博客站点配置文件

[root@web01 extra]# cat blog.conf 
    server {
        listen       80;
        server_name  blog.etiantian.org;
        location / {
            root   html/blog;
            index index.php index.html index.htm;
        }
        location ~ .*\.(php|php5)?$ {
            root   html/blog;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }
    }

4、其它bbs、cms网站搭建类似

 

linux运维、架构之路-数据库迁移

原文:http://www.cnblogs.com/yanxinjiang/p/7596903.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!