服务器配置xxljob

扩展小知识:

转发=映射

”本地转发”表示ssh发起方(也就是本地)是映射转发者

”远程转发也叫反向隧道”表示ssh发起方是映射真身,远程是映射转发者

也就是ssh发起方是转发者叫本地转发,或本地映射,远程转发是ssh接受方是转发者也就是本地不是转发者

通过ipconfig指令查询获得的p都是内网ip无法直接访问 , 这时候就可以使用内网穿透的方法进行连接

注册 及 配置

首先进入下面网站 ,登录注册

https://natapp.cn/

在这里插入图片描述
选择免费隧道 , 点击购买
在这里插入图片描述
购买完成,在我的隧道中配置
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
windows用户

修改资料中的 start.bat文件

#                      将秘钥改成自己的
start natapp -authtoken=59bb54a64f86b4a6

双击start.bat

可以将外网地址  注册到调度中心中

当云服务器中的调度任务触发时


通知  ====> 外网地址 ====> 转发本地ip+port 

linux用户及mac用户

mac用户根据实际情况下载客户端 https://natapp.cn/#download

linux用户直接将linux文件夹中的natapp拷贝

在Linux/Mac 下 需要先给执行权限

      chmod a+x natapp

​ 然后再运行

     ./natapp

​ linux ,同样给予可执行权限之后,运行

./natapp -authtoken=59bb54a64f86b4a6
xxljob配置参考

引入xxljob依赖

  <dependency>
    <groupId>com.xuxueli</groupId>
    <artifactId>xxl-job-core</artifactId> 
    <version>2.2.0</version>
  </dependency>

准备xxljob配置

@Data
@ConfigurationProperties(prefix = "xxljob")
public class XxJobConfigProperties {
    // 调度中心地址 
    private String adminAddress = "http://localhost:8888/xxl-job-admin";
    // 注册 执行器名称
    private String executorName = "default";
    // 当前执行器端口
    private int executorPort;
    // 日志文件输出路径
    private String logPath;
    // 注册到调度中心的  执行器地址
    private String executorAddress;
}

配置执行器

@Slf4j
@Configuration
@EnableConfigurationProperties(XxJobConfigProperties.class)
public class XxlJobConfig {
	@Autowired
    XxJobConfigProperties xxJobConfigProperties;
    @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        log.info(">>>>>>>>>>> xxl-job config init.");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(xxJobConfigProperties.getAdminAddress());
        xxlJobSpringExecutor.setAppname(xxJobConfigProperties.getExecutorName());
        xxlJobSpringExecutor.setPort(xxJobConfigProperties.getExecutorPort());
        xxlJobSpringExecutor.setLogRetentionDays(30);
        xxlJobSpringExecutor.setLogPath(xxJobConfigProperties.getLogPath());
        xxlJobSpringExecutor.setAddress(xxJobConfigProperties.getExecutorAddress());
        return xxlJobSpringExecutor;
    }
}

application.yml中配置

如果用的虚拟机:

xxljob:
  admin-address: http://192.168.200.130:8888/xxl-job-admin
  executor-name: leadnews-article-executor
  executor-port: 9999
  log-path: C:/xxljob/logs

如果用的云服务器:

xxljob:
  admin-address: http://外网地址:8888/xxl-job-admin
  executor-name: leadnews-article-executor
  executor-port: 9999
  log-path: C:/xxljob/logs
  executor-address: http://qnmgvh.natappfree.cc  # 内网穿透地址  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

攒了一袋星辰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值