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

网站源码如何保存国内外贸平台有哪些

网站源码如何保存,国内外贸平台有哪些,深圳制作企业网站的公司,dw织梦做网站版权声明:原创作品,请勿转载! 实验介绍:本文从安装软件起介绍简单的一主一从配置方式,一主多从的配置方式类似。本次共选用两台主机进行演示,操作系统为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://www.dtcms.com/wzjs/798453.html

相关文章:

  • 为什么网站突然打不开可以做哪些有趣的网站
  • 工厂做哪个网站好其它类型的定制营销型网站
  • 电子商务网站规书凡科网登录入口注册
  • 企业网站建站方案app调用 wordpress
  • 商城系统网站模板免费下载seo推广淘客
  • 莆田做网站公司论述农产品电商网站建设
  • 北海做网站网站建设网站建设合同 协议书
  • 个人网站做电影资源链接犯法吗织梦教程网
  • 免费的ui设计的网站重庆整合营销网站建设
  • 各大网站公司自己做网站推广
  • 郑州服装网站建设做虾皮网站赚钱吗
  • 网站建设分金手指科捷13海口制作网页公司
  • 上国外网站用什么机箱好网站下载app连接怎么做
  • 网站设计集团seo专业知识培训
  • 获取网站访客qq号手表回收网网站
  • 合肥房产网官方网站wordpress本地搬家
  • 美容养生连锁东莞网站建设浙江省建设网证书查询
  • 企业网站不被百度收录威海做网站
  • 坪山网站建设行业现状电子商务网站建设的需求
  • 做淘宝团购的网站wordpress 小工具 插件
  • 国外做图标网站青岛哪家做网站的公司
  • 网站通栏广告代码做暧暧国外网站
  • 在菲做平台网站网站换模板影响
  • 做网站可以用什么主题合肥网站建设首选 晨飞网络
  • 济南 网站 建设北京做网站建设
  • 设计网站如何打造收费做一个分销系统要多少钱
  • 产品网站免费模板下载地址网站开发的职业目标
  • 精准数据营销方案二级域名和一级域名优化难度
  • 重庆招聘网站有哪些合肥建站网站平台
  • 基金会网站开发方案外贸销售模式