Skip to content

Instantly share code, notes, and snippets.

@Buravo46
Last active March 20, 2018 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Buravo46/60e1ba6a4e629f32b846e1b1aa6ef3b8 to your computer and use it in GitHub Desktop.
Save Buravo46/60e1ba6a4e629f32b846e1b1aa6ef3b8 to your computer and use it in GitHub Desktop.
【Hackmd】インストール手順メモ

概要

Hackmdの構築

※下記手順でERROR発生中

手順

  • yum
yum update -y
yum install -y epel-release
  • nodebrewのインストール
curl -L git.io/nodebrew | perl - setup
echo "export PATH=\$HOME/.nodebrew/current/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc
  • nodeのインストール
# インストール可能なNode.jsのバージョン一覧
nodebrew ls-remote
# v6.13.1のインストール
nodebrew install-binary v6.13.1
# インストール済みのNode.jsのバージョン一覧
nodebrew ls
# v6.13.1への切り替え
nodebrew use v6.13.1
  • uWebSockets, node-gypのインストール
# install
npm install -g uws node-gyp
npm install -g mysql
npm install -g webpack
npm install -g copy-webpack-plugin
# link
npm link node-gyp
npm link uws
npm link mysql
npm link webpack
npm link copy-webpack-plugin
  • mysqlのインストール
# MySQLのインストール
yum install -y http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum install -y mysql-community-server
# MySQLの起動、自動起動化
systemctl start mysqld.service
systemctl enable mysqld.service
# ランダムで生成されたパスワードの出力
cat /var/log/mysqld.log | grep password
# MySQLの初期化
mysql_secure_installation
# Enter password for user root:<grepで検索したパスワード>
# New password:<新規パスワード>
# Re-enter new password:<新規パスワード>
# Change the password for root ? ((Press y|Y for Yes, any other key for No) :y
# New password:<新規パスワード>
# Re-enter new password:<新規パスワード>
# Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :y
# Remove anonymous users? (Press y|Y for Yes, any other key for No) :y
# Disallow root login remotely? (Press y|Y for Yes, any other key for No) :y
# Remove test database and access to it? (Press y|Y for Yes, any other key for No) :y
# Reload privilege tables now? (Press y|Y for Yes, any other key for No) :y
# MySQLの文字コードをutf8化
vi /etc/my.cnf
# 以下のように設定追加
[mysql]
default-character-set = utf8
[mysqld]
character-set-server=utf8
# 再起動
systemctl restart mysqld.service
# DB作成
mysql -u root -p -e "create database hackmd_db"
# user
mysql -u root -p -e "create user hackmd@localhost identified by 'Hackmd01?'"
# ユーザーにDB操作権限を付与
mysql -u root -p -e "grant all privileges on hackmd_db.* to hackmd@localhost identified by 'Hackmd01?'"
  • hackmdのインストール
yum install -y git
git clone https://github.com/hackmdio/hackmd.git
cd hackmd/
./bin/setup
cp config.json config-bak.json
vi config.json

{
    "production": {
        "domain": "localhost",
        "debug": false,
        "urlpath": "hackmd",
        "db": {
            "username": "hackmd",
            "password": "Hackmd01?",
            "database": "hackmd_db",
            "host": "localhost",
            "port": "3306",
            "dialect": "mysql"
        }
    }
}

export NODE_ENV='production'
export HMD_DB_URL='mysql://hackmd:Hackmd01?@localhost:3306/hackmd_db'
npm run build
node app.js

ERROR

環境変数をちゃんと設定できてなかったから下記エラーが発生

2018-03-14T15:21:11.399Z - info: dmp worker process started
Unhandled rejection SequelizeAccessDeniedError: ER_ACCESS_DENIED_ERROR: Access denied for user ''@'localhost' (using password: NO)
    at Handshake._callback (/root/hackmd/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:83:20)
    at Handshake.Sequence.end (/root/hackmd/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
    at Handshake.ErrorPacket (/root/hackmd/node_modules/mysql/lib/protocol/sequences/Handshake.js:132:8)
    at Protocol._parsePacket (/root/hackmd/node_modules/mysql/lib/protocol/Protocol.js:279:23)
    at Parser.write (/root/hackmd/node_modules/mysql/lib/protocol/Parser.js:76:12)
    at Protocol.write (/root/hackmd/node_modules/mysql/lib/protocol/Protocol.js:39:16)
    at Socket.<anonymous> (/root/hackmd/node_modules/mysql/lib/Connection.js:103:28)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:559:20)

connection-manager.jsのコネクション設定を修正したら以下は出なくなった。

Unhandled rejection SequelizeConnectionError: connect ETIMEDOUT
    at Handshake._callback (/root/hackmd/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:95:20)
    at Handshake.Sequence.end (/root/hackmd/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
    at Protocol.handleNetworkError (/root/hackmd/node_modules/mysql/lib/protocol/Protocol.js:363:14)
    at Connection._handleNetworkError (/root/hackmd/node_modules/mysql/lib/Connection.js:428:18)
    at Connection._handleConnectTimeout (/root/hackmd/node_modules/mysql/lib/Connection.js:424:8)
    at Socket.g (events.js:292:16)
    at emitNone (events.js:86:13)
    at Socket.emit (events.js:185:7)
    at Socket._onTimeout (net.js:348:8)
    at ontimeout (timers.js:386:11)
    at tryOnTimeout (timers.js:250:5)
    at Timer.listOnTimeout (timers.js:214:5)

DNSのlookタイムアウトエラーみたいなのでnmcli c mod デバイス名 ipv4.dns "8.8.8.8"systemctl restart networkをすると出なくなった。

Unhandled rejection SequelizeConnectionError: getaddrinfo EAI_AGAIN hackmd:3306
    at Handshake._callback (/root/hackmd/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:96:20)
    at Handshake.Sequence.end (/root/hackmd/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
    at Protocol.handleNetworkError (/root/hackmd/node_modules/mysql/lib/protocol/Protocol.js:363:14)
    at Connection._handleNetworkError (/root/hackmd/node_modules/mysql/lib/Connection.js:428:18)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at connectErrorNT (net.js:1040:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

未解決

Unhandled rejection SequelizeHostNotFoundError: getaddrinfo ENOTFOUND hackmd hackmd:3306
    at Handshake._callback (/root/hackmd/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:87:20)
    at Handshake.Sequence.end (/root/hackmd/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
    at Protocol.handleNetworkError (/root/hackmd/node_modules/mysql/lib/protocol/Protocol.js:363:14)
    at Connection._handleNetworkError (/root/hackmd/node_modules/mysql/lib/Connection.js:428:18)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at connectErrorNT (net.js:1040:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

参考サイト

https://qiita.com/ritukiii/items/08df5be6d50871124aaf

https://qiita.com/kazuhiro1128/items/bb003bbc5747f55938a2

http://chaika.hatenablog.com/entry/2016/12/07/120000

https://qiita.com/sinmetal/items/154e81823f386279b33c

https://qiita.com/kumagi/items/ec948c957910cd052056

https://qiita.com/YoheiMiyamoto/items/f454a6c759f2245b085f

https://wiki.communecter.org/en/hackmd-_-configuration.html

http://server.etutsplus.com/centos-7-dns-resover/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment