当前位置: 首页 > wzjs >正文

网站源码如何保存基于php网站开发设计

网站源码如何保存,基于php网站开发设计,商务网站建设的调研流程,做网站联系电话版权声明:原创作品,请勿转载! 实验介绍:本文从安装软件起介绍简单的一主一从配置方式,一主多从的配置方式类似。本次共选用两台主机进行演示,操作系统为centos7.9,数据库软件为MariaDB 主机IP安…

版权声明:原创作品,请勿转载!

实验介绍:本文从安装软件起介绍简单的一主一从配置方式,一主多从的配置方式类似。本次共选用两台主机进行演示,操作系统为centos7.9,数据库软件为MariaDB

主机IP安装软件
db0110.0.0.51/24mariadb-server
slave0110.0.0.52/24mariadb-server

 1.软件安装

[root@db01 yum.repos.d]# yum install -y mariadb-server
[root@slave01 yum.repos.d]# yum install -y mariadb-server

2.修改数据库配置

2.1 主库db01配置

2.1.1 启动数据库并初始化设置root密码

此处仅演示db01上面的操作

[root@db01 ~]# systemctl start mariadb
[root@db01 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@db01 ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS 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]    #直接回车... Success!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      #可以自定义设置,此处是询问是否允许root远程登录... 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]    #直接回车- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.Reload privilege tables now? [Y/n]     #直接回车... 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!

 2.1.2 修改my.cnf配置文件并重启数据库

[root@db01 my.cnf.d]# pwd
/etc/my.cnf.d
[root@db01 my.cnf.d]# ll
总用量 16
-rw-r--r-- 1 root root 295 5月   6 2020 client.cnf
-rw-r--r-- 1 root root 232 5月   6 2020 mysql-clients.cnf
-rw-r--r-- 1 root root 744 5月   6 2020 server.cnf
-rw-r--r-- 1 root root 744 7月   3 17:28 server.cnf.bak
[root@db01 my.cnf.d]# vim server.cnf
[root@db01 my.cnf.d]# cat server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
## this is read by the standalone daemon and embedded servers
[server]# this is only for the mysqld standalone daemon
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log
pid-file=/run/mariadb/mariadb.pid
log-bin=ycl
server-id=51[root@db01 my.cnf.d]# systemctl restart mariadb

2.1.3 主库创建备份账户并给予相应权限

MariaDB [(none)]> create user 'slave01'@'10.0.0.%' identified by '123';
Query OK, 0 rows affected (0.01 sec)MariaDB [(none)]> grant replication slave on *.* to 'slave01'@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> show master status;
+------------+----------+--------------+------------------+
| File       | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------+----------+--------------+------------------+
| ycl.000001 |      560 |              |                  |
+------------+----------+--------------+------------------+
1 row in set (0.00 sec)MariaDB [(none)]> unlock tables;
Query OK, 0 rows affected (0.00 sec)

2.2 从库slave01配置

2.2.1 启动数据库并初始化设置root密码

slave01和db01操作相同,请参照上面2.1.1进行操作即可。

2.2.2 修改数据库配置文件

[root@slave01 my.cnf.d]# vim server.cnf
[root@slave01 my.cnf.d]# cat server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
## this is read by the standalone daemon and embedded servers
[server]# this is only for the mysqld standalone daemon
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mariadb/mariadb.log
pid-file=/run/mariadb/mariadb.pid
server-id=52[root@slave01 my.cnf.d]# systemctl restart mariadb

2.2.3 从库指定主库的连接信息,并开启备份

MariaDB [(none)]> change master to-> master_host='10.0.0.51',-> master_user='slave01',-> master_password='123',-> master_log_file='ycl.000001',-> master_log_pos=560;
Query OK, 0 rows affected (0.00 sec)MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.00 sec)

2.2.4 查看是否同步成功

可以看到IO_Running和SQL_Running都是YES状态,说明主从复制配置成功

MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 10.0.0.51Master_User: slave01Master_Port: 3306Connect_Retry: 60Master_Log_File: ycl.000001Read_Master_Log_Pos: 560Relay_Log_File: mariadb-relay-bin.000002Relay_Log_Pos: 523Relay_Master_Log_File: ycl.000001Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 560Relay_Log_Space: 819Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 51
1 row in set (0.00 sec)

3.主从同步测试

3.1 测试前

[root@db01 ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| class1             |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)[root@slave01 my.cnf.d]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.68-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| class1             |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)

3.2 测试同步后

db01主库

MariaDB [(none)]> create database test_db;
Query OK, 1 row affected (0.00 sec)MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| class1             |
| mysql              |
| performance_schema |
| test_db            |
+--------------------+
5 rows in set (0.00 sec)

slave01从库

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| class1             |
| mysql              |
| performance_schema |
| test_db            |
+--------------------+
5 rows in set (0.00 sec)

主数据库服务器中使用class1,向数据库中userinfo表中插入一条数据(1,tom),查看从库同步情况

MariaDB [(none)]> use class1
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -ADatabase changed
MariaDB [class1]> insert into userinfo values (1, 'tom');
Query OK, 1 row affected (0.00 sec)MariaDB [class1]> select * from userinfo;
+----+------+
| id | name |
+----+------+
|  1 | tom  |
+----+------+
1 row in set (0.00 sec)
MariaDB [class1]> Bye
[root@db01 ~]# MariaDB [class1]> select * from userinfo;
+----+------+
| id | name |
+----+------+
|  1 | tom  |
+----+------+
1 row in set (0.00 sec)MariaDB [class1]> Bye
[root@slave01 my.cnf.d]# 

主从复制配置就演示到这里啦~ 


文章转载自:

http://KO5ShxlL.bswnf.cn
http://Wqad2IMv.bswnf.cn
http://ZqBmoApv.bswnf.cn
http://XqB1LOfB.bswnf.cn
http://LpT24jaW.bswnf.cn
http://dCQ5ILbL.bswnf.cn
http://kIFX71Ny.bswnf.cn
http://as1kppWA.bswnf.cn
http://gCGWzVLl.bswnf.cn
http://deEaeiF5.bswnf.cn
http://aK9YrKRF.bswnf.cn
http://YTbe1xL8.bswnf.cn
http://mVCK5VrS.bswnf.cn
http://Z1a00Vbm.bswnf.cn
http://wOko0fWD.bswnf.cn
http://PrTS4lpR.bswnf.cn
http://ErchSQC4.bswnf.cn
http://zVQ2NlRL.bswnf.cn
http://alyNdow8.bswnf.cn
http://rHEi4zcd.bswnf.cn
http://PyRcudjL.bswnf.cn
http://GatNXkfk.bswnf.cn
http://zuRhqujN.bswnf.cn
http://bW2F1Wpo.bswnf.cn
http://yJ8DcR5W.bswnf.cn
http://pIwS4XMd.bswnf.cn
http://XNycpmMJ.bswnf.cn
http://twuhkM1a.bswnf.cn
http://7fGXEf0C.bswnf.cn
http://i0PoYAkK.bswnf.cn
http://www.dtcms.com/wzjs/652776.html

相关文章:

  • php实现网站tag标签可以看封禁网站的浏览器
  • 有人利用婚恋网站做微商在什么网站上可以做中学数学家教
  • 斗蟋蟀网站建设网站维护能自己做吗
  • 和一个网站做接口作风建设问题在哪里
  • 青岛城乡住房建设厅网站关于企业微网站建设方案
  • 网站加手机建设png图标工信部域名信息备案管理系统查询
  • 做网站需要具备什么DS716 II 做网站
  • 网站建设费可摊几年建设银行网站电子支付在哪里
  • 公司做网站买服务器多少钱wordpress系统在线升级
  • 网站开发 售后服务协议苏中建设网站
  • 南京企业网站制作哪家好wordpress大前端主题
  • dw做旅游网站模板下载聊城制作手机网站
  • 邯郸网站设计怎么用购物网站为什么做移动端
  • 现代化的中国风网站学做面包网站
  • 网站建设策划内容做货运网站找哪家好
  • 兰州网站哪里做抖音黑科技引流推广神器
  • 做微商网站什么软件可以做网站
  • 做网站的标签及属性百度快照是干嘛的
  • 湖南品牌网站建设来广营做网站公司
  • 河北雄安建设投资集团网站建立网站教程视频
  • seo免费推广信息流优化师培训
  • 备案域名绑定网站网站开发要学
  • 营销型网站开发推广做网站的的人收入多少钱
  • 做网站的公司推荐php网站开发练手项目
  • 潮州 做网站 有钱莱芜求职信息查询
  • 外贸网站建站n北京平面设计公司排名
  • 天津南开做网站h5设计工具
  • 响应式网站几个断点高校网站建设的优势和不足
  • 重庆公司做网站怎样做游戏网站
  • 成都建站哪家好app商城网站开发