데이터 베이스 MySQL 튜토리얼 mysql高可用方案之MMM

mysql高可用方案之MMM

Jun 07, 2016 pm 02:55 PM
1 mysql 사용 가능 계획 고가용성

环境规划: 主db1 IP:192.168.1.247 host:tong1 主db2 IP:192.168.1.248 host:tong2 从db3 IP:192.168.1.249 host:tong3 monitor IP:192.168.1.249 host:tong3 数据库:mysql-5.6.21 mysqldba技术群 378190849 武汉-linux运维群 236415619 1.网络环境布置 ton

环境规划:

主db1       IP:192.168.1.247   host:tong1

主db2       IP:192.168.1.248   host:tong2

从db3       IP:192.168.1.249   host:tong3

monitor     IP:192.168.1.249   host:tong3

数据库:mysql-5.6.21


mysql dba技术群 378190849

武汉-linux运维群 236415619

 

1.网络环境布置

tong1数据节点:

[root@tong1 ~]# ifconfig  eth0
eth0      Link encap:Ethernet  HWaddr 10:78:D2:C7:83:03 
          inet addr:192.168.1.247  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::1278:d2ff:fec7:8303/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4953337 errors:0 dropped:0 overruns:0 frame:0
          TX packets:78512 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:346785301 (330.7 MiB)  TX bytes:5389268 (5.1 MiB)

[root@tong1 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3

[root@tong1 ~]#

 

tong2数据节点:

[root@tong2 ~]# ifconfig  eth0
eth0      Link encap:Ethernet  HWaddr 10:78:D2:C7:17:E8 
          inet addr:192.168.1.248  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::1278:d2ff:fec7:17e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4930658 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19441 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:315661835 (301.0 MiB)  TX bytes:2133138 (2.0 MiB)

[root@tong2 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3

[root@tong2 ~]#

 

tong3监控节点:

[root@tong3 ~]# ifconfig  eth0
eth0      Link encap:Ethernet  HWaddr 10:78:D2:C8:F7:50 
          inet addr:192.168.1.249  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::1278:d2ff:fec8:f750/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6864426 errors:0 dropped:0 overruns:0 frame:0
          TX packets:99046 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:694563286 (662.3 MiB)  TX bytes:7322797 (6.9 MiB)

[root@tong3 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3
[root@tong3 ~]#

 

2.在监控节点上tong3安装mysql-mmm软件

下载地址:http://mysql-mmm.org/downloads

[root@tong3 ~]# tar xvf mysql-mmm-2.2.1.tar.gz
[root@tong3 ~]# cd mysql-mmm-2.2.1
[root@tong3 mysql-mmm-2.2.1]# make && make install

[root@tong3 mysql-mmm-2.2.1]# mmm_
mmm_agentd   mmm_backup   mmm_clone    mmm_control  mmm_mond     mmm_restore  
[root@tong3 mysql-mmm-2.2.1]# ll /etc/mysql-mmm/
total 16
-rw-r-----. 1 root root   33 Apr 29 14:06 mmm_agent.conf
-rw-r-----. 1 root root  684 Apr 29 14:06 mmm_common.conf
-rw-r-----. 1 root root  321 Apr 29 14:06 mmm_mon.conf
-rw-r-----. 1 root root 1293 Apr 29 14:06 mmm_tools.conf
[root@tong3 mysql-mmm-2.2.1]#


3.在tong1,tong2,tong3节点安装mysql数据库(步骤一样)

[root@tong1 ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz

[root@tong1 ~]# tar xvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz  -C /usr/local/

[root@tong1 ~]# cd /usr/local/

[root@tong1 ~]# mv mysql-5.6.23-linux-glibc2.5-x86_64/ mysql-5.6.23

[root@tong1 ~]# cd mysql-5.6.23/

[root@tong1 ~]# ./scripts/mysql_install_db --user=mysql --group=mysql --basedir=/usr/local/mysql-5.6.23 --datadir=/usr/local/mysql-5.6.23/data

[root@tong1 ~]# cp -a my.cnf  /etc/

[root@tong1 ~]# cp -a support-files/mysql.server  /etc/init.d/mysqld

[root@tong1 ~]# chkconfig  --add mysqld

[root@tong1 ~]# chkconfig  mysqld on

[root@tong1 ~]# vim /etc/my.cnf

basedir = /usr/local/mysql-5.6.23
datadir = /usr/local/mysql-5.6.23/data
port = 3306
server_id = 20             --server_id在三台主机不同,分别用10,20,30表示
socket = /tmp/mysql.sock

[root@tong1 ~]# pkill  mysqld

[root@tong1 ~]# /etc/init.d/mysqld  restart

[root@tong1 ~]# /usr/local/mysql-5.6.23/bin/mysqladmin  -u root password 'system'

[root@tong1 ~]# /usr/local/mysql-5.6.23/bin/mysql -u root -p  --输入密码system
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
[root@tong1 ~]#


4.将tong1和tong2配置成主主架构

tong1节点配置文件:

[root@tong1 ~]# vim /etc/my.cnf

basedir = /usr/local/mysql-5.6.23
datadir = /usr/local/mysql-5.6.23/data
port = 3306
server_id = 20
socket = /tmp/mysql.sock

replicate-do-db=tong                 --复制tong数据库
replicate-ignore-db=mysql            --忽略mysql数据库

log-bin=mysql-bin                    --开启二进制日志
log-bin-index=mysql-bin-index

auto_increment_offset=1
auto_increment_increment=2


relay-log=relay-log                   --开启中继日志
relay-log-index=relay-log-index


log_slave_updates       --当任意一台主宕机,从可以接管主应用
sync-binlog=1

[root@tong1 ~]#


tong2节点配置文件:

[root@tong2 ~]# vim /etc/my.cnf

basedir = /usr/local/mysql-5.6.23
datadir = /usr/local/mysql-5.6.23/data
port = 3306
server_id = 10
socket = /tmp/mysql.sock

replicate-do-db=tong
replicate-ignore-db=mysql

log-bin=mysql-bin
log-bin-index=mysql-bin-index

auto_increment_offset=2
auto_increment_increment=2


relay-log=relay-log
relay-log-index=relay-log-index


log_slave_updates
sync-binlog=1

[root@tong2 ~]#


tong3节点配置文件:

[root@tong3 ~]# vim /etc/my.cnf

basedir = /usr/local/mysql-5.6.23
datadir = /usr/local/mysql-5.6.23/data
port = 3306
server_id = 30
socket = /tmp/mysql.sock

replicate-do-db=tong
replicate-ignore-db=mysql

[root@tong3 ~]#


配置主主模式:

tong1节点:

[root@tong1 ~]# /etc/init.d/mysqld restart
Shutting down MySQL.... SUCCESS!
Starting MySQL. SUCCESS!
[root@tong1 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.23-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant replication slave,replication client on *.* to repl_user@'192.168.1.%' identified by 'system!#%246';         --创建复制用户

Query OK, 0 rows affected (0.00 sec)

mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |      120 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

mysql> 


tong2节点:

[root@tong2 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.23-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant replication slave,replication client on *.* to repl_user@'192.168.1.%' identified by 'system!#%246';

Query OK, 0 rows affected (0.00 sec)

mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |      120 |              |                  |                   |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)

mysql> change master to master_host='192.168.1.247',master_port=3306,master_user='repl_user',master_password='system!#%246',master_log_file='mysql-bin.000001',master_log_pos=120;    --复制tong1中的数据
Query OK, 0 rows affected, 2 warnings (0.50 sec)

mysql> start slave;                 --开启从服务
Query OK, 0 rows affected (0.05 sec)

mysql>


tong1节点:

mysql>  change master to master_host='192.168.1.248',master_port=3306,master_user='repl_user',master_password='system!#%246',master_log_file='mysql-bin.000001',master_log_pos=120;   --复制tong2中的数据
Query OK, 0 rows affected, 2 warnings (0.22 sec)

mysql> start slave;
Query OK, 0 rows affected (0.05 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.248
                  Master_User: repl_user
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 120
               Relay_Log_File: relay-log.000002
                Relay_Log_Pos: 283
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes            --主主同步成功
            Slave_SQL_Running: Yes
              Replicate_Do_DB: tong
          Replicate_Ignore_DB: mysql
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 120
              Relay_Log_Space: 450
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_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: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 10
                  Master_UUID: de5d22d1-ed4b-11e4-9390-1078d2c717e8
             Master_Info_File: /usr/local/mysql-5.6.23/data/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
1 row in set (0.00 sec)


mysql> 



5.测试主主架构是否生效

tong1节点:

mysql> create table a(a int);
Query OK, 0 rows affected (0.39 sec)

mysql> insert into a values(1);
Query OK, 1 row affected (0.03 sec)

mysql> select * from a;
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql>


tong2节点:

mysql> \u tong
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from a;
+------+
| a    |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql> insert into a values(2);
Query OK, 1 row affected (0.03 sec)

mysql> select * from a;
+------+
| a    |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.00 sec)

mysql>


6.将tong3设置成tong1节点的从机

[root@tong3 ~]# /etc/init.d/mysqld  restart

Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@tong3 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.6.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> change master to master_host='192.168.1.247',master_port=3306,master_user='repl_user',master_password='system!#%246',master_log_file='mysql-bin.000001',master_log_pos=120;    --复制tong1中的数据
Query OK, 0 rows affected, 2 warnings (0.27 sec)

mysql> start slave;
Query OK, 0 rows affected (0.07 sec)

mysql> \u tong
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from a;    --数据已同步
+------+
| a    |
+------+
|    1 |
|    2 |
+------+
2 rows in set (0.00 sec)

mysql>


7.在三个数据库节点分别创建监控用户和代理用户

mysql> grant replication client on *.* to 'mmm_moniton'@'192.168.1.%' identified by 'moniton';
Query OK, 0 rows affected (0.00 sec)

mysql>  grant super,replication client,process on *.* to 'mmm_agent'@'192.168.1.%' identified by 'agent';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 


8.在监控节点修改配置文件

[root@tong3 ~]# cd /etc/mysql-mmm/
[root@tong3 mysql-mmm]# ll
total 16
-rw-r-----. 1 root root   33 Apr 29 14:06 mmm_agent.conf
-rw-r-----. 1 root root  684 Apr 29 14:06 mmm_common.conf
-rw-r-----. 1 root root  321 Apr 29 14:06 mmm_mon.conf
-rw-r-----. 1 root root 1293 Apr 29 14:06 mmm_tools.conf
[root@tong3 mysql-mmm]# vim mmm_common.conf 

active_master_role      writer



        cluster_interface              eth0    --心跳网卡接口

        pid_path                       /var/run/mmm_agentd.pid
        bin_path                       /usr/lib/mysql-mmm

        replication_user               repl_user        --复制用户名和密码
        replication_password           system!#%246    

        agent_user                      mmm_agent       --代理用户名和密码
        agent_password                  agent


    --主机名
        ip                              192.168.1.247    --tong1的IP地址
        mode                            master           --主模式
        peer                            tong1            --主机名



        ip                              192.168.1.248
        mode                            master
        peer                            tong2



        ip                              192.168.1.249
        mode                            slave         --从服务器




        hosts                           tong1, tong2     --tong1和tong2可写
        ips                             192.168.1.120
        mode                            exclusive



        hosts                           tong1, tong2, tong3   --三台可读
        ips                             192.168.1.121
        mode                            balanced



[root@tong3 mysql-mmm]# vim mmm_mon.conf

include mmm_common.conf


        ip                                      127.0.0.1
        pid_path                                /var/run/mmm_mond.pid
        bin_path                                /usr/lib/mysql-mmm
        status_path                             /var/lib/misc/mmm_mond.status
        ping_ips                                192.168.1.247, 192.168.1.248, 192.168.1.249
        auto_set_online                         10



        monitor_user                    mmm_moniton    --监控用户名和密码
        monitor_password                moniton


debug 1               --为1是开启服务打印日志,为0是只开启服务

[root@tong3 mysql-mmm]# cat mmm_agent.conf
include mmm_common.conf
this tong3                        --主机名
[root@tong3 mysql-mmm]#


9.将tong3节点的mmm_common.conf复制到tong1和tong2节点中

[root@tong3 mysql-mmm]# scp mmm_common.conf tong1:/etc/mysql-mmm/
mmm_common.conf                              100%  674     0.7KB/s   00:00    
You have mail in /var/spool/mail/root
[root@tong3 mysql-mmm]# scp mmm_common.conf tong2:/etc/mysql-mmm/
mmm_common.conf                              100%  674     0.7KB/s   00:00    
[root@tong3 mysql-mmm]# 


tong1,tong2修改mmm_agent.conf文件并启动服务

[root@tong1 mysql-mmm]# cat mmm_agent.conf
include mmm_common.conf
this tong1                        --修改主机名
[root@tong1 mysql-mmm]# /etc/init.d/mysql-mmm-agent restart    --重启服务
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Shutting down MMM Agent daemon. Ok
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Starting MMM Agent daemon... Ok
[root@tong1 mysql-mmm]# 


tong3启动mmm-mysql-agent和mysql-mmm-monitor服务

[root@tong3 mysql-mmm]# /etc/init.d/mysql-mmm-agent  restart
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Shutting down MMM Agent daemon. Ok
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Starting MMM Agent daemon... Ok
[root@tong3 mysql-mmm]# /etc/init.d/mysql-mmm-monitor  restart
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Shutting down MMM Monitor daemon:  not running.
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Starting MMM Monitor daemon: Ok
[root@tong3 mysql-mmm]# mmm_control  show
  tong1(192.168.1.247) master/ONLINE. Roles: writer(192.168.1.120)
  tong2(192.168.1.248) master/ONLINE. Roles:
  tong3(192.168.1.249) slave/ONLINE. Roles: reader(192.168.1.121)

[root@tong3 mysql-mmm]# mmm_control  set_offline tong1
OK: State of 'tong1' changed to ADMIN_OFFLINE. Now you can wait some time and check all roles!
[root@tong3 mysql-mmm]# mmm_control  show
  tong1(192.168.1.247) master/ADMIN_OFFLINE. Roles:
  tong2(192.168.1.248) master/ONLINE. Roles: writer(192.168.1.120)
  tong3(192.168.1.249) slave/ONLINE. Roles: reader(192.168.1.121)

[root@tong3 mysql-mmm]# mmm_control  set_offline tong3
OK: State of 'tong3' changed to ADMIN_OFFLINE. Now you can wait some time and check all roles!
[root@tong3 mysql-mmm]# mmm_control  show
  tong1(192.168.1.247) master/ADMIN_OFFLINE. Roles:
  tong2(192.168.1.248) master/ONLINE. Roles: reader(192.168.1.121), writer(192.168.1.120)
  tong3(192.168.1.249) slave/ADMIN_OFFLINE. Roles:

[root@tong3 mysql-mmm]# mmm_control  set_online tong1
OK: State of 'tong1' changed to ONLINE. Now you can wait some time and check its new roles!
[root@tong3 mysql-mmm]# mmm_control  set_online tong3
OK: State of 'tong3' changed to ONLINE. Now you can wait some time and check its new roles!
[root@tong3 mysql-mmm]# mmm_control  show
  tong1(192.168.1.247) master/ONLINE. Roles: reader(192.168.1.121)
  tong2(192.168.1.248) master/ONLINE. Roles: writer(192.168.1.120)
  tong3(192.168.1.249) slave/ONLINE. Roles:

You have mail in /var/spool/mail/root
[root@tong3 mysql-mmm]

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
2 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
2 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

PHP의 빅데이터 구조 처리 능력 PHP의 빅데이터 구조 처리 능력 May 08, 2024 am 10:24 AM

빅 데이터 구조 처리 기술: 청킹(Chunking): 데이터 세트를 분할하고 청크로 처리하여 메모리 소비를 줄입니다. 생성기: 전체 데이터 세트를 로드하지 않고 데이터 항목을 하나씩 생성하므로 무제한 데이터 세트에 적합합니다. 스트리밍: 파일을 읽거나 결과를 한 줄씩 쿼리하므로 대용량 파일이나 원격 데이터에 적합합니다. 외부 저장소: 매우 큰 데이터 세트의 경우 데이터를 데이터베이스 또는 NoSQL에 저장합니다.

PHP에서 MySQL 백업 및 복원을 사용하는 방법은 무엇입니까? PHP에서 MySQL 백업 및 복원을 사용하는 방법은 무엇입니까? Jun 03, 2024 pm 12:19 PM

PHP에서 MySQL 데이터베이스를 백업하고 복원하는 작업은 다음 단계에 따라 수행할 수 있습니다. 데이터베이스 백업: mysqldump 명령을 사용하여 데이터베이스를 SQL 파일로 덤프합니다. 데이터베이스 복원: mysql 명령을 사용하여 SQL 파일에서 데이터베이스를 복원합니다.

PHP에서 MySQL 쿼리 성능을 최적화하는 방법은 무엇입니까? PHP에서 MySQL 쿼리 성능을 최적화하는 방법은 무엇입니까? Jun 03, 2024 pm 08:11 PM

선형 복잡성에서 로그 복잡성까지 조회 시간을 줄이는 인덱스를 구축하여 MySQL 쿼리 성능을 최적화할 수 있습니다. SQL 삽입을 방지하고 쿼리 성능을 향상하려면 PREPAREDStatements를 사용하세요. 쿼리 결과를 제한하고 서버에서 처리되는 데이터의 양을 줄입니다. 적절한 조인 유형 사용, 인덱스 생성, 하위 쿼리 사용 고려 등 조인 쿼리를 최적화합니다. 쿼리를 분석하여 병목 현상을 식별하고, 캐싱을 사용하여 데이터베이스 로드를 줄이고, 오버헤드를 최소화합니다.

PHP를 사용하여 MySQL 테이블에 데이터를 삽입하는 방법은 무엇입니까? PHP를 사용하여 MySQL 테이블에 데이터를 삽입하는 방법은 무엇입니까? Jun 02, 2024 pm 02:26 PM

MySQL 테이블에 데이터를 삽입하는 방법은 무엇입니까? 데이터베이스에 연결: mysqli를 사용하여 데이터베이스에 대한 연결을 설정합니다. SQL 쿼리 준비: 삽입할 열과 값을 지정하는 INSERT 문을 작성합니다. 쿼리 실행: query() 메서드를 사용하여 삽입 쿼리를 실행하면 확인 메시지가 출력됩니다.

PHP에서 MySQL 저장 프로시저를 사용하는 방법은 무엇입니까? PHP에서 MySQL 저장 프로시저를 사용하는 방법은 무엇입니까? Jun 02, 2024 pm 02:13 PM

PHP에서 MySQL 저장 프로시저를 사용하려면: PDO 또는 MySQLi 확장을 사용하여 MySQL 데이터베이스에 연결합니다. 저장 프로시저를 호출하는 문을 준비합니다. 저장 프로시저를 실행합니다. 결과 집합을 처리합니다(저장 프로시저가 결과를 반환하는 경우). 데이터베이스 연결을 닫습니다.

PHP를 사용하여 MySQL 테이블을 만드는 방법은 무엇입니까? PHP를 사용하여 MySQL 테이블을 만드는 방법은 무엇입니까? Jun 04, 2024 pm 01:57 PM

PHP를 사용하여 MySQL 테이블을 생성하려면 다음 단계가 필요합니다. 데이터베이스에 연결합니다. 데이터베이스가 없으면 작성하십시오. 데이터베이스를 선택합니다. 테이블을 생성합니다. 쿼리를 실행합니다. 연결을 닫습니다.

MySQL 8.4에서 mysql_native_password가 로드되지 않음 오류를 수정하는 방법 MySQL 8.4에서 mysql_native_password가 로드되지 않음 오류를 수정하는 방법 Dec 09, 2024 am 11:42 AM

MySQL 8.4(2024년 최신 LTS 릴리스)에 도입된 주요 변경 사항 중 하나는 "MySQL 기본 비밀번호" 플러그인이 더 이상 기본적으로 활성화되지 않는다는 것입니다. 또한 MySQL 9.0에서는 이 플러그인을 완전히 제거합니다. 이 변경 사항은 PHP 및 기타 앱에 영향을 미칩니다.

오라클 데이터베이스와 mysql의 차이점 오라클 데이터베이스와 mysql의 차이점 May 10, 2024 am 01:54 AM

Oracle 데이터베이스와 MySQL은 모두 관계형 모델을 기반으로 하는 데이터베이스이지만 호환성, 확장성, 데이터 유형 및 보안 측면에서 Oracle이 우수하고, MySQL은 속도와 유연성에 중점을 두고 중소 규모 데이터 세트에 더 적합합니다. ① Oracle은 광범위한 데이터 유형을 제공하고, ② 고급 보안 기능을 제공하고, ③ 엔터프라이즈급 애플리케이션에 적합하고, ① MySQL은 NoSQL 데이터 유형을 지원하고, ② 보안 조치가 적고, ③ 중소 규모 애플리케이션에 적합합니다.

See all articles