线上演示服务环境的搭建
一、基础环境搭建
1、python3
准备相关的jar包 Index of /ftp/python/3.7.9/
scp Python-3.7.9.tgz root@192.168.1.245:/opt/dockerinstall/python3/
yum -y install gcc
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
tar -zxvf Python-3.7.9.tgz
mkdir /usr/local/python3
cd Python-3.7.9/
./configure --prefix=/usr/local/python3
make && make install
sudo ln -sf /usr/local/python3/bin/python3.7 /usr/bin/python3
sudo ln -sf /usr/local/python3/bin/pip3.7 /usr/bin/pip3
配置python3的路径
cat ~/.bashrc
vim ~/.bashrc
添加
export PATH="/usr/local/python3/bin:$PATH"
source ~/.bashrc
2、安装 paddlenlp 2.5.2
升级pip3
/usr/local/python3/bin/python3.7 -m pip install --upgrade pip
参考 飞桨PaddlePaddle-源于产业实践的开源深度学习平台
pip3 install paddlenlp==2.5.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
代码安装
参考:PaddleNLP/docs/get_started/installation.rst at develop · PaddlePaddle/PaddleNLP · GitHub
git clone https://github.com/PaddlePaddle/PaddleNLP.git 下载不了,用之前已下载的工程
多试几次 下载成功
最新的develop分支 没有applications目录,还是需要用之前已下载的工程
scp root@192.168.1.243:/opt/dockerinstall/PaddleNLP.tar.gz .
cd /opt/dockerinstall/PaddleNLP/applications/text_classification/multi_class/deploy/simple_serving
pip3 install paddlepaddle -i https://pypi.tuna.tsinghua.edu.cn/simple
---------------------------
升级gcc 这段没有用
scp root@192.168.1.243:/opt/dockerinstall/glibc-2.23.tar.gz .
tar -xzf glibc-2.23.tar.gz
cd glibc-2.23
mkdir build
cd build
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
make -j$(nproc)
sudo make install
rebot
---------------------
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
发现少了GLIBCXX_3.4.20,解决方法是升级libstdc++.
sudo yum provides libstdc++.so.6
cd /opt/dockerinstall/
sudo wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip
unzip libstdc.so_.6.0.26.zip
cp libstdc++.so.6.0.26 /usr/lib64/
ls -l | grep libstdc++
sudo rm libstdc++.so.6
sudo ln -s libstdc++.so.6.0.26 libstdc++.so.6
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
pip3 install urllib3==1.26.18
pip show urllib3
启动命令
cd /opt/dockerinstall/PaddleNLP/applications/text_classification/multi_class/deploy/simple_serving
nohup python3 -m uvicorn main_new:app --host 192.168.1.245 --port 6001 --workers 4 > paddlenlpweb_new.log 2>&1 &
tail -500f paddlenlpweb_new.log
curl -X POST http://192.168.1.245:6001/ -H 'Content-Type: application/json' -d '{"data":[{"text": "智能大屏"}, {"text": "智能销售"}]}'
-------------------------------------------------------------------------------------------------------------------------------
2、ES服务
docker network create esol-net
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.14.1
cd /home/dockerinstall/es
mkdir data plugins
chmod 777 data
chmod 777 plugins
mkdir config
scp root@192.168.1.248:/home/dockerinstall/es/config/elasticsearch.yml .
vim elasticsearch.yml
# 集群名称
cluster.name: esol-cluster
# 节点名称
node.name: node-1
# 网络地址
network.host: 0.0.0.0
network.publish_host: 192.168.1.245
# 集群节点配置
discovery.seed_hosts: ["192.168.1.245:9300"]
# 主节点候选
cluster.initial_master_nodes: ["node-1"]
#
# 客户端端口
http.port: 9200
# 集群节点端口
transport.port: 9300
#
# 是否开启安全认证
xpack.security.enabled: false
xpack.security.enrollment.enabled: true
#
# 是否开启ssl
xpack.security.http.ssl:
enabled: false
# #keystore.path: /usr/share/elasticsearch/config/certs/http.p12
# #truststore.path: /usr/share/elasticsearch/config/certs/http.p12
#
# 是否开启访问安全认证
xpack.security.transport.ssl:
enabled: false
# #verification_mode: certificate
# #keystore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
# #truststore.path: /usr/share/elasticsearch/config/certs/elastic-certificates.p12
#
# # 跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
http.host: 0.0.0.0
vim /etc/sysctl.conf
vm.max_map_count = 2000000
docker run -d --privileged=true --name es --network es-net -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms8g -Xmx8g -XX:MaxDirectMemorySize=4g" --memory=10g -v /home/dockerinstall/es/data:/usr/share/elasticsearch/data -v /home/dockerinstall/es/plugins:/usr/share/elasticsearch/plugins -v /home/dockerinstall/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:8.14.1
安装kibana
docker pull docker.elastic.co/kibana/kibana:8.14.1
mkdir kibana
cd /home/dockerinstall/kibana
mkdir data config
chmod 777 data/
scp root@192.168.1.248:/home/dockerinstall/kibana/config/kibana.yml .
vim kibana.yml
启动
docker run -d --name kibana --network es-net -p 5601:5601 -v /home/dockerinstall/kibana/data:/usr/share/kibana/data -v /home/dockerinstall/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml docker.elastic.co/kibana/kibana:8.14.1
查看节点信息
192.168.1.245:9200
http://192.168.1.245:5601/
安装插件
cd /home/dockerinstall/es_plugins
scp root@192.168.1.248:/home/dockerinstall/es_plugins/elasticsearch-analysis-ik-8.14.1.zip .
cp elasticsearch-analysis-ik-8.14.1.zip ../es/plugins/
unzip elasticsearch-analysis-ik-8.14.1.zip -d analysis-ik/
rm -rf elasticsearch-analysis-ik-8.14.1.zip
docker restart 5f388feaa8da
docker exec -it 5f388feaa8da bash
./bin/elasticsearch-plugin list
插件安装成功
192.168.1.245:9200/_cat/plugins?v=true
3、MySQL 安装
已有mysql 8 服务 重启即可
docker start 01e9ca6e0116
mysql -uroot -h192.168.1.245 -P3306 -p******
3、minIO服务
vim /etc/hosts
ping minio5
docker-compose -v
如果没有则安装
方法一
sudo pip3 install setuptools-rust --index-url https://mirrors.aliyun.com/pypi/simple
sudo pip3 install bcrypt --index-url https://mirrors.aliyun.com/pypi/simple
sudo pip3 install docker-compose --index-url https://mirrors.aliyun.com/pypi/simple
sudo yum install -y epel-release
sudo yum install -y docker-compose
docker-compose --version
方法二:手动下载并安装深色版本
-
wget https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64 -O /usr/local/bin/docker-compose
-
赋予执行权限:
sudo chmod +x /usr/local/bin/docker-compose
-
验证安装:
docker-compose --version
下载较慢
mkdir minio-data1
mkdir minio-data2
mkdir minio
scp root@192.168.1.243:/home/dockerinstall/minio/docker-compose.yml .
version: "3"
services:
minio:
image: quay.io/minio/minio
container_name: minio-node5
hostname: minio5
expose:
- "19000"
- "19001"
environment:
- MINIO_ROOT_USER=minio
- MINIO_ROOT_PASSWORD=minio@123
volumes:
- /home/minio-data1:/data1
- /home/minio-data2:/data2
command: server /data1 /data2 --console-address ':19001' --address ':19000'
privileged: true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:19000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
extra_hosts:
- minio5:192.168.1.245
restart: always
network_mode: host
nginx:
image: nginx:latest
hostname: nginx
volumes:
- /home/dockerinstall/nginx/conf.d/nginx.conf:/etc/nginx/nginx.conf:ro
- /home/dockerinstall/nginx/cert/server1.crt:/etc/nginx/ssl/server1.crt:ro
- /home/dockerinstall/nginx/cert/server1.key:/etc/nginx/ssl/server1.key:ro
ports:
- "9000:9090"
- "9001:9091"
- "443:443"
extra_hosts:
- minio5:192.168.1.245
restart: always
mkdir nginx
mkdir cert
mkdir conf.d
scp root@192.168.1.243:/home/dockerinstall/nginx/conf.d/nginx.conf .
scp root@192.168.1.243:/home/dockerinstall/nginx/cert/server1.crt .
scp root@192.168.1.243:/home/dockerinstall/nginx/cert/server1.key .
sudo yum install tree
查看目录结构:
带nginx (245)
user nginx; # 设置 Nginx 运行的用户为 "nginx"。
worker_processes auto; # 自动确定工作进程的数量,通常是根据 CPU 核心数来决定。
error_log /var/log/nginx/error.log warn; # 将错误日志记录到指定路径,并仅记录警告及以上级别的日志。
pid /var/run/nginx.pid; # 指定 Nginx 进程 ID 文件的路径。
events {
worker_connections 4096; # 设置每个工作进程的最大并发连接数。
}
http {
include /etc/nginx/mime.types; # 包含 MIME 类型配置文件。
default_type application/octet-stream; # 设置默认 MIME 类型。
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; # 启用高效文件传输。
keepalive_timeout 65; # 设置保持连接的超时时间。
upstream adobe { # 定义了一个名为 "adobe" 的负载均衡组,包含三个服务器。
server minio5:19000;
}
upstream console { # 定义了一个名为 "console" 的负载均衡组,同样包含三个服务器,并使用 ip_hash 进行基于 IP 的会话保持。
ip_hash;
server minio5:19001;
}
# HTTP 服务器块,用于重定向 HTTP 到 HTTPS
server {
listen 80; # 监听 80 端口,用于将 HTTP 请求重定向到 HTTPS。
server_name 192.168.1.245; # 设置服务器名称,这里是 IP 地址。
return 301 https://$host$request_uri; # 将 HTTP 请求重定向到 HTTPS。
}
# HTTPS 服务器块
server {
listen 443 ssl; # 监听 443 端口,用于 SSL。
listen [::]:443 ssl; # 监听 IPv6 地址的 443 端口,用于 SSL。
server_name 192.168.1.245; # 设置服务器名称,这里是 IP 地址。
ssl_certificate /etc/nginx/ssl/server1.crt; # SSL 证书文件路径。
ssl_certificate_key /etc/nginx/ssl/server1.key; # SSL 私钥文件路径。
ssl_session_timeout 5m; # SSL 会话缓存的有效时间。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 支持的 SSL/TLS 版本。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; # 支持的加密套件。
ssl_prefer_server_ciphers on; # 优先使用服务器端的加密套件列表。
# To allow special characters in headers
ignore_invalid_headers off; # 允许特殊字符出现在 HTTP 头中。
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0; # 允许上传任意大小的文件。
# To disable buffering
proxy_buffering off; # 关闭代理缓冲。
proxy_request_buffering off; # 不对请求体进行缓冲。
location / { # 定义根路径的处理规则。
proxy_set_header Host $http_host; # 设置 Host 头。
proxy_set_header X-Real-IP $remote_addr; # 设置客户端真实 IP。
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 设置客户端 IP 列表。
proxy_set_header X-Forwarded-Proto $scheme; # 设置协议类型。
proxy_connect_timeout 300; # 设置连接超时时间。
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1; # 使用 HTTP/1.1 版本。
proxy_set_header Connection ""; # 清空 Connection 头,避免代理服务器使用 close 或者 keep-alive。
# For WebSocket support
proxy_set_header Upgrade $http_upgrade; # 设置升级协议头。
proxy_set_header Connection "upgrade"; # 设置连接类型为升级。
chunked_transfer_encoding off; # 禁用分块传输编码。
proxy_pass http://adobe; # 指定代理目标。
}
}
# 另一个服务器块监听 9091 端口
server {
listen 9091;
listen [::]:9091; # 监听 IPv6 地址的 9091 端口。
server_name 192.168.1.245;
# To allow special characters in headers
ignore_invalid_headers off; # 允许特殊字符出现在 HTTP 头中。
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0; # 允许上传任意大小的文件。
# To disable buffering
proxy_buffering off; # 关闭代理缓冲。
proxy_request_buffering off; # 不对请求体进行缓冲。
location / { # 定义根路径的处理规则。
proxy_set_header Host $http_host; # 设置 Host 头。
proxy_set_header X-Real-IP $remote_addr; # 设置客户端真实 IP。
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 设置客户端 IP 列表。
proxy_set_header X-Forwarded-Proto $scheme; # 设置协议类型。
proxy_set_header X-NginX-Proxy true; # 设置代理标识。
# This is necessary to pass the correct IP to be hashed
real_ip_header X-Real-IP; # 指定使用哪个头作为真实 IP。
proxy_connect_timeout 300; # 设置连接超时时间。
# To support websocket
proxy_http_version 1.1; # 使用 HTTP/1.1 版本。
proxy_set_header Upgrade $http_upgrade; # 设置升级协议头。
proxy_set_header Connection "upgrade"; # 设置连接类型为升级。
chunked_transfer_encoding off; # 禁用分块传输编码。
proxy_pass http://console; # 指定代理目标。
}
}
# 另一个服务器块监听 9090 端口
server {
listen 9090;
listen [::]:9090; # 监听 IPv6 地址的 9090 端口。
server_name 192.168.1.245;
# To allow special characters in headers
ignore_invalid_headers off; # 允许特殊字符出现在 HTTP 头中。
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0; # 允许上传任意大小的文件。
# To disable buffering
proxy_buffering off; # 关闭代理缓冲。
proxy_request_buffering off; # 不对请求体进行缓冲。
location / { # 定义根路径的处理规则。
proxy_set_header Host $http_host; # 设置 Host 头。
proxy_set_header X-Real-IP $remote_addr; # 设置客户端真实 IP。
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 设置客户端 IP 列表。
proxy_set_header X-Forwarded-Proto $scheme; # 设置协议类型。
proxy_connect_timeout 300; # 设置连接超时时间。
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1; # 使用 HTTP/1.1 版本。
proxy_set_header Connection ""; # 清空 Connection 头,避免代理服务器使用 close 或者 keep-alive。
chunked_transfer_encoding off; # 禁用分块传输编码。
proxy_pass http://adobe; # 指定代理目标。
}
}
}
配置docker 镜像源:
cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://dockerproxy.com","https://ccr.ccs.tencentyun.com","https://hub-mirror.c.163.com","https://developer.aliyun.com/mirror/","https://registry.cn-hangzhou.aliyuncs.com","https://dockerhub.azk8s.cn","https://tcr.tuna.tsinghua.edu.cn/","https://9cpn8tt6.mirror.aliyuncs.com","https://mirror.baidubce.com","https://mirror.ccs.tencentyun.com"],
"insecure-registries": ["http://192.168.1.249:8086","https://192.168.1.249:16443"],
"live-restore": true
}
测试是否好使 或者查看 docker info 信息
docker pull ccr.ccs.tencentyun.com/library/nginx:latest
在 /home/dockerinstall/minio目录下启动
docker-compose up -d
docker ps
查看 发现报错了
FATAL Unable to prepare the list of endpoints: Invalid ellipsis format in (http://minio{5}/data{1...2}), Ellipsis range must be provided in format {N...M} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4
> Please provide correct combination of local/remote paths
HINT:
For more information, please refer to https://min.io/docs/minio/linux/operations/concepts/erasure-coding.html
FATAL Unable to prepare the list of endpoints: Invalid ellipsis format in (http://minio{5}/data{1...2}), Ellipsis range must be provided in format {N...M} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4
> Please provide correct combination of local/remote paths
HINT:
For more information, please refer to https://min.io/docs/minio/linux/operations/concepts/erasure-coding.html
FATAL Unable to prepare the list of endpoints: Invalid ellipsis format in (http://minio{5}/data{1...2}), Ellipsis range must be provided in format {N...M} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4
在配置 MinIO 时提供的端点格式不正确。MinIO 在使用分布式模式时,需要正确地指定多个存储节点的地址。错误信息指出,你在使用椭圆符号 {N...M}
时格式不正确。
错误分析
错误信息中提到的格式问题在于:
- 椭圆符号
{N...M}
必须是正整数,并且M
必须大于N
。 - 最小范围必须为 4。
正确的格式示例
假设你有 5 个 MinIO 节点,地址分别为 http://minio1/data
, http://minio2/data
, http://minio3/data
, http://minio4/data
, http://minio5/data
,正确的格式应该是:
http://minio{1...5}/data
改为支持单点: command: server /data1 /data2 --console-address ':19001' --address ':19000'
验证可以登录了
5、JDK和数智平台web服务
mysql -uroot -h192.168.1.245 -P3306 -p******
创建数据库
create database business_chatgpt;
将工程中table.sql中的表全部创建
/opt/dockerinstall/mysql_sql/table.sql
mysql -h 127.0.0.1 -u root -p****** business_chatgpt < /opt/dockerinstall/mysql_sql/table.sql
ES 的模板配置
PUT /_index_template/content_erp_nlp_help
{
"index_patterns": ["content_erp*"],
"priority": 100,
"template": {
"settings": {
"analysis": {
"analyzer": {
"my_ik_analyzer": {
"type": "ik_smart"
}
}
},
"number_of_shards": 1,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"id": {"type": "long"},
"content": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"content_vector": {"type": "dense_vector","similarity": "cosine","index": true,"dims": 768,"element_type": "float","index_options": {"type": "hnsw","m": 16,"ef_construction": 128}},
"content_answer": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"title": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"param": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"type": {"type": "keyword"},
"questionId": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"createTime": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"updateTime": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"hitCount": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"answerPattern": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"nearQuestionVOList": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"questionEnclosureVOList": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"questionRelationVOList": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"rmsRoutingAnswerVos": {"type": "text","analyzer": "ik_max_word","search_analyzer": "ik_smart"},
"label": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"question": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
创建测试索引 创建别名
PUT /content_erp_nlp_help_test
POST /_aliases
{
"actions": [
{ "add": { "index": "content_erp_nlp_help_test", "alias": "content_erp_nlp_help_alia" } }
]
}
GET /_alias/content_erp_nlp_help_alia
可以写入ES数据了。
部署 web工程