免费资源网 – https://freexyz.cn/
目录一、环境准备二、配置网络三、开放端口四、安装jdk五、安装docker六、运行环境搭建五.启动java项目
一、环境准备
1. CentOS-7-x86_64-DVD-2003.iso
2. docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm
3. emqx-4.2.6.tar
4. influxdb-1.7-alpine.tar
5. mysql-5.7.tar
6. reids-6-alpine.tar
7. xshell (连接centos7)
8. xftp (上传文件)二、配置网络
1.切换目录
[root@localhost app]# cd /etc/sysconfig/network-scripts/ [root@localhost network-scripts]# ls ifcfg-enp0s32.修改网络配置文件配置静态ip
修改项:
BOOTPROTO=”static”新增项:
IPADDR=192.168.1.153 NETWORK=255.255.255.0 GATEWAY=192.168.1.1 HWADDR=08:00:27:3B:CE:45 DNS1=114.114.114.114 DNS2=192.168.1.1配置文件示例:
TYPE=”Ethernet” PROXY_METHOD=”yes” BROWSER_ONLY=”no” BOOTPROTO=”static” DEFROUTE=”yes” IPV4_FAILURE_FATAL=”no” IPV6INIT=”yes” IPV6_AUTOCONF=”yes” IPV6_DEFROUTE=”yes” IPV6_FAILURE_FATAL=”no” IPV6_ADDR_GEN_MODE=”stable-privacy” NAME=”enp0s3″ UUID=”d8a2c147-efe7-4913-a3aa-f63ffb62335e” DEVICE=”enp0s3″ ONBOOT=”yes” IPADDR=192.168.1.153 NETWORK=255.255.255.0 GATEWAY=192.168.1.1 HWADDR=08:00:27:3B:CE:45 DNS1=114.114.114.114 DNS2=192.168.1.13.重启网卡
service network restart4.验证网络是否通畅
ping www.baidu.com三、开放端口
开端口命令:
firewall-cmd –zone=public –add-port=80/tcp –add-port=3306/tcp –add-port=6379/tcp –add-port=8081/tcp –add-port=1883/tcp –add-port=8083/tcp –add-port=8883/tcp –add-port=8084/tcp –add-port=18083/tcp –add-port=8086/tcp –permanent 重启防火墙:
systemctl restart firewalld.service 查看开启的所有端口:
firewall-cmd –list-ports命令含义:
–zone #作用域 –add-port=80/tcp #添加端口,格式为:端口/通讯协议 –permanent #永久生效,没有此参数重启后失效四、安装jdk
1.解压jdk安装包
tar -zxvf jdk-8u261-linux-x64.tar.gz 2.查看jdk路径
[root@localhost tool]# cd jdk1.8.0_261/ [root@localhost jdk1.8.0_261]# pwd /opt/tool/jdk1.8.0_261 3.配置环境变量
[root@localhost jdk1.8.0_261]# vi /etc/profile在profile文件末尾加上以下配置(按键 i 进入编辑模式,:wq 保存并退出)
#java export JAVA_HOME=/opt/tool/jdk1.8.0_261 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib 4.使配置生效并验证
[root@localhost jdk1.8.0_261]# source /etc/profile [root@localhost jdk1.8.0_261]# java -version java version “1.8.0_261” Java(TM) SE Runtime Environment (build 1.8.0_261-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)五、安装docker
1.yum 安装docker
yum install -y docker-ce-18.03.0.ce-1.el7.centos.x86_64.rpm 2.启动docker,设置开机启动并验证
[root@localhost tool]# systemctl start docker.service [root@localhost tool]# systemctl enable docker.service Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service. [root@localhost tool]# docker version Client: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:09:15 2018 OS/Arch: linux/amd64 Experimental: false Orchestrator: swarm Server: Engine: Version: 18.03.0-ce API version: 1.37 (minimum version 1.12) Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:13:03 2018 OS/Arch: linux/amd64 Experimental: false 3.设置镜像加速器
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-EOF { “registry-mirrors”: [“https://p9gdavtl.mirror.aliyuncs.com”] } EOF sudo systemctl daemon-reload sudo systemctl restart docker六、运行环境搭建
导出镜像
[root]# docker save > mysql-5.7.tar mysql:5.7 1.导入镜像
[root@localhost tool]# docker load < influxdb-1.7-alpine.tar [root@localhost tool]# docker load < mysql-5.7.tar [root@localhost tool]# docker load < emqx-4.2.6.tar [root@localhost tool]# docker load < reids-6-alpine.tar2.启动镜像
2.1 启动mysql
[root@localhost tool]# sudo docker run –restart=always -p 3306:3306 –name mysql -v /opt/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 –lower_case_table_names=1 2.2 启动redis
[root@localhost tool]# docker run –restart=always -p 6379:6379 –name redis -v /opt/redis/data:/data -d redis:6-alpine redis-server –requirepass “123456” –appendonly yes 2.3 启动emqx
[root@localhost tool]# docker run –restart=always -d –name emqx -p 8081:8081 -p 1883:1883 -p 8083:8083 -p 8883:8883 -p 8084:8084 -p 18083:18083 emqx/emqx:4.2.62.4 启动influxdb (不需要安装)
[root@localhost tool]# docker run –restart=always -d -p 9083:8083 -p 8086:8086 –name influxdb influxdb:1.7-alpine 2.4.1 进入容器,创建用户
[root@localhost tool]# docker exec -it cf bash2.4.2
bash-5.0# influx 2.4.3 创建用户名密码
create user “root” with password 123456 with all privileges 2.4.4 用户名密码登陆
bash-5.0# influx -username root -password 123456五.启动java项目
nohup java -jar demo.jar >catalina.out 2>&1 &
免费资源网 – https://freexyz.cn/
© 版权声明
THE END
暂无评论内容