TheOpenCloudEngine / uEngine-bill

A Kill-bill based SaaS-billing management portal. uEngine team extended the killbill platform to suit enterprise-level requirements such as GUI-based management portal and platform-revinue-share functionalities.
http://uengine.org/products/billing
9 stars 7 forks source link

배포(Docker) 및 유저 가이드 #33

Open SeungpilPark opened 7 years ago

SeungpilPark commented 7 years ago

KPM 으로 플러그인 설치법 https://github.com/killbill/killbill-cloud/blob/master/kpm/README.md#dev-mode

Dev Mode

If you are a developer and either modifying an existing plugin or creating a new plugin, KPM can be used to install the code of your plugin. Before we look at KPM commands, make sure you read the Plugin Development Documentation.

Let 's assume we are modifying the code for the (ruby) cybersource plugin. You would have to first build the plugin package, and then you could use KPM to install the plugin. We suggest you specify a plugin_key with a namespace dev: to make it clear this is not a released version. Also in the case of ruby, the package already contains all the directory structure including the version, so only the location of the tar.gz needs to be specified.

> kpm install_ruby_plugin 'dev:cybersource' --from-source-file="<PATH_TO>/killbill-cybersource-3.3.0.tar.gz"

Let 's assume now that we are modifying the code for the (java) adyen plugin. The plugin first needs to be built using the maven-bundle-plugin to produce the OSGI jar under the target directory. Then, this jar can be installed but here we also need to specify a version since the archive does not embed any filesystem structure but only contains the binary (jar). The same applies with regard to the plugin_key where we suggest to specify a namespace dev:.

> kpm install_java_plugin 'dev:adyen' --from-source-file="<PATH_TO>/adyen-plugin-0.3.2-SNAPSHOT.jar" --version="0.3.2"

The command kpm inspect can be used to see what has been installed. In the case of dev plugin most info related to GROUP ID, ARTIFACT ID, PACKAGING and SHA1 will be missing because no real download occured.

Finally, when it is time to use a released version of a plugin, we first recommend to uninstall the dev version, by using the kpm uninstall command and using the plugin_key and then installing the released version. For instance the following sequence could happen:

> kpm inspect
___________________________________________________________________________________________________________________________
|          PLUGIN NAME |      PLUGIN KEY | TYPE | GROUP ID | ARTIFACT ID | PACKAGING | VERSIONS sha1=[], def=(*), del=(x) |
___________________________________________________________________________________________________________________________
| killbill-cybersource | dev:cybersource | ruby |      ??? |         ??? |       ??? |                      3.3.0[???](*) |
|                adyen |       dev:adyen | java |      ??? |         ??? |       ??? |                      0.3.2[???](*) |
___________________________________________________________________________________________________________________________

> kpm uninstall 'dev:cybersource'
Removing the following versions of the killbill-cybersource plugin: 3.3.0
Done!

> kpm inspect

_____________________________________________________________________________________________________________
| PLUGIN NAME | PLUGIN KEY | TYPE | GROUP ID | ARTIFACT ID | PACKAGING | VERSIONS sha1=[], def=(*), del=(x) |
_____________________________________________________________________________________________________________
|       adyen |  dev:adyen | java |      ??? |         ??? |       ??? |                      0.3.2[???](*) |
_____________________________________________________________________________________________________________

> kpm install_ruby_plugin cybersource
[...]

> kpm inspect
_______________________________________________________________________________________________________________________________________________________
|          PLUGIN NAME |  PLUGIN KEY | TYPE |                          GROUP ID |        ARTIFACT ID | PACKAGING | VERSIONS sha1=[], def=(*), del=(x) |
_______________________________________________________________________________________________________________________________________________________
| killbill-cybersource | cybersource | ruby | org.kill-bill.billing.plugin.ruby | cybersource-plugin |    tar.gz |                 4.0.2[e0901f..](*) |
|                adyen |   dev:adyen | java |                               ??? |                ??? |       ??? |                      0.3.2[???](*) |
_______________________________________________________________________________________________________________________________________________________
SeungpilPark commented 7 years ago

Docker Container 내부의 엔트로피 사용법.

다음은 harbur/haveged 도커파일 내용이다.

FROM ubuntu:14.04
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -yq rng-tools haveged && apt-get clean
ENTRYPOINT ["haveged"]
CMD ["-F"]

실행은

docker run --privileged -d harbur/haveged:1.7c-1

--privileged 는 리눅스 커널의 기능을 Mother host 에서 공유하여 사용할 수 있는 선언이다. uengine-billing docker 를 부팅시킬 때 해당 옵션 및 haveged 를 실행하도록 하기.

uengine-bill Docker (임시 버전 - Mysql 포함)

Ubuntu 14.04 Base

--우분투 도커 실행
$ docker run -i -t ubuntu:14.04 /bin/bash

--설치 파일
$ sudo apt-get update
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:webupd8team/java -y
sudo apt-get update
sudo apt-get install oracle-java8-installer oracle-java8-set-default wget unzip -y

$ cd
$ wget https://s3.ap-northeast-2.amazonaws.com/uengine-bill/1.0.2/bundles.zip
$ wget https://s3.ap-northeast-2.amazonaws.com/uengine-bill/1.0.2/killbill-profiles-killbill-0.18.7-SNAPSHOT.war
$ wget https://s3.ap-northeast-2.amazonaws.com/uengine-bill/1.0.2/uengine-bill-all.sql
$ wget https://s3.ap-northeast-2.amazonaws.com/uengine-bill/1.0.2/reports.zip
$ wget https://s3.ap-northeast-2.amazonaws.com/uengine-bill/1.0.2/uengine-bill-web-1.0.2-SNAPSHOT.war
$ wget https://s3.ap-northeast-2.amazonaws.com/uengine-bill/1.0.2/apache-tomcat-8.0.42.tar.gz

$ sudo mkdir /var/tmp/bundles
$ sudo unzip bundles.zip -d /var/tmp/bundles

$ tar -xvf apache-tomcat-8.0.42.tar.gz
$ cp killbill-profiles-killbill-0.18.7-SNAPSHOT.war apache-tomcat-8.0.42/webapps/killbill.war
$ cp uengine-bill-web-1.0.2-SNAPSHOT.war apache-tomcat-8.0.42/webapps/ROOT.war 
$ chmod +x apache-tomcat-8.0.42/webapps/killbill.war
$ chmod +x apache-tomcat-8.0.42/webapps/ROOT.war
$ rm -rf apache-tomcat-8.0.42/webapps/ROOT

-- Jruby 설치
$ sudo apt-get install curl
$ sudo mkdir -p /var/lib/jruby
$ sudo su (root 권한으로 설치할 것)
$ curl -SL http://jruby.org.s3.amazonaws.com/downloads/1.7.26/jruby-bin-1.7.26.tar.gz \
    | tar -z -x --strip-components=1 -C /var/lib/jruby
$ exit (root 권한 빠져나올 것)

$ sudo vi .bash_profile
.
.
export PATH="/var/lib/jruby/bin:$PATH"

$ source .bash_profile 
$ gem env

--Mysql (추후 외부 연동으로 빠질것)
$ sudo apt-get install mysql-client-5.6 mysql-server-5.6
$ mysql -uroot

CREATE DATABASE killbill CHARACTER SET UTF8 COLLATE UTF8_GENERAL_CI;
DROP USER 'killbill'@'localhost';
CREATE USER 'killbill'@'localhost' IDENTIFIED BY 'killbill';
GRANT ALL PRIVILEGES ON *.* TO 'killbill'@'localhost' identified by 'killbill';
FLUSH PRIVILEGES;

INSERT INTO mysql.user (host,USER,password,ssl_cipher,x509_issuer,x509_subject,authentication_string) value ('%','killbill',password('killbill') ,'', '','',''); 
GRANT ALL PRIVILEGES ON *.* TO 'killbill'@'%'; FLUSH PRIVILEGES;
EXIT;

$ mysql -u killbill -p killbill < uengine-bill-all.sql

Enter password: killbill

$ unzip reports.zip
$ vi seed_reports.sh

#!/usr/bin/env bash

HERE=`cd \`dirname $0\`; pwd`

MYSQL_HOST=${MYSQL_HOST-"127.0.0.1"}
MYSQL_USER=${MYSQL_USER-"killbill"}
MYSQL_PASSWORD=${MYSQL_PASSWORD-"killbill"}
MYSQL_DATABASE=${MYSQL_DATABASE-"killbill"}
.
.

$ sh ./seed_reports.sh
$ sh ./seed_reports.sh

--톰캣 시작에 haveged, mysql 시작 등록
$ cd apache-tomcat-8.0.42
$ vi bin/catalina.sh
.
.
haveged -F &
service mysql start

--Ntp
$ sudo apt-get install ntp

--Entropy
$ sudo apt-get install haveged

vi /etc/default/haveged

.
.
DAEMON_ARGS="-w 1024"

$ update-rc.d haveged defaults

--컨테이너 커밋
$ exit
$ docker commit <container-id> uengine-bill:1.0.2

컨테이너 실행

데몬으로 띄울 경우 docker 옵션 -d 추가하도록 한다.

docker run -m=3000m --privileged -t -i \
-e CATALINA_OPTS='-server -Xms1024m -Xmx2048m -XX:NewSize=512m -XX:MaxNewSize=1024m -XX:PermSize=512m -XX:MaxPermSize=1024m -Djava.awt.headless=true' \
-e JAVA_OPTS='-Djdbc.driver=com.mysql.jdbc.Driver -Dorg.killbill.dao.url=jdbc:mysql://localhost:3306/killbill -Dorg.killbill.dao.user=killbill -Dorg.killbill.dao.password=killbill -Dorg.killbill.billing.osgi.dao.url=jdbc:mysql://localhost:3306/killbill -Dorg.killbill.billing.osgi.dao.user=killbill -Dorg.killbill.billing.osgi.dao.password=killbill -Dorg.killbill.osgi.bundle.install.dir=/var/tmp/bundles -Dorg.killbill.server.test.mode=true -Dorg.killbill.notificationq.main.queue.mode=POLLING -Dorg.killbill.persistent.bus.external.queue.mode=POLLING -Dorg.killbill.persistent.bus.main.queue.mode=POLLING -Dorg.killbill.notificationq.analytics.tableName=analytics_notifications -Dorg.killbill.notificationq.analytics.historyTableName=analytics_notifications_history -Dorg.killbill.catalog.mode=dynamic -Dorg.killbill.payment.retry.days=1,1,1 -Dorg.killbill.mail.smtp.host=smtp.gmail.com -Dorg.killbill.mail.smtp.port=587 -Dorg.killbill.mail.smtp.auth=true -Dorg.killbill.mail.smtp.user=flamingo.workflow@gmail.com -Dorg.killbill.mail.smtp.password=princoprinco9 -Dorg.killbill.mail.from=support@uengine.org -Dorg.killbill.mail.fromname=uengine -Dorg.killbill.mail.useSSL=true -Dorg.killbill.mail.redirect.address=http://192.168.99.100:8080 -Dorg.killbill.invoice.emailNotificationsEnabled=true -Dorg.killbill.invoice.globalLock.retries=200 -Dkillbill.url=http://localhost:8080/killbill -Dkillbill.user=admin -Dkillbill.password=password -Diam.trust.client.key=e74a9505-a811-407f-b4f6-129b7af1c703 -Diam.trust.client.secret=109cf590-ac67-4b8c-912a-913373ada046 -Diam.host=iam.essencia.live -Diam.port=8080' \
-p 8080:8080 --name uengine-bill uengine-bill:1.0.2 /bin/bash /root/apache-tomcat-8.0.42/bin/catalina.sh run