Docker_入门Centos7 Docker安装mysql elasticsearch redis rabbimq xxl-job(详细安装教程)

基础设施请采用docker部署,
关闭防火墙:

systemctl stop firewalld &&\
systemctl disable firewalld

docker安装

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce-18.03.1.ce
systemctl enable docker
systemctl start docker

部署elasticsearch
建立数据存储目录:

mkdir -p /opt/data/esdata
chmod -R 777 /opt/data/esdata

配置扩展词典api: elasticsearch使用管理端维护的分词,需要修改IKAnalyzer.cfg.xml中的remote_ext_dict配置路径

mkdir -p /opt/ik
cd /opt/ik
vi IKAnalyzer.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <comment>IK Analyzer 扩展配置</comment>
    <!--用户可以在这里配置远程扩展字典 -->
    <entry key="remote_ext_dict">http://api.base.test.com/load-customwords?secret_key=secret_value</entry>
</properties>

运行elasticsearch

docker run --rm -d --name elasticsearch -v /opt/data/esdata:/usr/share/elasticsearch/data  -v /opt/ik/IKAnalyzer.cfg.xml:/usr/share/elasticsearch/plugins/ik/config/IKAnalyzer.cfg.xml  -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" registry.cn-beijing.aliyuncs.com/javashop-k8s-images/elasticsearch:6.2.2
默认cluster-name是docker-cluster
验证:http://<ip>:9200/_cluster/health

部署rabbimq
建立数据存储目录:

mkdir -p /opt/data/mqdata
chmod -R 777 /opt/data/mqdata

运行mq:

docker run --restart=always  -d --hostname rabbit \
 -p 15672:15672  -p 5672:5672 -p 25672:25672 -p 4369:4369 -p 35672:35672 \
 -v /opt/data/mqdata:/var/lib/rabbitmq \
 -e RABBITMQ_ERLANG_COOKIE='MY-SECRET-KEY' \
 --name rabbitmq   registry.cn-beijing.aliyuncs.com/javashop-k8s-images/rabbitmq:3.6.14

建议修改guest的密码,切创建自己的vhost和用户

部署redis:
建立数据目录

mkdir -p /opt/data/redisdata
chmod -R 777 /opt/data/redisdata

运行redis

docker run --restart=always -d -p 6379:6379 \
-v /opt/data/redisdata:/data \
--name redis registry.cn-beijing.aliyuncs.com/javashop-k8s-images/redis:5.0.4-alpine \
redis-server --appendonly yes --requirepass "123456"

部署mysql

mkdir -p /home/mysql/{conf,logs,data/mysql}
vi /home/mysql/conf/my.cnf
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
symbolic-links=0
lower_case_table_names=1
!includedir /etc/mysql/conf.d/

运行mysql容器:

docker run --restart=always -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 --name mysql -v /home/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /home/mysql/logs:/logs -v /home/mysql/data/mysql:/var/lib/mysql   registry.cn-beijing.aliyuncs.com/javashop-k8s-images/mysql:5.6.35

说明:如果使用mysql5.7版本,则在数据库配置中sql_model的值不能包含NO_BACKSLASH_ESCAPES,当sql_mode中包涵no_backslash_escapes时,反斜杠""为普通字符而不是转义字符。

部署xxl-job

docker run --rm -e PARAMS="--spring.datasource.url=jdbc:mysql://192.168.1.112:3306/xxl_job?Unicode=true&characterEncoding=UTF-8  --spring.datasource.username=root --spring.datasource.password=123456" -p 8080:8080 -v /tmp:/data/applogs --name xxl-job-admin  -d  registry.cn-beijing.aliyuncs.com/javashop-k8s-images/xxl-job-admin:2.0.0

安装nacos

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

安装静态页(openresty)

# 进入opt目录
cd /opt
# 下载配置文件
git clone [email protected]:enation/deploy-script.git --branch 7.2.2_rc

编辑配置文件:

vi /opt/deploy-script/openresty/lua/single_connector.lua

修改相应的redis配置:

local ok, err = red:connect("192.168.2.5", 6379)

修改访问静态页异常重定向地址

ngx.redirect("https://www.test.com/404.html")

启动openresty:

docker run --rm -d --name openresty -p 8081:80 -v /opt/deploy-script/openresty/:/usr/local/openresty/nginx/conf/  registry.cn-beijing.aliyuncs.com/javashop-k8s-images/openresty:nok8s-v1

验证
首先进入redis中:

docker exec -it redis redis-cli

然后在redis中执行如下命令:

set /PC/index.html 'hello pc'

你可能感兴趣的:(java,docker,centos,mysql,elasticsearch)