JoyLau's Blog

JoyLau 的技术学习与思考

步骤

https://copr.fedorainfracloud.org/coprs/ibotty/prometheus-exporters/

curl -Lo /etc/yum.repos.d/_copr_ibotty-prometheus-exporters.repo https://copr.fedorainfracloud.org/coprs/ibotty/prometheus-exporters/repo/epel-7/ibotty-prometheus-exporters-epel-7.repo

yum -y install node_exporter

systemctl enable node_exporter

systemctl start node_exporter

echo “success”

关闭机器防火墙:

systemctl stop firewalld.service

systemctl disable firewalld.service

在test.jar 的同目录下新建一个与 NeedReplace 类的全路径相同的目录,执行以下命令
md com\lovedata\bigdata\jar
执行 java -jar 来进行替换
jar uvf test.jar com\lovedata\bigdata\jar\NeedReplace.class

主:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
version: "3"
services:
mysql:
image: mysql:8.0.22
container_name: mysql
restart: always
security_opt:
- seccomp:unconfined
ports:
- 3306:3306
volumes:
- ./mysql-data:/var/lib/mysql
- ./my.cnf:/etc/mysql/my.cnf
environment:
- MYSQL_ROOT_PASSWORD=Kaiyuan@2020
- TZ=Asia/Shanghai

my.cnf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL

# Custom config should go here
!includedir /etc/mysql/conf.d/

max_connections=1024

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

server-id=1

最主要的配置: server-id=1

从:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
version: "3"
services:
mysql:
image: mysql:8.0.22
container_name: mysql-slave-1
restart: always
security_opt:
- seccomp:unconfined
ports:
- 3306:3306
volumes:
- ./mysql-data:/var/lib/mysql
- ./my.cnf:/etc/mysql/my.cnf
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
environment:
- MYSQL_ROOT_PASSWORD=Kaiyuan@2020
- TZ=Asia/Shanghai

my.cnf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL

# Custom config should go here
!includedir /etc/mysql/conf.d/

max_connections=1024

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

server-id=2
super-read-only

和主不同的是, server-id=2, super-read-only 开启只读模式

init.sql:

1
2
3
change master to master_host='10.55.3.122',master_port=3306,master_user='root',master_password='Kaiyuan@2020';
reset slave;
start slave;

配置

  1. 将原先的接口提取出来,单独写一份
    @FeignClient(value = “etc-exchange”, contextId = “etc-exchange-2”, fallback = PsamRemoteServiceFallback2.class)
    重新声明一个 contextId

  2. 添加配置项

1
2
3
4
5
6
feign:
client:
config:
etc-exchange-2:
connect-timeout: 3000
read-timeout: 3000

说明

@JsonFormat(pattern = “yyyy-MM-dd HH:mm:ss”) : 后端 =>前端的转换
@DateTimeFormat(pattern = “yyyy-MM-dd’T’HH:mm:ss”) : 前端 => 后端的转换
@JsonDeserialize(using = LocalDateTimeDeserializer.class) : jackson 反序列化
@JsonSerialize(using = LocalDateTimeSerializer.class): jackson 序列化

注意:

  1. 当 @JsonFormat 和 @JsonDeserialize 或者 @JsonSerialize 同时存在时, @JsonFormat 优先级更高

  2. @JsonFormat不仅可以完成后台到前台参数传递的类型转换,还可以实现前台到后台类型转换。

当content-type为application/json时,优先使用@JsonFormat的pattern进行类型转换。而不会使用@DateTimeFormat进行类型转换。

步骤

设置环境变量:

1
2
3
4
5
  env:
- name: GF_SERVER_ROOT_URL
value: "%(protocol)s://%(domain)s:%(http_port)s/grafana"
- name: GF_SERVER_SERVE_FROM_SUB_PATH
value: "true"

此时 NGINX 进行反向代理的配置:

1
2
3
4
5
6
location /grafana/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://10.55.3.160:31120/;
}
0%