赞
踩
目录
创建文件hmy.cnf到/tmp/mysql/conf,并写入内容
建议使用阿里云服务器,安全可靠https://www.aliyun.com/
注意:在完成创建完阿里云实例后,一定要设置安全组,否则无法访问端口
yum update
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 list docker-ce --showduplicates | sort -r
- yum install docker-ce #安装最新版
-
- yum install docker-ce-20.10.1-3.el7 #安装指定版本(推荐安装此方式)
- #创建目录地址
- mkdir -p /etc/docker
-
- #创建 daemon 文件
- vi /etc/docker/daemon.json
- {
- "registry-mirrors": ["自己个人的docker 加速地址"]
- }
- systemctl daemon-reload
- systemctl restart docker
- # 关闭
- systemctl stop firewalld
- # 禁止开机启动防火墙
- systemctl disable firewalld
- systemctl start docker # 启动docker服务
-
- systemctl stop docker # 停止docker服务
-
- systemctl restart docker # 重启docker服务
docker -v
- yum install -y bash-completion
- source /usr/share/bash-completion/bash_completion
- source /usr/share/bash-completion/completions/docker
docker pull nginx
docker run --name nginx-latest -v html:/usr/share/nginx/html -p 80:80 -d nginx
注:目录需自行修改本机HTML目录地址
docker pull mysql:5.7
- #进入tmp目录,创建/tmp/mysql/data和/tmp/mysql/conf
- mkdir -p /tmp/mysql/data // 存放生成的数据信息
- mkdir -p /tmp/mysql/conf // 存放共享的配置文件信息
- [mysqld]
- skip-name-resolve
- character_set_server=utf8
- datadir=/var/lib/mysql
- server-id=1000
- docker run \
- --name mysql \
- -e MYSQL_ROOT_PASSWORD=root \
- -p 3306:3306 \
- -d \
- -v /tmp/mysql/data:/var/lib/mysql \
- -v /tmp/mysql/conf/hmy.cnf:/etc/mysql/conf.d/my.cnf \
- --privileged \
- mysql:5.7
- ## 容器化部署
-
- #拉取镜像并创建启动容器
- docker pull mysql:5.7
-
- #详细方式
- docker run --name mysql --restart=always -p 3306:3306 --privileged=true -ti -e MYSQL_ROOT_PASSWORD=itcast142 -e MYSQL_USER=user -e MYSQL_PASSWORD=itcast142 -e TZ=Asia/Shanghai -v /usr/soft/mysql/docker/3306/config/:/etc/mysql/conf.d -v /usr/soft/mysql/docker/3306/data/:/var/lib/mysql -v /usr/soft/mysql/docker/3306/logs/:/var/log/mysql -d mysql:5.7
-
- #-e 代表添加环境变量 MYSQL_ROOT_PASSWORD 是root用户的远程登陆密码(如果是在容器中使用root登录的话,那么其密码为空)
-
- #进入容器
- docker exec -it mysql /bin/bash
-
- #登录容器内mysql
- mysql -uroot -p
-
- #退出容器
- exit
-
- 如果容器创建完容器,但mysql的时区不对,需要通过下面的配置来修改时区:
-
-
- #进入容器
- docker exec -it mysql5.7 bash
-
- #查看当前时区
- date -R
-
- #修改时区 方式一:
- cp /usr/share/zoneinfo/PRC /etc/localtime
-
- # 或者 方式二:
- ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker pull nacos/nacos-server:1.4.1
docker run --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server:1.4.1
docker pull rabbitmq:3.8-management
- docker run \
- -e RABBITMQ_DEFAULT_USER=root \
- -e RABBITMQ_DEFAULT_PASS=root \
- -v mq-plugin:/plugins \
- --name rabbitmq \
- --hostname mq \
- -p 15672:15672 \
- -p 5672:5672 \
- -d \
- rabbitmq:3.8-management
docker pull elasticsearch:7.10.1
- mkdir -p /usr/soft/elasticsearch/config
- mkdir -p /usr/soft/elasticsearch/data
- mkdir -p /usr/soft/elasticsearch/plugins
- mkdir -p /usr/soft/elasticsearch/logs
echo "http.host: 0.0.0.0" > /usr/soft/elasticsearch/config/elasticsearch.yml
chmod -R 775 /usr/soft/elasticsearch
- docker run -id --name elasticsearch \
- -e "cluster.name=ly-elastic" \
- -e "http.host=0.0.0.0" \
- -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
- -e "discovery.type=single-node" \
- -e http.cors.enabled=true \
- -e http.cors.allow-origin="*" \
- -e http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization \
- -e http.cors.allow-credentials=true \
- -v /usr/soft/elasticsearch/data:/usr/share/elasticsearch/data \
- -v /usr/soft/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
- -v /usr/soft/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
- -v /usr/soft/elasticsearch/logs:/usr/share/elasticsearch/logs \
- --privileged \
- --hostname elasticsearch \
- -p 9200:9200 \
- -p 9300:9300 \
- elasticsearch:7.10.1
docker pull kibana:7.10.1
mkdir -p /usr/soft/kibana/config
- #
- # ** THIS IS AN AUTO-GENERATED FILE **
- #
-
- # Default Kibana configuration for docker target
- # 根据自己实际IP修改elasticsearch地址
- server.name: kibana
- server.host: "0"
- elasticsearch.hosts: [ "http://47.101.72.43:9200" ]
- xpack.monitoring.ui.container.elasticsearch.enabled: true
- docker run -d \
- --name=kibana \
- -p 5601:5601 \
- -v /usr/soft/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml \
- kibana:7.10.1
- # 1、进入/usr/soft/elasticsearch/plugins
- cd /usr/soft/elasticsearch/plugins
- # 2、新建文件目录 ik 并且进入
- mkdir ik
- cd ik
-
- # 3、解压elasticsearch-analysis-ik-7.10.1.zip
- yum -y install unzip
- unzip elasticsearch-analysis-ik-7.10.1.zip
-
- # 4、重启容器
- docker restart elasticsearch
-
- # 5、查看es日志
- docker logs -f elasticsearch
-
- # 6、重启 kibana
- docker restart kibana
打开IK分词器config目录
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
- <properties>
- <comment>IK Analyzer 扩展配置</comment>
- <!--用户可以在这里配置自己的扩展字典 *** 添加扩展词典-->
- <entry key="ext_dict">ext.dic</entry>
- <!--用户可以在这里配置自己的扩展停止词字典-->
- <entry key="ext_stopwords">stopword.dic</entry>
- <!--用户可以在这里配置远程扩展字典 -->
- <!-- <entry key="remote_ext_dict">words_location</entry> -->
- <!--用户可以在这里配置远程扩展停止词字典-->
- <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
- </properties>
新建一个 ext.dic,可以参考config目录下复制一个配置文件进行修改
- 清冽
- 高富帅
- 白富美
在 stopword.dic 添加停用词
- 烦人
- 烦人精
- docker restart elasticsearch
- docker restart kibana
-
- # 查看 日志
- docker logs -f elasticsearch
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。