spring cloud微服务pig的安装部署1.环境说明2.下载pig项目3.配置本地hosts4.数据的安装和初始化4.1下载数据库4.2安装数据库4.3修改mysql配置文件4.4启动mysql4.5创建pig数据库4.6初始化pig数据库4.7安装并启动redis5.pig配置文件修改5.1redis 密码配置5.2数据库密码配置6.安装maven编译pig6.1准备好jdk和maven的包6.2安装jdk6.3安装maven7.运行pig项目7.1按顺序启动pig各个服务组件7.2验证8.部署pig前端8.1拉取前端代码8.2安装nodejs8.3安装依赖8.4启动pig-ui
中间件 | 版本 | 安装方式 |
---|---|---|
JDK | 1.8 | rpm安装 |
Mysql | 5.7 | 二进制安装 |
redis | 3.2+ | yum安装 |
nodejs | 8.0+ | yum安装 |
maven | 3.6.0 | 二进制安装 |
xxxxxxxxxx
91[root@oldboy ~]# cd /opt/
2[root@oldboy opt]# git clone https://gitee.com/log4j/pig.git
3Cloning into 'pig'...
4remote: Enumerating objects: 12777, done.
5remote: Counting objects: 100% (12777/12777), done.
6remote: Compressing objects: 100% (5330/5330), done.
7remote: Total 12777 (delta 4887), reused 11610 (delta 4432)
8Receiving objects: 100% (12777/12777), 13.89 MiB | 803.00 KiB/s, done.
9Resolving deltas: 100% (4887/4887), done.
xxxxxxxxxx
41127.0.0.1 pig-mysql
2127.0.0.1 pig-redis
3127.0.0.1 pig-gateway
4127.0.0.1 pig-eureka
xxxxxxxxxx
91[root@oldboy opt]# wget http://mirror.sohu.com/mysql/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
2--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
3Resolving mirror.sohu.com (mirror.sohu.com)... 123.125.123.141
4Connecting to mirror.sohu.com (mirror.sohu.com)|123.125.123.141|:80... connected.
5HTTP request sent, awaiting response... 200 OK
6Length: 644399365 (615M) [application/octet-stream]
7Saving to: ‘mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz’
8.......
9
xxxxxxxxxx
311#解压并移动到/app/mysql目录
2[root@oldboy opt]# mkdir -p /app/
3[root@oldboy opt]# tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz
4[root@oldboy opt]# mv mysql-5.7.23-linux-glibc2.12-x86_64 /app/mysql
5[root@oldboy opt]# ls -l /app/mysql/
6total 36
7drwxr-xr-x 2 root root 4096 Jul 12 07:19 bin
8-rw-r--r-- 1 7161 31415 17987 Jun 8 2018 COPYING
9drwxr-xr-x 2 root root 55 Jul 12 07:19 docs
10drwxr-xr-x 3 root root 4096 Jul 12 07:19 include
11drwxr-xr-x 5 root root 230 Jul 12 07:19 lib
12drwxr-xr-x 4 root root 30 Jul 12 07:19 man
13-rw-r--r-- 1 7161 31415 2478 Jun 8 2018 README
14drwxr-xr-x 28 root root 4096 Jul 12 07:19 share
15drwxr-xr-x 2 root root 90 Jul 12 07:19 support-files
16#修改环境变量:
17[root@oldboy opt]# vim /etc/profile
18export PATH=/app/mysql/bin:$PATH
19[root@oldboy opt]# source /etc/profile
20#建立mysql用户和组
21[root@oldboy opt]# useradd mysql
22#创建相关目录并修改权限
23[root@oldboy opt]# mkdir /data/mysql -p
24[root@oldboy opt]# chown -R mysql.mysql /app/*
25[root@oldboy opt]# chown -R mysql.mysql /data/*
26#安装依赖包
27[root@oldboy opt]# yum install -y libaio
28#初始化数据
29[root@oldboy opt]# mysqld --initialize --user=mysql --basedir=/app/mysql --datadir=/data/mysql
30#非常重要,注意查看临时随机密码
312019-07-11T23:27:20.701930Z 1 [Note] A temporary password is generated for root@localhost: =q/zYCK8gq3y
xxxxxxxxxx
101vim /etc/my.cnf
2[mysqld]
3user=mysql
4basedir=/app/mysql
5datadir=/data/mysql
6server_id=6
7port=3306
8socket=/tmp/mysql.sock
9[mysql]
10socket=/tmp/mysql.sock
xxxxxxxxxx
51[root@oldboy opt]# cd /app/mysql/support-files/
2[root@oldboy support-files]# cp mysql.server /etc/init.d/mysqld
3[root@oldboy support-files]# /etc/init.d/mysqld start
4Starting MySQL.Logging to '/data/mysql/oldboy.err'.
5 SUCCESS!
xxxxxxxxxx
41#用到前面的临时随机密码
2mysqladmin -uroot -p'=q/zYCK8gq3y' password root
3mysql -uroot -proot
4mysql> create database pig default character set utf8mb4;
xxxxxxxxxx
21[root@oldboy support-files]# cd /opt/pig/db/
2[root@oldboy db]# mysql -uroot -proot pig <pig.sql
xxxxxxxxxx
51[root@oldboy db]# yum install epel-release.noarch -y
2...输出略
3[root@oldboy db]# yum install redis -y
4...输出略
5[root@oldboy db]# systemctl start redis
vi /opt/pig/pig-config/src/main/resources/config/application-dev.yml
xxxxxxxxxx
41# redis 相关,无密码为空即可,不要修改成IP,修改hosts
2spring
3 redis
4 password
为了简单,强哥在这里建议你redis直接空密码
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
xxxxxxxxxx
51# 数据源,只需要修改密码即可,不要修改成IP,修改hosts
2spring
3 datasource
4 username root
5 password root
如果你的mysql的root用户密码已经是root,那么你不需要修改刚才的三个配置文件
xxxxxxxxxx
21[root@oldboy ~]# ls
2anaconda-ks.cfg apache-maven-3.6.0-bin.tar.gz jdk-8u102-linux-x64.rpm
xxxxxxxxxx
131[root@oldboy ~]# rpm -ivh jdk-8u102-linux-x64.rpm
2Preparing... ################################# [100%]
3Updating / installing...
4 1:jdk1.8.0_102-2000:1.8.0_102-fcs ################################# [100%]
5Unpacking JAR files...
6 tools.jar...
7 plugin.jar...
8 javaws.jar...
9 deploy.jar...
10 rt.jar...
11 jsse.jar...
12 charsets.jar...
13 localedata.jar...
xxxxxxxxxx
141[root@oldboy ~]# tar xf apache-maven-3.6.0-bin.tar.gz -C /usr/local/
2[root@oldboy ~]# ln -s /usr/local/apache-maven-3.6.0 /usr/local/maven
3[root@oldboy ~]# vim /etc/profile
4#文件结尾添加两行
5export M2_HOME=/usr/local/maven
6export PATH=${M2_HOME}/bin:$PATH
7
8[root@oldboy ~]# source /etc/profile
9[root@oldboy ~]# mvn -v
10Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
11Maven home: /usr/local/maven
12Java version: 1.8.0_102, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_102/jre
13Default locale: en_US, platform encoding: UTF-8
14OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
6.4编译pig项目
xxxxxxxxxx
61[root@oldboy ~]# cd /opt/pig/
2[root@oldboy pig]# ls
3db LICENSE pig-common pig-eureka pig-upms pom.xml
4docker-compose.yml pig-auth pig-config pig-gateway pig-visual README.md
5[root@oldboy pig]# mvn clean package
6......
编译成功截图
xxxxxxxxxx
261[root@oldboy pig]# java -jar pig-eureka.jar &>/dev/null &
2[1] 2397
3[root@oldboy pig]# java -jar pig-config.jar &>/dev/null &
4[2] 2419
5[root@oldboy pig]#
6[root@oldboy pig]# java -jar pig-gateway.jar &>/dev/null &
7[3] 2466
8[root@oldboy pig]# java -jar pig-auth.jar &>/dev/null &
9[4] 2495
10[root@oldboy pig]# java -jar pig-upms-biz.jar &>/dev/null &
11[5] 2517
12#等待一段时间之后
13[root@oldboy pig]# netstat -lntup
14Active Internet connections (only servers)
15Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
16tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 3172/redis-server 1
17tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 966/sshd
18tcp6 0 0 :::9999 :::* LISTEN 3858/java
19tcp6 0 0 :::22 :::* LISTEN 966/sshd
20tcp6 0 0 :::3000 :::* LISTEN 3952/java
21tcp6 0 0 :::8888 :::* LISTEN 3681/java
22tcp6 0 0 :::8761 :::* LISTEN 3664/java
23tcp6 0 0 :::4000 :::* LISTEN 4021/java
24tcp6 0 0 :::3306 :::* LISTEN 2887/mysqld
25udp 0 0 127.0.0.1:323 0.0.0.0:* 772/chronyd
26udp6 0 0 ::1:323 :::* 772/chronyd
访问eureka http://<你的ip>:8761
xxxxxxxxxx
91[root@oldboy opt]# cd /opt/
2[root@oldboy opt]# git clone https://gitee.com/log4j/pig-ui.git
3Cloning into 'pig-ui'...
4remote: Enumerating objects: 2677, done.
5remote: Counting objects: 100% (2677/2677), done.
6remote: Compressing objects: 100% (1356/1356), done.
7remote: Total 2677 (delta 1363), reused 2220 (delta 1085)
8Receiving objects: 100% (2677/2677), 7.81 MiB | 212.00 KiB/s, done.
9Resolving deltas: 100% (1363/1363), done.
xxxxxxxxxx
51#配置nodejs yum源
2[root@oldboy pig-ui]# curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
3内容略
4#安装
5[root@oldboy pig-ui]# yum install -y nodejs
xxxxxxxxxx
51#更换npm源
2[root@oldboy pig-ui]# npm config set registry https://registry.npm.taobao.org
3#安装依赖
4[root@oldboy pig-ui]# npm install
5npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
xxxxxxxxxx
141[root@oldboy pig-ui]# npm run dev
2
3> pig-ui@2.3.1 dev /opt/pig-ui
4> vue-cli-service serve
5#输出略
6
7 DONE Compiled successfully in 20926ms 10:38:31 AM
8
9 App running at:
10 - Local: http://localhost:8080
11 - Network: http://192.168.100.100:8080
12
13 Note that the development build is not optimized.
14 To create a production build, run npm run build.
浏览器访问
安装完成