spring cloud微服务pig的安装部署

环境说明

中间件 版本 安装方式
JDK 1.8 rpm安装
Mysql 5.7 二进制安装
redis 3.2+ yum安装
nodejs 8.0+ yum安装
maven 3.6.0 二进制安装

注意内存给4G,因为java比较消耗内存,给小了可能pig启动失败没有端口

 

下载pig项目

新版pig没有/opt/pig/pig-config/src/main/resources/config/application-dev.yml 文件

#下载新版pig
[root@k8s-master ~]# cd /opt
[root@k8s-master opt]# wget https://gitee.com/log4j/pig/repository/archive/v2.4.4?format=tar.gz

 注: 下载的是pig稳定版,并且有config配置文件。 码云下载地址:https://gitee.com/log4j/pig/releases

配置本地hosts解析

[root@k8s-master opt]# vim /etc/hosts
127.0.0.1   pig-mysql
127.0.0.1   pig-redis
127.0.0.1   pig-gateway
127.0.0.1   pig-eureka

数据库安装与初始化

下载数据库

[root@oldboy opt]# wget http://mirror.sohu.com/mysql/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
--2020-01-21 10:24:58--  http://mirror.sohu.com/mysql/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
Resolving mirror.sohu.com (mirror.sohu.com)... 123.125.123.141
Connecting to mirror.sohu.com (mirror.sohu.com)|123.125.123.141|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 644399365 (615M) [application/octet-stream]
Saving to: ‘mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz’

100%[===============================================================>] 644,399,365  515KB/s   in 20m 29s

2020-01-21 10:45:28 (512 KB/s) - ‘mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz’ saved [644399365/644399365]

安装数据库

#解压并移动到/app/mysql目录
[root@oldboy opt]# mkdir -p /app/
[root@oldboy opt]# tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz 
[root@oldboy opt]# mv mysql-5.7.23-linux-glibc2.12-x86_64 /app/mysql
[root@oldboy opt]# ls -l /app/mysql/
total 36
drwxr-xr-x  2 root root   4096 Jul 12 07:19 bin
-rw-r--r--  1 7161 31415 17987 Jun  8  2018 COPYING
drwxr-xr-x  2 root root     55 Jul 12 07:19 docs
drwxr-xr-x  3 root root   4096 Jul 12 07:19 include
drwxr-xr-x  5 root root    230 Jul 12 07:19 lib
drwxr-xr-x  4 root root     30 Jul 12 07:19 man
-rw-r--r--  1 7161 31415  2478 Jun  8  2018 README
drwxr-xr-x 28 root root   4096 Jul 12 07:19 share
drwxr-xr-x  2 root root     90 Jul 12 07:19 support-files
#修改环境变量:
[root@oldboy opt]# vim /etc/profile
export PATH=/app/mysql/bin:$PATH
[root@oldboy opt]# source /etc/profile
#建立mysql用户和组
[root@oldboy opt]# useradd mysql
#创建相关目录并修改权限
[root@oldboy opt]# mkdir /data/mysql -p 
[root@oldboy opt]# chown -R mysql.mysql /app/*
[root@oldboy opt]# chown -R mysql.mysql /data/*
#安装依赖包
[root@oldboy opt]# yum install -y libaio
#初始化数据
[root@oldboy opt]# mysqld --initialize  --user=mysql --basedir=/app/mysql --datadir=/data/mysql
#非常重要,注意查看临时随机密码
2020-02-04T11:31:13.715638Z 1 [Note] A temporary password is generated for root@localhost: 2S8hslot=7b3

 

修改mysql配置文件

[root@k8s-master mysql]# vim /etc/my.cnf
[mysqld]
user=mysql
basedir=/app/mysql
datadir=/data/mysql
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock

启动mysql

[root@k8s-master mysql]# cd /app/mysql/support-files/
[root@k8s-master support-files]# cp mysql.server /etc/init.d/mysqld
[root@k8s-master support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/k8s-master.err'.
 SUCCESS! 

创建pig数据库

##用到上面创建的随机密码
[root@k8s-master opt]# mysqladmin -uroot -p'XMt9s>91gxaC' password root
[root@k8s-master opt]# mysql -uroot -proot
mysql> create database pig default character set utf8mb4;
mysql> exit
Bye

初始化pig数据库

log4j-pig-2.3.0.tar.gz解压到 /opt

 tar xf log4j-pig-2.3.0.tar.gz  -C /opt/  
[root@k8s-master opt]# cd /opt/pig/db
[root@k8s-master db]# mysql -uroot -proot pig < pig.sql 

安装并启动redis

[root@k8s-master db]# yum install epel-release.noarch -y
[root@k8s-master db]# yum install redis -y
[root@k8s-master db]# systemctl start redis
[root@k8s-master db]# systemctl enable redis

pig配置文件修改

redis 密码配置

vi /opt/pig/pig-config/src/main/resources/config/application-dev.yml
# redis 相关,无密码为空即可,不要修改成IP,修改hosts
spring:
  redis:
    password:
#可以不设密码,简单。

数据库密码配置

如果mysql的root用户密码已经是root,就不用修改刚才的文件

vi  /opt/pig/pig-config/src/main/resources/config/pig-auth-dev.yml
vi  /opt/pig/pig-config/src/main/resources/config/pig-upms-dev.yml
vi  /opt/pig/pig-config/src/main/resources/config/pig-codegen-dev.yml

# 数据源,只需要修改密码即可,不要修改成IP,修改hosts
spring:
  datasource:
    username: root
    password: root

安装maven编译pig

apache-maven下载地址:http://mirrors.hust.edu.cn/apache/maven/maven-3/3.6.3/binaries/

jdk下载地址https://mkyong.com/java/how-to-install-oracle-jdk-8-on-centos/

准备好jdk和maven的包

apache-maven网盘下载:链接:https://pan.baidu.com/s/1DACOWr8qcOffKtE5swyb7w   提取码:f3xt

jdk-8u102网盘下载:链接:https://pan.baidu.com/s/136yWY4iWbucq6i6UeOFHiA      提取码:njof

[root@k8s~]# ls
anaconda-ks.cfg  apache-maven-3.6.0-bin.tar.gz  jdk-8u102-linux-x64.rpm

安装jdk

[root@oldboy ~]# rpm -ivh jdk-8u102-linux-x64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8.0_102-2000:1.8.0_102-fcs  ################################# [100%]
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...

安装maven

[root@oldboy ~]# tar xf apache-maven-3.6.0-bin.tar.gz -C /usr/local/
[root@oldboy ~]# ln -s /usr/local/apache-maven-3.6.0 /usr/local/maven
[root@oldboy ~]# vim /etc/profile
#文件结尾添加两行
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:$PATH
​
[root@oldboy ~]# source /etc/profile
[root@oldboy ~]# mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: /usr/local/maven
Java version: 1.8.0_102, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_102/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"

编译pig项目

[root@oldboy ~]# cd /opt/pig/
[root@oldboy pig]# ls
db                  LICENSE   pig-common  pig-eureka   pig-upms    pom.xml
docker-compose.yml  pig-auth  pig-config  pig-gateway  pig-visual  README.md
[root@oldboy pig]# mvn clean package

spring cloud微服务pig的安装部署_第1张图片

运行pig项目

按顺序启动pig各个服务组件

[root@k8s-master pig]# find /opt/pig/ -type f -name "*.jar"|xargs mv -t /opt/pig/
[root@k8s-master pig]# java -jar pig-eureka.jar &>/dev/null &
[root@k8s-master pig]# java -jar pig-config.jar &>/dev/null &
[root@k8s-master pig]# java -jar pig-gateway.jar &>/dev/null &
[root@k8s-master pig]# java -jar pig-auth.jar &>/dev/null &
[root@k8s-master pig]# java -jar pig-upms-biz.jar &>/dev/null &
##等一会全部启动后
[root@k8s-master ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      8872/redis-server 1 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      8873/sshd           
tcp6       0      0 :::3306                 :::*                    LISTEN      10601/mysqld        
tcp6       0      0 :::9999                 :::*                    LISTEN      10951/java          
tcp6       0      0 :::22                   :::*                    LISTEN      8873/sshd           
tcp6       0      0 :::3000                 :::*                    LISTEN      10858/java          
tcp6       0      0 :::8888                 :::*                    LISTEN      10785/java          
tcp6       0      0 :::8761                 :::*                    LISTEN      10717/java          
tcp6       0      0 :::4000                 :::*                    LISTEN      10896/java          
udp        0      0 127.0.0.1:323           0.0.0.0:*                           7298/chronyd        
udp6       0      0 ::1:323                 :::*                                7298/chronyd

遇到的坑服务启动完再去启动第二个服务,第一个就exit退出,执行一个命令就退出,最后使用了一个新的虚拟机 pig-gateway 然后重启一次,一共有7个tcp6启动

验证

访问eureka http://<你的ip>:8761

spring cloud微服务pig的安装部署_第2张图片

 

部署pig前端

拉取前端代码

[root@oldboy opt]# cd /opt/
[root@oldboy opt]# wget https://gitee.com/log4j/pig-ui/repository/archive/v2.4.4?format=tar.gz

注: 下载的是pig-ui稳定版 码云地址:https://gitee.com/log4j/pig-ui/releases

#配置nodejs yum源
[root@oldboy pig-ui]# curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
内容略
#安装
[root@oldboy pig-ui]# yum install -y nodejs

安装依赖

#更换npm源为淘宝
[root@oldboy pig-ui]# npm config set registry https://registry.npm.taobao.org
#安装依赖
[root@oldboy pig-ui]# npm install
npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.

注:安装依赖是需要好的网络,否则容易失败。

启动pig-ui

[root@oldboy pig-ui]# npm run dev
​
> pig-ui@2.3.1 dev /opt/pig-ui
> vue-cli-service serve
#输出略
​
 DONE  Compiled successfully in 20926ms                                                             10:38:31 AM         
  App running at:
  - Local:   http://localhost:8080 
  - Network: http://192.168.100.100:8080
​
  Note that the development build is not optimized.
  To create a production build, run npm run build.

 

你可能感兴趣的:(spring cloud微服务pig的安装部署)