Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Pig4Cloud
https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com
Admin
Tokens:
131,558
Snippets:
273
Trust Score:
2.1
Update:
1 year ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Frontend Deployment Steps Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/quick-start.mdx Guides through the process of deploying the frontend application, including checking Node.js version, cloning the UI repository, installing dependencies, and starting the development server. ```shell # Check node version (recommended: 18) node -v # If using a higher version, switch to 18 using 'n' command n 18 # Download frontend code git clone https://gitee.com/log4j/pig-ui.git # Install dependencies (using a mirror for potentially faster downloads) npm install --registry=https://registry.npmmirror.com # Start the frontend development server npm run dev # Access the system in your browser: http://localhost:8888 # Default username: admin # Default password: 123456 ``` -------------------------------- ### Install and Run TongRDS Node Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-tongrds-integration.mdx Steps to install and start a TongRDS Service Node. This includes extracting the service node package and running its startup script. ```bash tar -zxvf TongRDS-2.2.1.6.Node.tar.gz cd pmemdb/bin ./StartServer.sh ``` -------------------------------- ### Install and Run TongRDS MC Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-tongrds-integration.mdx Steps to install and start the TongRDS Control Center (MC). This involves extracting the archive, navigating to the directory, and executing the startup script. A license file is also required. ```bash tar -zxvf TongRDS-2.2.1.6.MC.tar.gz cd pcenter # Contact TongFangTong for license file ('licence') cd bin ./StartServer.sh ``` -------------------------------- ### Service Startup Order Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/quick-start.mdx Specifies the recommended order for starting microservices. Core services should be started first, followed by optional services like code generation and monitoring. ```java 1. pig-register/PigNacosApplication.java 2. pig-auth/PigAuthApplication.java 3. pig-upms-biz/PigAdminApplication 4. pig-gateway/PigGatewayApplication.java # Services to start when using code generation or monitoring: 5. pig-codegen/PigCodeGenApplication 6. pig-monitor/PigMonitorApplication 7. pig-quartz/PigQuartzApplication ``` -------------------------------- ### Start Server Applications Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/linux.mdx Commands to start various microservices and a monolithic application in the background using `nohup`. Each command redirects standard output and error to `/dev/null` to prevent logging to the console. ```shell # 微服务版本启动命令 nohup java -Dfile.encoding=utf-8 -jar pig-register.jar > /dev/null 2>&1 & nohup java -Dfile.encoding=utf-8 -jar pig-monitor.jar > /dev/null 2>&1 & nohup java -Dfile.encoding=utf-8 -jar pig-gateway.jar > /dev/null 2>&1 & nohup java -Dfile.encoding=utf-8 -jar pig-auth.jar > /dev/null 2>&1 & nohup java -Dfile.encoding=utf-8 -jar pig-upms-biz.jar > /dev/null 2>&1 & # 单体版本启动命令 nohup java -Dfile.encoding=utf-8 -jar pig-boot.jar > /dev/null 2>&1 & ``` -------------------------------- ### Frontend Deployment Troubleshooting Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/quick-start.mdx Provides troubleshooting steps for common issues during frontend deployment, specifically network problems during `npm install`. ```shell 1. If npm install fails due to network issues, delete the `node_modules` folder in the pig-ui root directory. 2. Re-execute the `npm install` command. 3. Ensure your Node.js version is not too high; version 18 is recommended. ``` -------------------------------- ### Start SkyWalking Server Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-skywalking-integration.mdx 启动 SkyWalking 服务器以开始收集和可视化追踪数据。此命令需要在 SkyWalking 的安装目录下执行。 ```shell sudo bin/startup.sh ``` -------------------------------- ### Install JDK 17 Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/linux.mdx Installs Zulu OpenJDK 17 on a CentOS system using an RPM package. It downloads the package, installs it using `rpm -ivh`, verifies the installation with `java -version`, and installs necessary font packages for graphical applications. ```shell wget https://cdn.azul.com/zulu/bin/zulu17.44.15-ca-jdk17.0.8-linux.x86_64.rpm rpm -ivh zulu17.44.15-ca-jdk17.0.8-linux.x86_64.rpm java -version yum install -y fontconfig mkfontscale ``` -------------------------------- ### Run Frontend Application Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/docker.mdx Navigates to the frontend's Docker directory and starts the frontend application using Docker Compose. It assumes the backend services have already been successfully started. ```shell cd pig-ui/docker # 启动请确保已经启动了后端应用 docker compose up -d ``` -------------------------------- ### Java 8 Date and Time API Examples Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/basics/java8-resources.mdx Provides examples for the new Date and Time API introduced in Java 8, replacing the older `java.util.Date` and `java.util.Calendar`. It covers classes like `LocalDate`, `LocalTime`, `LocalDateTime`, `ZonedDateTime`, and `Period`. ```Java This section links to Java code examples for the new Date and Time API. Please refer to the provided GitHub repository for the actual code. ``` -------------------------------- ### Install and Configure MySQL 8 Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/linux.mdx Installs MySQL 8 server and client on CentOS, configures it to ignore case for table names, restarts the service, and sets a root password. It also modifies user privileges to allow remote access. ```shell wget http://vip.pigx.top/mysql80-community-release-el7-11.noarch.rpm -O mysql80-community-release-el7-7.noarch.rpm rpm -ivh mysql80-community-release-el7-7.noarch.rpm yum install -y mysql mysql-server # 修改配置文件 vim /etc/my.cnf lower_case_table_names=1 # 重启 mysql systemctl restart mysqld # 查看默认密码 grep password /var/log/mysqld.log # mysql client 链接 mysql mysql -uroot -p alter user 'root'@'localhost' identified by 'ZxcRoot123!@#'; set global validate_password.check_user_name=0; set global validate_password.policy=0; set global validate_password.length=1; alter user 'root'@'localhost' identified by 'root'; # 修改为允许远程访问 use mysql; update user set host = '%' where user = 'root'; FLUSH PRIVILEGES; ``` -------------------------------- ### Install RabbitMQ via Docker Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-rabbitmq-integration.mdx Provides the Docker command to run a RabbitMQ instance with the management plugin enabled. This is a quick way to set up RabbitMQ for testing or development. ```shell docker run -d -p 5672:5672 -p 15672:15672 --name rabbitmq rabbitmq:management ``` -------------------------------- ### Install Docker CE on CentOS 7 Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/docker.mdx Installs Docker CE on CentOS 7 using YUM. It includes steps for adding the repository, installing the package, and starting the Docker service. It also checks the Docker version to ensure it meets the requirement of 19.x+. ```shell sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo yum makecache fast sudo yum -y install docker-ce sudo service docker start docker --version ``` -------------------------------- ### Download Project Repository Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/quick-start.mdx Clones the pig microservices project from Gitee to your local machine. This is the first step in the deployment process. ```shell git clone https://gitee.com/log4j/pig.git ``` -------------------------------- ### Spring Data Redis Example Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-tongrds-integration.mdx A Java service class demonstrating basic cache operations (setting and getting keys) using Spring Data Redis, which can be configured to connect to TongRDS. ```java import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; @Service public class RedisService { private final StringRedisTemplate redisTemplate; public RedisService(StringRedisTemplate redisTemplate) { this.redisTemplate = redisTemplate; } public void setKey(String key, String value) { redisTemplate.opsForValue().set(key, value); } public String getKey(String key) { return redisTemplate.opsForValue().get(key); } } ``` -------------------------------- ### Initialize Project Databases Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/quick-start.mdx Executes SQL scripts to initialize the core and Nacos configuration databases. Requires MySQL 5.7.8+ with utf8mb4 charset and utf8mb4_general_ci collation. ```sql -- 核心数据库 source db/pig.sql; -- nacos 配置 source db/pig_config.sql; ``` -------------------------------- ### 添加 log-trace-spring-boot3-starter 依赖 Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-lightweight-log-tracing.mdx 在需要进行日志链路追踪的微服务项目中,添加此 Maven 依赖。该依赖是实现跨服务日志关联和追踪的基础。 ```xml <dependency> <groupId>com.pig4cloud.plugin</groupId> <artifactId>log-trace-spring-boot3-starter</artifactId> <version>3.2.0</version> </dependency> ``` -------------------------------- ### Install Logstash JSON Lines Plugin Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-elk-integration.mdx Steps to install the `logstash-codec-json_lines` plugin within the Logstash Docker container. This involves entering the container, navigating to the bin directory, executing the plugin installation command, exiting, and restarting the Logstash service. ```shell # 进入 logstash 容器 docker exec -it logstash /bin/bash # 进入 bin 目录 cd /bin/ # 安装插件 logstash-plugin install logstash-codec-json_lines # 退出容器 exit # 重启 logstash 服务 docker restart logstash ``` -------------------------------- ### Install Redis Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/linux.mdx Installs the Redis server package on CentOS using yum and restarts the Redis service to ensure it is running. ```shell yum install redis systemctl restart redis ``` -------------------------------- ### 引入多级缓存依赖 Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-multi-level-cache.mdx 在 Maven 项目中引入 `multilevel-cache-spring-boot-starter` 依赖,以启用多级缓存功能。此依赖提供了集成 Caffeine 和 Redis 的 starter。 ```xml <dependency> <groupId>com.pig4cloud.plugin</groupId> <artifactId>multilevel-cache-spring-boot-starter</artifactId> <version>3.0.0</version> </dependency> ``` -------------------------------- ### Install element-china-area-data Package Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-ui-cascade-selector.mdx Instructions for installing the element-china-area-data package using npm or yarn. This package provides data for Chinese administrative divisions for use in cascader components. ```bash npm install element-china-area-data -S ``` ```bash yarn add element-china-area-data -S ``` -------------------------------- ### Initialize CentOS 7 Environment Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/linux.mdx Downloads and executes a CentOS 7 initialization script from a specified URL. This script is intended to perform initial system setup and configuration, requiring a parameter for customization. ```shell curl -O http://vip.pigx.top/os7init.sh sh os7init.sh pig4cloud ``` -------------------------------- ### Build and Push Docker Image with Maven Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/faq/deployment-issues/free-docker-registry.mdx This command sequence uses Maven to build a Docker image and then push it to a configured registry. It assumes the Docker plugin is set up in the Maven project. ```shell mvn docker:build && mvn docker:push ``` -------------------------------- ### Hutool: Get Current Date and Time Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/basics/java-util-usage.mdx Shows how to use Hutool's DateUtil to get the current date and time. The default format is 'yyyy-MM-dd HH:mm:ss', providing a convenient way to access timestamps. ```java DateUtil.now() ``` -------------------------------- ### 添加 RocketMQ 依赖 Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-rocketmq-integration.mdx 展示了如何在 PIG 项目的 Maven POM 文件中添加 RocketMQ 的 Spring Boot Starter 依赖,以便使用 RocketMQ 功能。 ```xml <dependency> <groupId>com.pig4cloud.plugin</groupId> <artifactId>rocketmq-spring-boot3-starter</artifactId> <version>2.2.3</version> </dependency> ``` -------------------------------- ### OAuth2 Token Request Example Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/auth/pig-token-authentication.mdx An example HTTP POST request to the /auth/oauth2/token endpoint for password grant type. It includes necessary headers like Host, Authorization, and Content-Type, along with the username and password in the request body. ```http POST /auth/oauth2/token?grant_type=password&scope=server HTTP/1.1 Host: pig-gateway:9999 Authorization: Basic dGVzdDp0ZXN0 Content-Type: application/x-www-form-urlencoded Content-Length: 32 username=admin&password=YehdBPev ``` -------------------------------- ### Add Maven Dependency Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/integration/pig-api-captcha.mdx Integrates the anti-reptile functionality into your project by adding the `anti-reptile-spring-boot-starter` dependency to your `pom.xml` file. This starter package provides automatic configuration for the anti-reptile features. ```xml <dependency> <groupId>com.pig4cloud.plugin</groupId> <artifactId>anti-reptile-spring-boot-starter</artifactId> <version>0.0.3</version> </dependency> ``` -------------------------------- ### Get Internationalized Messages using MsgUtils Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/function/backend-i18n.mdx 使用 `MsgUtils` 类根据错误码获取国际化消息,支持传入参数进行消息格式化。 ```java MsgUtils.getMessage(ErrorCodes.SYS_USER_USERNAME_EXISTING, username); ``` -------------------------------- ### Initialize Databases Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/deployment/linux.mdx SQL commands to initialize the application's databases. It connects to the MySQL server and sources SQL files for the core application data and Nacos configuration. ```sql mysql -uroot -proot -- 核心数据库 source db/pig.sql; -- nacos配置 source db/pig_config.sql; ``` -------------------------------- ### EnableFeignClients Usage Example (Java) Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/function/enable-pig-feign-clients.mdx Demonstrates the usage of the standard Spring Cloud `@EnableFeignClients` annotation within a Spring Boot application. This typically requires explicit configuration of base packages if not using defaults. ```java @EnableFeignClients @SpringCloudApplication public class PigAdminApplication { } ``` -------------------------------- ### Build Nacos from Source Code Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/basics/nacos-server-implementation.mdx Instructions to clone the Nacos repository, build it using Maven with the release profile, and locate the distribution package for running from source. ```bash git clone https://github.com/alibaba/nacos.git cd nacos/ mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U ls -al distribution/target/ cd distribution/target/nacos-server-$version/nacos/bin ``` -------------------------------- ### MsgUtils Detailed Usage Example Source: https://github.com/wiki-pig4cloud-com/wiki-pig4cloud-com/blob/main/dev/function/backend-i18n.mdx 提供了 `MsgUtils` 的详细 Java 实现示例,展示了如何通过 `MessageSource` 和 `Locale.CHINA` 获取本地化消息,支持无参和带参两种情况。 ```java /** * 通过 code 获取中文错误信息 * @param code 错误码 * @return 错误信息 */ public String getMessage(String code) { MessageSource messageSource = SpringUtil.getBean("messageSource"); return messageSource.getMessage(code, null, Locale.CHINA); } /** * 通过 code 和参数获取中文错误信息 * @param code 错误码 * @param objects 参数 * @return 错误信息 */ public String getMessage(String code, Object... objects) { MessageSource messageSource = SpringUtil.getBean("messageSource"); return messageSource.getMessage(code, objects, Locale.CHINA); } ```