개발 환경 :  ubuntu 18, php7.4, mysql 8.0

 

1. Mysql 설치

apt-get update
apt-get -y install mysql-server mysql-client
mysql -u root -p

 

create database HDVP;

create user 'HDVP'@'%' identified by '&HDVP@1234@HDVP';

grant all on HDVP.* to 'HDVP'@'%';


flush privileges;

use HDVP;

create table users (
         idx int not null auto_increment primary key,
         id char(20),
         name varchar(100),
         pw char(20)
         );

insert into users(id, name, pw) values('admin', '관리자', 'toor');
mysql -u HDVP -p


/etc/mysql/mysql.conf.d

vi mysqld.conf


bind-address            = 0.0.0.0
x   = 0.0.0.0

 

service mysql start

 

2. nginx + php 설치


apt-get -y install nginx

service nginx start

apt-get -y install php7.4-fpm

cd /etc/nginx/
vi nginx.conf

 

cd /etc/nginx/sites-available/
vi default


# 아래와 같이 수정

server {
    listen 80;
    listen [::]:80;
    root /var/www/html;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

server {
    listen 80;
    listen [::]:80;
} 

 

 


cd /etc/php/7.4/fpm/
vi php.ini        40% 즘

service php7.4-fpm reload
service nginx reload

cd /var/www/html/

vi info.php
<?php
phpinfo();
?>

 


http://ip주소/info.php

 

apt-cache search php7.4


apt-get -y install php7.4-mysql php7.4-curl php7.4-gd php7.4-intl php-pear php-imagick php7.4-imap
     php7.4-mcrypt php-memcache  php7.4-pspell php7.4-recode php7.4-sqlite3 php7.4-tidy
     php7.4-xmlrpc php7.4-xsl php7.4-mbstring php-gettext


apt-get -y install php-apcu

service php7.4-fpm reload

 

 index.php

 
<?php
$conn = mysqli_connect(
  'localhost',
  'HDVP',
  '&HDVP@1234@HDVP',
  'HDVP');
$sql = "SELECT * FROM users WHERE id = 'admin'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
echo $row['id'];
echo '<h1>'.$row['name'].'</h1>';
?>

 

 

 

 

 

 

 


 

'' 카테고리의 다른 글

DB튜닝 테이블에 데이터가 많은 경우  (0) 2021.01.31
라디오 버튼 제이쿼리  (0) 2020.08.24
GS인증(보안성)  (7) 2020.04.13
express + morgan  (0) 2019.04.01
promise  (0) 2019.03.28
블로그 이미지

iesay

,

 

 

현재 저희는 eth 노드를 GO-language 로 구현한 go eth 를 줄인 geth 라는 이더리움 노드를 사용하고 있습니다. 설치 방법은 비트코인계열과 마찬 가지로 제공 하는 방법을 그대로 따라합니다

 

Ex) https://github.com/ethereum/go-ethereum/blob/master/README.md

Git 주소 https://github.com/ethereum/go-ethereum

 

 

- 노드 설치

apt-get update && sudo apt-get upgrade -y
apt-get install make
apt-get install build-essential


wget https://dl.google.com/go/go1.16.linux-amd64.tar.gz
tar -xzf go1.16.linux-amd64.tar.gz
mv go /usr/local
echo 'GOPATH="/usr/local/go"' >> ~/.profile
echo 'PATH="$PATH:$GOPATH/bin"' >> ~/.profile
source .profile

 

1. 해당 코인 github 접속, releases 탭으로 이동, 받고자 하는 버전의 source code (tar.gz) 링크 주소 복사, 설치하고자 하는 서버에서 다운로드 합니다.

Ex) https://github.com/ethereum/go-ethereum/archive/v1.9.20.tar.gz
2.
압축 해제 후, 해당 디렉토리로 이동합니다.
ex) tar -xvzf v1.9.20.tar.gz

3. make geth

4. 빌드가 끝난 후 /build/bin 에 있는 geth 실행 파일을 /usr/local/bin 으로 복사합니다.

Ex) cp geth /usr/local/bin

5. screen –S ETH 명령어로 screen 을 생성 후 아래와 같은 명령어로 geth 를 실행시켜 줍니다.

geth --rpc --rpcaddr 0.0.0.0 --port 30303 console

6.     이후 ctrl + a, d 커맨드를 통해 스크린을 유지한 채 빠져 나옵니다.
(
스크린 재 접속시 screen –r ETH)

 

cd 자기 자신 경로

#vi .screenrc

defscrollback 5000
termcapinfo xterm* ti@:te@
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n*%t%{-}%+w %= %c ${USER}@%H"
bindkey -k k1 select 0
bindkey -k k2 select 1
bindkey -k k3 select 2

 

 

 

 

- 노드 업그레이드

1. 노드 설치에 있는 1~3 까지 진행 합니다.

 2. screen –r ETH screen 접근 후 exit 명령어를 통해 노드를을 멈추고 ctrl+a , d 를 통해 screen을 유지한 채 나옵니다.

3.  설치 방법 4번을 진행 후 screen –r ETH 통해 접근 후 아래의 명령어로 노드를 실행 시켜 줍니다.

geth --rpc --rpcaddr 0.0.0.0 --port 30303  --datadir /home/eth/data console

 

 

 

- 노드 운영방법

시작 : screen 세션 생성 후

geth --rpc --rpcaddr 0.0.0.0 --port 30303 --datadir /home/eth/data console

종료 : screen –r ETH 을 통해 세션에 접근 후 콘솔 창에서 exit 명령어로 종료

kill로 종료할 시 블록이 깨질 수 있으므로 exit을 이용합니다.

아래 명령어는 콘솔창 기준입니다.

블록 높이 확인 : eth.blockNumber

Peer 확인 : admin.peers

Node 정보 : admin.nodeInfo

이외에 명령어는 아래에서 확인할 수 있습니다.

 


 https://ethereum.stackexchange.com/questions/28703/full-list-of-geth-terminal-commands

추가적으로 ethetc가 블록을 못 받아올 경우 노드를 재시작 해주면 됩니다.

블로그 이미지

iesay

,

출처 : http://wonwoo.ml/index.php/post/903

 

nodejs에서 비동기 개발 경험 있는데

webflux를 쓰지 않고 비동기를 사용해야 될일이 생겼다.

 

부하가 아주 많은 서비스중인 대상이 외부 API 인터페이스 통신하는데

10건중 2건 정도 간혈적으로 오류가 뜬다

그래서 response 가 없으면 한번 더 요청하는 로직을 추가 해도 이모양이다.

 

그래서 자바에 비동기를 부분적으로 사용할수 있다는걸 듣고

적용 하였다.

 

소스

 package com.mattjtodd.asyncresttemplateexample;

import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.client.AsyncRestTemplate;

import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;

@SpringBootApplication
public class AsyncRestTemplateExampleApplication {
 static AsyncRestTemplate asyncRestTemplate = new AsyncRestTemplate();
  
 
    public static void main(String[] args) throws InterruptedException, ExecutionException {
     asyncRestTemplateTest();
    }
   
   
    public static void asyncRestTemplateTest() throws InterruptedException, ExecutionException {
        ListenableFuture<ResponseEntity<Map>> entity = asyncRestTemplate.getForEntity("https://api.exchangeratesapi.io/latest?base=USD", Map.class);
        entity.addCallback(result -> {
            System.out.println(result.getStatusCode());
            System.out.println("body:          "+ result.getBody().toString());
        }, ex -> System.out.println(ex.getStackTrace()));

        System.out.println("asyncRestTemplateTest:             "+ Map.class);
        TimeUnit.SECONDS.sleep(8);
    }  
}

 

 

결과

16:58:20.514 [main] DEBUG org.springframework.web.client.AsyncRestTemplate - Created asynchronous GET request for "https://api.exchangeratesapi.io/latest?base=USD"
16:58:20.527 [main] DEBUG org.springframework.web.client.RestTemplate - Setting request Accept header to [application/json, application/*+json]
asyncRestTemplateTest:             interface java.util.Map
16:58:21.123 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.web.client.AsyncRestTemplate - Async GET request for "https://api.exchangeratesapi.io/latest?base=USD" resulted in 200 (OK)
16:58:21.124 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.web.client.RestTemplate - Reading [interface java.util.Map] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@732136b8]
200
body:          {rates={CAD=1.2775883576, HKD=7.7520997921, ISK=128.6486486486, PHP=48.1022869023, DKK=6.1841995842, HUF=297.9875259875, CZK=21.4045738046, GBP=0.7304199584, RON=4.0538877339, SEK=8.4114760915, IDR=14034.3534303534, INR=72.9513513514, BRL=5.4016632017, RUB=74.3491891892, HRK=6.2854885655, JPY=105.5883575884, THB=30.0191268191, CHF=0.9016216216, EUR=0.8316008316, MYR=4.0655301455, BGN=1.6264449064, TRY=7.0942203742, CNY=6.4547193347, NOK=8.5426195426, NZD=1.3920997921, ZAR=14.943950104, USD=1.0, MXN=20.2120582121, SGD=1.3361330561, AUD=1.305031185, ILS=3.2837422037, KRW=1120.8066528067, PLN=3.7275675676}, base=USD, date=2021-02-08}
 

 

'자바(Spring)' 카테고리의 다른 글

ajax 통신  (0) 2020.09.06
JSON 파일 파싱 스프링 java VO저장  (0) 2020.08.29
블로그 이미지

iesay

,

특정 테이블에 10GB 데이터가 있는 경우

 

TEMP 함수로 SWAP과 같이 변환

 

1] A_TABLE -> A_TABLE_TEMP로  3개월치 데이터 

   insert into   select

 

2] A_TABLE  -> A_TABLE_BACK 테이블 이름 변경  

 

3] A_TABLE_TEMP -> A  테이블 이름 변경

 

4] A_TABLE_BACK  새로운  Database로 이관

 

 

유저가 과거 자료를 원하는 경우 4에서 데이터 추출하여 알림

 

'' 카테고리의 다른 글

ubuntu nginx php mysql 구축  (0) 2021.03.03
라디오 버튼 제이쿼리  (0) 2020.08.24
GS인증(보안성)  (7) 2020.04.13
express + morgan  (0) 2019.04.01
promise  (0) 2019.03.28
블로그 이미지

iesay

,

nodemon 설정 방법

nodejs 2020. 12. 9. 16:19

app.js 


var express = require('express');

var app = express();

var logger = require('morgan');


// router 설정

var indexRouter = require('./routes/index');


app.use(logger('dev'));

app.use(express.json());

app.use(express.urlencoded({ extended: false }));


// view 경로 설정

app.set('views', __dirname + '/views');


// 화면 engine을 html로 설정

app.set('view engine', 'html');

app.engine('html', require('ejs').renderFile);


// port setup

app.set('port', process.env.PORT || 3000);



// 기본 path를 /public으로 설정(css, javascript 등의 파일 사용을 위해)

app.use(express.static(__dirname + '/public'));


app.use('/', indexRouter);


module.exports = app;


var server = app.listen(app.get('port'), function() {

    console.log('Express server listening on port ' + server.address().port);

  });

 



노드몬 설치 후 실행 된다.

 #nodemon app.js


'nodejs' 카테고리의 다른 글

nodejs so파일  (0) 2021.09.10
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
axios 전송  (0) 2020.12.08
web3.js 비동기 nodejs 함수 비교  (0) 2020.11.24
블로그 이미지

iesay

,

출처 :  

https://drhot552.github.io/blockchain/%EC%9D%B4%EB%8D%94%EB%A6%AC%EC%9B%80-%EB%B8%94%EB%A1%9D%EC%B2%B4%EC%9D%B8_Web3js%EC%8A%A4%EB%A7%88%ED%8A%B8%EC%BB%A8%ED%8A%B8%EB%9E%99%ED%8A%B8-%EC%8B%A4%ED%96%89%ED%95%98%EA%B8%B0/#%EC%8A%A4%EB%A7%88%ED%8A%B8%EC%BB%A8%ED%8A%B8%EB%9E%99%ED%8A%B8-%EC%8B%A4%ED%96%89


이더리음 스마트컨트렉 함수 실행하기

web3.eth.getTransactionCount(send_account, (err, txCount) => {

  const txObject = {

    nonce:    web3.utils.toHex(txCount),

    gasLimit: web3.utils.toHex(1000000), // Raise the gas limit to a much higher amount

    gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),

    to : "0x59c11C4Cc4B92Cc15A35E289F2df961E3E7BF548",

    data : MyContract.methods.setLock("0xAdE01D06890918738Ba85F82cd2BD08128b1E61b", 100).encodeABI()

  };

  const tx = new Tx(txObject);

  tx.sign(privateKey);

  const serializedTx = tx.serialize();

  const raw = '0x' + serializedTx.toString('hex');

  web3.eth.sendSignedTransaction(raw)

     .once('transactionHash', (hash) => {

       console.info('transactionHash', 'https://rinkeby.infura.io/tx/' + hash);

     })

     .once('receipt', (receipt) => {

       console.info('receipt', receipt);

       MyContract.methods.totalbalance().call().then(result => console.log("SmartContract Call: " + result));

    }).on('error', console.error);

  }); 


컨트렉 함수 : setLock

컨트렉 주소 : 0xAdE01D06890918738Ba85F82cd2BD08128b1E61b

대상 주소 : 0x59c11C4Cc4B92Cc15A35E289F2df961E3E7BF548


락걸린 대상의 송금 실패 내역





'이더리움' 카테고리의 다른 글

EIP-1559 분석  (2) 2021.07.12
graphsq + mongodb  (0) 2021.06.08
token 송금  (0) 2019.10.28
rinkeby.io facebook으로 테스트 이더 받기  (0) 2019.10.25
erc20 token balance 조회  (0) 2019.10.24
블로그 이미지

iesay

,

axios 전송

nodejs 2020. 12. 8. 10:43

form.html

 <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<form>

<span class="login100-form-title p-b-26">

Welcome </span>

<div class="wrap-input100 validate-input" data-validate="Valid email is: a@b.c">

<input class="input100" type="text" id="email" value="222@222.com">

</div>

<div class="wrap-input100 validate-input" data-validate="Enter password">

<span class="btn-show-pass">

<i class="zmdi zmdi-eye"></i>

</span>

<input class="input100" type="password" id="pass" value="@@@@@@@@@@">

</div>

<div class="container-login100-form-btn">

<div class="wrap-login100-form-btn">

<div class="login100-form-bgbtn">

</div>

<button class="login100-form-btn" onclick="login_click();">

Login </button>

</div>

</div>

</form>

<script>

function login_click()

{

var email = $("#email").val();

var pass =  $("#pass").val();

axios({

  method: 'post',

  url: '/login_auth',

  data: {

email: email,

pass: pass

  }

}).then(function (response) {

  console.log(response);

  })

  .catch(function (error) {

    console.log(error);

  });

}

</script>



jquery와 Axios를 활용한 form 값 전달





login_auth.js


router.post('/login_auth',async (req,res, bodyParser) => {

  var input_id = req.body.email;

  var input_pw = req.body.pass;

  console.log('  ',input_id);

  console.log('  ',input_pw); 

  res.json({ 'result' : 'true' });

})



data에 response값 전달

'nodejs' 카테고리의 다른 글

nodejs so파일  (0) 2021.09.10
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
nodemon 설정 방법  (0) 2020.12.09
web3.js 비동기 nodejs 함수 비교  (0) 2020.11.24
블로그 이미지

iesay

,
변경 전

 MyContract.methods.totalSupply().call((err, result)=> {

   console.log("result : ", result);

 })



변경 후

const app = async () => {

  try {

      const result = await MyContract.methods.totalSupply().call();

      console.log("result : ", result);

  }catch (error) { console.log('Task Failure',error);

  }

};

app();


동일 하게 동작 한다.

변경 후 코드가 유지보수 하기 조금 더 쉽다.


'nodejs' 카테고리의 다른 글

nodejs so파일  (0) 2021.09.10
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
nodemon 설정 방법  (0) 2020.12.09
axios 전송  (0) 2020.12.08
블로그 이미지

iesay

,

방화벽 설정

시스템 2020. 10. 26. 11:08

ports: 3306/tcp 22/tcp 8080/tcp 443/tcp 8443/tcp 444/tcp
firewall-cmd --list-all

firewall-cmd --reload


firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp 

 

'시스템' 카테고리의 다른 글

gitlab ci Docker 연동(nodejs)  (2) 2021.08.23
Configuring tzdata Dockerfile  (0) 2021.07.27
우분투 No space left on device  (0) 2020.06.26
gitlab 설치  (0) 2020.04.07
vscode , 버추얼박스  (0) 2019.11.05
블로그 이미지

iesay

,

Gitlab + Jenkins

Tools 2020. 10. 22. 16:13

출처

www.itzgeek.com/how-tos/linux/debian/install-and-configure-jenkins-on-centos-7-ubuntu-16-04-debian-9.html

tech.osci.kr/2020/01/16/86039236/

elfinlas.tistory.com/369

jotaerre.net/2020/08/20/instalacion-de-gitlab-y-jenkins-en-una-misma-maquina-error-502/blog.naver.com/jang_delay/222058655324

 

Instalación de GitLab y Jenkins en una misma máquina – Error 502

He realizado la instalación de GitLab y Jenkins en la misma máquina, y me he encontrado con que GitLab ha dejado de funcionar apareciendo el mensaje “Whoops, GitLab is taking too much time to…

jotaerre.net

apt-get update
apt-get install -y curl openssh-server ca-certificates

apt-get install -y postfix
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
EXTERNAL_URL="http://gitlab.kr" apt-get install gitlab-ee

http://내부ip주소/

gitlab-ctl reconfigure
gitlab-ctl start

gitlab-ctl stop

깃랩 설치 완료

 

 

 

 

젠킨스

apt update

apt install openjdk-8-jre-headless
java -version

wget https://pkg.jenkins.io/debian-stable/jenkins.io.key

apt-key add jenkins.io.key


echo "deb https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list


apt update

apt install -y jenkins

systemctl status jenkins


vi /var/lib/jenkins/secrets/initialAdminPassword

 

 

젠킨스 설치 완료

블로그 이미지

iesay

,