discuz mysql data_让discuz论坛的数据共享一个mysql数据库

让两台Web服务器使用同一个数据库来为用户提供discuz的论坛服务

d9520ce2d7c7e707f3459ecacf7824de.png

实验环境:

系统: Linux  5.8

所需的rpm包(系统光盘上自带的有):

httpd ,php53, php53-mbsting, php53-mysql, mysql, mysql-server

以及Discuz_7.2_FULL_SC_GBK.zip的源码包

首先请关闭selinux

# setenforce 0

1.在Server1上安装相关的rpm包

# yum -y install httpd php53 php53-mbstring php53-mysql

# /etc/init.d/httpd start

Starting httpd:                                            [  OK  ]

# chkconfig httpd on

测试apache是否能正常工作

ed9066ee1a87894094980ed067f323bc.png

# vi /etc/httpd/conf/httpd.conf

DirectoryIndex index.php  -->编辑这一项

# cd /var/www/html/

# vi index.php

phpinfo();

?>

# /etc/init.d/httpd restart

Stopping httpd:                                            [  OK  ]

Starting httpd:                                            [  OK  ]

测试php页面

2.安装discuz

# unzip Discuz_7.2_FULL_SC_GBK.zip -d /var/www/html/

# cd /var/www/html/

# rm -rf index.php readme utilities

# mv upload/* ./

# setfacl -m u:apache:rwx ./config.inc.php ./p_w_uploads/ ./forumdata/ ./forumdata/cache/ ./forumdata/templates/ ./forumdata/threadcaches/ ./forumdata/logs/ ./uc_client/data/cache/

3.更改php主配置文件

# vi /etc/php.ini

short_open_tag=On

date.timezone=Asia/Shanghai

解决乱码

# vi /etc/httpd/conf/httpd.conf

注释掉: AddDefaultCharsetUTF-8

4. 在172.16.45.2 上安装mysql

# yum -y install mysql mysql-server

# /etc/init.d/mysql start        -->  初始化数据库

# mysql

mysql>use mysql            设定当前默认操作的表

Reading table information for completion of table and column names

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

Databasechanged

mysql>SELECThost,user,passwordFROMuser;            查看用户信息

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

| host                  | user|password|

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

| localhost             | root |          |

| station90.example.com | root |          |

| 127.0.0.1             | root |          |

| localhost             |      |          |

| station90.example.com |      |          |

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

5 rowsinset(0.01 sec)

mysql>UPDATEuserSETpassword=password('redhat')WHEREuser='root';    为所有root用户更改密码

Query OK, 3 rowsaffected (0.00 sec)

Rowsmatched: 3  Changed: 3  Warnings: 0

mysql>SELECThost,user,passwordFROMuser;

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

| host                  | user|password|

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

| localhost             | root | 27c30f0241a5b69f |

| station90.example.com | root | 27c30f0241a5b69f |

| 127.0.0.1             | root | 27c30f0241a5b69f |

| localhost             |      |                  |

| station90.example.com |      |                  |

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

5 rowsinset(0.00 sec)

mysql>DROPUSER''@localhost;                删除匿名用户

Query OK, 0 rowsaffected (0.00 sec)

mysql>DROPUSER''@station90.example.com;

Query OK, 0 rowsaffected (0.00 sec)

mysql>SELECThost,user,passwordFROMuser;

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

| host                  | user|password|

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

| localhost             | root | 27c30f0241a5b69f |

| station90.example.com | root | 27c30f0241a5b69f |

| 127.0.0.1             | root | 27c30f0241a5b69f |

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

3 rowsinset(0.00 sec)

mysql>CREATEDATABASEdiscuz_db;                为discuz创建所需的数据库

Query OK, 1 row affected (0.00 sec)

mysql>GRANTALLONdiscuz_db.*TOdiscuz@'172.16.45.1'IDENTIFIEDBY'redhat';        为discuz这个用户授权

Query OK, 0 rowsaffected (0.00 sec)

mysql>GRANTALLONdiscuz_db.*TOdiscuz2@'172.16.45.3'IDENTIFIEDBY'redhat';    为discuz2这个用户授权

Query OK, 0 rowsaffected (0.00 sec)

mysql>FLUSH PRIVILEGES;                            更新授权表

Query OK, 0 rowsaffected (0.00 sec)

mysql> \q

Bye

# /etc/init.d/mysqld restart

Stopping MySQL:                                            [  OK  ]

Starting MySQL:                                            [  OK  ]

在浏览器中输入:172.16.45.1/install 进入discuz的安装配置界面

6a4d5f0f838945e28e898c90b6ea72ca.png

ef1fdf5d28f7a779d030f9490e97993e.png

0b33d784a62cd1523313bcdcccde83fe.png

b4a828fc943a6a0de5552dd41f4cff99.png

61d56d89b2c73be08facb6466573e757.png

5. 按照前面的方法在Server2上安装并配置好httpd、php和discuz

6.在浏览器中输入:172.16.45.3/intsall 安装配置Server2上的discuz

538a7c60daf5971a15c7d40232522cd7.png

选择强制安装

7.共享172.16.45.1的数据

(1).编辑 /etc/exports

添加:/var/www/html/p_w_uploads  172.16.45.3(ro)

8.在172.16.45.3上挂载共享目录

# mount -t nfs  172.16.45.1:/var/www/html/p_w_uploads   /var/www/html/p_w_uploads

开机自动挂载: 编辑/etc/fstab

172.16.45.1:/var/www/html/p_w_uploads    /var/www/html/p_w_uploads    nfs    defaults     0  0

over!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值