用户工具

站点工具


侧边栏

Welcome to Skyline-Wiki

Other

other:note

临时的笔记

Java

nginx 真实 ip 问题

tomcat 通过 nginx 做反向代理后,获取客户端 ip 时拿到的是 nginx 的 ip,并非真实客户 ip

解决方案:
在 nginx 配置文件中添加下面的一条配置,将真实 ip 加入请求头中
proxy_set_header X-Real-IP $remote_addr;

再通过 java 代码取出对应的请求头,即可拿到真实 ip

public static String getIpAddr(HttpServletRequest request) {
	String ipFromNginx = request.getHeader("X-Real-IP");
	if (StringUtils.isNotBlank(ipFromNginx) && !"unknown".equalsIgnoreCase(ipFromNginx)) {
		return ipFromNginx;
	} else {
		String remoteAddr = request.getRemoteAddr();
		return remoteAddr;
	}
}

Nginx 代理 WebSockets

通过增加 Upgrade 和 Connection 头信息,来支持代理 WebSocket

location /websocket/ {
	proxy_pass http://websocket;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
}

OSGI 基础

Eclipse Mars.2 最小 OSGI 启动环境:

Run Configurations > Bundles:

Target Platform:
 org.apache.felix.gogo.runtime
 org.apache.felix.gogo.shell
 org.eclipse.equinox.console
 org.eclipse.osgi

Run Configurations > Arguments:

Program arguments:
 -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console -clean

运行 ss 命令后输出:

osgi> ss
"Framework is launched."

id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.10.102.v20160118-1700
1	ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
2	ACTIVE      org.eclipse.equinox.console_1.1.100.v20141023-1406
3	ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
osgi>

SQL

部分内容已迁移

SELECT INTO 和 INSERT INTO SELECT 两种表复制语句

Oracle 查询被锁定表

SELECT 
  O.OBJECT_NAME, 
  S.MACHINE, 
  S.TERMINAL,
  S.USERNAME,
  S.OSUSER,
  S.PROGRAM,
  S.SID, 
  S.SERIAL#
FROM 
  GV$LOCKED_OBJECT L, 
  DBA_OBJECTS O, 
  GV$SESSION S 
WHERE 
  L.OBJECT_ID  = O.OBJECT_ID 
  AND L.SESSION_ID = S.SID;
-- 杀掉会话
ALTER SYSTEM KILL SESSION 'SID,SERIAL#';

Oracle 其他待学习函数

OVER()

WITH TEMP AS (
	SELECT '01' AS A, '11' AS B, '111' AS C FROM DUAL UNION ALL
	SELECT '01' AS A, '12' AS B, '121' AS C FROM DUAL UNION ALL
	SELECT '01' AS A, '12' AS B, '122' AS C FROM DUAL UNION ALL
	SELECT '02' AS A, '21' AS B, '211' AS C FROM DUAL UNION ALL
	SELECT '02' AS A, '22' AS B, '221' AS C FROM DUAL UNION ALL
	SELECT '03' AS A, '31' AS B, '311' AS C FROM DUAL
) SELECT * FROM (SELECT A, B, C, MAX(B) OVER (PARTITION BY A ) AS MAXS FROM TEMP) WHERE B = MAXS;

ROW_NUMBER()

SELECT T1.* FROM (
  SELECT ROW_NUMBER() OVER(PARTITION BY LYDH ORDER BY RKSJ DESC) RN, SUM(T.SSCS) OVER(PARTITION BY LYDH) SUM, T.LYDH, T.RKSJ, T.RKR FROM T_ERP_SHZTMX T
) T1 WHERE T1.RN = 1;
SELECT TRUNC(SYSDATE,'dd') FROM DUAL; --2013-01-06 返回当前年月日
SELECT TO_CHAR('0.8', 'FM99990.00') FROM DUAL;
-- 创建表同时创建散列分区
CREATE TABLE T_ERP_SMXSLSJLB_TEST
PARTITION BY HASH (KHMC)
 PARTITIONS 10
AS SELECT * FROM T_ERP_SMXSLSJLB_BAK WHERE ROWNUM < 100;
-- 散列分区分布
SELECT DBMS_ROWID.ROWID_OBJECT(ROWID) OBJ_ID, COUNT(*) FROM T_ERP_SMXSLSJLB_TEST GROUP BY DBMS_ROWID.ROWID_OBJECT(ROWID);
-- 创建局部索引
CREATE INDEX T_ERP_SMXSLSJLB_TEST_INDEX ON T_ERP_SMXSLSJLB_TEST(KHMC) LOCAL;
-- 删除表
DROP TABLE T_ERP_SMXSLSJLB_TEST;
-- 查询用户表分区
SELECT * FROM USER_TAB_PARTITIONS;
-- 查询用户回收站
SELECT * FROM USER_RECYCLEBIN;
SELECT COUNT(*) FROM USER_RECYCLEBIN;
-- 根据表名恢复表结构
FLASHBACK TABLE T_ERP_SMXSLSJLB_TEST TO BEFORE DROP;
FLASHBACK TABLE "BIN$cd3tXq/iGjngUzgKqMDBqA==$0" TO BEFORE DROP;
-- 清空回收站指定数据
PURGE TABLE "BIN$ceEiEsddHK3gUzgKqMACNA==$0";

其他技术

other/note.txt · 最后更改: 2019/06/19 02:58 由 devin