Fork me on GitHub

如何向Nexus上添加第三方Repository

登陆nexus

点击Repositories->Proxy Repository,如下图:
添加

在打开的页面中填入以下三项,然后点保存:
保存

Repository ID:仓库的唯一标识;
Repository Name:仓库的名称,在nexus中用这个来显示某个仓库;
Remote Storage Location:仓库的远程地址;

能看到在nexus中已经有了:
查看
注:Browse Remote这个tab如果没显示出来,刷新一下页面即可。
这个时候Browse Remote下已经能看到远程仓库的结构了,但Browser Storage下没有任何东西,说明构件还都没有从远程仓库拉取到nexus。

选择Public Repositories(这个是nexus对外的仓库地址),把getui从右边添加到左边,表示把getui的仓库添加到Public group中,这样才能对外可见。
设置权限
注:Browse Remote这个tab如果没显示出来,刷新一下页面即可。

在自己的maven项目中,配置依赖关系:

1
2
3
4
5
<dependency>
<groupId>com.gexin.platform</groupId>
<artifactId>gexin-rp-sdk-http</artifactId>
<version>4.0.1.7</version>
</dependency>

这样,项目首先会去nexus检索看有没有这个jar,如果没有,再在nexus中检索有没有这个jar相关的仓库配置,发现有,然后会去getui这个仓库将所有相关jar拉取到nexus中,然后下载到你本机的.m2目录下。这时,可以看到nexus的getui这个仓库的Browser Storage下也有了这些jar:
结果

从日志恢复数据

循环遍历日志

1
2
3
stat.txt
2016-11-09 00:00:23 "deviceId":"F9D4F729-7EE7-467F-BF3F-7D9D008EAB" "userId":"20048603"
2016-11-09 00:00:29 "deviceId":"c96996784f99e106c32138940da2987c" "osSystem":"Android6.0" "userId":"20066192"

过滤出无用字段(类似循环处理)

1
2
grep -i -v "osSystem" stat1.txt >> stat11.txt
grep -i "osSystem" stat1.txt >> stat12.txt

ffmpeg 编译安装

系统环境
Ubuntu 14.04.3 LTS
最近测试ffmpeg转推,使用老版本ffmpeg流转推一段时间会断掉,测试发现在新版本ffmpeg效果明显好很多。但是由于依赖众多(主要问题),编译花费了好长时间。
记录下编译过程。

ffmpeg 编译安装
依赖安装

1
2
3
4
5
6
7
apt-get install yasm pkg-config
apt-get install gnutls-bin libgnutls-dev libass-dev libfdk-aac-dev
libmp3lame0 libmp3lame-dev libpulse0 libpulse-dev libsoxr0 libsoxr-dev speex libspeex-dev libopus0 libopus-dev libvpx1 libvpx-dev
libwavpack1 libwavpack-dev
apt-get install libx264-dev libxvidcore-dev libopencore-amrwb-dev libopencore-amrnb-dev libfaad-dev libfaac-dev libmp3lame-dev libtwolame-dev liba52-0.7.4-dev libcddb2-dev libcdaudio-dev libcdio-cdda-dev libvorbis-dev libopenjpeg-dev
add-apt-repository ppa:sunab/kdenlive-release
apt-get install libvidstab1.0 libvidstab-dev

nginx 负载均衡配置

环境介绍

1
2
3
4
nginx version: nginx/1.10.1
负载机器:192.168.1.168 80
upstream机器:192.168.1.169:81
192.168.1.170:81

nginx安装

1
2
3
4
5
6
7
wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
#For Ubuntu 14.04 replace codename to trusty
deb http://nginx.org/packages/ubuntu/ trusty nginx
deb-src http://nginx.org/packages/ubuntu/ trusty nginx
apt-get update
apt-get install nginx

grafana influxdb构建自定义监控

grafana 安装

1
2
3
4
5
$ wget https://grafanarel.s3.amazonaws.com/builds/grafana_3.0.4-1464167696_amd64.deb
$ sudo apt-get install -y adduser libfontconfig
$ sudo dpkg -i grafana_3.0.4-1464167696_amd64.deb
/etc/init.d/grafana-server start/stop/status
http://192.168.1.158:3000/ admin/admin

influxdb 安装

1
2
3
wget https://dl.influxdata.com/influxdb/releases/influxdb_1.0.2_amd64.deb
sudo dpkg -i influxdb_1.0.2_amd64.deb
web访问influxdb http://192.168.1.158:8083/

Percona Toolkit使用小结

Percona Toolkit安装
1、下载包
2、安装

1
2
3
4
perl Makefile.PL
make
make test
make install

pt-online-schema-change 在线修改表结构

修改表结构前,切记备份!!!
pt-osc原理:
1、创建一个和要执行 alter 操作的表一样的新的空表结构(是alter之前的结构)
2、在新表执行alter table 语句(速度应该很快)
3、在原表中创建触发器3个触发器分别对应insert,update,delete操作
4、以一定块大小从原表拷贝数据到临时表,拷贝过程中通过原表上的触发器在原表进行的写操作都会更新到新建的临时表
5、Rename 原表到old表中,在把临时表Rename为原表
6、如果有参考该表的外键,根据alter-foreign-keys-method参数的值,检测外键相关的表,做相应设置的处理
7、默认最后将旧原表删除

Smokeping nginx 安装小记

nginx支持cgi

1
aptitude install fcgiwrap

nginx配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
smokeping.conf
server {
listen 80;
server_name 192.168.1.158;
#charset koi8-r;
access_log /data/log/nginx/smokeping_access.log ;
error_log /data/log/nginx/smokeping_error.log;
root /opt/smokeping;
index index.html index.htm index.php portal.php default.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# Include this file on your nginx.conf to support debian cgi-bin scripts using
# fcgiwrap
location ~ .*\.fcgi$ {
# Disable gzip (it makes scripts feel slower since they have to complete
# before getting gzipped)
gzip off;
# Set the root to /usr/lib (inside this location this means that we are
# giving access to the files under /usr/lib/cgi-bin)
root /opt/smokeping/htdocs;
# Fastcgi socket
fastcgi_pass unix:/var/run/fcgiwrap.socket;
# Fastcgi parameters, include the standard ones
include /etc/nginx/fastcgi_params;
# Adjust non standard parameters (SCRIPT_FILENAME)
#fastcgi_param SCRIPT_FILENAME /usr/lib$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /opt/smokeping/htdocs$fastcgi_script_name;
}
# deny access to .htaccess files, if Apache's document root
location ~ /\.ht {
deny all;
}
}

Zabbix 3.0 安装小记

zabbix_server部署

1、Zabbix 3.0 for Ubuntu 14.04 LTS:

1
2
3
4
5
wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+trusty_all.deb
dpkg -i zabbix-release_3.0-1+trusty_all.deb
apt-get update
apt-get install zabbix-server-mysql zabbix-frontend-php #安装server和frontend
apt-get install zabbix-agent #安装agent

2、初始化数据库

1
2
cd /usr/share/doc/zabbix-server-mysql
zcat create.sql.gz | mysql -uroot zabbix

Supervisor进程管理

Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动、重启、关闭进程。

Supervisor安装

1
apt-get install supervisor

Supervisor配置文件

默认配置文件/etc/supervisor/supervisord.conf
如过没有,生成默认配置文件

1
2
3
4
echo_supervisord_conf > /etc/supervisor/supervisord.conf
[supervisord] #supervisord本身的日志配置
logfile=/var/log/supervisor/supervisord.log ;
pidfile=/var/run/supervisord.pid ;

添加管理的java进程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
hello.conf
[program:showchat]
directory = /home/ljd/hello
command = /usr/local/jdk/bin/java -Xmx512M -Xms512M -classpath hello.jar com.ljd.Hello
autostart = true #子进程随supervisord启动而启动
startsecs = 5 #进程启动后跑了几秒,才被认定为成功启动。默认1
autorestart = true #子进程挂掉将被无条件重启
numprocs=1 #启动线程数目
user = rgbvr #指定运行用户
environment=CHAT_SETTING_HOME=/opt/hello/config #指定程序环境变量
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 20
redirect_stderr = true
stdout_logfile = /home/ljd/hello.log