<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
docker-compose常用配置
发表于
分类于
docker
version: '3'
services:
nginx-route:
image: hub.deri.org.cn/library/nginx
container_name: nginx-route
ports:
- "8080:80"
restart: always
volumes:
- "/etc/localtime:/etc/localtime"
- "/wuzhiyong/nginx.conf:/etc/nginx/nginx.conf"
authservice:
image: wuzhiyong/authservice
container_name: authservice
restart: always
volumes:
- "/etc/localtime:/etc/localtime"
dbcompare:
image: wuzhiyong/dbcompare
container_name: dbcompare
restart: always
volumes:
- "/etc/localtime:/etc/localtime"
graphcompare:
image: wuzhiyong/graphcompare
container_name: graphcompare
restart: always
volumes:
- "/etc/localtime:/etc/localtime"
- "/wuzhiyong/svg:/root/svg"
hbasecompare:
image: wuzhiyong/hbasecompare
container_name: hbasecompare
restart: always
volumes:
- "/etc/localtime:/etc/localtime"
extra_hosts:
- "hadoop1:172.16.0.7"
- "hadoop2:172.16.0.8"
- "hadoop3:172.16.0.9"
taskservice:
image: wuzhiyong/taskservice
container_name: taskservice
restart: always
volumes:
- "/etc/localtime:/etc/localtime"
networks:
nwzb:
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;
#gzip on;
include /etc/nginx/conf.d/*.conf;
upstream taskservice{
server taskservice:28080;
}
upstream authservice{
server authservice:25050;
}
upstream dbcompare{
server dbcompare:28082;
}
upstream hbasecompare{
server hbasecompare:26060;
}
upstream graphcompare{
server graphcompare:29090;
}
server {
listen 80 default_server;
server_name _;
location /ts {
proxy_pass http://taskservice;
}
location /auth {
proxy_pass http://authservice;
}
location /dbc {
proxy_pass http://dbcompare;
}
location /hbc {
proxy_pass http://hbasecompare;
}
location /graph {
proxy_pass http://graphcompare;
}
}
}
java容器中时区问题
发表于
分类于
java
nginx使用upstream实现负载均衡
发表于
分类于
tools
轮询(默认)
upstream servername {
server 10.0.0.1:8080;
server 10.0.0.2:8080;
}
权重
weight
默认为1
,weight
越大,负载的权重就越大
upstream servername {
server 10.0.0.1:8080 weight=5;
server 10.0.0.2:8080 weight=10;
}
IP哈希
请求按访问ip的hash结果分配
upstream servername {
ip_hash;
server 10.0.0.1:8080;
server 10.0.0.2:8080;
}
响应时间
按后端服务器的响应时间来分配请求,响应时间短的优先分配
upstream servername {
fair;
server 10.0.0.1:8080;
server 10.0.0.2:8080;
}
其它哈希
如:根据请求路径哈希,
hash_method
是使用的hash
算法
upstream servername {
fair;
server 10.0.0.1:8080;
server 10.0.0.2:8080;
hash $request_uri;
hash_method crc32;
}
down/backup
upstream servername {
// down 表示单前的server暂时不参与负载.
server 10.0.0.1:8080 down;
server 10.0.0.2:8080;
server 10.0.0.3:8080;
// 其它所有的非backup机器down或者忙的时候请求backup机器.
server 10.0.0.4:8080 backup;
}
参考链接
linux设置swap
发表于
分类于
linux
查看swap状态
[root@ecs ~]# free -m
total used free shared buff/cache available
Mem: 7820 4825 133 896 2862 1818
Swap: 0 0 0
# 无返回
swapon -s
# 空
cat /proc/swaps
通过文件设置swap
- 新建swap交换文件
# count设置文件大小,4G
dd if=/dev/zero of=/home/swap bs=1024 count=4096000
- 制作为swap格式文件
mkswap /home/swap
- 挂载swap分区
swapon /home/swap
此时通过free
命令已经可以看到swap
分区了,但是重启失效.
- 设置持久生效
vi /etc/fstab
# 在文件最后一行加上
/home/swap swap swap default 0 0
删除文件swap分区
- 先停止swap分区
swapoff /home/swap
- 删除swap分区文件
rm -rf /home/swap
- 删除自动装载配置
vi /etc/fstab
# 删除刚刚 增加的配置
通过分区配置swap
参考链接
nginx配置路由转发
发表于
分类于
tools
获取ngxin
docker pull hub.deri.org.cn/library/nginx
编写nginx.conf
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;
#gzip on;
include /etc/nginx/conf.d/*.conf;
upstream taskservice{
server 172.16.0.9:28080;
}
upstream authservice{
server 172.16.0.9:25050;
}
upstream dbcservice{
server 172.16.0.9:28082;
}
upstream hbcservice{
server 172.16.0.9:26060;
}
upstream graphservice{
server 172.16.0.9:29090;
}
server {
listen 80 default_server;
server_name _;
location /ts {
proxy_pass http://taskservice;
}
location /auth {
proxy_pass http://authservice;
}
location /dbc {
proxy_pass http://dbcservice;
}
location /hbc {
proxy_pass http://hbcservice;
}
location /graph {
proxy_pass http://graphservice;
}
}
}
启动nginx容器
docker run -d --name nginx -p 8080:80 -v /root/nginx/nginx.conf:/etc/nginx/nginx.conf nginx