Skip to content

Instantly share code, notes, and snippets.

View yangl's full-sized avatar
🎯
Focusing

YANGLiiN yangl

🎯
Focusing
View GitHub Profile
input {
file {
path => ["/data/metricslog/alive/*.log"]
start_position => "beginning"
type => "metrics-alive"
}
file {
@yangl
yangl / tomcat重启 restartall.sh
Last active May 22, 2016 10:20
tomcat配置相关 ./catalina.sh stop 0 -force是先通过调用Tomcat的shutdown端口关闭,然后再kill进程。
for i in {1..7};do
cd server$i
./stop.sh && ./start.sh
cd ../
done
@yangl
yangl / logcron.sh
Created September 22, 2015 11:39
定时切割删除日志
#!/bin/sh
log_dir="/data/metricslog"
date_dir=`date +%Y-%m-%d --date='yesterday'`
cd $log_dir
while read line
do
mv ./nginx/$line/metrics.access.log ./nginx/$line/metrics.access.log-$date_dir
@yangl
yangl / HttpClient.java
Last active May 18, 2018 01:54
OkHttpClient请求简单封装,支持重试、超时配置
package com.uxin.metrics.util;
import com.alibaba.fastjson.JSON;
import com.squareup.okhttp.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.backoff.BackOffPolicy;
@yangl
yangl / nginx-sticky-module用户session例子
Last active January 12, 2017 03:42
nginx-sticky-module使用说明
1.cd $NGINX_HOME,执行./sbin/nginx -V 查看安装参数;
2.得到安装参数后,添加nginx-sticky-module模块重新编译nginx,
./configure "之前的参数" --add-module=/nginx-sticky-module下载所在目录/nginx-sticky-module
make && make install
3.在upsteam中添加如下:
sticky name=srv_id expires=1h domain=uxin.com path=/;
@yangl
yangl / nginx手机端跳转配置.conf
Last active March 2, 2020 13:19
nginx根据user-agent手机端跳转,nginx rewrite详见:http://seanlook.com/2015/05/17/nginx-location-rewrite/
location = / {
if ($http_user_agent ~* "(Android|iPhone|iPod|Symbian|BlackBerry|Windows Phone|Mobile|J2ME)") {
rewrite ^ http://m.uxin.com permanent;
}
#htpasswd密码生成可用在线工具http://tool.oschina.net/htpasswd,加密方式选Crypt
auth_basic_user_file /data/soft/nginx/conf/htpasswd;
auth_basic "please input passwd, or contact YANGL";
@yangl
yangl / GuavaCache及@Value使用例子.java
Last active January 12, 2017 03:41
guava cache使用例子。。。注意在查询数据库时没有记录的情况,暂时获取CacheLoader.InvalidCacheLoadException异常,或者存放默认数据并标示NoDATA!@value注入static属性时注意要加到其非静态setter方法上即可!
package com.uxin.starclock.manage.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.uxin.starclock.common.Constant;
import com.uxin.starclock.common.exception.BaseException;
import com.uxin.starclock.dto.IncallringDto;
@yangl
yangl / cloudera安装文档.txt
Created April 1, 2016 04:26
cloudera安装文档
1.各个节点安装必需的包
yum install -y openssh openssh-clients vim libxslt libaio
2.配置ssh无密码认证(个人认为可以忽略的步骤)
(1)修改hosts.allow 将新的IP都加进去
(2)修改ssh的配置文件 允许root登录 ,再重启ssh服务
(3)在一台机器上ssh所有机器,获取所有的机器的公钥,再生成自己的ssh-key,无密码登录自己,把.ssh目录打包,传到每个机器上
3.修改hosts文件
@yangl
yangl / mysql.sh
Last active June 1, 2016 09:42
查询SQL并输出,动态拼表名
dd=`date -d yesterday "+%Y%m%d"`
sql="select count(1) c, status from t_customgift_${dd} where if_outapppush=1 group by status;"
mysql -h10.10.130.109 -ugrowth_log -pgrowth_uxin_com -Dgrowth -P3307 -e "${sql}"
@yangl
yangl / MetricsLog4j2ConfigurationFactory.java
Last active January 3, 2018 06:20
log4j2配置例子及使用编码方式增加配置(Log4j2.7+ 参数配置,避免外部项目再在配置文件中配置并防止他人修改)
package com.uxin.metrics.client;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender;
import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;