In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Common problems encountered in databases:
1. Upward expansion of scale up (personal hardware expansion) disadvantage: easy to reach the limit
two。 Expand scale out outward (the number of computers, grouped into clusters)
Moore's Law: every 18 months, the technology of the chip doubles, the price doubles, and the volume doubles.
Master-slave implementation of mysql:
High availability architecture diagram of enterprise database:
Mysql's built-in replication function is the basis for building large, high-performance applications.
Characteristics of mysql replication:
* how to copy mysql:
Master-slave replication of mysql is asynchronous.
Binlog binary log
Dump: a thread in the main mysql that sets the binary log
Icano thread: pull binaries on the main mysql and record them in relaylog
SQL thread: pull the log contents from relaylog and write to the database
Master-slave replication of mysql solves the problem of high availability
Actual combat exercise:
Master-Slave implementation of mysql
Master: vim / etc/my.cnf server-id=1 gives the server a unique ID number log_bin=mysql-bin opens binary file skip-name-resolve name resolution hostname mysql-master modifies hostname systemctl start mariadb cd / var/lib/mysql ls to check whether binary logs are generated mysql- uroot-p > GRANT REPLICATION SLAVE,REPLICATION CLIENT ON *. * TO slave@'172.17./%.%' IDENTIFIED BY 'magedu' Authorize / / > flush tables with read lock to lock / / > unlocak tables unlock the table > create database magedu; > use magedu; > create table M26 (id int not null,name char (20)); > show create table M26\ G; > insert into M26 values; > show binlog events; > show master status
From:
Vim / etc/mysql server-id=2 relay-log=mysql-relay-bin read_only = 1 log_bin = mysql-bin log_slave_updates=1 systemctl start mariadb cd / var/lib/mysql ls to see if a binary log is generated before starting the replication thread Specify the configuration of the server mysql- uroot-p > CHANGE MASTER TO MASTER_HOST='172.17.0.159', MASTER_USER='SLAVE', MASTER_PASSWORD='magedu', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=811 > start slave; > show tabless; > create tables M27 (id int not null,name char (20)); insert table on slave server > select * from M26
Show slave status\ G to see if it is successful
Implement the master-slave architecture:
The slave node needs to open the binary log, and the master-slave architecture can be built.
Mysql replication filter: limited to one or more data-related data, not all, carried out by the replication filter
What is self-growing ID:
What is a primary key: there are several attributes in a record in relational data. If one of the attribute groups (note that it is a group) can uniquely identify a record, the attribute group can become a primary key.
The function of primary key: 1. Can guarantee the uniqueness of the data, will not produce redundant data 2. It can speed up the operation of data.
Foreign keys: used for linked list query
Index: it is a collection of one or more column values in a table and a corresponding list of logical pointers to the data pages that physically identify these values in the table
The function of index is to help query data quickly.
Mysql master and slave each other:
1.vim / etc/my.cnf server-id=1 skip-name-resolve relay-log=mysql-relay-bin log-bin=mysql-bin log_slave_updates=1 auto_increment_increment=2 auto_increment_offset=1 # replicate_do_db=magedu systemctl restart mariadb mysql- uroot-p > show databases > show master status > CHANGE MASTER TO MASTER_HOST='172.17.0.170', MASTER_USER='SLAVE', MASTER_PASSWORD='magedu', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=245; > start slave; > show slave status; > use magedu > create table userinfo (id int PRIMARY KEY AUTO_INCREMENT, name varchar (50) NOT NULL); > show tables; > desc userinfo View table > insert into userinfo (name) value ('xiao'), (' da'), ('lao'); > select * from userinfo; 2.vim / etc/my.cnf server-id=2 relay-log=mysql-relay-bin log-bin=mysql-bin log_:wqslave_updates=1 auto_increment_increment=2 auto_increment_offset=2 # replicate_do_db=magedu systemctl restart mariadb mysql- uroot-p > show databases > show slave status\ G > CHANGE MASTER TO MASTER_HOST='172.17.0.159', MASTER_USER='SLAVE', MASTER_PASSWORD='magedu', MASTER_LOG_FILE='mysql-bin.000002', MASTER_LOG_POS=245; > start slave; > show slave status; > use magedu; > show tables; > insert into userinfo (name) value ('ni'), (' wo'), ('ta'); > select * from userinfo
Semi-synchronous replication: operations based on mutual master-slave replication
Primary node:
1. > INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so'; > SHOW GLOBA VARIABLES LIKE' rpl_semi%'; > set global rpl_semi_sync_master_enabled = 1; > stop slave; > start slave; cd / var/lib/mysql cd / var/log/mariadb tail-200mariadb.log View Log 2. > INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_slave.so' > SHOW GLOBA VARIABLES LIKE 'rpl_semi%'; > set global rpl_semi_sync_master_enabled = 1
MHA for mysql High availability Architecture:
1. Install and configure MHA
two。 Prepare the communication environment based on SSH mutual trust
3. Install the package to install yum install mha4mysql. It is also necessary to install ode package on ftp.
4. Initialize MHA for configuration
What are the benefits of mysql master-slave replication technology: improved performance and high availability
Icano thread and SQL thread
Introduction to ysql read-write separation, sub-library, sub-table and optimization
Select for update
Middleware: mysql proxy implements the proxy of mysql, one proxy (proxy of mysql) aliSQL proxySQL
Dynamic request: php-- > server node1
Static request: css images js html-- > server node2
Sub-database sub-table:
1. Horizontal split
two。 Vertical split
Mysql Optimization:
1. You can use data to cache common memcached
two。 There are many caching mechanisms in the database, and the corresponding caching strategy can be used.
3. For data, use indexes whenever possible
4. As far as requests are concerned, read-write separation can be achieved and load balancing of read requests can be achieved.
5. For a large database, we can divide the database and table according to the business logic.
6. All optimizations are stored in memory as much as possible
Tomcat and servlet
Programming language classification:
Hardware level: microcode programming, assembly language
System level: C Cosmopolitan. (C language has high performance)
Application level: JAVA,PHP,Python,Ruby,Perl,C#,.
Object-oriented: an object is an abstract description of things
Process-oriented: operate step by step according to the order in which things develop
JAVA uses object-oriented system design method, and JAVA can implement multi-tier architecture. For large-scale enterprise applications across platforms, JAVA has almost become the only choice.
PHP:PHP is suitable for rapid development, small and medium-sized application systems, low development cost and fast response to changing needs.
JAVA compiler (bytecode)-"virtual machine (interpreter) -" interpreter (translation)-"machine code"
.java-> .class-> machine code
How JAVA works:
Programming language compilation types can be roughly divided into three types:
1. Source code-compiler-native code-run
two。 Source code-interpreter-native code-run
3. Source code-intermediate language-virtual machine (equivalent to interpreter)-native code-run
You can find that in the end, you need to become native code before it can be executed.
Three branches of JAVA:
1.J2SE--java standard edition standard version
2.J2ME--java Micro edition is generally located in embedded applications.
3.J2EE--java Enterprise Edition is generally the application of server-side programs.
Servlet is completely dependent on the server side
The essence of servlet is a helper.
Static website technology and dynamic website technology:
What is servlet Technology: CGI solution as the main Camp of Java
The role of the servlet container: the Servlet container, also known as the servlet engine, is part of a web server or application server that provides network services on top of sent requests and responses, decodes MIME-based requests, and formats MIME-based responses
With servlet, users access servlet by clicking on a link or entering URL directly into the browser's address
What the servlet container can provide:
1. Communication support: using the method provided by the container, you can easily let servlet talk to the web server without having to set up your own serversocket and listen on the port.
two。 Life cycle management
3. Multithreading support
4.JSP support
Tomcat is the Apache Software Foundation.
The core of Tomcat is divided into three parts:
1.web container-dealing with static pages
2.Catalina servlet-a servlet container-handles catalinaLay
3. And then there is the JSP container, which translates a JSP page into a servlet.
The difference between JSP and servlet: JSP writes Java code in HTML, and servlet writes HTML code in Java. In fact, JSP is servlet after passing through the container interpreter.
JSEE-- > sevlet--- > CGI
Sevlet program written by java
The Java container comes to call
JSP html-- > java tag-- > sevlet
The relationship between tomcat and servlet: tomcat is actually a program written by servlet in Java
As the name implies, JRE is the environment of Java runtime, including Java virtual machine and Java basic class library.
JDK, as its name implies, is a Java development kit, which is developed by programs writing Java programs in Java language, and is provided to programmers.
JDK:yum install jdk-8u144-linux
Java-version can be viewed
Tomcat installation method:
Download 1.lftp 172.17.0.1 > cd pub > cd sources > ls > cd 7.x86_64 > cd jdk > ls > get jdk-8u144-linux
Yum localinstall jdk.
Default path
Cd / usr/lib/jvm
Cd / usr/java/jdk1.8.0_144/bin
Cd.. Java]
two。 Set environment variabl
Vim / etc/profile.d/java.sh
Export JAVA_HOME=/usr/java/jdk1.8.0_144
Export JRE_HOME=$JAVA_HOME/jre
Export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
Chmod + x / etc/profile.d/java.sh
. / etc/profile.d/java.sh for reading
Echo $JAVA_HOME View Jdk
Java-version can check again whether the version has changed.
3.lftp 172.17.0.1 cd pub cd sources cd 7.x86_64 cd tomcat mget apache-tomcat-7.0.78.tar.gz solo-2.2.0.war (deployment file)
Tar-xvf apache.
Cd apache-tomcat-7.0.78
Ls View
Cd..
Mv apache-tomcat-7.0.78 / usr/local/tomcat
Cd / usr/local/tomcat
Ls
Cd bin
. / catalina.sh start runs tomcat
Netstat-tunlp
172.17. Vera 8080 access test
Cd / conf server.xml main configuration profile
1.server:server represents the entire Catalina servlet container. 2.service: service is an intermediate component that lives inside server: 3.Connector component: connector handles communication with client 4.Engine component: in tomcat Each service can contain only one servlet engine 5.Host component: a host or virtual host located inside the engine to receive requests and process them accordingly is similar to the Nginx server 6.Context component: a context represents a web application that runs in a specific virtual host A host can contain multiple context (representing web applications) information such as Nginx location web.xml web application description files context.xml can be used to configure databases logging.properties log system-related configuration
Tomcat page: manmger
Admin
Test the jsp script
Cd webapps
Mkdir test
Cd test
Vim index.jsp
Tomcat related configuration:
Cd / usr/local/tomcat
Cd conf
Vim tomcat-users.xml
< role rolename="manager-gui" < role rolename="admin-gui" < user username="tomcat" password="tomcat" roles="manager-gui,admin-gui"/>. / bin/catalina.sh stop
. / bin/catalina.sh start
Deployment of Tomcat:
Deploy the solo package on ftp to Tomcat
Cp sols-2.2.0.war / usr/local/tomcat/webapps
Cd webapps
Mv solo-2.2.0.war / tmp
Cd webapps
Mv / tmp/solo-2.2.0.war. /
Cd logs log storage path
The principle of tomcat composition:
Service: the connector is combined with the engine
Connector: the connector is used to receive requests from users
Engine: the engine is used to process users' requests
Host: virtual host
Context: equivalent to location, that is, equivalent to routing, and can also be matched.
Servlet: it's the program.
The organizational structure of JSP webapp:
/: root directory of webapps
Index.jsp home page; cd / manager
Maven project management tool www.oschina.net java open source project
Mysql-uroot-p-D magedu < jeesns.sql Import File in magedu Database
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.