|
|
@@ -0,0 +1,268 @@ |
|
|
apt-get update && apt-get install -y aptitude git lxc-utils zfsutils-linux netfilter-persistent sysstat |
|
|
|
|
|
# find the partition ID that is linked to the storage serial number. |
|
|
# This will prevent from losing the partition if disk mapping changes |
|
|
ls -l /dev/disk/by-id/ | grep sda6 |
|
|
zpool create -f zdata /dev/disk/by-id/wwn-0x600507604092b628236df4851535cef5-part6 |
|
|
|
|
|
## Fixate internal IP address of the container |
|
|
systemctl stop lxc-net |
|
|
sed -i -e 's,^.*LXC_DHCP_CONFILE,LXC_DHCP_CONFILE,' /etc/default/lxc-net |
|
|
sed -i -e 's,10\.0\.3,10\.0\.11,g' /etc/default/lxc-net |
|
|
cat >/etc/lxc/dnsmasq.conf <<'EOT' |
|
|
dhcp-host=lightapi,10.0.11.10 |
|
|
EOT |
|
|
systemctl start lxc-net |
|
|
|
|
|
# Optionally, a parent filesystem. You either create child entries, or |
|
|
# you can also use a flat naming scheme, like zdata/lightapi_lxc |
|
|
zfs create zdata/lightapi |
|
|
zfs set recordsize=128k zdata/lightapi |
|
|
zfs set atime=off zdata/lightapi |
|
|
|
|
|
# LXC container contents |
|
|
zfs create -o mountpoint=/var/lib/lxc/lightapi zdata/lightapi/lxc |
|
|
|
|
|
# EOS blocks log, compressed, with 8KB records |
|
|
zfs create -o mountpoint=/var/lib/lxc/lightapi/rootfs/home/eosio/data zdata/lightapi/eosdata |
|
|
zfs set compression=lz4 zdata/lightapi/eosdata |
|
|
zfs set primarycache=all zdata/lightapi/eosdata |
|
|
zfs set recordsize=8k zdata/lightapi/eosdata |
|
|
|
|
|
# EOS state shared memory. 4KB records, uncompressed, content is not cached |
|
|
zfs create -o mountpoint=/var/lib/lxc/lightapi/rootfs/home/eosio/data/state zdata/lightapi/eosstate |
|
|
zfs set recordsize=4k zdata/lightapi/eosstate |
|
|
zfs set primarycache=metadata zdata/lightapi/eosstate |
|
|
|
|
|
# MySQL data. Innodb standard write size is 16KB |
|
|
zfs create -o mountpoint=/var/lib/lxc/lightapi/rootfs/var/lib/mysql zdata/lightapi/mysql |
|
|
zfs set recordsize=16k zdata/lightapi/mysql |
|
|
zfs set primarycache=metadata zdata/lightapi/mysql |
|
|
|
|
|
# MySQL Innodb log and binlog for replication. Compressed, 128KB records. Full cache to allow random size appending. |
|
|
zfs create -o mountpoint=/var/lib/lxc/lightapi/rootfs/var/lib/mysql-log zdata/lightapi/mysqllog |
|
|
zfs set compression=lz4 zdata/lightapi/mysqllog |
|
|
zfs set primarycache=all zdata/lightapi/mysqllog |
|
|
|
|
|
# Download Ubuntu 18.04 packages and set up a new container |
|
|
lxc-create -n lightapi -t download -- --dist ubuntu --release bionic --arch amd64 |
|
|
|
|
|
# Allow SSH to the container, provided that you have an SSH agent running |
|
|
mkdir /var/lib/lxc/lightapi/rootfs/home/eosio/.ssh/ |
|
|
cp .ssh/authorized_keys /var/lib/lxc/lightapi/rootfs/home/eosio/.ssh/ |
|
|
|
|
|
# if needed, also adjust the MAC address to be unique |
|
|
echo "lxc.start.auto = 1" >> /var/lib/lxc/lightapi/config |
|
|
|
|
|
lxc-start -n lightapi |
|
|
lxc-attach -n lightapi |
|
|
|
|
|
# this user was in default template |
|
|
userdel -r ubuntu |
|
|
|
|
|
# generic packages and MariaDB |
|
|
apt-get update && apt-get install -y aptitude git openssh-server net-tools \ |
|
|
mariadb-server mariadb-client |
|
|
|
|
|
chown mysql.mysql /var/lib/mysql-log |
|
|
|
|
|
systemctl stop mariadb |
|
|
|
|
|
cat >/etc/mysql/mariadb.conf.d/90-lightapi.cnf <<'EOT' |
|
|
[mysqld] |
|
|
server_id=11 |
|
|
bind-address=0.0.0.0 |
|
|
default_storage_engine=InnoDB |
|
|
innodb_buffer_pool_size = 10G |
|
|
innodb_doublewrite = 0 |
|
|
innodb_checksum_algorithm = none |
|
|
innodb_flush_log_at_trx_commit=1 |
|
|
innodb_log_group_home_dir = /var/lib/mysql-log |
|
|
innodb_locks_unsafe_for_binlog = 1 |
|
|
sync_binlog=1 |
|
|
log_bin=/var/lib/mysql-log/binlog-fra01 |
|
|
binlog_format=row |
|
|
expire_logs_days=3 |
|
|
log_slave_updates=true |
|
|
gtid_domain_id = 11 |
|
|
gtid_strict_mode = ON |
|
|
EOT |
|
|
|
|
|
rm /var/lib/mysql/ib_logfile* |
|
|
rm /var/lib/mysql/binlog* |
|
|
|
|
|
systemctl start mariadb |
|
|
|
|
|
# Needed for ZMQ plugin |
|
|
apt-get install -y pkg-config libzmq5-dev |
|
|
|
|
|
# ZMQ plugin receiver dependencies |
|
|
apt-get install -y cpanminus gcc g++ libzmq5-dev mariadb-server \ |
|
|
libdbi-perl libmysqlclient-dev libexcel-writer-xlsx-perl \ |
|
|
libjson-xs-perl libjson-perl |
|
|
|
|
|
|
|
|
useradd -G sudo -s /bin/bash eosio |
|
|
sed -i -e 's,^\%sudo.*,%sudo ALL=(ALL:ALL) NOPASSWD:ALL,' /etc/sudoers |
|
|
chown -R eosio:eosio /home/eosio |
|
|
chmod 700 /home/eosio/.ssh/ |
|
|
chmod 600 /home/eosio/.ssh/authorized_keys |
|
|
|
|
|
# out of LXC container |
|
|
exit |
|
|
|
|
|
# in again, as eosio user |
|
|
ssh -A [email protected] |
|
|
|
|
|
mkdir build |
|
|
cd build |
|
|
git clone https://github.com/cc32d9/eos_zmq_plugin.git |
|
|
git clone https://github.com/EOSIO/eos --recursive |
|
|
cd eos |
|
|
LOCAL_CMAKE_FLAGS="-DEOSIO_ADDITIONAL_PLUGINS=${HOME}/build/eos_zmq_plugin" ./eosio_build.sh |
|
|
sudo ./eosio_install.sh |
|
|
|
|
|
sudo -i |
|
|
|
|
|
## Light API ZMQ receiver |
|
|
cpanm DBD::MariaDB |
|
|
cpanm ZMQ::Raw |
|
|
cpanm Starman |
|
|
|
|
|
cd /opt |
|
|
git clone https://github.com/cc32d9/eos_zmq_light_api.git |
|
|
cd eos_zmq_light_api |
|
|
|
|
|
sudo mysql <sql/lightapi_dbcreate.sql |
|
|
sh setup/add_eos_mainnet.sh |
|
|
|
|
|
vi /etc/default/lightapi_eos |
|
|
# add the ZMQ socket details: |
|
|
# DBWRITE_OPTS=--pull=tcp://127.0.0.1:5556 |
|
|
|
|
|
# Optionally, edit /etc/default/lightapi_api and adjust variables |
|
|
# that are predefined in systemd/lightapi_api.service |
|
|
|
|
|
cd systemd |
|
|
sh install_systemd_dbwrite.sh |
|
|
sh install_systemd_api.sh |
|
|
|
|
|
# go back to eosio user |
|
|
exit |
|
|
|
|
|
#### nodeos configuration #### |
|
|
# Take P2P endpoints near to you from https://eosnodes.privex.io/ |
|
|
cat >etc/config.ini <<'EOT' |
|
|
chain-state-db-size-mb = 32768 |
|
|
wasm-runtime = wabt |
|
|
validation-mode = light |
|
|
http-server-address = 0.0.0.0:8888 |
|
|
p2p-listen-endpoint = 0.0.0.0:9856 |
|
|
p2p-server-address = :9856 |
|
|
allowed-connection = any |
|
|
access-control-allow-origin = * |
|
|
verbose-http-errors = true |
|
|
contracts-console = true |
|
|
max-clients = 100 |
|
|
plugin = eosio::chain_plugin |
|
|
plugin = eosio::chain_api_plugin |
|
|
plugin = eosio::db_size_api_plugin |
|
|
plugin = eosio::zmq_plugin |
|
|
zmq-sender-bind = tcp://0.0.0.0:5556 |
|
|
sync-fetch-span = 1000 |
|
|
p2p-peer-address = eos-seed-de.privex.io:9876 |
|
|
p2p-peer-address = api.eosuk.io:12000 |
|
|
p2p-peer-address = p2p2.eossweden.eu:9966 |
|
|
p2p-peer-address = peer.eosgeneva.io:9876 |
|
|
EOT |
|
|
|
|
|
cat >etc/logging.json <<'EOT' |
|
|
{ |
|
|
"includes": [], |
|
|
"appenders": [{ |
|
|
"name": "consoleout", |
|
|
"type": "console", |
|
|
"args": { |
|
|
"stream": "std_out", |
|
|
"level_colors": [{ |
|
|
"level": "debug", |
|
|
"color": "green" |
|
|
},{ |
|
|
"level": "warn", |
|
|
"color": "brown" |
|
|
},{ |
|
|
"level": "error", |
|
|
"color": "red" |
|
|
} |
|
|
] |
|
|
}, |
|
|
"enabled": true |
|
|
} |
|
|
], |
|
|
"loggers": [{ |
|
|
"name": "default", |
|
|
"level": "warn", |
|
|
"enabled": true, |
|
|
"additivity": false, |
|
|
"appenders": [ |
|
|
"consoleout" |
|
|
] |
|
|
} |
|
|
] |
|
|
} |
|
|
EOT |
|
|
|
|
|
cat >etc/genesis.json <<'EOT' |
|
|
{ |
|
|
"initial_timestamp": "2018-06-08T08:08:08.888", |
|
|
"initial_key": "EOS7EarnUhcyYqmdnPon8rm7mBCTnBoot6o7fE2WzjvEX2TdggbL3", |
|
|
"initial_configuration": { |
|
|
"max_block_net_usage": 1048576, |
|
|
"target_block_net_usage_pct": 1000, |
|
|
"max_transaction_net_usage": 524288, |
|
|
"base_per_transaction_net_usage": 12, |
|
|
"net_usage_leeway": 500, |
|
|
"context_free_discount_net_usage_num": 20, |
|
|
"context_free_discount_net_usage_den": 100, |
|
|
"max_block_cpu_usage": 200000, |
|
|
"target_block_cpu_usage_pct": 1000, |
|
|
"max_transaction_cpu_usage": 150000, |
|
|
"min_transaction_cpu_usage": 100, |
|
|
"max_transaction_lifetime": 3600, |
|
|
"deferred_trx_expiration_window": 600, |
|
|
"max_transaction_delay": 3888000, |
|
|
"max_inline_action_size": 4096, |
|
|
"max_inline_action_depth": 4, |
|
|
"max_authority_depth": 6 |
|
|
} |
|
|
} |
|
|
EOT |
|
|
|
|
|
|
|
|
initialize the blockchain with genesis. This is a one-time operation, and you can press Ctrl-C when it runs for few seconds. |
|
|
/usr/local/eosio/bin/nodeos --data-dir /home/eosio/data --config-dir /home/eosio/etc --genesis-json=etc/genesis.json |
|
|
Ctrl-C |
|
|
|
|
|
cat >etc/nodeos.service <<'EOT' |
|
|
[Unit] |
|
|
Description=EOS nodeos |
|
|
[Service] |
|
|
Type=simple |
|
|
ExecStart=/usr/local/eosio/bin/nodeos --data-dir /home/eosio/data --config-dir /home/eosio/etc |
|
|
TimeoutStartSec=30s |
|
|
TimeoutStopSec=300s |
|
|
Restart=no |
|
|
User=eosio |
|
|
Group=eosio |
|
|
KillMode=control-group |
|
|
[Install] |
|
|
WantedBy=multi-user.target |
|
|
EOT |
|
|
|
|
|
sudo cp etc/nodeos.service /etc/systemd/system/ |
|
|
sudo systemctl daemon-reload |
|
|
sudo systemctl enable nodeos |
|
|
sudo systemctl restart nodeos |
|
|
|
|
|
|
|
|
|