0%

远程开发

可以减少硬盘要求、数据集中存放,便于服务器调试,了解服务器部署,但是要求网络稳定

vs code

1
读取config,远程安装code,但是java工程,在git使用时,没法使用本地,只能使用code插件,不好用

idea remote

1
配置ssh, 下载idea,激活验证码(远程激活失败、占用cache 6g)

remote jvm debug

1
2
java 程序添加参数:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

mac sshfs

brew install Caskroom/cask/osxfuse

brew install sshfs

1
2
3
4
5
6
7
8
9
10
11
brew install --cask macfuse
brew install gromgit/fuse/sshfs-mac
brew link --overwrite sshfs-mac

mkdir ~/remote

sshfs foxhello-home:/home/fmzh/project ~/remote

ls ~/remote

umount ~/remote

参考

  1. sshfs 安装

域名映射 frp不占用80、443

frp结合nginx处理

frp 配置文件

server 配置

1
2
3
4
5
6
7
8
9
[common]
bind_port = 10500
token = 123456
vhost_http_port = 10580
dashboard_addr = 0.0.0.0
dashboard_port = 10599

dashboard_user = admin
dashboard_pwd = 123456

client 配置

1
2
3
4
5
6
7
8
9
10
[common]
server_addr = 8.8.8.8
server_port = 10500
token = 123456

[web-gitlab]
type = http
local_ip = 192.168.3.31
local_port = 80
custom_domains = gitlab.foxhello.com

nginx 配置文件

nginx配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# 服务器端管理后台
server {
listen 80;
server_name foxhello.com www.foxhello.com;
return 301 https://$host$request_uri;


# location / {
# proxy_pass http://127.0.0.1:7999;
# proxy_set_header Host $host:80;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_hide_header X-Powered-By;
#
# root /var/www/build;
# index index.html;
# }
}

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

# 代理http web
server {
listen 80;
server_name *.foxhello.com;
return 301 https://$host$request_uri;

# location / {
# proxy_pass http://127.0.0.1:10580;
# proxy_set_header Host $host:80;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_hide_header X-Powered-By;
#
# client_max_body_size 2048m;
#
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $connection_upgrade;
# }
}

# 如果启用SSL
server {
listen 443 ssl;
server_name foxhello.com www.foxhello.com;

# ssl on;
ssl_certificate /etc/nginx/ssl/foxhello.com/foxhello.com.crt;
ssl_certificate_key /etc/nginx/ssl/foxhello.com/foxhello.com.key;
ssl_prefer_server_ciphers on;
ssl_session_timeout 60m;

location / {
root /var/www/build;
index index.html;
}
}

server {
listen 443 ssl;
server_name *.foxhello.com;

# ssl on;
ssl_certificate /etc/nginx/ssl/foxhello.com/foxhello.com.crt;
ssl_certificate_key /etc/nginx/ssl/foxhello.com/foxhello.com.key;
ssl_prefer_server_ciphers on;
ssl_session_timeout 60m;

location / {
proxy_pass http://127.0.0.1:10580;
# proxy_set_header Host $host:80;
proxy_set_header Host $host:443;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;

client_max_body_size 2048m;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}

mongodb ui

samueltallet/mongodb-php-gui 不支持mongodb-3.4版本

1
2
3
docker pull samueltallet/mongodb-php-gui

docker run --name mongodb-ui -p 5000:5000 samueltallet/mongodb-php-gui

mongo-express 支持3.4版本

1
2
3
4
docker pull mongo-express

docker run -it --rm --name mongo-express -p 5000:8081 -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="172.31.0.5" mongo-express

参考

  1. mongodb-php-gui
  2. mongo-express
  3. github mongo-express

centos扩容

数据分区扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
df -Th

fdisk -l

lsblk -f

fdisk /dev/vdb 默认回车
n
w

lsblk -f

# xfs 文件系统格式
mkfs.xfs -f /dev/vdb1

mkdir /data

mount -t xfs /dev/vdb1 /data

df -h

# 开机自动挂载
vi /etc/fstab
/dev/vdb1 /data xfs defaults 0 0

hk.server9扩容文档 (系统分区扩容)

—–阿里云服务器系统盘在线扩容

1、控制台在线扩容

1.1、扩容前检查
df -h
expand-00.png
1.2、进入服务器管理界面
https://ecs.console.aliyun.com/#/server/region/cn-hongkong
方法一:
进入服务器界面

进入详情后,点击扩容

方法二:
在云盘中找到服务器对应的磁盘,点击扩展

1.2、磁盘扩容(修改容量)

2、挂载镜像

2.1、检查磁盘信息
fdisk -l
expand-01.png
2.2、挂载磁盘
growpart /dev/vda 1
resize2fs /dev/vda1
expand-03.png

20230330 - 添加 (resize2fs失败,使用以下命令)
https://blog.csdn.net/m0_37490554/article/details/108976019
xfs_growfs /dev/vda1

3、检查-扩容成功

expand-04.png

4、参考

4.1、阿里云教程:
https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.6.1257.1ba71ce30NgizH
4.2、csdn教程:
https://blog.csdn.net/zhangyingchengqi/article/details/103308258

virtualbox centos 扩容

virtualbox 扩容

1
2
3
4
5
6
cd C:\Program Files\Oracle\VirtualBox

VBoxManage list hdds

C:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd 0bd9c696-1735-48ce-81cf-04e9f64c2418 --resize 51200
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

centos 扩容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
df -TH
lsblk

# 创建分区
fdisk /dev/sda
n(ew partion)
p(rimary 主分区)
回车
w( 保存 写入 )

fdisk -l
reboot(重启才会挂载新磁盘)

pvcreate /dev/sda3
pvdisplay

vgdisplay
vgextend centos /dev/sda3
vgdisplay

lvdisplay
lvextend -L +300G /dev/centos/root
lvdisplay

df -h
xfs_growfs /dev/centos/root
df -h

ubuntu 22.04 扩容

1
2
3
4
5
6
7
sudo lvdisplay
sudo lvextend -L +197G /dev/ubuntu-vg/ubuntu-lv
sudo lvdisplay

df -h
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
df -h

参考

  1. Linux系统如何创建和挂载XFS文件系统
  2. 新建硬盘分区并挂载
  3. Centos挂载硬盘
  4. centos 扩容

nginx 端口转发 (达到frp效果)

nginx配置

配置文件内容

1
2
3
4
5
6
7
8
9
10
11
# /usr/local/openresty/nginx/conf/nginx.conf
events {
worker_connections 1024;
}

#### 核心是该行,和http同级
include /usr/local/openresty/nginx/conf/stream.d/*.conf;

http {
include mime.types;
default_type application/octet-stream;

子端口配置 tcp.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
stream {
server {
listen 5222;
proxy_pass 103.145.23.28:5222;
}
}

#stream {
# upstream backend {
# server backend1.example.com:12345;
# server backend2.example.com:12345;
# }
#
# server {
# listen 12345;
# proxy_pass backend;
# }
#}

参考

  1. 使用Nginx转发TCP/UDP
  2. 使用Nginx进行TCP/UDP端口转发

io高,导致服务器慢

io高检测

1
2
3
4
5
6
7
8
9
10
11
12
# 动态监测各个volume的io占用情况
iostat -x 1 10

# io占用高
iotop

#
sar 1 10

# 应用安装
yum -y install sysstat
yum install lsof

文件句柄检测

1
2
3
4
5
6
7
8
9
ulimit -a
# 查看系统打开句柄最大数量
more /proc/sys/fs/file-max
# 查看打开句柄总数
lsof|awk '{print $2}'|wc -l
# 根据打开文件句柄的数量降序排列,其中第二列为进程ID
lsof|awk '{print $2}'|sort|uniq -c|sort -nr|more

ps -ef |grep
1
2
3
4
修改linux系统参数。vi /etc/security/limits.conf 添加
*  soft  nofile  65536
*  hard  nofile  65536
修改以后保存,注销当前用户,重新登录,执行ulimit -a ,ok ,参数生效了:

问题原因:

  1. 同一分钟内,请求最多时候有10个对同一个ipa包进行重签请求
  2. linux多进程zsign对同一ipa包解压,ipa文件处理无法释放,导致io高

解决方法:

  1. 重签时,先将源包复制一份,对复制包进行重签处理
  2. 定时清除复制的包
  3. 观察是否还存在该问题;是否存在磁盘满情况

处理方法

  1. 直接kill unzip的程序
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    ps -ef  |grep zip | xargs kill

    ps -ef |grep unzip | xargs kill

    pid=`ps ax | grep -i ${SERVER} |grep java | grep -v grep | awk '{print $1}'`
    if [ -z "$pid" ] ; then
    echo "No ${SERVER} Server running."
    exit 0;
    fi
    kill ${pid}
  2. 升级服务器配置
    4核8g内存升级为8核16g内存

参考

  1. centos 查看磁盘io使用情况,centos找出占用io读写很高的进程
  2. linux 文件句柄数查看命令

docker镜像生成

dockerfile

1
2
3
4
5
6
7
8
9
10
# Dockerfile 文件
FROM openjdk:8u342-jdk

COPY /*.jar /app.jar

CMD ["--server.port=8080"]

EXPOSE 8080

ENTRYPOINT ["java","-jar","/app.jar"]

docker compose

将容器转成镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 生成镜像
docker commit nginx-chinese-color foxhello.com/nginx/chinese-colors:1.0.0

# 保存镜像
docker save -o chinacolor.tar foxhello.com/nginx/chinese-colors:1.0.0

# 加载镜像
docker load --input chinacolor.tar

# 运行程序
docker run --name chinacolor -p 9966:80 -d foxhello.com/nginx/chinese-colors:1.0.0

# 访问网址
http://127.0.0.1:9966

将镜像上云

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
docker login
fmzh

# 重命名镜像
docker tag foxhello.com/nginx/chinese-colors:1.0.0 fmzh/chinacolor

# 在官网创建路径
https://hub.docker.com/repositories/fmzh

# 上传镜像
docker push fmzh/chinacolor

# 下载镜像
docker pull fmzh/chinacolor:latest

# 运行
docker run --name chinacolor -p 9966:80 -d fmzh/chinacolor

# 访问网址
http://127.0.0.1:9966

将镜像上nexus

1
2
3
4
5
6
7
8
9
10
11
12
# nexus docker上传要求https 且是8082端口
docker login https://nexus.foxhello.com -u admin -p fmzh201

# 重命名镜像
docker tag fmzh/chinacolor nexus-docker.foxhello.com/nginx/chinese-colors:1.0.0

# 上传镜像
docker push nexus-docker.foxhello.com/nginx/chinese-colors:1.0.0

# 下载镜像
docker login https://nexus-docker.foxhello.com
docker pull nexus-docker.foxhello.com/nginx/chinese-colors:1.0.0

参考

  1. 容器打包成镜像
  2. 镜像上云
  3. Dockerfile 示例
  4. docker 上 nexus