2013년 11월 26일 화요일

모든 테이블 복구 하기. (all tables should be repaired in mysql)

모든 테이블을 리페어 하는 Stored procedure 를 작성할 필요가 있어서, 적어 봅니다.


alll tables should be repaired using open cursor in mysql.


DELIMITER $$
USE `getty`$$
DROP PROCEDURE IF EXISTS `test_repair_all`$$
CREATE DEFINER=`database name`@`%` PROCEDURE `test_repair_all`()
BEGIN
DECLARE pTableName VARCHAR(64);
DECLARE noMoreRows BOOLEAN DEFAULT FALSE;

DECLARE curTableList CURSOR FOR
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE 1=1
AND TABLE_SCHEMA = 'database name'
LIMIT 1;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET noMoreRows = TRUE;

OPEN curTableList; curTableListLoop: LOOP
IF ( noMoreRows ) THEN
CLOSE curTableList;
LEAVE curTableListLoop;
END IF;

FETCH curTableList INTO pTableName;

SET @s = CONCAT('repair table database name.', pTableName);
PREPARE stmt FROM @s;
EXECUTE stmt;

END LOOP curTableListLoop;

END$$

DELIMITER ;

2013년 11월 25일 월요일

테이블 정보 얻어 오기 - get information of table / column from each database (Oracle, MS-SQL, Mysql)

####################[오라클] 테이블 목록, 프로시저, 패키지 목록(패키지 내용등) 가져오는 방법 ####################
오라클에서 테이블, 프로시저, 패키지 목록 가져오는 방법
select * from all_objects;
select * from sys_objects;
select * from user_objects;
오라클에서 프로시저, 패키지등의 내용 가져오는 방법
select * from USER_SOURCE;
select * from ALL_SOURCE;
 
오라클에서 테이블의 칼럼 목록 가져오는 방법
select * from cols;




#################### [DB2]시스템정보보기 (테이블/칼럼정보등) ####################
list tables for schema CCS
- - SELECT TABNAME,INDNAME,COLNAMES
,UNIQUERULE,INDEXTYPE
FROM SYSCAT.INDEXES
WHERE TABSCHEMA='CCS' ;
-- DESCRIBE TABLE 테이블이름
===== 참조카달로그뷰===
참고로 DB2에 있는 시스템 카탈로그 뷰 입니다.
=========================================
SYSCAT.CHECKS 점검제한조건
SYSCAT.COLUMNS 컬럼
SYSCAT.COLCHECKS 점검 제한 조건이 참조하는 컬럼
SYSCAT.KEYCOLUSE 키에서 사용되는 컬럼
SYSCAT.DATATYPES 데이터 유형
SYSCAT.FUNCPARMS 함수 매개변수 또는 함수의 결과
SYSCAT.REFERENCES 참조 제한 조건
SYSCAT.SCHEMATA 스키마
SYSCAT.TABCONST 테이블 제한 조건
SYSCAT.TABLES 테이블
SYSCAT.TRIGGERS 트리거
SYSCAT.FUNCTIONS 사용자 정의 함수
SYSCAT.VIEWS 뷰
=========================================
===테이블조회 ============================
select TABNAME,COLNAME,TYPESCHEMA,LENGTH,NULLS,DEFAULT,REMARKS
from SYSCAT.COLUMNS
where TABSCHEMA ='CCS' --AND TABNAME = 'TBH001'
ORDER BY TABNAME,COLNO
===========================================

#################### [Mysql] 테이블/컬럼/인덱스 목록 가져오기 ####################
=> 테이블정보 조회
SELECT TABLE_SCHEMA, 
       TABLE_NAME, 
       TABLE_COMMENT , 
       AUTO_INCREMENT 
  FROM INFORMATION_SCHEMA.TABLES 
 WHERE TABLE_TYPE = 'BASE TABLE' 
       AND TABLE_NAME = 'table_nameXXX' ;  

=> 컬럼정보조회
SELECT COLUMN_COMMENT, 
       COLUMN_TYPE, 
       COLUMN_KEY, 
       COLUMN_NAME, 
       IS_NULLABLE
  FROM INFORMATION_SCHEMA.COLUMNS 
 WHERE TABLE_NAME = ' table_nameXXX ' 
       AND TABLE_SCHEMA = 'xxxxxxxxxxxxxx'

2013년 11월 7일 목요일

MySQL error 1236: Client requested master to start replication from impossible position

원인 (cause)
===========
I/O 부하 / 등 여러가지 이유로 인해 Master / Slave 의 Replication이 깨진 상황.
( Client requested master to start replication from impossible position )

현황(status)
===========
mysql>show master status;
localhost-bin.000001 = 400

mysql>show slave status;
localhost-bin.000001 = 100

mysql log
=========
131104 16:16:57 [Note] Slave I/O thread: connected to master 'replicator@121.78.118.224:3306',replication started in log 'localhost-bin.000001' at position 20031086
131104 23:05:39 [ERROR] Error reading packet from server: error reading log entry ( server_errno=1236)
131104 23:05:39 [ERROR] Got fatal error 1236: 'error reading log entry' from master when reading data from binary log
131104 23:05:39 [Note] Slave I/O thread exiting, read up to log 'localhost-bin.000001', position 22002773


결과
===========
Salve 서버의 로그 포지션을 마스터와 일치하게 한 후, Slave 다시 시작.

STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_POS = 0;
CHANGE MASTER TO MASTER_LOG_FILE = 'mysql-bin.000014';
START SLAVE;

2013년 10월 30일 수요일

MS MCP 자격증 조회및 관리 사이트접속하기

1. 사이트에 접속하여 자격증 조회

https://mcp.microsoft.com/mcp/Default.mspx 에 접속하여 MSN 인증을 통해 자격증을 확인할 수 있다.

2. 사이트에서 MCP ID / Access Code 코드를 물어보는 경우, 받은 메일을 확인하여 입력하여 확인 가능

3. Access Code 가 없을 경우
https://mcp.microsoft.com/Authenticate/ResetAccessCode/ResetAccessCode.aspx
를 이용하여 Access Code를 임시로 발급 받을 수 있다.

4. 이도저도 않되면 전화다.
전화 : 080-605-0880
한글 :1 => 1 : 인증 => 1: 인증,  담당자 통화 후 계정 정보를 확인하고 메일로 보내 준다.

메일은 30분 이내로 도착한다고 이야기 해 준다.

2013년 10월 22일 화요일

Installing Apache Solr on Windows with Tomcat

Installing Apache Solr on Windows with Tomcat


15

FEB

By: bhanuism


1) JDK


Install java development kit  preferably version 1.6 or greater.


2)Tomcat


As a complete web dev environment for windows i recommend using XAMPP. It comes with built in Tomcat servlet, so you won’t have to waste your time installing tomcat. Well regarding version of tomcat, i have successfully tested solr on tomcat 5,6 and 7.

Tomcat can be managed from xampp control panel or you can install it as a windows service so that it can be run independently from xampp. Well doesn’t matter much whether it is xampp service or a windows service. To install it as a windows service run the ‘service‘ batch file in c:\xampp\tomcat\bin .

After installation to check if tomcat is running open you browser and ping

 localhost:8080




Xampp download

http://www.apachefriends.org/en/xampp-windows.html#641


3) Solr install


Download the latest solr release which is currently solr 3.6. Download the tarball fromhere and extract it to say  downloads\apache-solr-3.6.0


a) Preparing solr home directory

Make a new directory in C:\ and name it solr.

Copy dist and contrib directories from downloads\apache-solr-3.6.0 i.e.downloads\apache-solr-3.6.0\dist and downloads\apache-solr-3.6.0\contrib toC:\solr\dist and C:\solr\contrib

Make a directory named solr inside C:\solr and copy  downloads\apache-solr-3.6.0\example directory contents to it. Now C:\solr\solr is what is called solr home.

b) Configuring tomcat to detect solr

Copy  downloads\apache-solr-3.6.0\dist\apache-solr-3.6.0.war file toC:\xampp\tomcat\webapps directory and rename it to solr. If tomcat service is on you will find that a solr directory is automatically created. If tomcat is off don’t bother it would be created next time tomcat starts.


2.    Now run C:\xampp\tomcat\bin\tomcat7w.exe (7 is for the version), select java tab and in java options pane write -Dsolr.solr.home=C:\solr\solr . Click OK and configuration is done. Restart tomcat.


c) Test solr

In your browser enter localhost:8080/solr/admin and you will see.


That’s it. Solr is installed and now it can be used to do fast searching on huge amount of data from any source be it a sql database or a file. But to do that a lot of work still needs to be done related to request handlers and schemas. In the future posts i will be talking about the internals of solr.


Copy from: http://solrapache.blogspot.com/2012/06/installing-apache-solr-on-windows-with.html


——————————————————————————————————————————-


Notation: if you want to query solr with json data please add &wt=json in the end of line


——————————————————————————————————————————-

2013년 10월 10일 목요일

Imagemagick 사용 예제 사이트(linked example site)


convert input.jpg -pointsize 80 -draw "gravity center fill black text 0,0 'Rubblewebs' " output.png

2013년 10월 7일 월요일

squid 에서 특정 캐시 삭제.

아직 발생하지 않아, 실행해 보지 않음.



proxy에서는 PURGE를 지원하고 있습니다.
쉽게 풀어 쓰면.. 특정 캐시를 삭제할 수 있는 method를 지원하고 있습니다.
일반적으로,
- 정상적으로 삭제하면 HTTP STATUS CODE 200 OK를
- 실패했을 경우 HTTP status code 404를
- 서버에서 PURGE method가 지원되지 않을 경우 403을 반환합니다.

제가 사용하고 있는 squid의 예를 들어 간단하게 설명하겠습니다.

[squid.conf] 수정(EDIT)
#--------------------------------
# acl 정책
#--------------------------------
......
acl PURGE method PURGE
acl MethodType method GET POST PURGE
......

#--------------------------------
# TAG: http_access
#--------------------------------
........
http_access deny !MethodType // 3개의 method 외 차단
........
http_access allow PURGE localhost // PURGE를 localhost에서 허용
http_access deny purge // PURGE 그 외 네트워크 대역 차단
.........
[squid.conf] reload
[root@ns1 ~]# /etc/init.d/squid reload 또는
[root@ns1 ~]# squid -k reconfigure

[squid.conf] 삭제(DELETE)
[root@ns1 ~]# telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
PURGE http://www.rootman.co.kr/images/AAA.jpg HTTP/1.0
HTTP/1.0 404 Not Found
Server: squid/2.5.STABLE14
Mime-Version: 1.0
Date: Fri, 08 May 2009 14:51:37 GMT
Content-Length: 0

Connection closed by foreign host.

일반적으로 정상적으로 삭제되면 HTTP status code 200 OK 가 나타나고,
실패했을 경우 404(not found), purge method가 지원되지 않을 경우 403 status code가 나타납니다.
하지만, 저는 좀 특이하게 쓰는지라... 404가 나왔습니다...
log를 보면 정상적으로 삭제된 것을 확인할 수 있습니다.

[access.log] squid 로그
127.0.0.0 - - [09/May/2009:00:44:02 +0900] "PURGE http://www.rootman.co.kr/images/AAA.jpg HTTP/1.0" 404 129 TCP_MISS:NONE
// purge 처리를 하여 AAA.jpg가 삭제 처리되어 squid 처리 후 cache에 없다는 것을 확인(TCP_MISS)

119.194.111.0 - - [09/May/2009:00:44:10 +0900] "GET http://www.rootman.co.kr:1111/images/AAA.jpg HTTP/1.1" 200 34305 TCP_HIT:NONE
// cache에 파일이 없으므로, 웹서버에서 AA.jpg를 읽어들여 caching함(TCP_HIT)
119.194.111.0 - - [09/May/2009:00:44:14 +0900] "GET http://www.rootman.co.kr:1111/images/AAA.jpg HTTP/1.1" 304 246 TCP_IMS_HIT:NONE
// cache에 파일이 있고, 재요청 시 캐시에서 read (TCP_IMS_HIT,브라우저캐싱)