In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Original articles, welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
Original link address: "actual combat" open source project dockerized operation and maintenance deployment-front-end java deployment (8)
This section mainly talks about the deployment of the front-end need to pay attention to the point, itself renren-fast this project is developed through nodejs, nodejs compiled to generate html,css,img so, we do not have to use nginx directly in the container to access static files. Source code: https://github.com/limingios/netFuture/blob/master/ front end /
Https://github.com/daxiongYang/renren-fast-vue
Modify connection address
Should be modified to http://192.168.66.151:6201/renren-fast;
Pack and modify the image. Domestic packaging is faster.
Http://npm.taobao.org/
Installation
You can use our customized cnpm (gzip Compression support) command line tool instead of the default npm:
$npm install-g cnpm-- registry= https://registry.npm.taobao.org
This directory is uploaded to nginx.
Renren-nginx
The nginx here is not to do load balancing, but to do static html static running environment.
Create a container
Use the network segment of the host
Docker run-it-d-- name fn1\-v / root/fn1/nginx.conf:/etc/nginx/nginxc.conf\-v / root/fn1/renren-vue:/home/fn1/renren-vue\-- privileged-- net=host nginx write the configuration file of nginx
User nginx
Worker_processes 1
Error_log / var/log/nginx/error.log warn
Pid / var/run/nginx.pid
Events {
Worker_connections 1024
}
Http {
Include / etc/nginx/mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65 Proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m * Proxy_temp_file_write_size 64k server {listen 6501; server_name 192.168.66.100; location / {root / home/fn1/renren-vue; index index.html;}}
}
# renren-nginx > the nginx here is not used for load balancing, but for static running environment of static html. * create container > use the host network segment ```bashdocker run-it-d-name fn2\-v / root/fn2/nginx.conf:/etc/nginx/nginxc.conf\-v / root/fn2/renren-vue:/home/fn1/renren-vue\-- privileged-- net=host nginx to write the configuration file of nginx
User nginx
Worker_processes 1
Error_log / var/log/nginx/error.log warn
Pid / var/run/nginx.pid
Events {
Worker_connections 1024
}
Http {
Include / etc/nginx/mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65 Proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m * Proxy_temp_file_write_size 64k server {listen 6502; server_name 192.168.66.100; location / {root / home/fn2/renren-vue; index index.html;}}
}
# renren-nginx > the nginx here is not used for load balancing, but for static running environment of static html. * create container > use the host network segment ```bashdocker run-it-d-name fn3\-v / root/fn3/nginx.conf:/etc/nginx/nginxc.conf\-v / root/fn3/renren-vue:/home/fn1/renren-vue\-- privileged-- net=host nginx to write the configuration file of nginx
User nginx
Worker_processes 1
Error_log / var/log/nginx/error.log warn
Pid / var/run/nginx.pid
Events {
Worker_connections 1024
}
Http {
Include / etc/nginx/mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65 Proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m * Proxy_temp_file_write_size 64k server {listen 6503; server_name 192.168.66.100; location / {root / home/fn3/renren-vue; index index.html;}}
}
# qia load balancer! [] (creation of https://upload-images.jianshu.io/upload_images/11223715-0521406dd545ab33.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)##### nginx-ff1* ff1 container ```bashdocker run-it-d-name ff1\-v / root/ff1/nginx.conf:/etc/nginx/nginx.conf\-- net=host\-- privileged-- configuration of net=host nginx load balancer ff1-nginx
User nginx
Worker_processes 1
Error_log / var/log/nginx/error.log warn
Pid / var/run/nginx.pid
Events {
Worker_connections 1024
}
Http {
Include / etc/nginx/mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65 Proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m * Proxy_temp_file_write_size 64kuptowstream fn {server 192.168.66.100 server 6501; server 192.168.66.100 fn 6502; server 192.168.66.100 fn 6503;} server {listen 6601; server_name 192.168.66.100; location / {proxy_pass http://fn; index index.html index.htm;}}
}
# creation of nginx-ff2* ff2 Container ```bashdocker run-it-d-- name ff2\-v / root/ff2/nginx.conf:/etc/nginx/nginx.conf\-- net=host\-- privileged-- configuration of net=host nginx load balancer ff2-nginx
User nginx
Worker_processes 1
Error_log / var/log/nginx/error.log warn
Pid / var/run/nginx.pid
Events {
Worker_connections 1024
}
Http {
Include / etc/nginx/mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65 Proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m * Proxy_temp_file_write_size 64kuptowstream fn {server 192.168.66.100 server 6501; server 192.168.66.100 fn 6502; server 192.168.66.100 fn 6503;} server {listen 6602; server_name 192.168.66.100; location / {proxy_pass http://fn; index index.html index.htm;}}
}
# dual-server hot backup load balancer solution for frontend project > ff1 and ff2 have been set before, and the backend can be accessed normally, but without keepalived, they cannot compete for ip before and cannot achieve dual-server hot backup. This time, let's talk about the dual-computer hot standby. ! [] (http://upload-images.jianshu.io/upload_images/11223715-2f22450c56914920?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)> enters container ff1 and then installs keepalived > keepalived must be in the container where ff1 resides, or you can download an image of nginx-keepalived in docker repository. Here, keepalived is installed directly in the container.
Docker exec-it ff1 / bin/bash
# write to dns to prevent apt-get update from finding the server
Echo "nameserver 8.8.8.8" | tee / etc/resolv.conf > / dev/null
Apt-get clean
Apt-get update
Apt-get install vim
Vi / etc/apt/sources.list
> sources.list add the following
Deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
Deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
Deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
Deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
Deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
Deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
* update apt feeds
Apt-get clean
Apt-get update
Apt-get install keepalived
Apt-get install vim
! [] (http://upload-images.jianshu.io/upload_images/11223715-19bf6ee9786cc44e?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)* keepalived configuration file > path within the container: / etc/keepalived/keepalived.conf
Vi / etc/keepalived/keepalived.conf
> keepalived.conf
Vrrp_instance VI_1 {
State MASTER
Interface ens33
Virtual_router_id 51
Priority 100
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 123456
}
Virtual_ipaddress {
192.168.66.152
}
}
Virtual_server 192.168.66.152 6701 {
Delay_loop 3
Lb_algo rr
Lb_kind NAT
Persistence_timeout 50
Protocol TCP
Real_server 192.168.66.100 6601 {
Weight 1
}
}
1. VI_1 name can be customized 2. State MASTER | identity of keepalived (MASTER master server, BACKUP backup server, will not preempt virtual machine ip). If they are all main MASTER, they will compete with each other for IP. If they get it, it will be MASTER, and the other is SLAVE. 3. Interface network card, define a virtual IP definition to that network card. The name of the network card device. Eth43 is the host and the network card. 4. Virtual_router_id 51 | Virtual routing identity. The virtual routing identifiers of MASTER and BACKUP must be the same. The identity can be 0-255. 5. Priority 100 | weight. The weight importance of MASTER is higher than that of BACKUP. The larger the number is, the higher the priority level is. It can be done according to the configuration of the hardware, and the higher the level of grabbing the largest weight. 6. Advert_int 1 | heartbeat detection. The time interval, in seconds, for synchronization checks between MASTER and BACKUP nodes. The master and backup must be consistent. 7. Authentication | Master / slave server verification method. Master and standby must use the same password in order to communicate properly. For heartbeat detection, you need to log in to a host with an account password. 8. Virtual_ipaddress | Virtual ip address. You can set multiple virtual ip addresses, one for each line. According to the ip configured on the eth43 configured above. 192.168.66.151 is a self-defined virtual ip* startup keeplived > in-container launch.
Service keepalived start
> enter the container ff2 and install keepalived > keepalived must be in the container where the ff2 resides, or you can download an image of nginx-keepalived in the docker repository. Here, keepalived is installed directly in the container.
Docker exec-it ff2 / bin/bash
# write to dns to prevent apt-get update from finding the server
Echo "nameserver 8.8.8.8" | tee / etc/resolv.conf > / dev/null
Apt-get clean
Apt-get update
Apt-get install vim
Vi / etc/apt/sources.list
> sources.list add the following
Deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
Deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse
Deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted
Deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
Deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted
Deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted
Deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted
! [] (http://upload-images.jianshu.io/upload_images/11223715-4bf2654b4295a06c?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)* updates apt source
Apt-get clean
Apt-get update
Apt-get install keepalived
Apt-get install vim
* keepalived configuration file > path within the container: / etc/keepalived/keepalived.conf
Vi / etc/keepalived/keepalived.conf
> keepalived.conf
Vrrp_instance VI_1 {
State MASTER
Interface ens33
Virtual_router_id 51
Priority 100
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 123456
}
Virtual_ipaddress {
192.168.66.152
}
}
Virtual_server 192.168.66.152 6701 {
Delay_loop 3
Lb_algo rr
Lb_kind NAT
Persistence_timeout 50
Protocol TCP
Real_server 192.168.66.100 6602 {
Weight 1
}
}
1. VI_1 name can be customized 2. State MASTER | identity of keepalived (MASTER master server, BACKUP backup server, will not preempt virtual machine ip). If they are all main MASTER, they will compete with each other for IP. If they get it, it will be MASTER, and the other is SLAVE. 3. Interface network card, define a virtual IP definition to that network card. The name of the network card device. Eth43 is the host and the network card. 4. Virtual_router_id 51 | Virtual routing identity. The virtual routing identifiers of MASTER and BACKUP must be the same. The identity can be 0-255. 5. Priority 100 | weight. The weight importance of MASTER is higher than that of BACKUP. The larger the number is, the higher the priority level is. It can be done according to the configuration of the hardware, and the higher the level of grabbing the largest weight. 6. Advert_int 1 | heartbeat detection. The time interval, in seconds, for synchronization checks between MASTER and BACKUP nodes. The master and backup must be consistent. 7. Authentication | Master / slave server verification method. Master and standby must use the same password in order to communicate properly. For heartbeat detection, you need to log in to a host with an account password. 8. Virtual_ipaddress | Virtual ip address. You can set multiple virtual ip addresses, one for each line. According to the ip configured on the eth43 configured above. 192.168.66.151 is a self-defined virtual ip* startup keeplived > in-container launch.
Service keepalived start
PS: the front and back end deployments are basically the same. Start multiple containers first, then set up 2 loads, and install keepalived in the load to do hot backup. The point is to figure out the port. But to be honest, this is a routine exercise and personal project, if it is multiple machines, you can't do this. Next time, let multiple machines work together through the docker swarm network. ! [] (http://upload-images.jianshu.io/upload_images/11223715-3407e1c7ac8d7935?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
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.