spring cloud微服务pig的安装部署

1.环境说明

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

2.下载pig项目

[root@oldboy ~]# cd /opt/
[root@oldboy opt]# git clone https://gitee.com/log4j/pig.git
Cloning into 'pig'...
remote: Enumerating objects: 12777, done.
remote: Counting objects: 100% (12777/12777), done.
remote: Compressing objects: 100% (5330/5330), done.
remote: Total 12777 (delta 4887), reused 11610 (delta 4432)
Receiving objects: 100% (12777/12777), 13.89 MiB | 803.00 KiB/s, done.
Resolving deltas: 100% (4887/4887), done.

3.配置本地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

4.数据的安装和初始化

4.1下载数据库

[root@oldboy opt]# wget http://mirror.sohu.com/mysql/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
--2019-07-12 07:12:22--  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’
.......

4.2安装数据库

#解压并移动到/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
#非常重要,注意查看临时随机密码
2019-07-11T23:27:20.701930Z 1 [Note] A temporary password is generated for root@localhost: =q/zYCK8gq3y

4.3修改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

4.4启动mysql

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

4.5创建pig数据库

#用到前面的临时随机密码
mysqladmin -uroot -p'=q/zYCK8gq3y' password root
mysql -uroot -proot
mysql> create database pig default character set utf8mb4;

4.6初始化pig数据库

[root@oldboy support-files]# cd /opt/pig/db/
[root@oldboy db]# mysql -uroot -proot pig 

4.7安装并启动redis

[root@oldboy db]# yum install epel-release.noarch -y
...输出略
[root@oldboy db]# yum install redis -y
...输出略
[root@oldboy db]# systemctl start redis

5.pig配置文件修改

5.1redis 密码配置

vi /opt/pig/pig-config/src/main/resources/config/application-dev.yml
# redis 相关,无密码为空即可,不要修改成IP,修改hosts
spring:
  redis:
    password:
为了简单,强哥在这里建议你redis直接空密码

5.2数据库密码配置

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
如果你的mysql的root用户密码已经是root,那么你不需要修改刚才的三个配置文件

6.安装maven编译pig

6.1准备好jdk和maven的包

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

6.2安装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...

6.3安装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"

6.4编译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的安装部署_第2张图片
image.png

7.运行pig项目

spring cloud微服务pig的安装部署_第3张图片
image.png

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

[root@oldboy pig]# java -jar pig-eureka.jar &>/dev/null &
[1] 2397
[root@oldboy pig]# java -jar pig-config.jar &>/dev/null &
[2] 2419
[root@oldboy pig]# 
[root@oldboy pig]# java -jar pig-gateway.jar &>/dev/null &
[3] 2466
[root@oldboy pig]# java -jar pig-auth.jar &>/dev/null &
[4] 2495
[root@oldboy pig]# java -jar pig-upms-biz.jar &>/dev/null &
[5] 2517
#等待一段时间之后
[root@oldboy pig]# 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      3172/redis-server 1 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      966/sshd            
tcp6       0      0 :::9999                 :::*                    LISTEN      3858/java           
tcp6       0      0 :::22                   :::*                    LISTEN      966/sshd            
tcp6       0      0 :::3000                 :::*                    LISTEN      3952/java           
tcp6       0      0 :::8888                 :::*                    LISTEN      3681/java           
tcp6       0      0 :::8761                 :::*                    LISTEN      3664/java           
tcp6       0      0 :::4000                 :::*                    LISTEN      4021/java           
tcp6       0      0 :::3306                 :::*                    LISTEN      2887/mysqld         
udp        0      0 127.0.0.1:323           0.0.0.0:*                           772/chronyd         
udp6       0      0 ::1:323                 :::*                                772/chronyd  

7.2验证

访问eureka http://<你的ip>:8761
用户名:pig 密码:pig

spring cloud微服务pig的安装部署_第4张图片
image.png

8.部署pig前端

8.1拉取前端代码

[root@oldboy opt]# cd /opt/
[root@oldboy opt]# git clone https://gitee.com/log4j/pig-ui.git
Cloning into 'pig-ui'...
remote: Enumerating objects: 2677, done.
remote: Counting objects: 100% (2677/2677), done.
remote: Compressing objects: 100% (1356/1356), done.
remote: Total 2677 (delta 1363), reused 2220 (delta 1085)
Receiving objects: 100% (2677/2677), 7.81 MiB | 212.00 KiB/s, done.
Resolving deltas: 100% (1363/1363), done.

8.2安装nodejs

#配置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

8.3安装依赖

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

8.4启动pig-ui

[root@oldboy pig-ui]# npm run dev
​
> [email protected] 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的安装部署_第5张图片
image.png
spring cloud微服务pig的安装部署_第6张图片
image.png

安装完成.

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