1. Install mypy
$ pip install -U mypy

2. Install PyCharm mypy plugin
- Plugins > Marketplace > Mypy

3. Set path to mypy in mypy plugin settings
- Preferences > Mypy > Path (And Test)

4. Install boto3-stubs with boto3 services you use
$ python -m pip install 'boto3-stubs[s3,athena]'



참고 : 
https://pypi.org/project/boto3-stubs/#installation

# serverless.yml

service: service-name
provider:
  name: aws
  environment:
    FOO: bar

functions:
  hello:
    handler: handler.hello
    FOO2: bar2

 

# Python handler

 

import os
...

FOO = os.environ['FOO'])
...

 

 

참고 :

https://serverless.com/framework/docs/providers/aws/guide/functions#environment-variables

1. Athena JDBC Driver 다운로드

- https://docs.aws.amazon.com/athena/latest/ug/connect-with-jdbc.html

 

 

2. Driver 추가

- [+] 아이콘 > Driver

 

 

1). Genaral 탭

- Name : ex) AWS Athena

- Driver files : [+] 아이콘 > Custom JARs... > 다운로드 받은 Athena JDBC Driver 선택

- Class : com.simba.athena.jdbc.Driver

- URL templates :

# AWS profile 사용시

jdbc:awsathena://AwsRegion=[{host::ap-northeast-2}][\?<;,{:identifier}={:param}>]

# Key, Secret 사용시

jdbc:awsathena://AwsRegion=[{host::ap-northeast-2}][\?<;,UID={user:param},PWD={password:param},{:identifier}={:param}>]

 

2). Advanced 탭

- S3OutputLocation : s3://쿼리-output-버킷명/

- Workgroup : primary

 

# AWS profile 사용시 필요

- AwsCredentialsProviderClass : com.simba.athena.amazonaws.auth.DefaultAWSCredentialsProviderChain

 

 

3. Data Source 추가

- [+] 아이콘> Data Source > AWS Athena

- Name : 원하는 이름

 

# AWS profile 사용시

- Host (AWS region) 확인 후 Test Connection

 

# Key, Secret 사용시

- Host : AWS region

- User : AWS Access Key Id

- Password : AWS Secret Access Key

> Test Connection

 

 

mysqldump on slave
mysql replication backup on slave
mysqldump for additional slave


Master에 영향을 주지 않고 특정 슬레이브에서 덤프를 하고 싶을때
mysqldump option --dump-slave 옵션 사용 가능


예시)
mysqldump --all-databases --dump-slave=2 --single-transaction --order-by-primary -u 계정 -p > /덤프/파일명.sql

--dump-slave=2 : dump를 실행하는 슬레이브에 설정된 Master 서버 정보를 dump 파일에 CHANGE MASTER TO 로 기록

1: 실제 statement로 기록 / 2: CHANGE MASTER TO를 주석 처리


--------------

관련 옵션)
--master-data=2 : dump를 실행하는 서버의 정보를 CHANGE MASTER TO 정보로 기록

마스터에서 직접 dump를 실행할 경우나, 슬레이브에서 슬레이브 체인을 구성할때{M -> S(M) -> S} 활용 가능



참고:
https://dev.mysql.com/doc/refman/5.6/en/mysqldump.html#option_mysqldump_dump-slave

'개발' 카테고리의 다른 글

PHP Session handler Redis 설정  (0) 2017.12.22
Let’s Encrypt SSL 인증서 설치 경로 변경  (0) 2017.12.22
uCloud NAS 연결  (0) 2017.12.22
Hshare Demon Install (CentOS 6.9)  (0) 2017.12.22
[CodeIgniter] URL에서 index.php 제거  (0) 2017.03.20


Ubuntu 12.04, PHP 5.x 기준

PhpRedis 설치

su

cd /tmp
git clone https://github.com/nicolasff/phpredis.git
cd phpredis
phpize
./configure
make && make install
echo extension=redis.so > /etc/php5/conf.d/redis.ini
php -i | grep -E 'Redis Support|Registered save handlers'
  • Redis Support => enabled 확인
  • Registered save handlers => redis 포함 확인

PHP Session handler 설정 변경

vi /etc/php5/apache2/php.ini

-----------------------------
...
;; 주석처리
;session.save_handler = files

;; 아래 내용 추가
session.save_handler = redis
session.save_path = "tcp://레디스서버IP:포트?auth=패스워드"
...

  • Apache 재시작 후 Redis에 세션 데이터 생성 여부 확인
service apache2 restart



참고: https://github.com/phpredis/phpredis


(Let’s Encrypt config directory change)
(Let’s Encrypt certificate directory change)
(/etc/letsencrypt change)



* --config-dir 옵션으로 키파일 위치 변경 가능

$ certbot-auto certonly --webroot --webroot-path=/var/www --config-dir /변경할/디렉토리 -d 도메인 -d 추가도메인


* 인증서 생성시 --config-dir 옵션을 사용해서 설정 디렉토리를 변경한 경우, 이후 certbot-auto 관련 명령시 --config-dir 옵션 추가 필요
$ certbot-auto renew --config-dir /설정한/디렉토리



참고: https://letsencrypt.readthedocs.io/en/latest/using.html#lock-files


- Ubuntu 12.04 기준


사전 확인

  • 과정 중 root 계정 필요
  • 마운트하려는 서버에서 lshw -C network 실행시 eth1 항목이 확인되지 않는다면 uCloud 콘솔에서 CIP 연결 필요함


eth1 interface 추가

$ su

$ vi /etc/network/interfaces
- 아래 내용 추가
auto eth1
iface eth1 inet dhcp

  • 적용

$ service networking restart

$ ifconfig
- eth1 인식 확인


Mount

  • 관련 패키지 설치

$ apt-get update

$ apt-get install nfs-common

  • NAS 볼륨 확인
$ showmount -e 10.xx.xx.xx

  • 대상 디렉토리 생성 후 mount

$ mkdir /대상디렉토리

$ mount -t nfs 10.xx.xx.xx:/볼륨명 /대상디렉토리
$ df -h
- 마운트 확인

  • reboot시에도 마운트 되도록 설정

$ vi /etc/fstab

- 아래 내용 추가
10.xx.xx.xx:/볼륨명       /대상디렉토리    nfs     ru      0       0

  • /etc/fstab 설정 오류 확인

$ mount -a

 

- 오류가 있을 경우에만 해당 사항 출력




참고: https://ucloudbiz.olleh.com/portal/portal.portalinfo.html


====================
Hshare Install
CentOS 6.9
====================

su
yum update -y

## build-essential
yum groupinstall 'Development Tools'


------------
# OpenSSL ECC
------------
## openssl elliptic curve cryptography
cd /usr/local/src/
wget https://www.openssl.org/source/openssl-1.0.2m.tar.gz
tar -zxf openssl-1.0.2m.tar.gz
cd openssl-1.0.2m
./config --prefix=/usr --openssldir=/usr/local/openssl shared
make
make test
make install

## check
openssl version
- (OpenSSL 1.0.2m)
openssl ecparam -list_curves
- (include secp256k1)


------------
# Dependencies
------------
## ld -lz
yum install zlib-devel -y
## Berkeley DB
// yum install db4-devel -y (include zlib)
## Boost
yum install boost-devel -y

## qrencode, miniupnpc
rpm -ivh ftp://195.220.108.108/linux/dag/redhat/el6/en/x86_64/dag/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum install qrencode-devel -y
yum install miniupnpc-devel -y


------------
# Build
------------
cd /usr/local/src/
git clone https://github.com/HcashOrg/Hshare.git hshare
cd hshare/src/

## nano makefile.unix 수정
nano makefile.unix
   기존: -l boost_thread$(BOOST_LIB_SUFFIX) \
   수정: -l boost_thread-mt$(BOOST_LIB_SUFFIX) \
make -f makefile.unix




# Public Node
addnode=52.193.215.1
addnode=119.254.102.218
addnode=139.198.188.182
addnode=124.42.118.99
addnode=121.201.24.167
addnode=209.9.107.116
addnode=13.56.173.122
addnode=54.79.47.132
addnode=13.54.61.175
addnode=34.203.15.31
addnode=52.59.144.109
addnode=35.177.31.30
addnode=52.220.111.66
addnode=13.114.115.237
addnode=13.126.121.197
addnode=35.182.200.22
addnode=54.233.180.109
addnode=52.64.238.215




1. httpd.conf

1) rewrite_module 활성화
#LoadModule rewrite_module modules/mod_rewrite.so
라인 주석 해제
 
2) .htaccess 사용을 위해 AllowOverride 옵션을 All로 변경
#AllowOverride None
AllowOverride All

- 수정 후 Apache 재시작



2. 루트 폴더에 .htaccess 파일 생성

<IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteCond $1 !^(index\.php|images|robots\.txt) # 처리를 제외할 파일이나 디렉토리를 추가
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>




3. CI config.php 수정


- index_page 수정
//$config['index_page'] = 'index.php';
$config['index_page'] = '';



Tomcat catalina.out daily logrotate



1. logrotate 설정 디렉토리로 이동
$ cd /etc/logrotate.d/


2. 설정 파일 생성
$ nano tomcat

/var/local/tomcat/logs/catalina.out {
     copytruncate
     daily
     rotate 30
     missingok
     notifempty
     dateext
}


3. (선택) 현재 파일 강제 갱신
$ logrotate -f /etc/logrotate.d/tomcat




설정 파일 참고 :
http://linuxcommand.org/man_pages/logrotate8.html




+ Recent posts