用centos 搞了3-4天仪表盘仍然有各种报错,索性祭出终极大法,换Ubuntu

ubuntu默认没开ssh,无法远程,先开sshd

sudo apt-get install openssh-server

sudo /etc/init.d/ssh start

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第1张图片

先下载一些库

apt-get install git libmysqlclient-dev libpq-dev libsqlite3-dev ruby-dev libxml2-dev libxslt-dev nodejs

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第2张图片

git也要安装下

sudo apt-get update

sudo apt-get install git

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第3张图片

下载仪表盘程序

cd /usr/share

sudo mkdir -pv puppet-dashboar

cd puppet-dashboard

sudo git clone https://github.com/sodabrew/puppet-dashboard.git

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第4张图片

安装mariadb

sudo apt install mariadb-server

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第5张图片

启动下

/etc/init.d/mysql start

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第6张图片

sudo systemctl stop mysql

sudo mysqld_safe --skip-grant-tables &

mysql -u root

select Host,User,plugin from mysql.user where User='root';

update mysql.user set plugin='mysql_native_password';

update mysql.user set password=PASSWORD("12345.coM") where User='root';

flush privileges;

systemctl stop mysql

mysql就不贴图了

配置下mysql缓存

vim /etc/mysql/my.cnf

加一行

max_allowed_packet = 32M

systemctl start mysql

创建表和用户

CREATE DATABASE dashboard_production CHARACTER SET utf8;

CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'my_password';

GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';

把样本复制出来,填入数据库连接信息

sudo cp config/settings.yml.example config/settings.yml

sudo cp config/database.yml.example config/database.yml

sudo vim config/database.yml

0d2762e30a5745e29fed56b5e0a3a64f

安装gem,并且用gem 部署bundle

sudo gem install bundler

6e6aa82377db41db862ecee70efec8cf

sudo bundle install --deployment

一路顺畅

30d93e9cfb1b46289e2f48531d204c1a

设置数据库和编译

sudo RAILS_ENV=production bundle exec rake db:setup

b31ba1c142d64af0a0deb1e58989a1a4

生产环境缺少密码

cd config

vim secrets.yml

里面开发和测试环境都是hard code写的安全码

生产环境不建议存明文密码

production:

secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

# Do not keep production secrets in the unencrypted secrets file.

# Instead, either read values from the environment.

# Or, use `bin/rails secrets:setup` to configure encrypted secrets

# and move the `production:` environment over there.

建议通过

export SECRET_KEY_BASE=$(bundle exec rails secret)

我先创建测试环境

sudo RAILS_ENV=test bundle exec rake db:setup

a97589c1f301430fb7ca1a6206da8cb9

创建test表和用户

CREATE DATABASE dashboard_test CHARACTER SET utf8;

CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'my_password';

GRANT ALL PRIVILEGES ON dashboard_test.* TO 'dashboard'@'localhost';

4a2400b8786248578b92bef3546fed24

仍然有外键冲突

不管了,先让我试试看预编译

sudo RAILS_ENV=test bundle exec rake assets:precompile

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第7张图片

无报错

sudo RAILS_ENV=test bundle exec rails server

Puppet 实验十一 ubunto 安装 puppet-dashboard 仪表盘_第8张图片

终于看到了久违的webui