Centos创建以太坊私有链

首先第一步当然是更新,然后使用yum命令安装golang语言

yum –y update
yum install golang
git clone https://github.com/ethereum/go-ethereum.git  
cd go-ethereum  
make all
cd go-ethereum
make all

这里出现了编译错误,提示go的版本1.8.3,编译需要最少1.9。前往https://www.golangtc.com/download goland下载go1.10.1.linux-amd64.tar.gz,再次安装前需要卸载原有的golang,yum –y remove golang

tar -C /usr/local -xzf go1.10.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

重复make,在go-ethereum/build/bin使用ll命令,会罗列文件夹内的在go-ethereum/build/bin目录下创建init.json的文本文件,内容如下:

{
  "config": {
        "chainId": 14,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x05000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

保存并退出文件,同目录下执行./geth –datadir “/app/chain” init init.json完成创世区块的创建,同目录下执行./geth –rpc –rpccorsdomain “*” –datadir “/app/chain” –port “30303” –rpcapi “db,eth,net,web3” –networkid 100000 console每次启动多使用此命令。

这时进入geth命令,可以创建账户转账查余额等操作

//查看coinbase账户余额
baseAccount = eth.accounts[0]
num = eth.getBalance(baseAccount)
//换算单位为eth
web3.fromWei(num)
//新建一个账户
personal.newAccount("account")
//查看新建账户的余额
account1 = eth.accounts[1]
eth.getBalance(account1)
//从coinbase账户转给account1账户1eth
personal.unlockAccount(baseAccount ,"coinbase")
eth.sendTransaction({from:baseAccount,to:account1,value:web3.toWei(1,"ether")})
//观察挖矿shell的输出,等待交易打包完成后,查询account1的账户余额
eth.getBalance(account1)

此时账户余额为零,因为我们的交易还未成功写进区块,写进区块的方式是挖矿,我们再次开启挖矿,挖矿成功后,并停止挖矿,再次查看余额。到这里就完成了私有链创建,账户创建,挖矿,转账等操作。私有链用于调试,在私有链上挖矿是没有意义的。

 

参考文献:

https://www.cnblogs.com/beyang/p/8469227.html

https://blog.csdn.net/wo541075754/article/details/78926177

https://blog.csdn.net/koastal/article/details/78737543

 

 

 

低配电脑挖矿门罗币MONERO Mining Machine

建站的时候租用了一台服务器,centos的操作系统。上面只放了两个网站, CPU使用率基本为零,偶尔操作的时候也只有40%,闲置是极大的浪费。资料说门罗币(monero)可以用cpu挖,那我也挖门罗币吧。

首先要有钱包地址,本地钱包或者在线钱包,我选择了后者,所以前者就不多说了。在线平台有很多,网友说这家还不错https://mymonero.com/https://hitbtc.com/,注册账号之后在account里找到钱包地址,下面会用到。

接下来要在服务器上安装挖矿工具,以下命令复制粘贴。

yum install centos-release-scl cmake3 hwloc-devel libmicrohttpd-devel openssl-devel
yum install devtoolset-4-gcc*
scl enable devtoolset-4 bash
git clone https://github.com/fireice-uk/xmr-stak-cpu xmr-stak
cd xmr-stak
cmake3 .
make install

安装成功之后输入/usr/local/bin/cmake –version视版本略有不同,然后修改config.txt文件,在文件中的109行-111行填入矿池钱包地址等信息,端口3333难度较低笔记本也可以算,5555,7777和9999要求都较高,文件中有照着来就可以,基本如下。将26行左右cpu_threads_conf及随后中括号前的星号删除,同样文件中有照着来就可以。

"pool_address" : "gulf.moneroocean.stream:10016", "wallet_address" : "43VPcU1khYu7S3H91b4txQfrs5wsuwAShVUXFnZMbXtLfQFomQhxb7pjXqrT3anyZ22j7DEE74GkbVcQFyH2nNiC3d2Vne3", "pool_password" : "x",

输入接下来的命令就可以挖矿了。

cd /root/xmr-stak/bin/
./xmr-stak-cpu

但是有时会遇到MEMORY ALLOC FAILED: mmap failed的问题,停止运行后进入/etc/security/limits.conf,在文末添加

* soft memlock 262144
* hard memlock 262144

保存并退出,输入下面的命令后重启。一般这样问题就解决了。

sysctl -w vm.nr_hugepages=128

更新11042018:xmr-stak工具已经升级了可以在安装的时候运行以下命令。

yum -y install epel-release
yum -y install centos-release-scl cmake3 hwloc-devel libmicrohttpd-devel openssl-devel git screen nano make htop
yum -y install devtoolset-4-gcc*
scl enable devtoolset-4 bash
git clone https://github.com/fireice-uk/xmr-stak.git
cd xmr-stak/
cmake3 . -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF
make install
cd bin/
./xmr-stak

更新18042018:门罗难度已经太高了,提交的计算结果一般都会被矿池拒绝,转挖永旺币AEON,钱包地址记得换成自己的。

"pool_address" : "huadong1-aeon.ppxxmr.com:1333", 
"wallet_address" : "WmscEEuYBKQ5Cb3PDACu4QNDqisRwLsErUjhUKYcCn1L8ZCbYVFnPxVhFaaEttMUt9c61Em6dP1WeHkyDtyRgWf11Q6LU4HWM", 
"pool_password" : "x",

这里附上一个可能出现的问题及解决方法的链接。

https://www.ezloo.com/2018/01/monero_xmr_stak.html

参考文献:

https://maijiaoben.com/centos-monero.html
https://qing.su/article/129.html
http://www.hostloc.com/thread-415078-1-1.html

 

The followings are just for practicing English.

An ECS with centos installed was rent while creating websites. Only two websites are running on it. CPU usage usually is 0%, and sometimes 40% at most. Leaving it unused is a waste. It is sad that CPU calculation can obtain Monero, so let’s do it.

The first step is to get a wallet address. There are two methods to get it, local registration and online registration. The later one is chosen, so the previous one is neglected here. There are many platforms, such as https://mymonero.com/, and https://hitbtc.com/. After registration, you need to copy the address, which will be used later.

Copy and paste the commands to install mining tool on the server:

yum install centos-release-scl cmake3 hwloc-devel libmicrohttpd-devel openssl-devel
yum install devtoolset-4-gcc*
scl enable devtoolset-4 bash
git clone https://github.com/fireice-uk/xmr-stak-cpu xmr-stak
cd xmr-stak
cmake3 .
make install

After installation, check the version by input: /usr/local/bin/cmake –version. The commands may vary depending on the versions. Then, modify “config.txt”, input your pool address, your wallet address, and your password ID based on the examples at line 109-111, and delete the “*” at line 25-29 approximately. Port 3333 is the easiest for low & mid-range CPUs.

After these, you can start mining by input the following commands:

cd /root/xmr-stak/bin/
./xmr-stak-cpu

However, I met the problem of MEMORY ALLOC FAILED: mmap failed. The solution is to stop mining and enter /etc/security/limits.conf, add the following lines in the end of the file:

* soft memlock 262144
* hard memlock 262144

Save and exit the file and input “sysctl -w vm.nr_hugepages=128”. Then, reboot.

Real name authentication of domain name in China

Earlier this day, one of the websites on my server cannot be reached. After checking, I found the cause was the domain had not been authenticated.

According to Chinese Internet network domain name management method,  .xin /.cn/.com/.net/.top/.xyz/.club/.vip/.shop/.wang/.ren/.site/.我爱你/.集团/.biz/.red/.kim/.pro/.info/.mobi/.ltd/.group/.link/.ink/.在线/.中文网/.网址/.work/.online/ .tech/.fun/.store/. must have real name authentication。Otherwise, it will be in the status of Serverhold.

Details can be accessed here:

https://help.aliyun.com/knowledge_detail/41880.html#%E4%B9%B0%E5%9F%9F%E5%90%8D%E5%BF%85%E9%A1%BB%E8%BF%9B%E8%A1%8C%E5%AE%9E%E5%90%8D%E8%AE%A4%E8%AF%81%E5%90%97%EF%BC%9F

Multi-sites and 404 of Permalinks issue

Initially, I was going to write something about using Modelica for simulations of HVAC systems. But I have been assigned to other tasks. So, I just share some experience about connecting one IP with multi-domains here.

My server has been running a website already when the server is set for running multi-sites, the original files are reordered for a clean view. I used the method for adding the site to Nginx firstly. But it did not work. While searching for solutions, I realized that my server is mainly using Apache, the easier way was to set up virtual hosts. So the codes added to /etc/httpd/conf/http.conf are as follows:

<VirtualHost *:80>
ServerAdmin example@example.com
DocumentRoot /var/www/html/a
ServerName www.a.com
ErrorLog /var/log/httpd/a/error_log
CustomLog /var/log/httpd/a/access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin example@example.com
DocumentRoot /var/www/html/b
ServerName www.b.com
ErrorLog /var/log/httpd/b/error_log
CustomLog /var/log/httpd/b/access_log common
</VirtualHost>

Then, I created another database for the other site. Unfortunately, my own site failed to work while opening blogs. The blogs can only work when permalinks are default. Then, the problem is solved by enabling the “mod_rewrite” for the folders that contain WordPress files thanks to Don.

Adding the following codes to /etc/httpd/conf/http.conf.

<Directory "/var/www/html/***">
Order allow,deny
Allow from all
AllowOverride All
</Directory>

 

Bibliography:

https://yq.aliyun.com/ziliao/48568

https://community.rackspace.com/products/f/48/t/3180

Set Up A Desktop On A Sever

Recently, I tried to download recovery image for my Surface Pro 3 from the official website.  The established downloading link lost connection after a few minutes and the download speed was within 10 kb/s.

Since the server rent from Aliyun is overseas, I considered to download it from the server. There are two options considered, usage of a text web browser or installation of a desktop.

Firstly, I used w3m and elinks. Both returned the result of ‘JavaScript is disabled’. The text web browsers do not support JavaScript. There are extensions of w3m-js, but I did not find available links.

yum install w3m w3m-img –y(rpm -e w3m w3m-img)
yum install links
yum install elinks(rpm -e links elinks);

Then, I have to install a desktop for it. Install X Windows and Desktop. After the work is done, I want to have it uninstalled.

yum -y groupinstall "X Window System" "MATE Desktop"
(sometimes, yum -y groupinstall "X Window System"  "MATE Desktop")
systemctl set-default graphical.target
reboot

yum -y groupremove "X Window System" "MATE Desktop"
(sometimes, yum groups remove "X Window System" "MATE Desktop")
systemctl set-default multi-user.target
reboot

Bibliography:

https://help.aliyun.com/knowledge_detail/41227.html

https://jingyan.baidu.com/article/4b52d702b5bd90fc5c774ba7.html

IDF2JSON

The last version eliminated all comments because they are not needed in the JSON format. But the comments can be used as properties. So, I did some modifications. Since I am not familiar with Fortran. All the work is done with Python by replacing characters to change the structure. The results are shown below:

{
    "_Version": "8.8",
    "_Timestep": "4",
    "_Building": {
        " Name": "Simple One Zone w Windows",
        " North Axis (deg)": "0",
        " Terrain": "Suburbs",
        " Loads Convergence Tolerance Value": "0.04",
        " Temperature Convergence Tolerance Value (deltaC)": "0.004",
        " Solar Distribution": "MinimalShadowing",
        " Maximum Number of Warmup Days": "30",
        " Minimum Number of Warmup Days": "6"
    },
    "_HeatBalanceAlgorithm": "ConductionTransferFunction",
    "_SurfaceConvectionAlgorithm___Inside": "TARP",
    "_SurfaceConvectionAlgorithm___Outside": "DOE-2",
    "_SimulationControl": {
        " Do Zone Sizing Calculation": "No",
        " Do System Sizing Calculation": "No",
        " Do Plant Sizing Calculation": "No",
        " Run Simulation for Sizing Periods": "Yes",
        " Run Simulation for Weather File Run Periods": "No"
    },
    "_RunPeriod": {
        " Name": "Null",
        " Begin Month": "1",
        " Begin Day of Month": "1",
        " End Month": "12",
        " End Day of Month": "31",
        " Day of Week for Start Day": "Tuesday",
        " Use Weather File Holidays and Special Days": "Yes",
        " Use Weather File Daylight Saving Period": "Yes",
        " Apply Weekend Holiday Rule": "No",
        " Use Weather File Rain Indicators": "Yes",
        " Use Weather File Snow Indicators": "Yes"
    },
    "_Site___Location": {
        " Name": "Denver Stapleton Intl Arpt CO USA WMO=724690",
        " Latitude (deg)": "39.77",
        " Longitude (deg)": "-104.87",
        " Time Zone (hr)": "-7.00",
        " Elevation (m)": "1611.00"
    },
    "_SizingPeriod___DesignDay": {
        " Name": "Denver Stapleton Intl Arpt Ann Clg 1% Condns DB=>MWB",
        " Month": "7",
        " Day of Month": "21",
        " Day Type": "SummerDesignDay",
        " Maximum Dry-Bulb Temperature (C)": "32.6",
        " Daily Dry-Bulb Temperature Range (deltaC)": "15.2",
        " Dry-Bulb Temperature Range Modifier Type": "Null",
        " Dry-Bulb Temperature Range Modifier Day Schedule Name": "Null",
        " Humidity Condition Type": "Wetbulb",
        " Wetbulb or DewPoint at Maximum Dry-Bulb (C)": "15.6",
        " Humidity Condition Day Schedule Name": "Null",
        " Humidity Ratio at Maximum Dry-Bulb (kgWater/kgDryAir)": "Null",
        " Enthalpy at Maximum Dry-Bulb (J/kg)": "Null",
        " Daily Wet-Bulb Temperature Range (deltaC)": "Null",
        " Barometric Pressure (Pa)": "83411.",
        " Wind Speed (m/s)": "4",
        " Wind Direction (deg)": "120",
        " Rain Indicator": "No",
        " Snow Indicator": "No",
        " Daylight Saving Time Indicator": "No",
        " Solar Model Indicator": "ASHRAEClearSky",
        " Beam Solar Day Schedule Name": "Null",
        " Diffuse Solar Day Schedule Name": "Null",
        " ASHRAE Clear Sky Optical Depth for Beam Irradiance (taub) (dimensionless)": "Null",
        " ASHRAE Clear Sky Optical Depth for Diffuse Irradiance (taud) (dimensionless)": "Null",
        " Sky Clearness": "1.00"
    },
    "_Material___NoMass": {
        " Name": "R31LAYER",
        " Roughness": "Rough",
        " Thermal Resistance (m2-K/W)": "5.456",
        " Thermal Absorptance": "0.9000000",
        " Solar Absorptance": "0.7500000",
        " Visible Absorptance": "0.7500000"
    },
    "_Material": {
        " Name": "C5 - 4 IN HW CONCRETE",
        " Roughness": "MediumRough",
        " Thickness (m)": "0.1014984",
        " Conductivity (W/m-K)": "1.729577",
        " Density (kg/m3)": "2242.585",
        " Specific Heat (J/kg-K)": "836.8000",
        " Thermal Absorptance": "0.9000000",
        " Solar Absorptance": "0.6500000",
        " Visible Absorptance": "0.6500000"
    },
    "_Construction": {
        " Name": "ROOF31",
        " Outside Layer": "R31LAYER"
    },
    "_Construction___WindowDataFile": {
        " Name": "DoubleClear",
        " File Name": "..BACKSLASHdatasetsBACKSLASHWindow5DataFile.dat"
    },
    "_Site___GroundTemperature___BuildingSurface": "18.89,18.92,19.02,19.12,19.21,19.23,19.07,19.32,19.09,19.21,19.13,18.96",
    "_Zone": {
        " Name": "ZONE ONE",
        " Direction of Relative North (deg)": "0",
        " X Origin (m)": "0",
        " Y Origin (m)": "0",
        " Z Origin (m)": "0",
        " Type": "1",
        " Multiplier": "1",
        " Ceiling Height (m)": "autocalculate",
        " Volume (m3)": "autocalculate"
    },
    "_ScheduleTypeLimits": {
        " Name": "Fraction",
        " Lower Limit Value": "0.0",
        " Upper Limit Value": "1.0",
        " Numeric Type": "CONTINUOUS"
    },
    "_GlobalGeometryRules": {
        " Starting Vertex Position": "UpperLeftCorner",
        " Vertex Entry Direction": "CounterClockWise",
        " Coordinate System": "World"
    },
    "_BuildingSurface___Detailed": {
        " Name": "Zn001___Roof001",
        " Surface Type": "Roof",
        " Construction Name": "ROOF31",
        " Zone Name": "ZONE ONE",
        " Outside Boundary Condition": "Outdoors",
        " Outside Boundary Condition Object": "Null",
        " Sun Exposure": "SunExposed",
        " Wind Exposure": "WindExposed",
        " View Factor to Ground": "0",
        " Number of Vertices": "4",
        " X,Y,Z ==> Vertex 1 (m)": "0.000000,15.24000,4.572",
        " X,Y,Z ==> Vertex 2 (m)": "0.000000,0.000000,4.572",
        " X,Y,Z ==> Vertex 3 (m)": "15.24000,0.000000,4.572",
        " X,Y,Z ==> Vertex 4 (m)": "15.24000,15.24000,4.572"
    },
    "_FenestrationSurface___Detailed": {
        " Name": "Zn001_Wall001_Win001",
        " Surface Type": "Window",
        " Construction Name": "DoubleClear",
        " Building Surface Name": "Zn001___Wall001",
        " Outside Boundary Condition Object": "Null",
        " View Factor to Ground": "0.5000000",
        " Shading Control Name": "Null",
        " Frame and Divider Name": "Null",
        " Multiplier": "1.0",
        " Number of Vertices": "4",
        " X,Y,Z ==> Vertex 1 (m)": "0.548000,0,2.5000",
        " X,Y,Z ==> Vertex 2 (m)": "0.548000,0,0.5000",
        " X,Y,Z ==> Vertex 3 (m)": "5.548000,0,0.5000",
        " X,Y,Z ==> Vertex 4 (m)": "5.548000,0,2.5000"
    },
    "_Output___Variable": "ZN001___WALL001___WIN001,Surface Outside Face Temperature,timestep",
    "_Output___VariableDictionary": "Regular",
    "_Output___Surfaces___Drawing": "dxf",
    "_Output___Surfaces___List": "details",
    "_Output___Constructions": "Constructions",
    "_Output___Meter___MeterFileOnly": "EnergyTransfer___Facility,hourly",
    "_OutputControl___Table___Style": {
        " Column Separator": "HTML"
    },
    "_Output___Table___SummaryReports": {
        " Report 1 Name": "AllSummary"
    }
}

JSON implementation for EnergyPlus IDF

EnergyPlus is developed based on Fortran 950. The file format looks very like JavaScript Object Notation (JSON). By extracting the comments as properties, it can be transformed to JSON format. I did some modifications to EnergyPlus IDF file and transformed it to JSON format with Python. The JSON file was validated by https://www.bejson.com/. Then, I transformed it back to IDF and ran the simulation again. An example file is shown below.

{
"Version": "8.8",
"Timestep": "4",
"Building": "___Simple One Zone w Windows,___0,___Suburbs,___0.04,___0.004,___MinimalShadowing,___30,___6",
"HeatBalanceAlgorithm": "ConductionTransferFunction",
"SurfaceConvectionAlgorithm___Inside": "TARP",
"SurfaceConvectionAlgorithm___Outside": "DOE-2",
"SimulationControl": "___No,___No,___No,___Yes,___No",
"RunPeriod": "___Null,___1,___1,___12,___31,___Tuesday,___Yes,___Yes,___No,___Yes,___Yes",
"Site___Location": "___Denver Stapleton Intl Arpt CO USA WMO=724690,___39.77,___-104.87,___-7.00,___1611.00",
"SizingPeriod___DesignDay": "___Denver Stapleton Intl Arpt Ann Clg 1% Condns DB=>MWB,___7,___21,___SummerDesignDay,___32.6,___15.2,___Null,___Null,___Wetbulb,___15.6,___Null,___Null,___Null,___Null,___83411.,___4,___120,___No,___No,___No,___ASHRAEClearSky,___Null,___Null,___Null,___Null,___1.00",
"Material___NoMass": "___R31LAYER,___Rough,___5.456,___0.9000000,___0.7500000,___0.7500000",
"Material": "___C5 - 4 IN HW CONCRETE,___MediumRough,___0.1014984,___1.729577,___2242.585,___836.8000,___0.9000000,___0.6500000,___0.6500000",
"Construction": "___ROOF31,___R31LAYER",
"Construction___WindowDataFile": "___DoubleClear,___..BACKSLASHdatasetsBACKSLASHWindow5DataFile.dat",
"Site___GroundTemperature___BuildingSurface": "18.89,18.92,19.02,19.12,19.21,19.23,19.07,19.32,19.09,19.21,19.13,18.96",
"Zone": "___ZONE ONE,___0,___0,___0,___0,___1,___1,___autocalculate,___autocalculate",
"ScheduleTypeLimits": "___Fraction,___0.0,___1.0,___CONTINUOUS",
"GlobalGeometryRules": "___UpperLeftCorner,___CounterClockWise,___World",
"BuildingSurface___Detailed": "___Zn001___Roof001,___Roof,___ROOF31,___ZONE ONE,___Outdoors,___Null,___SunExposed,___WindExposed,___0,___4,___0.000000,15.24000,4.572,___0.000000,0.000000,4.572,___15.24000,0.000000,4.572,___15.24000,15.24000,4.572",
"FenestrationSurface___Detailed": "___Zn001___Wall001___Win001,___Window,___DoubleClear,___Zn001___Wall001,___Null,___0.5000000,___Null,___Null,___1.0,___4,___0.548000,0,2.5000,___0.548000,0,0.5000,___5.548000,0,0.5000,___5.548000,0,2.5000",
"Output___Variable": "ZN001___WALL001___WIN001,Surface Outside Face Temperature,timestep",
"Output___VariableDictionary": "Regular",
"Output___Surfaces___Drawing": "dxf",
"Output___Surfaces___List": "details",
"Output___Constructions": "Constructions",
"Output___Meter___MeterFileOnly": "EnergyTransfer___Facility,hourly",
"OutputControl___Table___Style": "___HTML",
"Output___Table___SummaryReports": "___AllSummary"
}

Error establishing a database connection

After upgrading to Version 4.9. I got an error of Error establishing a database connection. The possible cause of ‘Error establishing a database connection’ is the problems in MySQL, check the username and password in wp-config.php. But the causes may vary.
Firstly, open ‘wp-config.php’ and set ‘define(‘WP_DEBUG’, ‘true’)’;
Then, go to the website to see the possible problems. In my case, the website indicated two errors, problems with my MySQL account and a warning: mysql_connect(): Headers and client library minor version mismatch.
I used this command ‘php -i|grep Client’ to check the possible cause of the warning. Turned out it was the version of MySQL being too old.
So, I changed the MySQL account settings in the wp-config file. Then, reinstalled MySQL to its newest version and restarted services with following lines:

yum remove php-MySQL
yum install php-mysqlnd
systemctl restart httpd
systemctl restart mysqld

Thanks to:
http://blog.csdn.net/ausboyue/article/details/52790222
https://devework.com/debugging-in-wordpress.html