baiyan
apache correlation
Using apache to configure multiport bindings to implement a local microservice architecture
Configuration file httpd.conf:
Listen 80 Listen 9399 DocumentRoot "C:/Users/jiangbaiyan/PhpstormProjects/NicoRobin/public" <Directory "C:/Users/jiangbaiyan/PhpstormProjects/NicoRobin/public"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> <VirtualHost _default_:9399> DocumentRoot "C:/Users/jiangbaiyan/PhpstormProjects/cmdb/public" ServerName localhost:9399 </VirtualHost> <Directory "C:/Users/jiangbaiyan/PhpstormProjects/cmdb/public/"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory>
This configuration allows apache to bind multiple ports, enabling multiple microservices to run simultaneously locally.
apache.htaccess file
This file defines the rules for URL overrides (equivalent to rewrite for nginx).We often encounter the problem of binding the root directory, but always returning a 404 status code.Perhaps there is no URL rewrite file for.htaccess in your root directory.Since your URL is incorrect, it is not located in the correct resource file.Also note that you want to set AllowOverride All in the <Directory>permission control label of httpd.conf, and that you want to turn on apache's URL Rewrite Module by removing the comment before the mod_rewrite module.Usually a.htaccess file looks like this:
<IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
Database correlation
The trade-off between field redundancy and table join in MySQL table structure design
This week, we encountered such a problem in our business: a spare parts inventory table, we need to know which manufacturer, model, machine room and so on this spare part is, while the manufacturer, model, machine room are stored in another table.There are two options for storing this information:
- First option:
id | Vendor id | Model id | Room id | Other fields |
---|
- The second option:
id | Vendor Name | Model name | Room name | Other fields |
---|
Comparing the two schemes, the first one has the following advantages and disadvantages:
Advantages: Use related queries when querying, so you can update these information synchronously when querying inventory when manufacturer/model/room changes, and insert only id, which is very convenient and insert-friendly
Disadvantages: Associated queries consume performance and require three tables to be joined. Their performance is not high and they are not friendly to queries.
The second option has the following advantages and disadvantages:
Advantages: No table joins are needed when querying, high query performance and query friendliness
Disadvantage: When the manufacturer/model/room changes, it is not possible to synchronously update the information when querying the inventory.Therefore, this scheme is more suitable for manufacturers/models with little change in this information.And when inserting inventory, you need to query the specific name of the manufacturer/model, which is not friendly for insertion.
docker correlation
Mapping docker external to internal ports
When the docker container is started, network applications and services within the container cannot be accessed through the network outside the container without specifying port mapping parameters.At this point you must use the port binding between the host and the internal docker. We use the docker PS-A command to view the port binding:
[root@A02-R05-I222-112 jiangbaiyan]# docker ps -a | grep jiangbaiyan 671e1d9e8aa4 develop:2.2 "/bin/bash" 2 weeks ago Up 13 days 0.0.0.0:12422->22/tcp, 0.0.0.0:12480->80/tcp, 0.0.0.0:12481->81/tcp, 0.0.0.0:12482->82/tcp, 0.0.0.0:12483->83/tcp, 0.0.0.0:12484->84/tcp, 0.0.0.0:12485->85/tcp, 0.0.0.0:12486->86/tcp, 0.0.0.0:12487->87/tcp, 0.0.0.0:12488->88/tcp, 0.0.0.0:12489->89/tcp jiangbaiyan
For example, we map port 22 of the docker jiangbaiyan to port 12422 on the external host, so we execute the following commands on the external host:
ssh root@127.0.0.1 -p 12422
This allows you to successfully enter the docker on the external host.Note that different docker instances have different external host ports bound. The current docker instance jiangbaiyan has port 12422, and possibly other docker instances have port 12423.This allows us to access different dockers through different ports.