【Java】Java常用环境搭建


docker安装

#卸载系统之前的docker

sudo yum remove docker \

docker-client \

docker-client-latest \

docker-common \

docker-latest \

docker-latest-logrotate \

docker-logrotate \

docker-engine

sudo yum install -y yum-utils

# 配置镜像

sudo yum-config-manager \

--add-repo \

https://download.docker.com/linux/centos/docker-ce.repo

sudo yum install docker-ce docker-ce-cli containerd.io

sudo systemctl start docker

# 设置开机自启动

sudo systemctl enable docker

docker -v

sudo docker images

# 配置镜像加速

sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'

{

"registry-mirrors": ["https://xdub84vk.mirror.aliyuncs.com"]

}

EOF

sudo systemctl daemon-reload

sudo systemctl restart docker

docker安装mysql

# --name指定容器名字 -v目录挂载 -p指定端口映射  -e设置mysql参数 -d后台运行

sudo docker run -p 3306:3306 --name mysql \

-v /root/app/mysql/log:/var/log/mysql \

-v /root/app/mysql/data:/var/lib/mysql \

-v /root/app/mysql/conf:/etc/mysql \

-e MYSQL_ROOT_PASSWORD=root \

-d mysql:5.7

# 进入容器内部

docker exec -it 471 bash

whereis mysql

#mysql: /usr/bin/mysql /usr/lib/mysql /etc/mysql /usr/share/mysql

# 修改配置文件

vim /root/app/mysql/conf/my.cnf

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

[mysqld]

init_connect='SET collation_connection = utf8_unicode_ci'

init_connect='SET NAMES utf8'

character-set-server=utf8

collation-server=utf8_unicode_ci

skip-character-set-client-handshake

skip-name-resolve

# 重启

docker restart mysql

# 查看配置文件是否生效

docker exec -it 471 bash

[email protected]:/# cat /etc/mysql/my.cnf

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

[mysqld]

init_connect='SET collation_connection = utf8_unicode_ci'

init_connect='SET NAMES utf8'

character-set-server=utf8

collation-server=utf8_unicode_ci

skip-character-set-client-handshake

skip-name-resolve

# 开机启动

docker update mysql --restart=always

docker 安装redis

# 创建挂载目录

mkdir -p /root/app/redis/conf

touch /root/app/redis/conf/redis.conf

# 启动

docker run -p 6379:6379 --name redis \

-v /root/app/redis/data:/data \

-v /root/app/redis/conf/redis.conf:/etc/redis/redis.conf \

-d redis redis-server /etc/redis/redis.conf

# 进入容器内

docker exec -it redis redis-cli

#设置持久化 设置aof类型的持久化方式

vim /root/app/redis/conf/redis.conf

appendonly yes

# 开机启动

docker update redis --restart=always

docker 安装es以及kibana

# 版本要一致

docker pull docker.elastic.co/kibana/kibana:7.9.3

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.9.3

mkdir -p /root/app/elasticsearch/config

mkdir -p /root/app/elasticsearch/data

echo "http.host: 0.0.0.0" >/root/app/elasticsearch/config/elasticsearch.yml

chmod -R 777 /root/app/elasticsearch/

# 启动

docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \

-e "discovery.type=single-node" \

-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \

-v /root/app/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \

-v /root/app/elasticsearch/data:/usr/share/elasticsearch/data \

-v /root/app/elasticsearch/plugins:/usr/share/elasticsearch/plugins \

-d docker.elastic.co/elasticsearch/elasticsearch:7.9.3

docker run --name kibana -e ELASTICSEARCH_HOSTS=http://47.112.150.204:9200 -p 5601:5601 -d docker.elastic.co/kibana/kibana:7.9.3

docker update elasticsearch --restart=always

docker update kibana --restart=always

# 分词器

git clone https://github.com/medcl/elasticsearch-analysis-ik

cd elasticsearch-analysis-ik

git checkout tags/{version}

mvn clean

mvn compile

mvn package

安装nginx

docker run -p80:80 --name nginx -

docker container cp nginx:/etc/nginx .

mkdir nginx

mv conf nginx/

cd nginx

docker run -p 80:80 --name nginx \

-v /root/app/nginx/html:/usr/share/nginx/html \

-v /root/app/nginx/logs:/var/log/nginx \

-v /root/app/nginx/conf/:/etc/nginx \

-d nginx

docker container cp nginx:/etc/nginx/conf/ /root/app/nginx/conf/

【Java】Java常用环境搭建

nacos安装

https://github.com/alibaba/nacos

# 以单机模式启动

cd /root/app/nacos/bin

sh startup.sh -m standalone

以上是 【Java】Java常用环境搭建 的全部内容, 来源链接: utcz.com/a/87090.html

回到顶部