Docker java项目发布/开发环境搭建

线上部署项目/开发环境搭建命令大全

关闭windows10 指定应用
https://blog.csdn.net/xzpaiwangchao/article/details/123950844

# 查询指定应用 PID
netstat -ano|findstr 8080
# 关闭指定程序
taskkill /PID 22876 /F

# cmd手动启动 nginx
cd ../nginx.exe

# 查询是否启动
tasklist /fi "imagename eq nginx.exe"

# 启动nginx
start nginx

# 停止服务
nginx -s stop
`https://cloud.tencent.com/developer/article/1888447`

# 杀掉所有的nginx
taskkill /f /t /im nginx.exe

安装Docker

安装 docker-compose

sudo curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose- ( u n a m e − s ) − (uname -s)- (unames)(uname -m)” -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
[root@k8s-node1 ~]# docker-compose --version
docker-compose version 1.29.2, build 5becea4c

关于docker容器导致硬盘耗尽解决方案

df -i
df -h 
cannot create temp file for here document: No space left on device

磁盘空间满了

1. df -h

查哪个盘满了

 2. find  /  -size +1000000

找出过大文件,一般日志居多

3.删除无用文件

rm /var/lib/docker/volumes/4811c480e7cf205e2763f168053237b1597ad838879d84ea92c8bc9bce364c7f/_data/zz/sys_log.ibd
  • 加速安装https://yeasy.gitbook.io/docker_practice/install/centos
  • 官网安装https://docs.docker.com/engine/install/centos/
  • idea 使用可能小技巧 大括号换行
    https://jingyan.baidu.com/article/ac6a9a5e2e29852b653eac30.html
    在这里插入图片描述

idea使用 maven_docker 插件

https://blog.csdn.net/jackcheng1117/article/details/83080303

$ sudo systemctl enable docker
$ sudo systemctl start docker

# 开机自启
systemctl enable docker.service

docker 启动失败
cd /www/server/docker/overlay2/eca04d29fdebf83d76a33e5afa1f0a9dcae634246d8b5993209430d4b795b865/diff

安装依赖

官方参考地址:https://docs.docker.com/install/linux/docker-ce/centos/

里面包含包下载地址: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

安装依赖

sudo yum install -y yum-utils  device-mapper-persistent-data  lvm2sudo 

yum-config-manager  --add-repo https://download.docker.com/linux/centos/docker-ce.reposudo yum install docker-ce docker-ce-cli containerd.io

如果报错:Problem: package docker-ce-3:19.03.4-3.el7.x86_64 requires containerd.io >= 1.2.2-3 那就先装新版的 containerd.io

img

dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

再装剩下两个

sudo yum install docker-ce docker-ce-clisudo systemctl start dockerdocker --version

如果国外的Docker镜像很慢的话,则可以基于阿里云镜像来安装Docker。

url

执行一下三个命令,从阿里云的镜像下载Docker。注意,下面给出的第二条命令的链接是撰写文章时最新的链接,实际下载时,最好去检查一下是否有更新。

yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repodnf install https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.1.el7.x86_64.rpmdnf install docker-ce

接着,设置开机自启Docker并启动Docker:

systemctl enable docker.service

systemctl start docker.service

开机自启

sudo systemctl enable docker

镜像加速

选择其中之一即可

# 阿里镜像加速
mkdir -p /etc/docker
#
tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://l90lo6hm.mirror.aliyuncs.com"]
}
EOF


tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [
        "https://docker.mirrors.ustc.edu.cn",
        "https://hub-mirror.c.163.com",
        "https://mirror.ccs.tencentyun.com",
        "https://registry.docker-cn.com"
    ]
}
EOF
#
sudo systemctl daemon-reload
sudo systemctl restart docker

安装宝塔

非必要操作,主要用于linux监控性能
官网

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

卸载docker

$ sudo yum remove docker \                  docker-client \                  docker-client-latest \                  docker-common \                  docker-latest \                  docker-latest-logrotate \                  docker-logrotate \                  docker-engine$ sudo yum install -y yum-utils# 官网yum源$ sudo yum-config-manager \    --add-repo \    https://download.docker.com/linux/centos/docker-ce.repo# 阿里云yum源$ sudo yum-config-manager \    --add-repo \  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# 将软件包信息提前在本地缓存一份,用来提高搜索安装软件的速度# yum makecache fast    $ sudo yum install docker-ce docker-ce-cli containerd.io$ sudo systemctl start docker

添加ubuntu 中文字体解决activit5.22乱码问题

# 容器内字体存放路径/usr/share/fonts/truetype/dejavu# 修改字体执行权限chmod 744 /usr/share/fonts/truetype/dejavu/simsun.ttc# 刷新字体缓存fc-cache -fv
@Configurationpublic class ActivityConfig implements ProcessEngineConfigurationConfigurer {    private static final String ActivityFontName = "宋体";    private static final String LabelFontName = "宋体";    private static final String AnnotationFontName = "宋体";    private static final String XmlEncoding = "UTF-8";    @Override    public void configure(SpringProcessEngineConfiguration springProcessEngineConfiguration) {        springProcessEngineConfiguration.setActivityFontName(ActivityFontName);        springProcessEngineConfiguration.setLabelFontName(LabelFontName);        springProcessEngineConfiguration.setAnnotationFontName(AnnotationFontName);        springProcessEngineConfiguration.setXmlEncoding(XmlEncoding);    }}

关闭防火墙 (线上部署请忽略)

#关闭防火墙systemctl stop firewalldsystemctl disable firewalld#关闭Linuxsed -i 's/enforcing/disabled/' /etc/selinux/configsetenforce 0#关闭swap  swapoff -a #临时关闭sed -ri 's/.*swap.*/#&/' /etc/fstab #永久关闭free -g #验证,swap必须为0#设置CentOS的时区,以避免因时区带来的BUGtimedatectl set-timezone Asia/Shanghai

查看docker信息

# 查看docker 版本信息docker -v# 查看 本地镜像库docker images# 开机启动systemctl enable docker

修改docker源为阿里云

sudo mkdir -p /etc/dockersudo tee /etc/docker/daemon.json <<-'EOF'{  "registry-mirrors": ["https://aeb49y3h.mirror.aliyuncs.com"]}EOFsudo systemctl daemon-reloadsudo systemctl restart docker

docker镜像自动启动

docker update redis --restart=alwaysdocker update mysql --restart=always

拉取Docker images

docker pull mysql:5.7docker pull openjdkdocker pull redisdocker pull nginx# 容器自启docker update mysql --restart=alwaysdocker update nginx --restart=always

安装MySQL

docker run -p 3306:3306 --name mysql \ -v /mydata/mysql/log:/var/log/mysql \ -v /mydata/mysql/data:/var/lib/mysql \ -v /mydata/mysql/conf:/etc/mysql \ -e MYSQL_ROOT_PASSWORD=root \ -d mysql:5.7# 重启docker restart mysql

MySQL配置文件

[mysqld]default-character-set=utf8[client]default-character-set=utf8[mysql]default-character-set=utf8#第二份配置文件[client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld]init_connect='SET collation_connection = utf8_unicode_ci'init_connect='SET NAMES utf8'character-set-server=utf8collation-server=utf8_unicode_ciskip-character-set-client-handshakeskip-name-resolve

安装Redis

mkdir -p /mydata/redis/conftouch /mydata/redis/conf/redis.conf# 安装docker run -p 6379:6379 --name redis \-v /mydata/redis/data:/data \-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \-d redis redis-server /etc/redis/redis.conf# 修改配置文件vi  /mydata/redis/conf/redis.conf# 设置自启docker update redis --restart=always# 编辑redis 配置文件vi /mydata/redis/conf/redis.conf

Redis配置文件

# 配置持久化appendonly yes

安装java运行环境

#打包项目mvn clean install -Dmaven.test.skip=true
# 创建目录挂载# docker volume create j1
# 查看目录挂载路径# docker volume inspect j1
#创建数据卷,上传JAR文件# 在_data 文件夹中上传文件 
#启动容器docker run -it -d --name jar -v /mydata/renren:/home/soft --net=host openjdk
#进入j1容器docker exec -it j1 bash
#启动Java项目nohup java -jar /home/soft/renren-fast.jar	
# 项目地址
# http://localhost:8080/renren-fast/swagger/index.html# http://amewin.xyz/renren-fast/swagger/index.html#
# 项目部署后台运行(3中方法)# 1. & 后台运行java -jar renren-fast.jar &
# 2.使用 nohup (推荐)nohup java -jar renren-fast.jar nohup java -jar renren-fast.jar>temp.txt & (推荐)
# 3.使用命令java -jar renren-fast.jar --然后使用 按命令 ctrl + Z 输入 bg

安装Nginx <后端>

#创建nginx配置文夹映射mkdir -p /mydata/renrentouch /mydata/renren/nginx.confvi /mydata/renren/nginx.conf#创建nginx容器docker run -it -d --name nginx -v /mydata/renren/nginx.conf:/etc/nginx/nginx.conf --net=host --privileged nginx

后端Nginx配置

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;	proxy_redirect          off;	proxy_set_header        Host $host;	proxy_set_header        X-Real-IP $remote_addr;	proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;	client_max_body_size    10m;	client_body_buffer_size   128k;	proxy_connect_timeout   5s;	proxy_send_timeout      5s;	proxy_read_timeout      5s;	proxy_buffer_size        4k;	proxy_buffers           4 32k;	proxy_busy_buffers_size  64k;	proxy_temp_file_write_size 64k;	upstream tomcat {		# 使用的是war 打包方式 及springboot项目		# 部署 根据线上环境进行配置		server 10.0.4.14:6001;		# server 192.168.56.104:6002;		# server 192.168.56.104:6003;	}	server {		# 代理端口        listen       80;        server_name  localhost;        location / {            proxy_pass   http://tomcat;            index  index.html index.htm;        }    }}

安装Nginx <前端>

# mkdir -p /mydata/nginx/html 前端配置文件# mkdir -p /mydata/nginx/logs 日志# mkdir -p /mydata/nginx/conf 配置文件# 创建配置文件touch /mydata/nginx/conf/nginx.confvi /mydata/nginx/conf/nginx.confdocker run -p 80:80 --name nginx \ -v /mydata/nginx/html:/usr/share/nginx/html \ -v /mydata/nginx/logs:/var/log/nginx \ -v /mydata/nginx/conf/:/etc/nginx \ -d nginx

前端Nginx配置

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;	proxy_redirect          off;	proxy_set_header        Host $host;	proxy_set_header        X-Real-IP $remote_addr;	proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;	client_max_body_size    10m;	client_body_buffer_size   128k;	proxy_connect_timeout   5s;	proxy_send_timeout      5s;	proxy_read_timeout      5s;	proxy_buffer_size        4k;	proxy_buffers           4 32k;	proxy_busy_buffers_size  64k;	proxy_temp_file_write_size 64k;	server {		listen 80; #代理端口		server_name  localhost; #代理ip		location  /  {			root  /home/fn1/renren-vue;			index  index.html;		}	}}

Linux 安装部署

mysql 操作 

```mysql
 drop database RUNOOB;
 
 drop database if exists kim_kks;
 
 create database 
 
 use kim_kks;
 source /use/loacle/app/

错误:Client does not support authentication protocol requested by server; consider upgrading MySQL client

客户端不支持服务器请求的认证协议;考虑升级MySQL客户端

先登录:
mysql -u root -p
#接着输入你的密码查看密码
grep “A temporary password” /var/log/mysqld.log
解决办法:
ALTER USER ‘root’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘你的密码’;
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘你的密码’;
SELECT plugin FROM mysql.user WHERE User = ‘root’;

安装mysql

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

sudo yum install mysql-server
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
sudo yum install mysql-server
 
 
 rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
 yum --enablerepo=mysql80-community install mysql-community-server
   
   


### Python 项目部署

#### 复杂的方案 

**项目部署 (完整版)**

1) 首先安装docker:

```shell
# 用 yum 安装并启动yum  install docker -y && systemctl start docker
  1. 下载自定义镜像需要用到的基础镜像:
# 这里以centos7为例docker pull python:3.9
  1. 基础镜像已经准备好了,接下来准备好需要部署的环境服务,以及python项目:
# 安装下载工具yum install wget ### 创建 dockerfile 文件mkdir dockerfile && cd dockerfile### 下载 python(这里以3.7为例)wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz### 下载 openssl (非必要操作)### wget http://www.openssl.org/source/openssl-1.1.1.tar.gz### 将 python 项目<复制/上传>到此目录### cp ~/test.py .### 以及 python 项目的依赖库### cp ~/requirements.txt .
  1. 需要自定义docker镜像的大致内容准备好了,接下来编写dockerfile:
### 使用执行容器FROM centos:centos7
### 设置镜像创建者名称MAINTAINER Amewin
### 下载编译需要用到的软件 pythonRUN yum install -y gcc gcc-c++ autoconf automake libtool make zlib* libffi-devel

### 下载编译需要用到的软件 opensslRUN yum install -y zlib zlib-dev openssl-devel sqlite-devel bzip2-devel libffi libffi-devel gcc gcc-c++
### 安装opensslADD openssl-1.1.1.tar.gz /usr/local/src
### 示例:将得到如下文件夹 
/usr/local/src/openssl-1.1.1
# 等价如下命令
#COPY openssl-1.1.1.tar.gz /usr/local/src#WORKDIR /usr/local/src#RUN tar -zxvf openssl-1.1.1.tar.gz

### ADD 和 COPY 两个命令类似 都可以拷贝 文件或文件夹
### (只要不是压缩包 ADD COPY 没有本质区别,官方建议使用:COPY)
### ADD 解压到指定文件夹<文件夹不存在会自动创建> 注意:源压缩文件不会复制进images
### 设置切换目录WORKDIR /usr/local/src/openssl-1.1.1
### 设置ssl环境变量RUN ./config --prefix=$HOME/openssl shared zlib && make && make install
### RUN 执行指定命令 多条指令可以 && 连接RUN source $HOME/.bash_profile
### 安装openssl end
### 将dockerfile目录下的python-3.7.3.tgz复制到docker容器内
COPY Python-3.7.9.tgz /usr/local/srcWORKDIR /usr/local/srcRUN tar -xf Python-3.7.9.tgz
### 类似于如下命令 但 /usr/local/src/Python-3.7.9.tgz 不存在
### ADD Python-3.7.9.tgz /usr/local/srcWORKDIR /usr/local/src/Python-3.7.9
### --with-openssl=$HOME/openssl (非必要参数)RUN ./configure --prefix=/usr/local/python37 --with-openssl=$HOME/openssl && make && make install### 设置环境变量ENV PATH /usr/local/python37/bin:$PATH### 创建工作目录
### ADD
### 将python项目复制到 /spider工作目录下COPY ./proxy /spider### 设置 /spider 为工作目录WORKDIR /spider

### 下载 python 项目的依赖库RUN pip3 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r requirements.txt

### 在创建个爬取的数据存放的目录,这个需要根据自己代码里面设置的目录来创建,例如:
### VOLUME /data
### 更改openssl 避免 No module named _ssl
### 必须安装编译后,在执行,该命令不然那报错RUN echo '_ssl _ssl.c \-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \-L$(SSL)/lib -lssl -lcrypto' \>> /usr/local/src/Python-3.7.9/Modules/Setup
### WORKDIR 切换目录WORKDIR /usr/local/src/Python-3.7.9
### 进行安装RUN  make && make install
### 修改 docker exec -it <id/imagesName> bash 进入默认路径WORKDIR /spider
### 最后一步,运行docker镜像时运行自己的python项目
### 可以多个参数: CMD ["python3","a","main.py"]CMD ["python3","main.py"]
### CMD 该方法是可被 /bin/bash -c "nohup ping -i 1000 www.baidu.com" 覆盖
###  docker run -d centos /bin/bash -c "nohup ping -i 1000 www.baidu.com"
### ENTRYPOINT ["python3","main.py"]
### ENTRYPOINT CMD 类似 但ENTRYPOINT 不允许 更改run 参数

更改COMMAND 启动参数

[root@A python2]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMEScd0bc9ff8cf3 python1:v1 “python3 main.py” 4 hours ago Up 4 hours proxy1be8263c3b5b3 python1:v1 “/bin/bash -c 'nohup…” 4 hours ago Up 4 hours proxy2

Python项目部署(简化版)

1)配置部署环境

# 获取python images 环境 根据实际需求选择docker pull python:3.9
#docker pull python:3.8
#docker pull python:3.7
# 创建目录mkdir -p /mydata/python-spidercd /mydata/python-spidertouch Dockerfile
# 将运行项目copy到proxy内mkdir proxyvi Dockerfile
[root@Amewin python-spider]
# lsDockerfile  proxy
[root@A test]# vi Dockerfile

2)编写Dockerfile

# 使用python3.9镜像创建FROM python:3.9# 作者名称MAINTAINER Amewin# 将spider 拷贝到容器内/data # COPY (宿主机目录/文件) (容器目录)COPY ./proxy /spider # 切换工作目录WORKDIR /spider # 执行shell 下载相关依赖RUN pip3 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r requirements.txt# 容器启动 run 启动参数CMD ["python3","main.py"]

3)执行Dockerfile

### docker build -t 镜像名:版本号   镜像名:版本号 均为自定义  别忘了末尾的点“.”docker build -t pythonspider:v1 .### 通过 docker images命令就可以看到刚刚创建的镜像docker images### 运行docker run -d --name spider  pythonspider:v1### -d为后台运行,--name 后面设置容器名,-v 是目录共享,主机目录和docker容器内目录共享。创建dockerfile的时候,有这一句 VOLUME /data 就是作为共享目录使用的,“:”前的目录为主机目录,后面的目录为容器内目录。。。 最后一个参数 pythonspider:v1 镜像名

tomcat部署war

docker pull tomcat:8.5
docker run -d --name tomcat -p 8081:8080 -v \ 
/mydata/tomcat/web:/usr/local/tomcat/webapps -v \  
/mydata/tomcat/conf/server.xml:/usr/local/tomcat/conf/server.xml  tomcat:8.5

docker run -d --name tomcat_web -p 8082:8080 -v \  
/mydata/tomcat_web/web:/usr/local/tomcat/webapps -v  \ 
/mydata/tomcat_web/conf/server.xml:/usr/local/tomcat/conf/server.xml  tomcat:8.5

调整tomcat 内存大小

JAVA_OPTS="-Dfile.encoding=UTF-8-server -Xms1024m -Xmx2048m -XX:NewSize=512m -XX:MaxNewSize=1024m-XX:PermSize=256m -XX:MaxPermSize=256m -XX:MaxTenuringThreshold=10-XX:NewRatio=2 -XX:+DisableExplicitGC"

nginx 配置说明

user  www www;worker_processes auto;error_log  /www/wwwlogs/nginx_error.log  crit;pid        /www/server/nginx/logs/nginx.pid;worker_rlimit_nofile 51200;events    {        use epoll;        worker_connections 51200;        multi_accept on;    }http    {        include       mime.types;		#include luawaf.conf;		include proxy.conf;        default_type  application/octet-stream;        server_names_hash_bucket_size 512;        client_header_buffer_size 32k;        large_client_header_buffers 4 32k;        client_max_body_size 50m;        sendfile   on;        tcp_nopush on;        keepalive_timeout 60;        tcp_nodelay on;        fastcgi_connect_timeout 300;        fastcgi_send_timeout 300;        fastcgi_read_timeout 300;        fastcgi_buffer_size 64k;        fastcgi_buffers 4 64k;        fastcgi_busy_buffers_size 128k;        fastcgi_temp_file_write_size 256k;		fastcgi_intercept_errors on;        gzip on;        gzip_min_length  1k;        gzip_buffers     4 16k;        gzip_http_version 1.1;        gzip_comp_level 2;        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;        gzip_vary on;        gzip_proxied   expired no-cache no-store private auth;        gzip_disable   "MSIE [1-6]\.";        limit_conn_zone $binary_remote_addr zone=perip:10m;		limit_conn_zone $server_name zone=perserver:10m;        server_tokens off;        access_log off;server    {        listen 888;        server_name phpmyadmin;        index index.html index.htm index.php;        root  /www/server/phpmyadmin;        #error_page   404   /404.html;        include enable-php.conf;        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$        {            expires      30d;        }        location ~ .*\.(js|css)?$        {            expires      12h;        }        location ~ /\.        {            deny all;        }        access_log  /www/wwwlogs/access.log;    }  upstream tomcat {		# 使用的是war 打包方式 及springboot项目		# 部署 根据线上环境进行配置		server localhost:8081;		# server 192.168.56.104:6002;		# server 192.168.56.104:6003;	}	server {		listen 80;        listen 443 ssl http2;        server_name xxx.con;        #index index.php index.html index.htm default.php default.htm default.html;        #root /www/wwwroot/xxx.con;                #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则        #error_page 404/404.html;        ssl_certificate    /www/server/panel/vhost/cert/xxx.con/fullchain.pem;        ssl_certificate_key    /www/server/panel/vhost/cert/xxx.con/privkey.pem;        ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;        ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;        ssl_prefer_server_ciphers on;        ssl_session_cache shared:SSL:10m;        ssl_session_timeout 10m;        add_header Strict-Transport-Security "max-age=31536000";        error_page 497  https://$host$request_uri;        location / {            # $host 代表转发服务器            proxy_set_header Host $host;            proxy_redirect off;            # 记录真实IP            proxy_set_header X-Real-IP $remote_addr;            # 存储请求链路上各代理IP            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            # 连接超时时间            proxy_connect_timeout 60;            # nginx接收upstream server数据超时时间            proxy_read_timeout 600;            # nginx发送数据至upstream server超时时间            proxy_send_timeout 600;            # 反向代理到上面定义好的 upstream blogapi 下的服务器上            proxy_pass   http://tomcat;            index  index.html index.htm;        }    }    upstream tomcat_web {		# 使用的是war 打包方式 及springboot项目		# 部署 根据线上环境进行配置		server localhost:8082;		# server 192.168.56.104:6002;		# server 192.168.56.104:6003;	}	server {		listen 80;        listen 443 ssl http2;        server_name web.xxx.con;        ssl_certificate    /www/server/panel/vhost/cert/web.xxx.con/fullchain.pem;    ssl_certificate_key    /www/server/panel/vhost/cert/web.xxx.con/privkey.pem;        ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;        ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;        ssl_prefer_server_ciphers on;        ssl_session_cache shared:SSL:10m;        ssl_session_timeout 10m;        add_header Strict-Transport-Security "max-age=31536000";        error_page 497  https://$host$request_uri;        location / {            # $host 代表转发服务器            proxy_set_header Host $host;            proxy_redirect off;            # 记录真实IP            proxy_set_header X-Real-IP $remote_addr;            # 存储请求链路上各代理IP            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            # 连接超时时间            proxy_connect_timeout 60;            # nginx接收upstream server数据超时时间            proxy_read_timeout 600;            # nginx发送数据至upstream server超时时间            proxy_send_timeout 600;            # 反向代理到上面定义好的 upstream blogapi 下的服务器上            proxy_pass   http://tomcat_web;            index  index.html index.htm;        }    }include /www/server/panel/vhost/nginx/*.conf;}

开发环境搭建

# 拉取镜像
docker pull mysql:5.7
docker pull mysql:8docker pull redisdocker 
pull rabbitmqdocker pull elasticsearchdocker 
pull zookeeperdocker pull rabbitmq:managementdocker 
pull python:3.9

安装MySQL5.7

docker run -p 3306:3306 --name mysql \-v /mydata/mysql/log:/var/log/mysql \-v /mydata/mysql/data:/var/lib/mysql \-v /mydata/mysql/conf:/etc/mysql \-e MYSQL_ROOT_PASSWORD=root \-d mysql:5.7# 开机自启docker update mysql --restart=alwaysvi /mydata/mysql/conf/my.cnf

nacos用户创建

-- 创建一个nacos 用户 % 任何ip 登录-- 用有nacos 的完整权限-- grant all on nacos.* to 'nacos'@'%' identified by 'nacos';grant select,insert,update,delete on nacos.* to 'nacos'@'%' identified by 'nacos';-- 刷新权限列表flush privileges;
[client]default-character-set=utf8[mysql]default-character-set=utf8[mysqld]init_connect='SET collation_connection = utf8_unicode_ci'init_connect='SET NAMES utf8'character-set-server=utf8collection-server=utf8_unicode_ciskip-character-set-client-handshakeskip-name-resolve# skip-name-resolve 解决连接缓慢

MySQL主从数据配置

# Master节点
docker run -p 3307:3306 --name mysql-master \
-v /mydata/mysql/master/log:/var/log/mysql \
-v /mydata/mysql/master/data:/var/lib/mysql \
-v /mydata/mysql/master/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7 


# 修改master基本配置
vim /mydata/mysql/master/conf/my.cnf

[client]
default-character-set=utf8
 
[mysql]
default-character-set=utf8
 
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
# 注意:skip-name-resolve一定要加,不然连接mysql会超级慢
# 添加master主从复制部分配置
server_id=1
log-bin=mysql-bin
read-only=0
binlog-do-db=gmall_ums
binlog-do-db=gmall_pms
binlog-do-db=gmall_oms
binlog-do-db=gmall_sms
binlog-do-db=gmall_cms

# 忽略以下数据库
replicate-ignore-db=mysql
replicate-ignore-db=sys
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema

# 进入docker 容器
# 1、进入master容器
docker exec -it mysql /bin/bash
# 2、进入mysql内部 (mysql –uroot -p)
#    1)、授权root可以远程访问( 主从无关,为了方便我们远程连接mysql)
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
#    2)、添加用来同步的用户
       GRANT REPLICATION SLAVE ON *.* to 'backup'@'%' identified by '123456';
# 3、查看master状态
   show master status\G;



# Slave从节点
docker run -p 3316:3306 --name mysql-slaver-01 \
-v /mydata/mysql/slaver/log:/var/log/mysql \
-v /mydata/mysql/slaver/data:/var/lib/mysql \
-v /mydata/mysql/slaver/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7 
# 修改slave基本配置
vim /mydata/mysql/slaver/conf/my.cnf

[client]
default-character-set=utf8
 
[mysql]
default-character-set=utf8
 
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve 
# 添加master主从复制部分配置
server_id=2
log-bin=mysql-bin
read-only=1
# 配置同步数据库
binlog-do-db=gmall_ums
binlog-do-db=gmall_pms
binlog-do-db=gmall_oms
binlog-do-db=gmall_sms
binlog-do-db=gmall_cms

replicate-ignore-db=mysql
replicate-ignore-db=sys
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema

# 进入从节点容器

# 1、进入slaver容器
docker exec -it mysql-slaver-01 /bin/bash
# 2、进入mysql内部(mysql –uroot -p)
#    1)、授权root可以远程访问( 主从无关,为了方便我们远程连接mysql)
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;
#    2)、设置主库连接
change master to master_host='192.168.159.128',master_user='backup',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=0,master_port=3307;
#   3)、启动从库同步
start slave;
#   4)、查看从库状态
     show slave status\G;



安装MySQL8.0

# 安装mysql8.0
docker pull mysql
# 镜像更名
docker tag mysql:lastt mysql:8.0.21

docker run -p 3308:3306 --name mysql8 \
-v /mydata/mysql-8/conf:/etc/mysql/conf.d \
-v /mydata/mysql-8/log:/logs \
-v /mydata/mysql-8/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=root -d mysql:8.0.21 --lower-case-table-names=1


#进入容器
docker exec -it mysql8 bash
#登录mysql
mysql -u root -p 
# 密码 (回车) / root
# 查看用户信息
select host, user from user;
# 解决 root 不能远程登录的问题
mysql> update user set host = '%' where user = 'root';
mysql> flush privileges;
mysql> quit

# 修改密码
mysql> SET PASSWORD=root123	
8.0 导入函数
# 导入(函数/存储过程)
set global log_bin_trust_function_creators = 1;
字符集错误(1)
#【查询报错】
Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
# 修改表编码格式
alter table kks_encrypt_main convert to character set utf8 collate utf8_unicode_ci;
属性过多(2)

)ENGINE=MyISAM DEFAULT CHARSET=utf8;

#mysql 错误 Row size too large (> 8126)解决办法

set global innodb_file_per_table =ON;
SET GLOBAL innodb_file_format=barracuda;

CREATE TABLE `run_swop` (
  `run_swopuid` varchar(40)  NOT NULL,
  `inspection_person` varchar(200)  DEFAULT NULL,
  PRIMARY KEY (`run_swopuid`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
my.cnf mysql 8.0 配置信息
[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000
lower_case_table_names=1
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
skip-name-resolve
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

实用配置

[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000
lower_case_table_names=1
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
skip-name-resolve


[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

show variables 查看mysql 参数
show variables like '%table_names'是否启动大小写检验 0 true 1 false

URL:加速

URL:加速、避免不必要的校验
jdbc.url=jdbc:mysql://192.168.56.100:3306/test?useSSL=false&amp;allowPublicKeyRetrieval=true&amp;useUnicode=true&amp;characterEncoding=UTF-8

调整连接参数
# 最大连接数
set GLOBAL max_connections=2000;

show variables like "max_connections";
# 最大
show global status like 'Max_used_connections';
# 刷新配置文件
FLUSH PRIVILEGES;

1129-Host ‘192.168.1.xx’ is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’

# 最大连接数
 show variables like "max_connect_errors";
 set global max_connect_errors = 1000;
 show variables like "max_connect_errors";
 set GLOBAL max_connections=2000;
 FLUSH PRIVILEGES;

msyql8快速导出

# 宿主机运行
 docker exec -it 4c8dbcb057ab mysqldump   -uroot -p123456 kimzpp > /zpp/test_db.sql
执行导出(备份)数据库命令:
由第一步的结果可知,我们的 mysql 运行在一个叫 mysql_server 的 docker 容器中。而我们要备份的数据库就在里面,叫做 test_db。mysql 的用户名密码均为root,我们将文件备份到宿主机/opt/sql_bak文件夹下。

docker exec -it  mysql_server mysqldump -uroot -proot test_db > /opt/sql_bak/test_db.sql
导入数据
将宿主机上的数据sql复制到容器的文件下----因为是-v  启动  文件结构目录保持一致
docker cp /opt/gysql.sql  gysql (容器名称):/opt/gysql.sql  
进入容器---》docker exec -it gysql (容器名称) bash
登录容器内的mysql数据库------》mysql -uroot -p123456
创建对象的数据库  create database somp;
使用use somp   --->执行 source  /opt/gysql.sql
exit;

配置mysql8

pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
max_connections=800
find / -name my.cnf
 alter user root@'%' identified by 'temp' WITH MAX_QUERIES_PER_HOUR 0  MAX_UPDATES_PER_HOUR 0  MAX_CONNECTIONS_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
 


mysql 1126报错 User 'root' has exceeded the 'max_questions' resource (current value: 10000)

最近在项目中,从dev环境中导出的数据库脚本在本地执行拷贝数据时报这个错,找了很久才发现是数据库连接查询,更新的限制没有设置最大值。
解决步骤如下:
(1) use mysql;
(2) update user set max_questions=0;
(3) flush privileges;
同时对max_updates和max_connections进行设置,只要更改第2步中=0前面的量就行。
(1) use mysql;
(2) update user set max_updates=0;
(3) flush privileges;
(1) use mysql;
(2) update user set max_connections=0;
(3) flush privileges;



msyql8 主从搭建

原贴地址
https://blog.csdn.net/zyhlwzy/article/details/80569422

docker run -p 3304:3306 --name mysql8-m \
 -v /mydata/mysql8/master/conf:/etc/my.cnf \
 -v /mydata/mysql8/master/log:/logs \
 -v /mydata/mysql8/master/data:/var/lib/mysql \
 -e MYSQL_ROOT_PASSWORD=root -d mysql:8
docker inspect mysql8-m 
# get ip
"172.17.0.3"
CREATE USER 'repl'@'172.17.0.4' IDENTIFIED WITH mysql_native_password BY 'chenduxiu';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'172.17.0.4';
flush privileges;
docker run -p 3305:3306 --name mysql8-s \
-v /mydata/mysql8/slave/conf:/etc/my.cnf \
-v /mydata/mysql8/slave/log:/logs \
-v /mydata/mysql8/slave/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=root --link=mysql8-m -d mysql:8
docker inspect mysql8-s 
# get ip
"172.17.0.4"
mysql> CHANGE MASTER TO
MASTER_HOST='172.17.0.3',
MASTER_USER='repl',
MASTER_PASSWORD='chenduxiu',
MASTER_LOG_FILE='binlog.000002',
MASTER_LOG_POS=859;

安装MSSQL

安装mssql 需要2g 以上的内存,刚好2g 就不要试了。

docker search mssql
docker pull microsoft/mssql-server-linux

# 安装
docker run --name mssql -m 512m -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=root123' --net=host -d microsoft/mssql-server-linux

安装Redis

#redis-cli -a 密码 -p 端口 -h ip地址



mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
# 安装
docker run -p 6379:6379 --name redis \ 
	-v /mydata/redis/data:/data \ 
	-d redis:3.2 redis-server --appendonly yes
	
docker run -p 6379:6379 --name redis \
-v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf


# 配置文件
vi /mydata/redis/conf/redis.conf
# 配置文件
# 配置持久化
appendonly yes

安装ElasticSerch

mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
echo "http.host: 0.0.0.0" >> /mydata/elasticsearch/config/elasticsearch.yml
# 开始安装
docker run --name es -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data -d elasticsearch

##############以下非必要操作 安装中文 it 分词器##################
# 安装完毕后 安装it分词器
https://github.com/medcl/elasticsearch-analysis-ik/releases
# 查找es 相对应的版本
http://192.168.56.100:9200
"number": "5.6.12",
# 选择相对应的分词器 进行下载


# 进入docker 容器内
docker exec -it es bash
ls
cd plugins/
wget https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v6.4.2
# 下载相对应的分词器
# 解压
unzip elasticsearch-analysis-ik-5.6.12.zip
# 删除原来的文件
rm elasticsearch-analysis-ik-5.6.12.zip
# 改文件夹名称
mv elasticsearch/ it

# 启用分词器
cd /usr/share/elasticsearch/bin
# 执行
elasticsearch-plugin list
# root@7114cac90bc8:/usr/share/elasticsearch/bin# elasticsearch-plugin  list
# it

安装Kibana

官方构建参数文档

# 拉取容器
docker pull kibana
# 创建容器
docker run --name kibana -e ELASTICSEARCH_URL=http://192.168.56.10:9200 \
-p 5601:5601 -d kibana:latest
# ELASTICSEARCH_URL 配置elasticsearch 访问路径


# docker run --name ki  \
# --log-driver json-file  \
# --log-opt max-size=100m  \
# --log-opt max-file=2  \
# -e ELASTICSEARCH_URL=http://192.168.56.10:9200  \
# -p 5601:5601 -d kibana:latest

安装it 分词器

# 下载对应的版本 否则会出错
https://github.com/medcl/elasticsearch-analysis-ik/releases
docker exec -it es bash 
cd /usr/share/elasticsearch/plugins
mkdir it
exit
# 上传进入 宿主机 然后使用命令拷贝进入 容器 容器内下载缓慢
docker cp /mydata/elasticsearch-analysis-ik-7.10.1.zip es:/usr/share/elasticsearch/plugins/it/elasticsearch-analysis-ik-7.10.1.zip
# 拷贝进入容器
docker cp /mydata/elasticsearch/plugins/* es:/usr/share/elasticsearch/plugins
elasticsearch-plugin list
# 启用分词器
[root@A ~]# docker exec -it es bash
[root@2e503e30a231 elasticsearch]# cd /usr/share/elasticsearch/bin
[root@2e503e30a231 bin]# elasticsearch-plugin list
it
# 启动成功

安装elasticssearch kibana 7.10.1

# 拉取镜像
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
vi /mydata/elasticsearch/config/elasticsearch.yml
# 设置文件夹权限 ,不设置可能容器发写入 引发错误	
# 【解决】ElasticsearchException[failed to bind service]; nested: AccessDeniedException[/usr/share/elasticsearch/data/nodes]
# chmod 777 /mydata/elasticsearch/config
# chmod 777 /mydata/elasticsearch/data

docker pull elasticsearch:7.10.1
docker pull kibana:7.10.1

# 务必等待es 安装完毕后再安装 kibana
docker run --name es2 -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /mydata/elasticsearch/config/plugins:/usr/share/elasticsearch/plugins  -d   elasticsearch:7.10.1

# /mydata/elasticsearch/config/plugins 挂载分词器 避免进入反复进入容器
# 1.进入容器 修改配置文件
docker exec -it es bash
cd config
vi elasticsearch.yml

# es 配置文件start
cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
# es 配置文件end


# 安装kibana
docker run --name kibana --link=es -p 5601:5601 -v /mydata/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml -d kibana:7.10.1 

mkdir /mydata/kibana/config
vi /mydata/kibana/config/kibana.yml

--配置文件开始
# ** THIS IS AN AUTO-GENERATED FILE **
#

# Default Kibana configuration for docker target
# 7.10.1 Amewin
server.name: kibana
server.host: "0.0.0.0"
elasticsearch.hosts: [ "http://{ES ip}:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"
--配置文件结束

参考
https://www.cnblogs.com/lwc1st/p/14060309.html

安装es ik 分词器

# 拷贝进入容器
docker cp /mydata/elasticsearch/plugins/* es:/usr/share/elasticsearch/plugins
# 查看安装是否成功
elasticsearch-plugin list

# 自定义ik 分词器 分词
/mydata/elasticsearch/plugins/it/config/IKAnalyzer.cfg.xml
<entry key="remote_ext_dict">http://192.168.56.10/es/fenci.txt</entry>
# 前提是要安装好nginx 配置好  fenci.txt
# 启动容器
docker run -p 80:80 --name nginx -d nginx 
# 将容器内的配置文件取出容器外
docker container cp nginx:/etc/nginx .

mv nginx conf
mkdir nginx
mv conf/ nginx/

docker run -d -p 80:80 -p 443:443 --name nginx \
 -v /mydata/nginx/html:/usr/share/nginx/html  \
 -v /mydata/nginx/conf:/etc/nginx \
 -v /mydata/nginx/logs:/var/log/nginx nginx
 # 创建相应目录下文件
 /mydata/nginx/html/es/fenci.txt

安装Nginx

docker run -p 80:80 --name nginx \
-v /mydata/nginx/html:/usr/share/nginx/html \
-v /mydata/nginx/logs:/var/log/nginx \
-d nginx

Nginx配置 https 配置

docker run -d -p 80:80 -p 443:443 --name nginx 
 -v /mydata/nginx/html:/usr/share/nginx/html 
 -v /mydata/nginx/conf/nginx.conf:/etc/nginx/nginx.conf 
 -v /mydata/nginx/logs:/var/log/nginx nginx

配置文件(HTTP)

使用反向代理 不上HTTPS 配置

mkdir /mydata/nginx/html
mkdir /mydata/nginx/conf
touch /mydata/nginx/conf/nginx.conf
mkdir /mydata/nginx/logs
# 下面是配置文件
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;

	proxy_redirect          off;
	proxy_set_header        Host $host;
	proxy_set_header        X-Real-IP $remote_addr;
	proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
	client_max_body_size    10m;
	client_body_buffer_size   128k;
	proxy_connect_timeout   5s;
	proxy_send_timeout      5s;
	proxy_read_timeout      5s;
	proxy_buffer_size        4k;
	proxy_buffers           4 32k;
	proxy_busy_buffers_size  64k;
	proxy_temp_file_write_size 64k;

	upstream tomcat {
		# 使用的是war 打包方式 及springboot项目
		# 部署 根据线上环境进行配置
		server 10.0.8.9:8080;
		# server 192.168.56.104:6002;
		# server 192.168.56.104:6003;
	}
	server {
		# 代理端口
        listen       80;
        server_name  localhost;
        location / {
            proxy_pass   http://tomcat;
            index  index.html index.htm;
        }
    }
}

配置文件(HTTPS)

使用反向代理 上HTTPS 配置
将证书上传如docker nginx 容器内

使用命令 docker cp 本地目录 (容器名称/ID):容器路径
示例 docker cp /usr/ssl nginx:/etc/nginx/

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;

        proxy_redirect          off;
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size    10m;
        client_body_buffer_size   128k;
        proxy_connect_timeout   5s;
        proxy_send_timeout      5s;
        proxy_read_timeout      5s;
        proxy_buffer_size        4k;
        proxy_buffers           4 32k;
        proxy_busy_buffers_size  64k;
        proxy_temp_file_write_size 64k;

        upstream tomcat {
                # 使用的是war 打包方式 及springboot项目
                # 部署 根据线上环境进行配置
                server 10.0.8.9:8080;
                # server 192.168.56.104:6002;
                # server 192.168.56.104:6003;
        }
        server {
                # 代理端口
                listen       443;
                server_name  localhost;
                #填写绑定证书的域名
                #ssl on;
                server_name <域名>;
                #证书文件名称
                ssl_certificate <容器内ssl证书路径>.crt;
                #私钥文件名称
                ssl_certificate_key <容器内ssl证书路径>.key;
                ssl_session_timeout 5m;
                #请按照以下协议配置
                ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
                #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
                ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
                ssl_prefer_server_ciphers on;

                location / {
                		# 配置反向代理
                        proxy_pass   http://tomcat;
                        index  index.html index.htm;
        }
    }
}


安装zookeeper

docker run -d --name zk --restart always -p 2181:2181  \
 -v /mydata/zookeeper/data/:/data  \
 -v /mydata/zookeeper/conf/:/conf \
 -v /mydata/zookeeper/log/:/datalog --privileged  zookeeper

Docker安装zookeeper

# 使用docker 进行安装进行安装zookeeper
docker run -d --name zk --restart always -p 2181:2181 -v /mydata/zookeeper/data/:/data  -v /mydata/zookeeper/conf/:/conf -v /mydata/zookeeper/log/:/datalog --privileged  zookeeper
# 开机自启
docker update zk --restart=always


# 使用docker 进行安装
docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper


#启动kafka容器
docker run -d --name kafka- -publish 9092:9092 --linkzookeeper --env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 --env KAFKA_ADVERTISED_HOST_NAME=172.16.0.117  --env KAFKA_ADVERTISED_PORT=9092 --volume /etc/localtime:/etc/localtimewurstmeister/kafka:latest



调试zookeeper

  • 【1】 使用2010jar Zooinspector.jar
  • 【2】 使用dubbo 工具 dubbo-admin-2.6.0.war

【1】

java -jar zookeeper-dev-ZooInspector.jar

【2】

dubbo-admin-2.6.0.war
# 使用tomcat 8.5 bin/start.bat 启动
# 在web apache-tomcat-8.5.24\webapps\dubbo-admin-2.6.0
# 修改配置 文件的配置信息
"F:\02JavaYuanMa\apache-tomcat-8.5.24\webapps\dubbo-admin-2.6.0\WEB-INF\dubbo.properties"

# 访问地址
http://localhost:8080/dubbo-admin-2.6.0/governance/applications

Linux安装Zookeeper

  • 使用linux服务器配置Zookeeper作为集群
  • 上传至根目录
# 解压命令
tar -zxvf zookeeper-3.4.6.tar.gz -C /usr/local/
cd /usr/local/
# 查看路径
pwd
# 创建data
mkdir data
# 进入 conf
cd conf 
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
# 修改zookeeper配置文件 默认数据存放路径
dataDir=/usr/local/zookeeper-3.4.6/data/
# 路径可以使用
##: cd /usr/local/ <tab键>

配置zookeeper 环境变量

vi /etc/profile
# 配置
export ZOOKEEPER_HOME=<zookeeper安装目录>
export PATH=$PATH:$ZOOKEEPER_HOME/bin

# 刷新
source /etc/profile

启动停止Zookeeper

# 进入Zookeeper的bin目录,启动服务命令
 ./zkServer.sh start

# 停止服务命令
./zkServer.sh stop

# 查看服务状态:
./zkServer.sh status

安装rabbitmq

docker pull rabbitmq:management

docker run -d --name rabbitmq --publish 5671:5671  --publish 5672:5672 --publish 4369:4369  --publish 25672:25672 --publish 15671:15671  --publish 15672:15672  rabbitmq:management

docker run -d --name rabbitmq \ 
--publish 5671:5671 \
--publish 5672:5672 --publish 4369:4369 \ 
--publish 25672:25672 --publish 15671:15671 \ 
--publish 15672:15672 \
rabbitmq:management




https://developer.aliyun.com/article/769883

远程访问
http://localhost:15672/#/
http://192.168.56.10:15672/#/
username: guest
password : guest

安装RocketMQ

https://www.codenong.com/cs106665823/

# 拉取镜像
ocker pull rocketmqinc/rocketmq:4.4.0
docker pull pangliang/rocketmq-console-ng
# 设置配置文件 
mkdir -p /mydata/rocketmq
echo "brokerIP1=192.168.56.10" > /mydata/rocketmq/broker.properties

#NameServer
docker run --name rmqnamesrv -d -p 9876:9876 -e "MAX_POSSIBLE_HEAP=100000000"  rocketmqinc/rocketmq:4.4.0 sh mqnamesrv
#部署Broker
docker run --name rmqbroker -d -p 10911:10911 -p 10909:10909  --link rmqnamesrv:namesrv  -v /mydata/rocketmq/broker.properties:/opt/rocketmq-4.4.0/bin/broker.properties -e "MAX_POSSIBLE_HEAP=200000000" -e "NAMESRV_ADDR=namesrv:9876" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c broker.properties
#启动console
docker run --name rmqconsole -d -p 8080:8080 --link rmqnamesrv:namesrv -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876"  pangliang/rocketmq-console-ng

以上ip 根据实际情况修改

常考地址,与上述不同
https://zebinh.github.io/2020/07/RocketMQDeploymentWithSpringBootDemo/

安装nacos

docker run --restart=always --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server

安装Mongodb

docker pull mongo

$ docker run -p 27017:27017 --name mongo -v /mydata/mongo/db:/data/db -d mongo
# 创建容器 --auth 开启密码登录<不配置则需要密码登录> 
# --restart=on-failure:10:为mongo添加重启策略,在非零状态下退出,重试次数设置为10次
# docker run -itd --name mongo --restart=on-failure:10 -p 27017:27017 -v    /mydata/mongo/db:/data/db -e MONGO_INITDB_ROOT_USERNAME={admin} -e MONGO_INITDB_ROOT_PASSWORD={123456}   mongo --auth

# 设置用户登录密码
# 创建一个名为 admin,密码为 123456 的用户。
$ docker exec -it mongo mongo admin
# 创建一个名为 admin,密码为 123456 的用户。
# db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'}]});

# 尝试使用上面创建的用户信息进行连接。
db.auth('admin', '123456')
# 创建超级用户
db.createUser({ user: "root" , pwd: "root", roles: ["root"]})

参考地址
https://www.cnblogs.com/hewm/articles/12017441.html

安装FastDFS

# 拉取镜像
docker pull morunchang/fastdfs
# 运行tracker
docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh
# 运行storage
docker run ‐d ‐‐name storage ‐‐net=host ‐e TRACKER_IP=<your tracker
server address>:22122 ‐e GROUP_NAME=<group name> morunchang/fastdfs sh
storage.sh
# 示例 TRACKER_IP=实际虚拟机/服务器 IP
docker run -d --name storage --net=host -e TRACKER_IP=192.168.56.10.111:22122 -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh


/*
  1.使用的网络模式是–net=host, <your tracker server address> 替换为你机器的Ip即可
  2.<group name> 是组名,即storage的组
  3.如果想要增加新的storage服务器,再次运行该命令,注意更换 新组名

  4. docker ps 查看容器信息 
[root@iZh3cshm0xz7wjZ ~]# docker ps 
CONTAINER ID        IMAGE                COMMAND             CREATED              STATUS              PORTS               NAMES
ccdf6bbeab48        morunchang/fastdfs   "sh storage.sh"     5 seconds ago        Up 4 seconds                            storage
a7253c93bce1        morunchang/fastdfs   "sh tracker.sh"     About a minute ago   Up About a minute                       tracker
*/

安装docker-registry

docker pull registry
# 构建容器
docker run -d --name docker_registry -p 5000:5000 registry

查看部署是否成功

http://192.168.56.10:5000/v2/_catalog

安装informix

docker pull ibmcom/informix-developer-database

#启动 informix 
docker run -it --name informix --privileged -p 19088:9088 -p 19089:9089 
-p 27017:27017 -p 27018:27018 -p 27883:27883 -e LICENSE=accept ibmcom/informix-developer-database:latest -d

docker run -d --name informix --privileged -p 9088:9088 -p 9089:9089 -p 27017:27017 -p 27018:27018 \
-p 27883:27883 -e LICENSE=accept ibmcom/informix-developer-database:latest


密码

username: Informix
password:in4mix

##informix
informix.url=jdbc:informix-sqli://localhost:9088/sysadmin:INFORMIXSERVER=informix
informix.driverClassName=com.informix.jdbc.IfxDriver
informix.user=informix
informix.password=in4mix


在这里插入图片描述
在这里插入图片描述
默认用户名为informix,密码为in4mix

jdbc连接信息:

##informix
informix.url=jdbc:informix-sqli://localhost:9088/sysadmin:INFORMIXSERVER=informix
informix.driverClassName=com.informix.jdbc.IfxDriver
informix.user=informix
informix.password=in4mix

https://ixppq.gitee.io/2020/08/05/docker_install_informix/

安装flowable-ui

docker run --name flowable-ui -d -p 5050:8080 flowable/flowable-ui

访问地址
http://192.168.56.100:5050/flowable-ui/idm/#/login
username: admin
password: test

开机自启

docker update *--restart=always

docker update msyql--restart=always
docker update msyql8 --restart=always
docker update redis --restart=always
docker update zk --restart=always
docker update rabbitmq--restart=always

查看镜像版本

docker image inspect (docker image名称):latest|grep -i version
# 示例
docker image inspect mysql:latest|grep -i version
[root@localhost ~]# docker image inspect mysql:latest|grep -i version
                "GOSU_VERSION=1.12",
                "MYSQL_VERSION=8.0.21-1debian10"
        "DockerVersion": "18.09.7",
                "GOSU_VERSION=1.12",
                "MYSQL_VERSION=8.0.21-1debian10"

配置文件大全

学习ing
后续更新…

mydate
--mysql
	--conf
		--my.conf
	--log
	--data
--redis
	--conf
		--redis.conf
	--data	

CICD 持续部署 持续部署 持续集成

Gitlab

/home/gitlab目录来存放相应的数据,具体对应关系如下表。

宿主机位置容器位置作用
/home/gitlab/config/etc/gitlab用于存储 GitLab 配置文件
/home/gitlab/logs/var/log/gitlab用于存储日志
/home/gitlab/data/var/opt/gitlab用于存储应用数据
docker pull gitlab/gitlab-ce:latest

启动容器

docker run \
    --publish 4433:443 --publish 50080:80 --publish 50022:22 \
    --name gitlab \
    --volume /mydata/gitlab/config:/etc/gitlab \
    --volume /mydata/gitlab/logs:/var/log/gitlab \
    --volume /mydata/gitlab/data:/var/opt/gitlab \
    gitlab/gitlab-ce

关于gitlab 忘记密码解决方案

root@04837568b86c:/# gitlab-rails console production
Traceback (most recent call last):
        8: from bin/rails:4:in `<main>'
        7: from bin/rails:4:in `require'
        6: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/commands.rb:18:in `<top (required)>'
        5: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/command.rb:46:in `invoke'
        4: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/command/base.rb:69:in `perform'
        3: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        2: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        1: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/commands/console/console_command.rb:95:in `perform': wrong number of arguments (given 1, expected 0) (ArgumentError)
        9: from bin/rails:4:in `<main>'
        8: from bin/rails:4:in `require'
        7: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/commands.rb:18:in `<top (required)>'
        6: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/command.rb:46:in `invoke'
        5: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/railties-6.0.3.6/lib/rails/command/base.rb:69:in `perform'
        4: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        3: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
        2: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:20:in `run'
        1: from /opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:34:in `rescue in run'
/opt/gitlab/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:525:in `handle_argument_error': ERROR: "rails console" was called with arguments ["production"] (Thor::InvocationError)
Usage: "rails console [options]"
root@04837568b86c:/# gitlab-rails console -e production
--------------------------------------------------------------------------------
 Ruby:         ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
 GitLab:       13.12.4 (02b97bd2a77) FOSS
 GitLab Shell: 13.18.0
 PostgreSQL:   12.6
--------------------------------------------------------------------------------
Loading production environment (Rails 6.0.3.6)
irb(main):001:0> user = User.where(username:"root").first
=> #<User id:1 @root>
irb(main):002:0> user.password = "chenduxiu"
=> "chenduxiu"
irb(main):003:0> user.save!
Enqueued ActionMailer::MailDeliveryJob (Job ID: b4e8b074-4a07-47c6-a672-51de1460e804) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007fcce1f9a078 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true

接着查询一下用户:

irb(main):001:0> user = User.where(username:"root").first
=> #<User id:1 @root>

然后修改密码:

irb(main):002:0> user.password = "xuhuan911226"
=> "xuhuan911226"

然后保存:

irb(main):003:0> user.save!
=> true

原贴

https://blog.csdn.net/juanxiaseng0838/article/details/122684542

Jenkins

创建一个Jenkins目录

mkdir /data/jenkins_home;

启动容器

docker run -d --name jenkins -p 58080:8080 -v /mydata/jenkins/data/jenkins_home:/var/jenkins_home jenkins/jenkins;
# 容器
docker run --name jenkins-blueocean -d -p 58080:8080 -p 50000:50000   jenkinsci/blueocean
# 访问地址
http://192.168.56.10:8066/login?from=%2F
# 安装推荐插件
# web页面 能打开后
# 进入容器
docker exec -it jenkins-blueocean bash
# 查看密码
cat /var/jenkins_home/secrets/initialAdminPassword
# 将容器器的文件拷贝出来
docker container cp jenkins-blueocean:/var/jenkins_home /mydata/jenkins/data/
# 删除容器
docker rm -f jenkins-blueocean
# 添加目录权限
sudo chown -R 1000:1000 /mydata/jenkins/data
# 将容器
docker run --name jenkins -d -p 8066:8080 -p 50000:50000  -v /mydata/jenkins/data:/var/jenkins_home jenkinsci/blueocean
# 进入容器
docker exec -it jenkins bash


# 本地目录
cat /mydata/jenkins/data/secrets/initialAdminPassword

linux 软件安装

安装jdk

官网

# 上传文件 jdk-8u261-linux-x64.tar.gz 至/home
# 使用命令
tar -zxvf jdk-8u261-linux-x64.tar.gz
# 重命名
mv jdk1.8.0_261/ jdk8
# 转移
mv jdk8 /usr/
cd /usr/jdk8
pwd
# 复制 路径/usr/jdk8 配置【环境变量】
vi /etc/profile
# 尾部追加
export JAVA_HOME=/var/local/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
# 刷新 proffile
source /etc/profile
java -version
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)
cat /etc/profile
安装完成

安装maven

官网

# 上传文件 apache-maven-3.6.3.tar.gz 至/var/local/maven
# 使用命令
tar -zxvf apache-maven-3.6.3.tar.gz
# 重命名
mv apache-maven-3.6.3/ maven363
pwd
# 复制 路径 配置【环境变量】
vi /etc/profile
# 尾部追加
# MAVEN_HOME
MAVEN_HOME=/var/local/maven/apache-maven-3.6.3
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin

# 刷新 proffile
source /etc/profile

[root]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /var/local/maven/apache-maven-3.6.3
Java version: 1.8.0_41, vendor: Oracle Corporation, runtime: /var/local/java/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1127.19.1.el7.x86_64", arch: "amd64", family: "unix"
#安装完成

快速创建虚拟机

vagrant up

vagrant ssh

whoami

su root
vagrant


vi /etc/ssh/sshd_config
#PubkeyAuthentication yes
# 开启ssh 远程登录
PasswordAuthentication yes
# 重启sshd
service sshd restart

创建vagrant linux

Vagrant.configure("2") do |config|
  config.vm.box = "elrey741/kali-linux_amd64"
end

# 中文 root 配置教程
https://www.cxyzjd.com/article/mz_418/117968569

安装 nexus3

https://blog.csdn.net/linpxing1/article/details/108378323参考地址

docker run -d --name nexus3 -v /mydata/nexus3/data:/nexus-data -p 8081:8081 sonatype/nexus3

docker run -d -p 8088:8081 --name nexus -v /mydata/nexus3/data:/nexus-data -e INSTALL4J_ADD_VM_PARAMS="-Xms2048m -Xmx2048m -XX:MaxDirectMemorySize=2048m -Djava.util.prefs.userRoot=/some-other-dir" sonatype/nexus3

解决nexus 安装硬盘不足 启动失败

Error occurred while executing a write operation to database ‘component’ due to limited free space on the disk (3610 MB). The database is now working in read-only mode. Please close the database (or stop OrientDB), make room on your hard drive and then reopen the database. The minimal required space is 4096 MB. Required space is now set to 4096MB (you can change it by setting parameter storage.diskCache.diskFreeSpaceLimit) . DB name=”component”. -> [Help 1]

这一问题是由于默认要求在写入时要有4GB 的空闲空间,只需修改配置文件即可,位于安装目录下的bin/nexus.vmoptions文件中,由于上面使用的是 Docker安装,Alan 暂未深入研究如何将配置文件挂载到本机中,临时解决的方案是
https://alanhou.org/nexus-maven/ 原文

docker cp nexus:/opt/sonatype/nexus/bin/nexus.vmoptions /mydata
# 修改完成后再拷贝回去进行覆盖
# 如添加或修改参数-Dstorage.diskCache.diskFreeSpaceLimit=2048 【重点】
docker cp /mydata/nexus.vmoptions nexus:/opt/sonatype/nexus/bin/nexus.vmoptions

docker restart nexus

http://192.168.56.100:8081

首次启动 密码在/nexus-data/admin.password

cat /nexus-data/admin.password
admin
f47f1165-625d-45d9-ab51-81eaedf376d8 bash-4.4$

在这里插入图片描述

jar 上传私服

https://blog.csdn.net/lucky_ly/article/details/79951116
在这里插入图片描述

# nexus3 安装
docker run -p 8081:8081 -d -m 2048m --privileged=true --name nexus -v /mydata/nexus:/nexus-data -e INSTALL4J_ADD_VM_PARAMS="-Xms500m -Xmx2048m -XX:MaxDirectMemorySize=2048m -Djava.util.prefs.userRoot=/some-other-dir" sonatype/nexus3

# 修改文件夹 权限
chown -R 200 /mydata/nexus

# copy 配置文件
docker cp nexus:/opt/sonatype/nexus/bin/nexus.vmoptions /mydata/nexus

# 配置文件copy进容器
docker cp /mydata/nexus/nexus.vmoptions  nexus:/opt/sonatype/nexus/bin/nexus.vmoptions

vi  /mydata/nexus/nexus.vmoptions
# 修改完成后再拷贝回去进行覆盖
# 添加进配置文件 #
# 如添加或修改参数
-Dstorage.diskCache.diskFreeSpaceLimit=2048

/mydata/nexus/nexus.vmoptions

/opt/sonatype/nexus/bin/nexus.vmoptions
# nexus3 安装
docker run -p 8082:8081 -d -m 3048m --privileged=true --name nexus3 \
-v /mydata/nexus3:/nexus-data \
-e INSTALL4J_ADD_VM_PARAMS="-Xms500m -Xmx2048m -XX:MaxDirectMemorySize=2048m -Djava.util.prefs.userRoot=/some-other-dir"   \
-v /etc/localtime:/etc/localtime  \
sonatype/nexus3

# 修改文件夹 权限
chown -R 200 /mydata/nexus3

# copy 配置文件
docker cp nexus3:/opt/sonatype/nexus/bin/nexus.vmoptions /mydata/nexus3

# 配置文件copy进容器
docker cp /mydata/nexus3/nexus.vmoptions  nexus3:/opt/sonatype/nexus/bin/nexus.vmoptions

vi  /mydata/nexus3/nexus.vmoptions
# 修改完成后再拷贝回去进行覆盖
# 添加进配置文件 #
# 如添加或修改参数
-Dstorage.diskCache.diskFreeSpaceLimit=2048

/mydata/nexus/nexus.vmoptions

/opt/sonatype/nexus/bin/nexus.vmoptions

搭建 SpringCloud Alibaba 开发环境

安装Nacos(注册中心)

http://192.168.56.100:8848/nacos/#/login

username:nacos

password: nacos

docker run -d -p 8848:8848 --env MODE=standalone  --name nacos  nacos/nacos-server

安装zipkin(链路追踪)

docker run -d -p 9411:9411 openzipkin/zipkin 
或者
docker run -d -p 9411:9411 -p 9410:9410  \
--env STORAGE_TYPE=elasticsearch \
--env ES_HOSTS=192.168.56.100.9200 openzipkin/zipkin 

安装Sentinel(熔断限流)

http://192.168.56.100:8858/#/dashboard

usernaem : sentinel

password : sentinel

docker run --name sentinel -d -p 8858:8858 -d bladex/sentinel-dashboard

安装 Kibana Elasticsearch

http://192.168.56.100:9200/
http://192.168.56.100:5601/app/kibana

docker pull elasticsearch:7.4.2

mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data

echo "http.host:0.0.0.0">>/mydata/elasticsearch/config/elasticsearch.yml

###################

chmod -R 777/mydata/elasticsearch/ 保证权限
docker run --name elasticsearch -p 9200:9200 \
-p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms256m -Xmx256m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/ust/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.4.2

安装 kibana

sudo docker pull kibana:7.4.2

docker run --name kibana \
-v /mydata/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml \
--link=elasticsearch  \
-e ELASTICSEARCH_HOSTS=http://192.168.56.100:9200 -p 5601:5601 \
-d kibana:7.4.2

Kibana 配置文件

chmod -R 777 /mydata/kibana
#### kibana.yml config
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://192.168.56.100:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"

安装 Portainer (docker 可视化工具)

http://192.168.56.100:9000

docker run -d -p 9000:9000 --name portainer --restart always -v \
/var/run/docker.sock:/var/run/docker.sock -v \
/mydata/portainer/data:/data  \
-v /mydata/portainer/public:/public portainer/portainer

汉化
https://www.quchao.net/Portainer-CN.html

关于virtualBox 虚拟机复制无无网解决方案
ifconfig 命令无效
# 安装 ifconfig
sudo yum install net-tools

在这里插入图片描述
虚拟机使用桥接网
在这里插入图片描述

virtualBox 导入虚拟机 网络异常问题


#进入network-scripts
cd /etc/sysconfig/network-scripts/

#固定Linux ip地址
# ifcfg-eth1
# 调整网卡配置
vi ifcfg-eth1

NM_CONTROLLED=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.56.100
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no

#重启网络服务
service network restart
# 查看IP地址
ifconfig

导入后调整网络
在这里插入图片描述

npm install 淘宝源

npm config set registry http://registry.npm.taobao.org/
npm config get registry
# 官方源
npm config set registry https://registry.npmjs.org/

指定npm 安装源

npm install --registry=https://registry.npmmirror.com

关于node-sass 版本不对应node -v版本 启动失败!

版本查看
https://github.com/sass/node-sass/releases

安装失败

#卸载 node-sass
npm uninstall node-sass
# 安装新的sass
npm install node-sass@6.0.6 --registry=https://registry.npm.taobao.org

还源大全
https://www.cnblogs.com/steven-yang/p/12317646.html

1、查看npm镜像源的地址

npm config get registry

2、设置npm镜像源为淘宝镜像源

npm config set registry https://registry.npm.taobao.org 

3、还原官方默认源

npx nrm use npm

注意:还原官方默认源使用的是npx命令。需要全局安装npm install npm -g

4、同时也可以用npx快速设置淘宝源

npx nrm use taobao

Node.js多版本

安装nvm

https://github.com/coreybutler/nvm-windows/releases

下载指定版本 npm

nvm install v12.14.1 --reinstall-packages-from=10.18.1
nvm list
nvm use xxnode-version
nvm 

Node.js多版本

安装nvm

https://github.com/coreybutler/nvm-windows/releases

下载指定版本 npm

nvm install v12.14.1 --reinstall-packages-from=10.18.1
nvm list
nvm use xxnode-version
nvm 

nvm安装node没有npm的问题

https://www.jianshu.com/p/c0f1f4dfb684

nvm root
cd $root

nvm安装node没有npm的问题

https://www.jianshu.com/p/c0f1f4dfb684

nvm root
cd $root

Node.js多版本

安装nvm

https://github.com/coreybutler/nvm-windows/releases

下载指定版本 npm

nvm install v12.14.1 --reinstall-packages-from=10.18.1
nvm list
nvm use xxnode-version
nvm 

Node.js多版本

安装nvm

https://github.com/coreybutler/nvm-windows/releases

下载指定版本 npm

nvm install v12.14.1 --reinstall-packages-from=10.18.1
nvm list
nvm use xxnode-version
nvm 

nvm安装node没有npm的问题

https://www.jianshu.com/p/c0f1f4dfb684

nvm root
cd $root

nvm安装node没有npm的问题

https://www.jianshu.com/p/c0f1f4dfb684

nvm root
cd $root
Logo

华为云1024程序员节送福利,参与活动赢单人4000元礼包,更有热门技术干货免费学习

更多推荐