一、docker安装mysql
1、拉取mysql镜像
docker pull mysql
2、创建 mysql文件夹
mkdir -p /data/mysql/conf
3、创建mysql配置文件
touch /data/mysql/conf/my.cnf
4、编辑my.cnf文件
vi /data/mysql/conf/my.cnf
5、输入如下内容:
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# The MySQL Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Custom config should go here
!includedir /etc/mysql/conf.d/
default_authentication_plugin= mysql_native_password
6、运行mysql容器
docker run \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=pass \
-v /data/mysql/data:/var/lib/mysql:rw \
-v /data/mysql/log:/var/log/mysql:rw \
-v /data/mysql/conf/my.cnf:/etc/mysql/my.cnf:rw \
-v /etc/localtime:/etc/localtime:ro \
--name mysql \
--restart=always \
-d mysql
二、docker安装redis
1、拉取redis镜像
docker pull redis
2、创建redis文件夹
mkdir -p /data/redis/conf
3、创建redis配置文件
touch /data/redis/conf/redis.conf
4、编辑redis.conf文件
vi /data/redis/conf/redis.conf
5、输入如下内容:
开启redis 持久化
appendonly yes
6、运行redis容器
docker run \
-p 6379:6379 \
-v /data/redis/data:/data:rw \
-v /data/redis/conf/redis.conf:/etc/redis/redis.conf:rw \
--name redis \
--restart=always \
-d redis redis-server /etc/redis/redis.conf
三、docker安装nacos
1、拉取nacos镜像
docker pull nacos/nacos-server
2、创建nacos文件夹
mkdir -p /data/nacos/logs
mkdir -p /data/nacos/conf
3、创建nacos配置文件
touch /data/nacos/conf/application.properties
4、编辑application.properties文件
vi /data/nacos/conf/application.properties
5、输入如下内容:
注意修改为自己的数据库信息
server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://192.168.56.10:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=pass
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true
6、运行nacos容器
docker run \
-p 8848:8848 --name nacos \
-e PREFER_HOST_MODE=192.168.56.10 \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_MASTER_SERVICE_HOST=192.168.56.10 \
-e MYSQL_MASTER_SERVICE_PORT=3306 \
-e MYSQL_MASTER_SERVICE_USER=root \
-e MYSQL_MASTER_SERVICE_PASSWORD=pass \
-e MYSQL_MASTER_SERVICE_DB_NAME=nacos_config \
-v /data/nacos/logs:/home/nacos/logs \
-v /data/nacos/conf/custom.properties:/home/nacos/conf/application.properties \
--restart=always \
-d nacos/nacos-server
四、docker安装seata
1、拉取seata镜像
docker pull seataio/seata-server
2、创建seata文件夹
mkdir -p /data/seata/conf
3、创建配置文件file.conf和registry.conf
touch /data/seata/conf/file.conf
touch /data/seata/conf/registry.conf
4、编辑file.conf和registry.conf文件
{tabs-pane 编辑file.conf文件}
vi file.conf
## transaction log store, only used in seata-server
store {
## store mode: file、db、redis
mode = "db"
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
datasource = "druid"
dbType = "mysql"
driverClassName = "com.mysql.cj.jdbc.Driver"
url = "jdbc:mysql://192.168.56.10:3306/seata?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"
user = "root"
password = "pass"
minConn = 5
maxConn = 100
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
{/tabs-pane}
{tabs-pane 编辑registry.conf文件}vi registry.conf
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "192.168.56.10:8848"
namespace = "seata"
group = "SEATA_GROUP"
cluster = "default"
username = "nacos"
password = "nacos"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
serverAddr = "192.168.56.10:8848"
namespace = "seata"
group = "SEATA_GROUP"
username = "nacos"
password = "nacos"
}
file {
name = "file.conf"
}
}
{/tabs-pane}
6、推送seata配置到nacos
sh ${SEATAPATH}/script/config-center/nacos/nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP -t 5a3c7d6c-f497-4d68-a71a-2e5e3340b3ca -u username -w password
参数说明:
-h:主机,默认值为localhost。
-p:端口,默认值为8848。
-g:配置分组,默认值为’SEATA_GROUP’。
-t:命名空间,对应Nacos的namespace ID字段,默认值为’'。
-u:用户名,nacos 1.2.0+ 权限控制,默认为’'。
-w:密码,nacos 1.2.0+ 关于权限控制,默认值为’'。
推送脚本可前往官方地址下载:链接
下面贴出我的,在目录 /data/seata
下创建下面两个文件,之后直接执行下面的推送命令即可,注意路径一致
{tabs-pane config.txt文件}
vi config.txt
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://192.168.56.10:3306/seata?useUnicode=true
store.db.user=root
store.db.password=pass
store.db.minConn=5
store.db.maxConn=30
store.db.globalTable=global_table
store.db.branchTable=branch_table
store.db.queryLimit=100
store.db.lockTable=lock_table
store.db.maxWait=5000
{/tabs-pane}
{tabs-pane nacos-config.sh文件}vi nacos-config.sh
#!/usr/bin/env bash
# Copyright 1999-2019 Seata.io Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at、
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
while getopts ":h:p:g:t:u:w:" opt
do
case $opt in
h)
host=$OPTARG
;;
p)
port=$OPTARG
;;
g)
group=$OPTARG
;;
t)
tenant=$OPTARG
;;
u)
username=$OPTARG
;;
w)
password=$OPTARG
;;
?)
echo " USAGE OPTION: $0 [-h host] [-p port] [-g group] [-t tenant] [-u username] [-w password] "
exit 1
;;
esac
done
urlencode() {
for ((i=0; i < ${#1}; i++))
do
char="${1:$i:1}"
case $char in
[a-zA-Z0-9.~_-]) printf $char ;;
*) printf '%%%02X' "'$char" ;;
esac
done
}
if [[ -z ${host} ]]; then
host=localhost
fi
if [[ -z ${port} ]]; then
port=8848
fi
if [[ -z ${group} ]]; then
group="SEATA_GROUP"
fi
if [[ -z ${tenant} ]]; then
tenant=""
fi
if [[ -z ${username} ]]; then
username=""
fi
if [[ -z ${password} ]]; then
password=""
fi
nacosAddr=$host:$port
contentType="content-type:application/json;charset=UTF-8"
echo "set nacosAddr=$nacosAddr"
echo "set group=$group"
failCount=0
tempLog=$(mktemp -u)
function addConfig() {
curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$(urlencode $1)&group=$group&content=$(urlencode $2)&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null
if [[ -z $(cat "${tempLog}") ]]; then
echo " Please check the cluster status. "
exit 1
fi
if [[ $(cat "${tempLog}") =~ "true" ]]; then
echo "Set $1=$2 successfully "
else
echo "Set $1=$2 failure "
(( failCount++ ))
fi
}
count=0
for line in $(cat /data/seata/config.txt | sed s/[[:space:]]//g); do
(( count++ ))
key=${line%%=*}
value=${line#*=}
addConfig "${key}" "${value}"
done
echo "========================================================================="
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
echo "========================================================================="
if [[ ${failCount} -eq 0 ]]; then
echo " Init nacos config finished, please start seata-server. "
else
echo " init nacos config fail. "
fi
{/tabs-pane}
推送命令
sh nacos-config.sh -h 192.168.56.10 -p 8848 -g SEATA_GROUP -t seata -u nacos -w nacos
7、运行seata容器
docker run \
-p 8091:8091 --name seata \
-e SEATA_IP=192.168.56.10 \
-e SEATA_PORT=8091 \
-v /data/seata/conf/registry.conf:/seata-server/resources/registry.conf \
-v /data/seata/logs:/root/logs \
--privileged=true \
--restart always \
-d seataio/seata-server
五、docker安装sentinel
1、拉取sentinel镜像
docker pull bladex/sentinel-dashboard
2、运行sentinel容器
docker run \
-p 8858:8858 --name sentinel \
--restart always \
-d bladex/sentinel-dashboard
六、docker安装rabbitMq
1、拉取rabbitMq镜像
docker pull rabbitmq
2、创建rabbitMq文件夹
mkdir -p /data/rabbitmq
3、运行rabbitMq容器
docker run \
-p 5672:5672 -p 15672:15672 --name rabbitmq \
-v /data/rabbitmq:/var/lib/rabbitmq \
-e RABBITMQ_DEFAULT_USER=admin \
-e RABBITMQ_DEFAULT_PASS=admin \
--restart always \
-d rabbitmq
4、安装插件
docker exec -t rabbitmq rabbitmq-plugins enable rabbitmq_management
5、重启rabbitMq容器
七、docker安装fastDFS
1、拉取fastDFS镜像
docker pull season/fastdfs:1.2
2、创建fastDFS文件夹
mkdir -p /data/fastdfs/tracker/data
mkdir -p /data/fastdfs/storage/data
mkdir -p /data/fastdfs/storage/path
3、创建tracker容器
docker run \
-id --name tracker \
-p 22122:22122 \
-v /data/fastdfs/tracker/data:/fastdfs/tracker/data \
--restart=always --net host \
season/fastdfs:1.2 tracker
4、创建storage容器
docker run \
-id --name storage \
-v /data/fastdfs/storage/data:/fastdfs/store_path \
-e TRACKER_SERVER=192.168.56.30:22122 \
--restart=always --net host \
season/fastdfs:1.2 storage
5、复制tracker配置文件
docker cp tracker:/etc/fdfs/client.conf /data/fastdfs/tracker/
docker cp /data/fastdfs/tracker/client.conf tracker:/etc/fdfs
6、复制storage配置文件
docker cp storage:/etc/fdfs/client.conf /data/fastdfs/storage/
docker cp /data/fastdfs/storage/client.conf storage:/etc/fdfs
7、测试连接
fdfs_monitor client.conf
8、测试上传
echo "hello lywq" > hello.txt
fdfs_upload_file /etc/fdfs/client.conf hello.txt
9、创建fastdfs使用的nginx文件夹
mkdir -p /data/fastdfs/nginx
10、创建文件
docker cp storage:/etc/nginx/conf/nginx.conf /data/fastdfs/nginx/
11、配置nginx路由
location / {
root /fastdfs/store_path/data;
ngx_fastdfs_module;
}
12、运行fastdfs_nginx容器
docker run \
-id --name fastdfs_nginx \
-p 8866:80 \
-e TRACKER_SERVER=192.168.56.30:22122 \
-v /data/fastdfs/storage/data:/fastdfs/store_path \
-v /data/fastdfs/nginx/nginx.conf:/etc/nginx/conf/nginx.conf \
--restart=always \
season/fastdfs:1.2 nginx
八、docker安装Elastic search
1、拉取elasticsearch镜像
docker pull elasticsearch:7.3.0
2、创建elasticsearch文件夹
mkdir -p /data/elasticsearch/config
mkdir -p /data/elasticsearch/data
mkdir -p /data/elasticsearch/logs
mkdir -p /data/elasticsearch/plugins
chmod -R 777 /data/elasticsearch/
3、创建配置文件
简单启动一下 ,把镜像里面的elasticsearch.yml给cp出来,方便做映射
docker run -d --name elasticsearch elasticsearch:7.3.0
docker cp elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml /data/elasticsearch/config/
4、修改elasticsearch存储目录
不建议使用,设置了新的存储目录需要赋予权限
# 存储目录
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
5、运行elasticsearch容器
docker run \
-p 9200:9200 -p 9300:9300 --name elasticsearch \
-e "cluster.name=elasticsearch" \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \
-v /data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /data/elasticsearch/data:/usr/share/elasticsearch/data \
-v /data/elasticsearch/logs:/usr/share/elasticsearch/logs \
-v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
--restart always \
-d elasticsearch:7.3.0
6、查看日志验证是否启动成功
docker logs -f elasticsearch
7、设置密码
修改配置文件
#安全配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
重启elasticsearch
docker restart elasticsearch
进入容器
docker exec -it elasticsearch bash
设置密码
./bin/elasticsearch-setup-passwords interactive
8、日志报错解决
sqoop报错:
ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
解决方法:
修改jdk的文件jdk1.8.0_11/jre/lib/security/java.policy
具体配置如下:在文件中添加如下内容
grant {
permission javax.management.MBeanTrustPermission "register";
};
10、安装ik中文分词插件
九、docker安装kibana
1、拉取kibana镜像
docker pull kibana:7.3.0
2、创建kibana文件夹
mkdir -p /data/kibana/config
3、创建配置文件
docker inspect elasticsearch IPAddress
vi /data/kibana/config/kibana.yml
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://192.168.56.30:9200"]
xpack.monitoring.ui.container.elasticsearch.enabled: true
kibana.index: ".kibana"
i18n.locale: "zh-CN"
elasticsearch.username: "elastic"
elasticsearch.password: "elastic"
4、运行kibana容器
docker run \
-p 5601:5601 --name kibana \
-v /data/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml \
--restart always \
-d kibana:7.3.0
5、查看日志验证是否启动成功
docker logs -f kibana
十、docker安装canal-server
1、拉取canal-server镜像
docker pull canal/canal-server:v1.1.6
评论区