CentOS 最小镜像:
宝塔命令(全部yes):yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
选择要安装的基础组件
修改面板基本配置
取消宝塔面板安全地址登录限制
关闭安全入口:rm -f /www/server/panel/data/admin_path.pl
磁盘扩容参考:https://www.cnblogs.com/willamwang/p/12082465.html
Docker镜像加速地址
地址1:http://hub-mirror.c.163.com
地址2:https://registry.docker-cn.com
宝塔软件商店:Redis,Memcached,MongoDB,Docker,PM2
Jenkins的Docker版本安装:
// 如果目录没有权限就手动去宿主机给一下
docker run -d -p 18080:8080 --name jenkins -v /home/docker/jenkins_home:/var/jenkins_home -v /home/docker/host_home:/home -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone jenkins/jenkins:lts-centos7-jdk8
Jenkins安装:
下载:http://mirror.xmission.com/jenkins/war-stable/2.235.5/jenkins.war
安装与映射
默认账号密码:admin/admin
MySQL版本:docker run -d --name sonarqube -p 9090:9000 -p 9092:9092 -e "SONARQUBE_JDBC_USERNAME=[数据库用户名]" -e "SONARQUBE_JDBC_PASSWORD=[数据库密码]" -e "SONARQUBE_JDBC_URL=jdbc:mysql://[IP地址]:3306/[数据库名称]?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false" sonarqube:7.1
PostgreSQL版本:docker run -d --name sonarqube8.5.1 -p 9090:9000 -p 9092:9092 -e "SONARQUBE_JDBC_USERNAME=[数据库用户名]" -e "SONARQUBE_JDBC_PASSWORD=[数据库密码]" -e "SONARQUBE_JDBC_URL=jdbc:postgresql://[IP地址]:5432/[数据库名称]" sonarqube:8.5.1-community
安装成功后可以访问
生成Token:Security -> Users -> Token
安装汉化包和Java分析插件:
从宿主机复制插件到容器
docker cp /[路径]/[文件名] [容器名称]:/[容器内路径]
配置Sonar:
sonar.projectKey=${JOB_NAME}
sonar.projectName=${JOB_NAME}
sonar.projectVersion=${BUILD_VERSION}
sonar.language=java
sonar.sourceEncoding=UTF-8
sonar.sources=$WORKSPACE
sonar.java.binaries=$WORKSPACE
配置参考:https://www.jb51.net/article/196239.htm
如果Sonar安装的FindBug插件,使用Scanner会报错,写在FindBug即可
docker run --name elasticsearch -e JAVA_OPTS='-Xms512m -Xmx512m' -e "discovery.type=single-node" -d -p 9200:9200 -p 9300:9300 elasticsearch:7.7.0
# 1.进入容器
docker exec -it 容器名 /bin/bash
# 2.在线下载并安装,注意:版本号要一
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
# 3.进入到 plugins 目录可以看到IK分词器已经安装成功
WebUI工具(Dejavu)
docker run --name dejavu -p 1358:1358 -d appbaseio/dejavu
Kibana版本要和ElasticSearch一致
docker run --name kibana -p 5601:5601 --link elasticsearch:elasticsearch -d kibana:7.7.0
vi /usr/share/kibana/config/kibana.yml
Logstash版本要和ElasticSearch一致
docker run --name logstash -d -p 5044:5044 -p 9600:9600 --link elasticsearch:elasticsearch logstash:7.7.0
插件安装:logstash-output-elasticsearch
./logstash-plugin install logstash-output-elasticsearch
执行配置:center_goods_spu.conf
# 必须写上配置的完整路径,避免配置目录中.conf和.yml文件共存造成异常
./bin/logstash -f /usr/share/logstash/config/center_goods_spu.conf
配置完整实例
input {
# 可以配置多个数据源
jdbc {
# jar包目录必须在目录[ logstash-core/lib/jars ]下
jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/mysql-connector-java-8.0.22.jar"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://[IP地址]:3306/cloud_center?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true"
jdbc_user => "数据库账号"
jdbc_password => "数据库密码"
statement => "SELECT * FROM center_goods_spu WHERE update_time >= :sql_last_value"
jdbc_paging_enabled => "true"
jdbc_page_size => "1000"
schedule => "* * * * *"
# 索引类型
type => "center_goods_spu "
}
jdbc {
# jar包目录必须在目录[ logstash-core/lib/jars ]下
jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/mysql-connector-java-8.0.22.jar"
jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://[IP地址]:3306/cloud_center?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true"
jdbc_user => "数据库账号"
jdbc_password => "数据库密码"
# 执行的sql 文件路径+名称
statement_filepath => "/home/mysqlSQL/center_goods_category.sql"
jdbc_paging_enabled => "true"
jdbc_page_size => "1000"
schedule => "* * * * *"
# 索引类型
type => "center_goods_spu "
}
}
output {
# 可以配置多个数据源
if [type]=="center_goods_spu" {
elasticsearch {
hosts => ["192.168.0.248:9200"]
index => "center_goods_spu"
document_type => "center_goods_spu"
document_id => "%{id}"
}
if [type]=="center_goods_category" {
elasticsearch {
hosts => ["192.168.0.248:9200"]
index => "center_goods_category"
document_type => "center_goods_category"
document_id => "%{id}"
}
}
stdout {
codec => rubydebug
}
}
处理Logstash链接ES问题
问题:LogStash::Outputs::ElasticSearch::HttpClient::Pool::HostUnreachableError
处理方式:
处理Logstash中“path.data”问题
处理方式:删除目录[/usr/share/logstash/data]中的[.lock]文件
# 安装配套zookeeper
docker run --name=zookeeper -d -p 2181:2181 --privileged=true wurstmeister/zookeeper
# 安装配套kafka
docker run --name kafka -d -p 9092:9092 --privileged=true -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.1.248:2181/kafka -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.1.248:9092 -e KAFKA_LISTENERS=PLAINTEXT://:9092 wurstmeister/kafka
# 安装Kafka可视化管理工具
docker run --name kafka-manager -d --link zookeeper:zookeeper --link kafka:kafka -p 9001:9000 --env ZK_HOSTS=zookeeper:2181 sheepkiller/kafka-manager
docker run --name skywalking -d -p 1234:1234 -p 11800:11800 -p 12800:12800 --link elasticsearch:elasticsearch -e SW_STORAGE=elasticsearch -e SW_STORAGE_ES_CLUSTER_NODES=elasticsearch:9200 apache/skywalking-oap-server:6.6.0-es7
docker run --name skywalking-ui -d -p 8899:8080 --link skywalking:skywalking -e SW_OAP_ADDRESS=skywalking:12800 --restart always apache/skywalking-ui:6.6.0
连接:https://archive.apache.org/dist/skywalking/6.6.0/apache-skywalking-apm-6.6.0.tar.gz
解压缩:tar -zxvf 压缩文件名.tar.gz
#删除进程
kill -9 $(jps | grep [服务Jar包].jar | awk '{print $1}')
nohup java -Xms256m -Xmx512m -javaagent:/[skywalking apm路径]/apache-skywalking-apm-bin/agent/skywalking-agent.jar -Dskywalking.agent.service_name=[服务名] -Dskywalking.collector.backend_service=localhost:11800 -jar /[服务路径]/[服务Jar包].jar > /[服务路径]/[服务Jar包].log 2>&1 &
新增一个nginx配置 xxx.conf
server
{
listen 2888;
server_name [服务名];
access_log /[路径]/logs/access.log;
error_log /[路径]/logs/error.log;
location / {
root /[路径]/dist;
index index.html index.htm;
proxy_ssl_session_reuse off;
try_files $uri $uri/ /index.html =404;
}
location /api/ {
proxy_pass http://127.0.0.1:2828/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_ssl_session_reuse off;
}
}
scp -r /[本地目录] [email protected]:/[远程目录]
scp -r [email protected]:/[远程目录] /[本地目录]
压缩:tar zcf /[路径]/[文件名].tar.gz /[路径]
解压:tar -xzvf /[路径]/[文件名].tar.gz /[路径]
ssh [用户名]@[IP地址]
运行:docker run -d -p 8500:8500 -v /home/consul:/consul/data --name=consul consul:latest agent -server -bootstrap -ui -node=1 -client='0.0.0.0'
配置导出:consul kv export --http-addr=http://[ip地址]:8500 >consul_kv.json
配置导入:consul kv import --http-addr=http://[ip地址]:8500 @consul_kv.json
docker run --name nacos -p 8848:8848 \
--privileged=true \
-e JVM_XMS=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-d nacos/nacos-server
Nacos2.x以上版本安装命令如下(改版后增加了新的端口拓展)
docker run --name nacos
-p 7848:7848
-p 8848:8848
-p 9848:9848
-p 9849:9849
--privileged=true
-e JVM_XMX=1024m
-e JVM_XMS=512m
-e MODE=standalone
-e PREFER_HOST_MODE=hostname
-d nacos/nacos-server:v2.1.2
docker run -dit --name rabbitmq -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin -p 15672:15672 -p 5672:5672 rabbitmq:management
docker run -e PARAMS="--spring.datasource.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/xxl_job?Unicode=true&characterEncoding=UTF-8&useSSL=false --spring.datasource.username=root --spring.datasource.password=root --xxl.admin.login=false" -p 9080:8080 --name xxl-job-admin -d xuxueli/xxl-job-admin:2.2.0
docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin
docker run --name sentinel -d -p 8858:8858 -p 8719:8719 bladex/sentinel-dashboard
docker run -p 9000:9000 -p 9001:9001 --name minio -e "MINIO_ACCESS_KEY=admin" -e "MINIO_SECRET_KEY=admin123456" -v /home/docker/minio/data:/data -v /home/docker/minio/config:/root/.minio -v /etc/localtime:/etc/localtime minio/minio server /data --console-address ":9001"
-- 生成服务器秘钥
[root@xxxxx ~]# if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc; echo $SECRET_KEY; else echo $SECRET_KEY; fi
[root@xxxxx ~]# if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`; echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc; echo $BOOTSTRAP_TOKEN; else echo $BOOTSTRAP_TOKEN; fi
-- Docker安装堡垒机
docker run -d --name=jumpserver
-v /home/docker/jump_server_home/data:/opt/jumpserver/data
-v /home/docker/jump_server_home/koko:/opt/koko/data
-v /home/docker/jump_server_home/lion:/opt/lion/data
-p 8000:80
-p 2222:2222
-e SECRET_KEY=$SECRET_KEY
-e BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN
-e DB_HOST=【数据库IP】
-e DB_PORT=3306
-e DB_USER=【数据库用户】
-e DB_PASSWORD="【数据库密码】"
-e DB_NAME=【数据库名称】
-e REDIS_HOST=【Redis IP】
-e REDIS_PORT=6379
-e REDIS_PASSWORD="xckj1234."
jumpserver/jms_all:v2.5.0
# Root账号进入container
docker exec -it --user root [容器名称] /bin/bash
chmod 777 /[需授权目录]