赞
踩
一键安装docker
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo && \
sudo yum install docker-ce -y && sudo systemctl --now enable docker && sudo docker run --rm hello-world && \
sudo docker system prune -a --force && sudo docker version
docker pull nginx:1.22-alpine && docker run -d --name nginx nginx:1.22-alpine
cd /data && docker cp nginx:/etc/nginx ./
cd nginx && docker cp nginx:/usr/share/nginx/html ./ && docker cp nginx:/var/log/nginx/ ./logs
docker stop nginx && docker rm nginx
docker run -d --name nginx --restart=on-failure -p 8000-9000:8000-9000 -p 80:80 -p 443:443 \
-v /data/nginx:/etc/nginx -v /data/nginx/html:/usr/share/nginx/html \
-v /data/nginx/logs:/var/log/nginx nginx:1.22-alpine
–restart=on-failure:异常状态退出时自动重启
-p 8000-9000:8000-9000:映射整个8000~9000端口段到容器中,为将来业务拓展预留
docker pull redis:6.2.7-alpine
cd /data && mkdir redis && cd redis && wget https://raw.githubusercontent.com/redis/redis/6.2/redis.conf
vim redis.conf
#bind 127.0.0.1 #注释此配置;作用:限制redis只能本机访问
protected-mode no #改为:no;作用:redis保护模式,禁止外网访问
requirepass xxx #作用:redis连接密码,默认是注释的无需密码。建议手动打开设置
appendonly yes #改为yes;ADF持久化,单机建议开启;重启redis时可恢复数据(非必须);正常退出下:修改appendonly.aof文件删除末尾flushall后重启即可;异常奔溃下:修复aof文件:redis-check-aof --fix appendonly.aof后重启即可
appendfsync everysec # 保持默认everysec即可,每1秒持久化一次AOF,单机建议开启(非必须)
docker run -d --name redis --restart=on-failure -p 16379:6379 \
-v /data/redis/redis.conf:/etc/redis/redis.conf redis:6.2.7-alpine /etc/redis/redis.conf
–restart=on-failure:异常状态退出时自动重启
-p 16379:6379:映射宿主机的16379端口到redis容器的6379端口
docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=123456 mysql:8.0.30
-e MYSQL_ROOT_PASSWORD:root用户密码
此处需设置正确,后续步骤将拷贝出配置文件信息含有此密码信息等
docker logs -f mysql
3. 创建mysql目录,并将配置文件日志数据目录等拷贝至宿主机
cd /data && mkdir mysql && cd mysql && docker stop mysql && \
docker cp mysql:/etc/my.cnf ./ && docker cp mysql:/var/lib/mysql ./data
docker rm mysql
docker run -d --name mysql --restart=on-failure -p 13306:3306 -e MYSQL_ROOT_PASSWORD=123456 \
-v /data/mysql/my.cnf:/etc/my.cnf -v /data/mysql/data:/var/lib/mysql mysql:8.0.30
-e MYSQL_ROOT_PASSWORD:root用户密码(需与第一步密码一致)
–restart=on-failure:异常状态退出时自动重启
-p 13306:3306:映射宿主机的13306端口到mysql容器的3306端口
此功能非必须,按需配置
但是此版本容器看了下是默认允许的,所以如需允许外网登录可跳过下述步骤
docker exec -it mysql bash
mysql -uroot -p
use mysql;
select host, user, authentication_string, plugin from user where user = 'root';
update user set host = '%' where user = 'root';
flush privileges;
exit
Navicat无法连接mysql8.0
原因
mysql8 之前的版本中加密规则是 mysql_native_password,而在 mysql8 之后,加密规则是caching_sha2_password
解决问题方法有两种,一种是升级 navicat 驱动;一种是把 mysql 用户登录密码加密规则还原成 mysql_native_password
此文后续步骤以修改mysql加密规则为示例(各位看官按实际需要操作)
docker exec -it mysql bash
mysql -uroot -p
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '新密码';
exit
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因
这个错误发生在mysql 5.7 版本及以上版本会出现的问题:
mysql 5.7版本默认的sql配置是:sql_mode=“ONLY_FULL_GROUP_BY”,这个配置严格执行了"SQL92标准"。
很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。
在sql执行时,出现该原因:
简单来说就是:输出的结果是叫target list,就是select后面跟着的字段,还有一个地方group by column,就是group by后面跟着的字段。
由于开启了ONLY_FULL_GROUP_BY的设置,所以如果一个字段没有在target list和group by字段中同时出现,或者是聚合函数的值的话,那么这条sql查询是被mysql认为非法的,会报错误。
MySQL有any_value(field)函数,它主要的作用就是抑制ONLY_FULL_GROUP_BY值被拒绝。
这样sql语句不管是在ONLY_FULL_GROUP_BY模式关闭状态还是在开启模式都可以正常执行,不被mysql拒绝。
any_value()会选择被分到同一组的数据里第一条数据的指定列值作为返回数据。
vim /data/mysql/my.cnf
# 在[mysqld]下追加以下内容
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
docker restart mysql
创建数据库
CREATE DATABASE `数据库名` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
创建用户
CREATE USER '用户名'@'%' IDENTIFIED WITH mysql_native_password BY '密码';
用户授权权限
GRANT ALL ON 数据库名.* TO '用户名'@'%';
docker pull jenkins/jenkins:alpine-jdk8
若使用jdk11则可pull最新版jenkins,否则最新版配置jdk8时会有兼容bug
docker run -d --name jenkins jenkins/jenkins:alpine-jdk8
docker cp jenkins:/var/jenkins_home /data/
docker stop jenkins && docker rm jenkins
docker run -d --restart=unless-stopped --name jenkins -u root \
-v $(which docker):/usr/bin/docker \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /data/esp/:/data/esp/ \
-v /data/jenkins_home:/var/jenkins_home \
-v /etc/localtime:/etc/localtime \
-p 9095:8080 -p 50000:50000 jenkins/jenkins:alpine-jdk8
-uroot:已jenkins中root用户启动
-p:映射容器中8080、50000端口到宿主机的9095、50000端口
-v:映射项目部署目录及jenkins工作目录到容器中
-v /etc/localtime:/etc/localtime:同步容器与宿主机的时间
docker logs -f jenkins
*************************************************************
*************************************************************
*************************************************************
Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:
------------此处应有密码------------
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
*************************************************************
*************************************************************
*************************************************************
输入上文log中的密码点击继续即可,后续的个性化设置按需配置,此处只提供安装步骤
docker run -d --name zookeeper zookeeper:3.8.0
mkdir /data/zookeeper && cd /data/zookeeper
docker cp zookeeper:/conf/zoo.cfg ./ && docker cp zookeeper:/data ./ \
&& docker cp zookeeper:/datalog ./ && docker rm -f zookeeper
docker run -d --name zookeeper --restart=on-failure -p 2181:2181 \
-v /data/zookeeper/data:/data -v /data/zookeeper/datalog:/datalog \
-v /data/zookeeper/zoo.cfg:/conf/zoo.cfg zookeeper:3.8.0
–restart=on-failure:异常状态退出时自动重启
docker run -d --name kafka -e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
-e KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 --link zookeeper bitnami/kafka:3.3.1
KAFKA_CFG_ADVERTISED_LISTENERS
暴露的ip端口,生产填内网ip;测试填公网ip
KAFKA_CFG_ZOOKEEPER_CONNECT
zookeeper连接ip端口
mkdir /data/kafka && cd /data/kafka
docker cp kafka:/opt/bitnami/kafka/config ./ \
docker cp kafka:/opt/bitnami/kafka/bin ./ && docker rm -f kafka
vim bin/kafka-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
# 插入如下内容:↓
export JMX_PORT="9999"
fi
docker run -d --name kafka -p 9092:9092 -p 9999:9999 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
-e KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 \
-e KAFKA_CFG_MAX_REQUEST_SIZE=104857600 --link zookeeper \
-v /data/kafka/bin:/opt/bitnami/kafka/bin \
-v /data/kafka/config:/opt/bitnami/kafka/config bitnami/kafka:3.3.1
docker run -d --name kafka-eagle rottenleaf/kafka-eagle:2.0.3
mkdir /data/kafka-eagle && cd /data/kafka-eagle
docker cp kafka-eagle:/kafka-eagle/conf/system-config.properties ./ \
&& docker cp kafka-eagle:/kafka-eagle/logs ./ && docker rm -f kafka-eagle
vim system-config.properties
efak.zk.cluster.alias=cluster1
cluster1.zk.list=localhost:2181
# zookeeper客户端线程数,即zkCli个数
kafka.zk.limit.size=25
# web界面端口
efak.webui.port=8048
# 使用mysql:mysql8:com.mysql.cj.jdbc.Driver
efak.driver=com.mysql.jdbc.Driver
efak.url=jdbc:mysql://127.0.0.1:3306/kafka_eagle?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
efak.username=root
efak.password=123456
docker run -d --name kafka-eagle -p 8048:8048 --link zookeeper \
-v /data/kafka-eagle/system-config.properties:/kafka-eagle/conf/system-config.properties \
-v /data/kafka-eagle/logs:/kafka-eagle/logs rottenleaf/kafka-eagle:2.0.3
调整内核参数,否则无法启动
查看内核max_map_count参数值,默认为65530
cat /proc/sys/vm/max_map_count
重新设置max_map_count的值
sysctl -w vm.max_map_count=262144
立即生效
sysctl -p
docker pull elasticsearch:7.17.7 && docker run -d --name es -e "discovery.type=single-node" elasticsearch:7.17.7
mkdir /data/elasticsearch && cd /data/elasticsearch
docker cp es:/usr/share/elasticsearch/config ./ && docker cp es:/usr/share/elasticsearch/data ./ && docker cp es:/usr/share/elasticsearch/plugins ./
docker stop es && docker rm es
docker run -d --name es --restart=on-failure \
-p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" \
-v /data/elasticsearch/data:/usr/share/elasticsearch/data \
-v /data/elasticsearch/config:/usr/share/elasticsearch/config \
-v /data/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
elasticsearch:7.17.7
--restart=on-failure
:异常状态退出时自动重启
-e "discovery.type=single-node"
:以单机节点启动
访问:http://ip:9200
{
"name" : "58fb806ed441",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "bdMTiJNsQPmv0pgVoAYu1Q",
"version" : {
"number" : "7.17.7",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "78dcaaa8cee33438b91eca7f5c7f56a70fec9e80",
"build_date" : "2022-10-17T15:29:54.167373105Z",
"build_snapshot" : false,
"lucene_version" : "8.11.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
vim config/elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
# 开启安全验证
xpack.security.enabled: true
重启es生效配置
docker restart es
生成随机密码
docker exec -it es elasticsearch-setup-passwords auto
修改密码
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://127.0.0.1:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
docker exec -it es elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
若安装成功则会打印以下内容
-> Installing https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip
[=================================================] 100%??
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See https://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
Continue with installation? [y/N]y
-> Installed analysis-ik
-> Please restart Elasticsearch to activate any plugins installed
docker restart es
docker run -d --name kibana --link es -e ELASTICSEARCH_URL=http://es:9200 kibana:7.17.7
mkdir /data/kibana && cd /data/kibana
docker cp kibana:/usr/share/kibana/config ./ && docker rm -f kibana
vim config/kibana.yml
# elasticsearch连接地址
elasticsearch.hosts: [ "http://es:9200" ]
# elasticsearch账密(若无可不配置)
elasticsearch.username: "kibana"
elasticsearch.password: "密码为上述es生成随机密码对应的kibana_password"
docker run -d --name kibana --link es -p 15601:5601 \
-v /data/kibana/config:/usr/share/kibana/config kibana:7.17.7
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。