EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

docker iptables

http://blog.pulipuli.info/2011/07/




http://linux.vbird.org/linux_server/0250simple_firewall.php

iptables [-AI 鏈] [-io 網路介面] [-p tcp,udp] \
> [-s 來源IP/網域] [--sport 埠口範圍] \
> [-d 目標IP/網域] [--dport 埠口範圍] -j [ACCEPT|DROP|REJECT]
選項與參數:
--sport 埠口範圍:限制來源的埠口號碼,埠口號碼可以是連續的,例如 1024:65535
--dport 埠口範圍:限制目標的埠口號碼。


[root@www ~]# iptables -A INPUT [-m state] [--state 狀態]
選項與參數:
-m :一些 iptables 的外掛模組,主要常見的有:
     state :狀態模組
     mac   :網路卡硬體位址 (hardware address)
--state :一些封包的狀態,主要有:
     INVALID    :無效的封包,例如資料破損的封包狀態
     ESTABLISHED:已經連線成功的連線狀態;
     NEW        :想要新建立連線的封包狀態;
     RELATED    :這個最常用!表示這個封包是與我們主機發送出去的封包有關

範例:只要已建立或相關封包就予以通過,只要是不合法封包就丟棄
[root@www ~]# iptables -A INPUT -m state \
> --state RELATED,ESTABLISHED -j ACCEPT
[root@www ~]# iptables -A INPUT -m state --state INVALID -j DROP



https://www.booleanworld.com/depth-guide-iptables-linux-firewall/
https://www.lammertbies.nl/comm/info/iptables.html



docker csf

https://meta.discourse.org/t/applying-docker-discourse-iptables-rules-when-using-csf-firewall/70531/5




csf v12.08



NOTE: This feature is currently in BETA testing, so may not work correctly

This section provides the configuration of iptables rules to allow Docker
containers to communicate through the host. If the generated rules do not
work with your setup you will have to use a /etc/csf/csfpost.sh file and add
your own iptables configuration instead

1 to enable, 0 to disable



ethereum private chain by ubuntu


https://gist.github.com/javahippie/efee5417c69aaad3baf297dd2cd71fc6



version: '3.3'

services:
  go-ethereum:
    build:
      context: go-ethe/
    ports:
      - "8545:8545"
      - "30303:30303"
    networks:
      - elk

networks:
  elk:
    driver: bridge




FROM ubuntu:xenial

RUN apt-get update \
     && apt-get install -y wget \
     && rm -rf /var/lib/apt/lists/* 

WORKDIR "/opt"
ARG BINARY="geth-linux-amd64-1.8.17-8bbe7207.tar.gz"
RUN wget "https://gethstore.blob.core.windows.net/builds/$BINARY"
RUN tar -xzvf $BINARY --strip 1
RUN rm $BINARY

ADD ./genesis.json ./genesis.json
RUN ./geth init genesis.json

CMD nohup ./geth  --dev --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*"  --mine 
#geth --syncmode "light" --cache=2048

EXPOSE 8545
EXPOSE 30303

docker-machine ssh login use putty or xshell or winscp

1、Get key


Key Path
c:\user\xxxooo\.docker\machine\machines\%%%%%

xxxooo user

%%%%%  machine name


id_rsa  This is key



2、Need vm ip、id_rsa


Get IP:
1. docker-machine ssh %%%%%
2. ifconfig


If need PPK:winscp can auto change id_rsa to ppk


3、last step login VM account:docker


===========

https://github.com/boot2docker/boot2docker


Docker Machine auto logs in using the generated SSH key, but if you want to SSH into the machine manually (or you're not using a Docker Machine managed VM), the credentials are:

user: docker 
pass: tcuser

docker-compose ethereum geth private chain

Suggestion is use docker-machine for make docker machine is more easy. VirtualBox

windows Use HFS.exe for copy file to docker machine instance.




Directory < ethtest >
||=docker-compose.yml
||=< go-ether >
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=Dockerfile
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=start.sh
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=< genesis >
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp||=genesis.json


1、docker-compose.yml

import:

.keystore maybe no use, because run again docker-compose need to delete /go-ether/keystore
.entrypoint must have together Dockerfile ENTRYPOINT



version: '3.3'

services:
  go-ether:
    build:
      context: go-ether/
    volumes:
      #- ./go-ether/keystore:/root/.ethereum/devchain/keystore:rw
      - ./go-ether/genesis/genesis.json:/root/genesis/genesis.json:ro
      - /etc/localtime:/etc/localtime:ro
    entrypoint: /root/start.sh
    ports:
      - "8545:8545"
      - "30303:30303"
      - "30303:30303/udp"
    networks:
      - elk

networks:
  elk:
    driver: bridge




2、Dockerfile

import:

.COPY or ADD is ok
.Only start.sh is important, other line is for test and note
.Super important is start.sh file must end LF
https://sueboy.blogspot.com/2018/11/docker-compose-standardinitlinuxgo190.html




FROM ethereum/client-go:alltools-latest

RUN apk update &&\
    apk add git nodejs bash perl

#ADD ./genesis/genesis.json /root/genesis/genesis.json
#RUN geth init /root/genesis/genesis.json --datadir "~/.ethereum/devchain"

#RUN geth --dev --rpcapi "db,personal,eth,net,web3" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --mine 
#geth --syncmode "light" --cache=2048
#./geth --datadir /root/.ethereum --password /root/geth.password --unlock "0" --port 30310 --rpc --rpcaddr "0.0.0.0" -rpcapi "eth,web3" --rpcport 8110 --networkid 4567890 --dev --lightkdf --nodiscover --maxpeers 0 --verbosity 6 --pprof --pprofport 6110 $@ 2> /tmp/geth.log

COPY start.sh /root/start.sh
RUN chmod +x /root/start.sh

ENTRYPOINT /root/start.sh







3、start.sh

import:

.last geth must have --minerthreads=1 , only --mini is can't mining. --mini login check geth.mining get true, but still no mining.




#!/bin/bash
set -e
datadir="~/.ethereum/devchain"
ip=$(echo `awk 'END{print $1}' /etc/hosts`)

echo "======== geth ========"
echo "======== init ========"
geth --datadir=$datadir init "/root/genesis/genesis.json"

sleep 2
echo "======== bootnode ========"
#bootnode -nodekeyhex 08f0e1dee5c1b4645f3331a566009e41a4514b6cd28656d63d0449ecf812812b &
bootnode --genkey=boot.key
bootnode --nodekey=boot.key -verbosity 4 &
#bootnode --nodekey=boot.key  -writeaddress > bootnodeid.txt

sleep 2
echo "======== account ========"
echo "password" > ~/.accountpassword
echo "df504d175ae63abf209bad9dda965310d99559620550e74521a6798a41215f46" > ~/.privatekey
geth account import --datadir=$datadir --password ~/.accountpassword  ~/.privatekey

sleep 2
echo "======== mine ========"
#bootnodeId="enode://76a8171707eca17647a47ca99ffd348927dfa60102792ea349a25d5192e61855be83b786e376276a306afcceea4ffd1c9c77e4370b417efc39f328a0d068004c@127.0.0.1:30301"
bootnodeId="enode://"$bootnodeid"@"$ip":30301"
address="8cc5a1a0802db41db826c2fcb72423744338dcb0"
echo "bootnodeID:"$bootnodeId
geth --datadir=$datadir --bootnodes $bootnodeId --networkid 45671 --rpcapi "db,personal,eth,net,web3" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*"  --password ~/.accountpassword --etherbase $address --mine --minerthreads=1 2>geth.log





4、genesis.json



{
  "config": {
      "chainId": 45671,
      "homesteadBlock": 0,
      "eip150Block": 0,
      "eip150Hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0
  },
  "nonce": "0x0000000000000042",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x00",
  "gasLimit": "0x4c4b40",
  "difficulty": "0x0001",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "alloc": {
  }
}





important:

1、genesis.json chainId & start.sh networkid must same.

2、datadir must have and same. If datadir different or no set, maybe can use same geth chain.

3、log must 2>geth.log 2>xxxooo.log xxxooo is log name.

4、--bootnodes maybe can have or not. Here is for demom, can try.



=====easy command=====

=====docker-machine=====
docker-machine --driver=virtualbox machine1 --virtualbox-memory 2048 --virtualbox-cpu-count 2 --engine-opt dns=8.8.8.8

docker-machien start machine1
docker-machien ssh machine1
docker-machien stop machine1

Move machine1 hdd to D: , stop first then use VirtualBox Media manager, don't change ini or config file.

=====docker-machine=====


=====copy edit txt file=====
On windows use HFS.exe put file into HFS.

rm -f docker-compose.yml && wget http://ip address/docker-compose.yml

rm start.sh -f && wget http://ip address/start.sh && rm -f Dockerfile && wget http://ip address/Dockerfile && rm genesis/genesis.json -f && wget -O genesis/genesis.json http://ip address/genesis.json

=====copy edit txt file=====



=====docker-compose=====
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

.clear cache
chose 1:docker-compose rm -f && docker-compose pull && docker-compose up --build -d && docker-compose up
chose 2:docker-compose up --force-recreate

I use chose 1.
=====docker-compose=====



======login docker======
docker ps

xxxooo is docker container id, can use three or four word to login

docker exec -it xxxooo /bin/sh or /bin/bash Exit CTRL + P CTRL + Q
docker exec -it xxxooo geth attach ipc://root/.ethereum/devchain/geth.ipc

=====================


======login geth======
xxxooo is path, so "find / -name geth.ipc"

geth attach ipc:./xxxooo/geth.ipc


eth.accounts have account?
eth.mining can mining?
eth.blockNumber mining?
eth.getBalance(eth.accounts[0]) have ether coin?


$@ linux shell




http://jyhshin.pixnet.net/blog/post/39349999-shell-script-%E8%87%AA%E5%8B%95%E5%AE%9A%E7%BE%A9%E7%9A%84%E8%AE%8A%E6%95%B8



$@ 包含所有輸入的參數,$@ 即代表 $1, $2,....直到所有參數結束。$@ 用將所有參數以空白為間隔,存在 $@ 中。也就是說 $@ 代表了 "$1" "$2" "$3"....。

ethereum private chain 私有鏈

https://github.com/ethereum/go-ethereum/wiki/Private-network

https://medium.com/taipei-ethereum-meetup/%E4%BD%BF%E7%94%A8-go-ethereum-1-6-clique-poa-consensus-%E5%BB%BA%E7%AB%8B-private-chain-1-4d359f28feff

https://blog.fukuball.com/ethereum-%E9%96%8B%E7%99%BC%E7%AD%86%E8%A8%98-22geth-%E5%9F%BA%E7%A4%8E%E7%94%A8%E6%B3%95%E5%8F%8A%E6%9E%B6%E8%A8%AD-muti-nodes-%E7%A7%81%E6%9C%89%E9%8F%88/



https://medium.com/@javahippie/building-a-local-ethereum-network-with-docker-and-geth-5b9326b85f37


https://mshk.top/2017/11/go-ethereum-1-7-2/

https://www.tiny-calf.com/2018/02/01/GETH%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/


https://neighborhood999.github.io/2018/09/19/running-ethereum-on-docker/


https://github.com/yutianwu/ethereum-docker

https://github.com/yutianwu/ethereum-docker



ethereum eth --dev & networkid & chainId doesn't work with a custom genesis block

https://github.com/ethereum/go-ethereum/issues/15182



@robert-zaremba You can still use dev with datadir. Dev just uses a 0-period clique chain.

That said, --dev was not meant to be used on custom networks / genesis blocks. If you need a custom setup, you can init a chain of your choosing. Dev will try to be smart and configure a lot of stuff for easy testing, but it's not flexible, it's easy.



翻譯:

--dev不能用在 custom networks 和genesis blocks.



=========== Error understand ============

--dev  => 1337

So  use --dev  must networkid & chainId     set 1337 

docker-compose standard_init_linux.go:190: exec user process caused "no such file or directory"

docker-compose  Dockerfile always run script failed, many document is talking about

RUN chmod +x   xxxooo.sh

But still can't run, get error every time.

Answer:

Use notepad++, go to edit -> EOL conversion -> change from CRLF to LF.



standard_init_linux.go:190: exec user process caused "no such file or directory"

https://stackoverflow.com/questions/51508150/standard-init-linux-go190-exec-user-process-caused-no-such-file-or-directory




dockerfile RUN WORKDIR !!!!



https://yeasy.gitbooks.io/docker_practice/image/dockerfile/workdir.html



WORKDIR 指定工作目录

格式为 WORKDIR <工作目录路径>。

使用 WORKDIR 指令可以来指定工作目录(或者称为当前目录),以后各层的当前目录就被改为指定的目录,如该目录不存在,WORKDIR会帮你建立目录。

之前提到一些初学者常犯的错误是把 Dockerfile 等同于 Shell 脚本来书写,这种错误的理解还可能会导致出现下面这样的错误:RUN cd /app RUN echo "hello" > world.txt


如果将这个 Dockerfile 进行构建镜像运行后,会发现找不到 /app/world.txt 文件,或者其内容不是 hello。原因其实很简单,在 Shell 中,连续两行是同一个进程执行环境,因此前一个命令修改的内存状态,会直接影响后一个命令;而在 Dockerfile 中,这两行 RUN 命令的执行环境根本不同,是两个完全不同的容器。这就是对 Dockerfile 构建分层存储的概念不了解所导致的错误。

之前说过每一个 RUN 都是启动一个容器、执行命令、然后提交存储层文件变更。第一层 RUN cd /app 的执行仅仅是当前进程的工作目录变更,一个内存上的变化而已,其结果不会造成任何文件变更。而到第二层的时候,启动的是一个全新的容器,跟第一层的容器更完全没关系,自然不可能继承前一层构建过程中的内存变化。

因此如果需要改变以后各层的工作目录的位置,那么应该使用 WORKDIR 指令。

ethereum/client-go

https://geek.ink/forum/detail/34



entrypoint cmd command docker-compose



https://medium.freecodecamp.org/docker-entrypoint-cmd-dockerfile-best-practices-abc591c30e21

Step


First

Dockerfile ENTRYPOINT use all uppercase letters 

Docker Compose entrypoint  use lowercase letters.


Second

CMD / command
The main purpose of a 

CMD (Dockerfiles)
command (Docker Compose files) 

is to provide defaults when executing a container. These will be executed after the entrypoint.


===================
https://beginor.github.io/2017/10/21/dockerfile-cmd-and-entripoint.html




[轉]linux exec与重定向

http://xstarcd.github.io/wiki/shell/exec_redirect.html

ethereum geth to log



https://ethereum.stackexchange.com/questions/3229/geth-what-happened-to-logfile


geth 2> file




Example:


geth --dev --rpcapi "db,personal,eth,net,web3" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --mine 2>eth_output.log




.Dockfile

RUN geth --dev --rpcapi "db,personal,eth,net,web3" --rpc --rpcaddr "0.0.0.0" --rpccorsdomain "*" --mine 2>eth_output.log


===========

Have console & log & mining

./geth --datadir ./node2/data/ --networkid 55555 --port 30303 --rpcapi=db,eth,net,web3,personal,web3 --rpc --rpccorsdomain=* --password password.txt --mine --minerthreads=1 --verbosity 3 console 2>> /var/log/geth.log

PS:--rpccorsdomain=*  or --rpccorsdomain "*"  is ok,  --rpcorsdomain * is bad


Have console & log & mining & unlock

./geth --datadir ./node2/data/ --networkid 55555 --port 30303 --unlock 0x00000d0000b0000a000a000a0000d00fb0a0fb0b --rpcapi=db,eth,net,web3,personal,web3 --rpc --rpccorsdomain=* --password password.txt --mine --minerthreads=1 --verbosity 3 console 2>> /var/log/geth.log

PS:0x00000d0000b0000a000a000a0000d00fb0a0fb0b  account id


Have console & log & mining & unlock & backgroud run

tmux

./geth --datadir ./node2/data/ --networkid 55555 --port 30303 --unlock 0x00000d0000b0000a000a000a0000d00fb0a0fb0b --rpcapi=db,eth,net,web3,personal,web3 --rpc --rpccorsdomain=* --password password.txt --mine --minerthreads=1 --verbosity 3 console 2>> /var/log/geth.log

In tmux

  [Ctrl + b] d
  exit

or
  [Ctrl + b] s 

Shell
tmux ls
tmux attach -t 0



Ethereum Network ID Chain ID

https://qiita.com/hm0429/items/224d420364b36cf43e85


[轉]基于Docker的Ethereum 开发环境搭建

http://yutianx.info/2017/10/07/2017-10-07-docker-ethereum/


https://github.com/Capgemini-AIE/ethereum-docker

docker-machine on windows

1、close hyper-v
https://ugetfix.com/ask/how-to-disable-hyper-v-in-windows-10/

2、install Virtualbox

3、install git

4、https://docs.docker.com/machine/install-machine/#install-machine-directly

git-bash

base=https://github.com/docker/machine/releases/download/v0.14.0 && mkdir -p "$HOME/bin" && curl -L $base/docker-machine-Windows-x86_64.exe > "$HOME/bin/docker-machine.exe" && chmod +x "$HOME/bin/docker-machine.exe"


5、
git-bash

docker-machine create --driver=virtualbox machine1
docker-machine -s d:\docker create --driver=virtualbox machine1

docker-machine list

docker-machine ssh machine1
        docker run hello-world
        docker-machine env machine1


https://hk.saowen.com/a/00c8a80e4a74fcf80111ba570f4db601e204c12f61e3109fec92cac8a15456ae


docker-machine -s d:\docker create --driver=virtualbox --virtualbox-memory=2048 --virtualbox-cpu-count=2 --engine-opt dns=8.8.8.8 machine_name_ooxxooxx





=====

http://sueboy.blogspot.com/2018/11/docker-machine-ssh-login-use-xshell-or.html

user: docker
id_rsa