open-port
# 对端口放行
sudo firewall-cmd --add-port=${要开通的端口}/tcp --zone=public --permanent
# 重新加载
sudo firewall-cmd --reload
# 查看放行的端口列表
sudo firewall-cmd --list-port
conda
#### 1.下载地址
手动下载:[官方地址:https://repo.anaconda.com/archive/index.html](https://repo.anaconda.com/archive/index.html)
服务器上直接下载:
```shell
# 这里的Anaconda3-2021.05-Linux-x86_64.sh是在官网上选择好的conda的版本
wget -c https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
```
#### 2.参考文章
https://blog.csdn.net/weixin_40816738/article/details/130684650
#### 3.安装
```shell
# 一般正常yes,没什么意外情况
sh Anaconda3-2021.05-Linux-x86_64.sh
```
#### 4.添加到环境变量
```shell
# 编辑/etc/profile,并在末尾添加
export PATH=$PATH:${conda的安装位置}/bin
# 添加完保存再source /etc/profile,conda -V检查一下
```
#### 5.配置镜像
```
channels:
- http://mirrors.aliyun.com/anaconda/cloud/stackless
- https://mirrors.aliyun.com/anaconda/cloud/simpleitk
- https://mirrors.aliyun.com/anaconda/cloud/rdkit
- https://mirrors.aliyun.com/anaconda/cloud/rapidsai
- https://mirrors.aliyun.com/anaconda/cloud/qiime2
- https://mirrors.aliyun.com/anaconda/cloud/pyviz
- https://mirrors.aliyun.com/anaconda/cloud/pytorch3d
- https://mirrors.aliyun.com/anaconda/cloud/pytorch-test
- https://mirrors.aliyun.com/anaconda/cloud/pytorch
- https://mirrors.aliyun.com/anaconda/cloud/psi4
- https://mirrors.aliyun.com/anaconda/cloud/plotly
- https://mirrors.aliyun.com/anaconda/cloud/omnia
- https://mirrors.aliyun.com/anaconda/cloud/ohmeta
- https://mirrors.aliyun.com/anaconda/cloud/numba
- https://mirrors.aliyun.com/anaconda/cloud/msys2
- https://mirrors.aliyun.com/anaconda/cloud/mordred-descriptor
- https://mirrors.aliyun.com/anaconda/cloud/menpo
- https://mirrors.aliyun.com/anaconda/cloud/matsci
- https://mirrors.aliyun.com/anaconda/cloud/intel
- https://mirrors.aliyun.com/anaconda/cloud/idaholab
- https://mirrors.aliyun.com/anaconda/cloud/fermi
- https://mirrors.aliyun.com/anaconda/cloud/fastai
- https://mirrors.aliyun.com/anaconda/cloud/dglteam
- https://mirrors.aliyun.com/anaconda/cloud/deepmodeling
- https://mirrors.aliyun.com/anaconda/cloud/conda-forge
- https://mirrors.aliyun.com/anaconda/cloud/caffe2
- https://mirrors.aliyun.com/anaconda/cloud/c4aarch64
- https://mirrors.aliyun.com/anaconda/cloud/bioconda
- https://mirrors.aliyun.com/anaconda/cloud/biobakery
- https://mirrors.aliyun.com/anaconda/cloud/auto
- https://mirrors.aliyun.com/anaconda/cloud/Paddle
- https://mirrors.aliyun.com/anaconda/pkgs/r
- https://mirrors.aliyun.com/anaconda/pkgs/msys2
- https://mirrors.aliyun.com/anaconda/pkgs/main
- https://mirrors.aliyun.com/anaconda/pkgs/free
show_channel_urls: true
ssl_verify: true
allow_conda_downgrades: true
```
#### 6.常用命令
```shell
# 创建虚拟环境
conda create -n ${虚拟环境名称} ${python==3.7}
# 激活环境
conda activate ${虚拟环境名称}
# 退出环境
conda deactivate
# 查看虚拟环境
conda info --envs
# 删除虚拟环境
conda remove -n name --all
# 删除所有的安装包及cache(索引缓存、锁定文件、未使用过的包和tar包)
conda clean -y --all
```
nginx
#### 1.安装参考
```shell
# 解决 ./configure: error: C compiler cc is not found
# 或者 make: *** No rule to make target `build', needed by `default'. Stop.
# 或者 新机器安装nginx,在make编译是报错:
# 注意 需要删除原来configure的那个目录
sudo yum install -y gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel autoconf automake make gd gd-devel
```
#### 2.安装gzip
```shell
# 参考文档:https://blog.csdn.net/biraotian/article/details/117084463
./configure --prefix=/usr/local/nginx --with-http_gzip_static_module
```
#### 3.http中添加log_format
```
log_format log_json '{"time_local": "$time_iso8601", '
'"remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
'"http_referer": "$http_referer", '
'"request": "$request", '
'"status": $status, '
'"body_bytes_sent": $body_bytes_sent, '
'"http_user_agent": "$http_user_agent", '
'"http_x_forwarded_for": "$http_x_forwarded_for", '
'"upstream_addr": "$upstream_addr",'
'"upstream_connect_time": "$upstream_connect_time",'
'"upstream_response_time": "$upstream_response_time",'
'"upstream_header_time": "$upstream_header_time",'
'"upstream_http_host": "$upstream_http_host",'
'"request_time": "$request_time"'
' }';
```
#### 4.对应服务映射的模板样例
***注意:需要在http中引入该配置 ===> include /usr/local/nginx/conf/openapi.conf;***
```
server {
listen 9004;
server_name localhost;
location / {
proxy_pass http://app_electronic_letter/;
proxy_set_header Host $host:$server_port;
proxy_set_header user-agent $http_user_agent;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
client_body_buffer_size 1280k;
proxy_connect_timeout 5s;
proxy_send_timeout 900s;
proxy_read_timeout 900s;
proxy_buffering off;
proxy_temp_file_write_size 640k;
proxy_redirect off;
}
}
upstream app_electronic_letter {
server 172.17.9.13:9004 weight=1;
server 172.17.9.14:9004 weight=1;
}
```
#### 5.常用命令
```shell
# 查看nginx版本
nginx -v
# 检测nginx的配置文件
nginx -t
# 平滑重启:不会强制结束正在工作的连接,需要等所有连接都结束才会重启
nginx -s reload
# 指定配置文件启动,也可以不指定,使用默认的nginx.conf
nginx -c /etc/nginx/nginx.conf
```
restart-app
#!/bin/bash
source /etc/profile
# 杀掉之前的进程
pid=`ps -ef | grep -E NewMainHandler | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]; then
kill -9 $pid
fi
# 备份文件
# 调整配置
cd /app/bankc
tar -zxvf temp/bankc-internal.tar.gz -C ./bankc
cd bankc
cp -f dbconf_internal_prod.py dbconf.py
# 启动服务
nohup /usr/local/bin/python3 /app/bankc/bankc/NewMainHandler.py -mode=prod >/app/bankc/nohup.out 2>&1 &
service
[Unit]
Description=bdo-meeting
After=network.target
[Service]
Type=forking
User=jssuz.dev
WorkingDirectory=/app/bdo-meeting
ExecStart=/bin/bash /app/bdo-meeting/restart.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
虚拟环境
#### 1.通过poetry创建虚拟环境
```shell
# pip安装poetry
pip install poetry
# 创建虚拟环境
poetry env use ${python解释器路径}
# 进入虚拟环境
poetry shell
```
#### 2.通过venv创建虚拟环境
```shell
# ${python解释器路径} -m venv ${虚拟环境的位置}
/usr/local/python3 -m venv /app/venv/bankc
# 进入虚拟环境
source ${虚拟环境的位置}/bin/activate
```
#### 3.通过conda创建虚拟环境(推荐,好用)
***前提:conda已经安装配置好了***
```shell
# 创建虚拟环境
# 创建python的虚拟环境,就是python=什么什么版本,创建java虚拟环境,就是java=什么什么版本
conda create -n ${虚拟环境名称} python=${python_version}
# 激活/进入虚拟环境
conda activate ${虚拟环境名称}
# 退出虚拟环境
conda deactivate
# 查看虚拟环境列表
conda env list
# 删除虚拟环境
conda env remove --name ${虚拟环境名称}
```