In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how Nginx realizes asynchronous access to mysql". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian and go deep into it together to study and learn "how Nginx realizes asynchronous access to mysql"!
There is a module in nginx that has this function.(In the previous article, the extension is called a module. In the future, it will be called a module. The module may be accurate because the extension is a separate file, and the module is embedded in the main file.) This module is called drizzle-nginx-module.
It's not easy to compile this.
Download drizzle library first
Compile and configure options:
The copy code is as follows:
./ configure --without-server
make libdrizzle-1.0
make install-libdrizzle-1.0
Next is output, http directly output json string, how to do, and the next module, to the next module too many,
https://github.com/openresty/rds-json-nginx-module
The final configuration options are as follows:
The copy code is as follows:
./ configure --prefix=/opt/nginxrw --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --add-module=/data/src/lua-nginx-module-0.9.8 --add-module=/data/src/ngx_devel_kit-0.2.19 --add-module=/data/src/drizzle-nginx-module-0.1.7 --add-module=/data/src/rds-json-nginx-module-master
When you finally start nginx, you may also report that the drizzle shared library cannot be found. You can look at the configuration file: /etc/ld.so.conf. After changing the configuration, remember to use lddconfig to re-take effect.
how to use it
First declare a mysql server in the http module of nginx
The copy code is as follows:
upstream backend {
drizzle_server 172.21.107.247:3306 dbname=oneplus_user_sso password= user=root protocol=mysql;
}
Next up is the declaration that location handles
The copy code is as follows:
location /mysql {
set $my_sql 'select * from t_user limit 1';
drizzle_query $my_sql;
drizzle_pass backend;
drizzle_connect_timeout 500ms; # default 60s
drizzle_send_query_timeout 2s; # default 60s
drizzle_recv_cols_timeout 1s; # default 60s
drizzle_recv_rows_timeout 1s; # default 60s
rds_json on;
}
where rds_json on means output is in json format
Next, visit http://172.21.107.174/mysql,
You can output a user's information, and the format is json.
Thank you for reading, the above is the content of "Nginx how to achieve asynchronous access to mysql", after the study of this article, I believe that everyone has a deeper understanding of how Nginx achieves asynchronous access to mysql, and the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
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: 222
*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.