ELK安裝 GrokDebuger 腳本和Web環境

來源:本站原創 elk 超過1,201 views圍觀 0條評論

 

 https://www.cnblogs.com/liuning8023/p/5310541.html

 
第一部分,腳本解析形式
內容
安裝 RVM
安裝 Ruby 和 Gems
安裝 Rails
安裝 jls-grok
Ruby grok 解析
調試 grok

————————安裝rvm
rvm(Ruby Version Manager),是一個非常好用的ruby版本管理以及安裝工具。
[[email protected] grokbug]# gem install rvm
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
Fetching: rvm-1.11.3.9.gem (100%)
Successfully installed rvm-1.11.3.9
Parsing documentation for rvm-1.11.3.9
Installing ri documentation for rvm-1.11.3.9
1 gem installed
[[email protected] grokbug]# rvm
-bash: rvm: command not found
[[email protected] grokbug]# curl -sSL https://get.rvm.io | sudo bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: directory `/root/.gnupg’ created

安裝rvm失敗,轉用腳本安裝

https://github.com/huacnlee/init.d/blob/master/install_rvm

YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
1 gem installed
Bundler version 1.16.1
————————— Install Successed —————————–

[[email protected] grokbug]# rvm
-bash: rvm: command not found ———報錯

[[email protected] grokbug]# find / -name rvm
/usr/local/rvm/scripts/rvm

[[email protected] grokbug]# source /usr/local/rvm/scripts/rvm ——-解決

永久解決
將 source /usr/local/rvm/scripts/rvm 加入~/.bash_profile文件
[[email protected] grokbug]# rvm
Ruby enVironment Manager 1.29.3 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

[[email protected] grokbug]#

  [[email protected] grokbug]# /usr/local/rvm/bin/rvm list known
[[email protected] grokbug]# /usr/local/rvm/bin/rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.7]
[ruby-]2.3[.4]
[ruby-]2.4[.1]
ruby-head

————–安裝指定版本ruby

[[email protected] grokbug]# /usr/local/rvm/bin/rvm install 2.2.0 –disable-binary
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bzip2, libffi-devel, libtool, patch, readline-devel, sqlite-devel, libyaml-devel………..
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.2.0, this may take a while depending on your cpu(s)…
ruby-2.2.0 – #downloading ruby-2.2.0, this may take a while depending on your connection…
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.6M  100 12.6M    0     0   274k      0  0:00:47  0:00:47 –:–:–  249k
ruby-2.2.0 – #extracting ruby-2.2.0 to /usr/local/rvm/src/ruby-2.2.0….
ruby-2.2.0 – #applying patch /usr/local/rvm/patches/ruby/2.2.0/fix_installing_bundled_gems.patch.
ruby-2.2.0 – #applying patch /usr/local/rvm/patches/ruby/2.2.0/openssl3.patch.
ruby-2.2.0 – #configuring…………………………………………………
ruby-2.2.0 – #post-configuration..
ruby-2.2.0 – #compiling…………………………………………………………………….
ruby-2.2.0 – #installing……………………….
ruby-2.2.0 – #making binaries executable..
ruby-2.2.0 – #downloading rubygems-2.6.14
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  751k  100  751k    0     0   135k      0  0:00:05  0:00:05 –:–:–  178k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.2.0 – #extracting rubygems-2.6.14….
ruby-2.2.0 – #removing old rubygems………
ruby-2.2.0 – #installing rubygems-2.6.14………………………
ruby-2.2.0 – #gemset created /usr/local/rvm/gems/[email protected]
ruby-2.2.0 – #importing gemset /usr/local/rvm/gemsets/global.gems………………………………………..
ruby-2.2.0 – #generating global wrappers……..
ruby-2.2.0 – #gemset created /usr/local/rvm/gems/ruby-2.2.0
ruby-2.2.0 – #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.0 – #generating default wrappers……..
ruby-2.2.0 – #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.2.0 – #complete
Please be aware that you just installed a ruby that requires 2 patches just to be compiled on an up to date linux system.
This may have known and unaccounted for security vulnerabilities.
Please consider upgrading to ruby-2.4.1 which will have all of the latest security patches.
Ruby was built without documentation, to build it run: rvm docs generate-ri
[[email protected] grokbug]#

———切換ruby 版本
[[email protected] grokbug]# ruby -v
ruby 2.0.0p648 (2015-12-16) [x86_64-linux]

[[email protected] grokbug]# /usr/local/rvm/bin/rvm use 2.2.0

RVM is not a function, selecting rubies with ‘rvm use …’ will not work.  —報錯

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash –login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

[[email protected] grokbug]# source /usr/local/rvm/scripts/rvm ——-解決

切換ruby
[email protected] grokbug]# rvm use 2.2.0
Using /usr/local/rvm/gems/ruby-2.2.0

[[email protected] grokbug]# ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux] ———成功
[[email protected] grokbug]#

———安裝rails
 
  [[email protected] grokbug]# gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.4.gem (100%)
Successfully installed tzinfo-1.2.4
Fetching: activesupport-5.1.4.gem (100%)
ERROR:  Error installing rails:
    activesupport requires Ruby version >= 2.2.2.
[[email protected] grokbug]#

版本還是低。。繼續安裝

[[email protected] grokbug]# /usr/local/rvm/bin/rvm install 2.2.2 –disable-binary
Install of ruby-2.2.2 – #complete —完裝完成
[[email protected] grokbug]# rvm use 2.2.2
Using /usr/local/rvm/gems/ruby-2.2.2   —進行切換

繼續安裝rails
[[email protected] grokbug]# gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.1.gem (100%)
Successfully installed i18n-0.9.1
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.4.gem (100%)
Successfully installed tzinfo-1.2.4
Fetching: activesupport-5.1.4.gem (100%)
Successfully installed activesupport-5.1.4
Fetching: rack-2.0.3.gem (100%)
Successfully installed rack-2.0.3
Fetching: rack-test-0.8.2.gem (100%)
Successfully installed rack-test-0.8.2
Fetching: mini_portile2-2.3.0.gem (100%)
Successfully installed mini_portile2-2.3.0
Fetching: nokogiri-1.8.1.gem (100%)
Building native extensions.  This could take a while…
Successfully installed nokogiri-1.8.1
Fetching: crass-1.0.3.gem (100%)
Successfully installed crass-1.0.3
Fetching: loofah-2.1.1.gem (100%)
Successfully installed loofah-2.1.1
Fetching: rails-html-sanitizer-1.0.3.gem (100%)
Successfully installed rails-html-sanitizer-1.0.3
Fetching: rails-dom-testing-2.0.3.gem (100%)
Successfully installed rails-dom-testing-2.0.3
Fetching: builder-3.2.3.gem (100%)
Successfully installed builder-3.2.3
Fetching: erubi-1.7.0.gem (100%)
Successfully installed erubi-1.7.0
Fetching: actionview-5.1.4.gem (100%)
Successfully installed actionview-5.1.4
Fetching: actionpack-5.1.4.gem (100%)
Successfully installed actionpack-5.1.4
Fetching: activemodel-5.1.4.gem (100%)
Successfully installed activemodel-5.1.4
Fetching: arel-8.0.0.gem (100%)
Successfully installed arel-8.0.0
Fetching: activerecord-5.1.4.gem (100%)
Successfully installed activerecord-5.1.4
Fetching: globalid-0.4.1.gem (100%)
Successfully installed globalid-0.4.1
Fetching: activejob-5.1.4.gem (100%)
Successfully installed activejob-5.1.4
Fetching: mini_mime-1.0.0.gem (100%)
Successfully installed mini_mime-1.0.0
Fetching: mail-2.7.0.gem (100%)
Successfully installed mail-2.7.0
Fetching: actionmailer-5.1.4.gem (100%)
Successfully installed actionmailer-5.1.4
Fetching: nio4r-2.2.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed nio4r-2.2.0
Fetching: websocket-extensions-0.1.3.gem (100%)
Successfully installed websocket-extensions-0.1.3
Fetching: websocket-driver-0.6.5.gem (100%)
Building native extensions.  This could take a while…
Successfully installed websocket-driver-0.6.5
Fetching: actioncable-5.1.4.gem (100%)
Successfully installed actioncable-5.1.4
Fetching: thor-0.20.0.gem (100%)
Successfully installed thor-0.20.0
Fetching: method_source-0.9.0.gem (100%)
Successfully installed method_source-0.9.0
Fetching: railties-5.1.4.gem (100%)
Successfully installed railties-5.1.4
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Fetching: sprockets-3.7.1.gem (100%)
Successfully installed sprockets-3.7.1
Fetching: sprockets-rails-3.2.1.gem (100%)
Successfully installed sprockets-rails-3.2.1
Fetching: rails-5.1.4.gem (100%)
Successfully installed rails-5.1.4
Parsing documentation for concurrent-ruby-1.0.5
Installing ri documentation for concurrent-ruby-1.0.5
Parsing documentation for i18n-0.9.1
Installing ri documentation for i18n-0.9.1
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.4
Installing ri documentation for tzinfo-1.2.4
Parsing documentation for activesupport-5.1.4
Installing ri documentation for activesupport-5.1.4
Parsing documentation for rack-2.0.3
Installing ri documentation for rack-2.0.3
Parsing documentation for rack-test-0.8.2
Installing ri documentation for rack-test-0.8.2
Parsing documentation for mini_portile2-2.3.0
Installing ri documentation for mini_portile2-2.3.0
Parsing documentation for nokogiri-1.8.1
Installing ri documentation for nokogiri-1.8.1
Parsing documentation for crass-1.0.3
Installing ri documentation for crass-1.0.3
Parsing documentation for loofah-2.1.1
Installing ri documentation for loofah-2.1.1
Parsing documentation for rails-html-sanitizer-1.0.3
Installing ri documentation for rails-html-sanitizer-1.0.3
Parsing documentation for rails-dom-testing-2.0.3
Installing ri documentation for rails-dom-testing-2.0.3
Parsing documentation for builder-3.2.3
Installing ri documentation for builder-3.2.3
Parsing documentation for erubi-1.7.0
Installing ri documentation for erubi-1.7.0
Parsing documentation for actionview-5.1.4
Installing ri documentation for actionview-5.1.4
Parsing documentation for actionpack-5.1.4
Installing ri documentation for actionpack-5.1.4
Parsing documentation for activemodel-5.1.4
Installing ri documentation for activemodel-5.1.4
Parsing documentation for arel-8.0.0
Installing ri documentation for arel-8.0.0
Parsing documentation for activerecord-5.1.4
Installing ri documentation for activerecord-5.1.4
Parsing documentation for globalid-0.4.1
Installing ri documentation for globalid-0.4.1
Parsing documentation for activejob-5.1.4
Installing ri documentation for activejob-5.1.4
Parsing documentation for mini_mime-1.0.0
Installing ri documentation for mini_mime-1.0.0
Parsing documentation for mail-2.7.0
Installing ri documentation for mail-2.7.0
Parsing documentation for actionmailer-5.1.4
Installing ri documentation for actionmailer-5.1.4
Parsing documentation for nio4r-2.2.0
Installing ri documentation for nio4r-2.2.0
Parsing documentation for websocket-extensions-0.1.3
Installing ri documentation for websocket-extensions-0.1.3
Parsing documentation for websocket-driver-0.6.5
Installing ri documentation for websocket-driver-0.6.5
Parsing documentation for actioncable-5.1.4
Installing ri documentation for actioncable-5.1.4
Parsing documentation for thor-0.20.0
Installing ri documentation for thor-0.20.0
Parsing documentation for method_source-0.9.0
Installing ri documentation for method_source-0.9.0
Parsing documentation for railties-5.1.4
Installing ri documentation for railties-5.1.4
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
Parsing documentation for sprockets-3.7.1
Installing ri documentation for sprockets-3.7.1
Parsing documentation for sprockets-rails-3.2.1
Installing ri documentation for sprockets-rails-3.2.1
Parsing documentation for rails-5.1.4
Installing ri documentation for rails-5.1.4
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, arel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, thor, method_source, railties, bundler, sprockets, sprockets-rails, rails after 80 seconds
36 gems installed
[[email protected] grokbug]#
——————-安裝 jls-grok

[[email protected] grokbug]# gem install jls-grok
Fetching: cabin-0.9.0.gem (100%)
Successfully installed cabin-0.9.0
Fetching: jls-grok-0.11.4.gem (100%)
Successfully installed jls-grok-0.11.4
Parsing documentation for cabin-0.9.0
Installing ri documentation for cabin-0.9.0
Parsing documentation for jls-grok-0.11.4
Installing ri documentation for jls-grok-0.11.4
Done installing documentation for cabin, jls-grok after 0 seconds
2 gems installed
[[email protected] grokbug]#

———-以上安裝安成后

Ruby grok 解析
編寫一個 Ruby 腳本,用來調試 Grok 表達式。

require ‘rubygems’
 
gem ‘jls-grok’, ‘=0.11.2’
 
require ‘grok-pure’
 
require ‘optparse’
 
require ‘json’
 
options = {}
 
ARGV.push(‘-h’) if ARGV.size === 0
 
OptionParser.new do |opts|
 
  opts.banner = ‘Run grokdebug at your terminal.’
 
  options[:dirs] = %w(patterns)
 
  options[:named] = false
 
  opts.on(‘-d DIR1,DIR2’, ‘–dirs DIR1,DIR2’, Array, ‘Set grok patterns directories. Default: "./patterns"’) do |value|
 
    options[:dirs] = value
 
  end
 
  opts.on(‘-m MESSAGE’, ‘–msg MESSAGE’, ‘Your raw message to be matched’) do |value|
 
    options[:message] = value
 
  end
 
  opts.on(‘-p PATTERN’, ‘–pattern PATTERN’, ‘Your grok pattern to be compiled’) do |value|
 
    options[:pattern] = value
 
  end
 
  opts.on(‘-n’, ‘–named’, ‘Named captures only’) do
 
  end
 
end.parse!
 
grok = Grok.new
 
options[:dirs].each do |dir|
 
  if File.directory?(dir)
 
    dir = File.join(dir, "*")
 
  end
 
  Dir.glob(dir).each do |file|
 
    grok.add_patterns_from_file(file)
 
  end
 
end
 
grok.compile(options[:pattern], options[:named])
 
puts JSON.pretty_generate(grok.match(options[:message]).captures())
 
調試 grok
[[email protected] myruby]$ ruby grokdebug.rb -m ‘10.1.1.1’ -p ‘%{IP:client}’
{
  "client": [
    "10.1.1.1"
  ],
  "IPV6": [
    null
  ],
  "IPV4": [
    "10.1.1.1"
  ]
}
 
[[email protected] myruby]$ ruby  grokdebug.rb -m ‘10.1.8.166:8000’ -p ‘%{HOSTPORT:test}’
{
  "test": [
    "10.1.8.166:8000"
  ],
  "IPORHOST": [
    "10.1.8.166"
  ],
  "IP": [
    "10.1.8.166"
  ],
  "IPV6": [
    null
  ],
  "IPV4": [
    "10.1.8.166"
  ],
  "HOSTNAME": [
    null
  ],
  "POSINT": [
    "8000"
  ]
}
[[email protected] myruby]$
若提示找不到“pattern”,你可以將 logstash 目錄底下的復制過來拿來用~

———–來個IIS的復雜解析———
[[email protected] grokdebug]# ruby grokdebug.rb -m ‘2010-07-30 01:06:43 192.168.0.102 – 192.168.0.102 80 GET /css/rss.xslt – 304 0 140 358 0 HTTP/1.1 www.mvpboss1004.com Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+InfoPath.2;+360SE) -‘ -p ‘%{TIMESTAMP_ISO8601:@timestamp} %{IP:c_ip} %{NOTSPACE:cs_username} %{IP:s_ip} %{NUMBER:s_port} %{WORD:cs_method} %{URIPATH:cs_uri_stem} %{NOTSPACE:cs_uri_query} %{NUMBER:sc_status} %{NUMBER:sc_winstatus} %{NUMBER:sc_bytes} %{NUMBER:cs_bytes} %{NUMBER:time_taken} %{NOTSPACE:cs_version} %{NOTSPACE:cs_host} %{NOTSPACE:cs_useragent} %{NOTSPACE:cs_referer}’
{
  "@timestamp": [
    "2010-07-30 01:06:43"
  ],
  "YEAR": [
    "2010"
  ],
  "MONTHNUM": [
    "07"
  ],
  "MONTHDAY": [
    "30"
  ],
  "HOUR": [
    "01",
    null
  ],
  "MINUTE": [
    "06",
    null
  ],
  "SECOND": [
    "43"
  ],
  "ISO8601_TIMEZONE": [
    null
  ],
  "c_ip": [
    "192.168.0.102"
  ],
  "IPV6": [
    null,
    null
  ],
  "IPV4": [
    "192.168.0.102",
    "192.168.0.102"
  ],
  "cs_username": [
    "-"
  ],
  "s_ip": [
    "192.168.0.102"
  ],
  "s_port": [
    "80"
  ],
  "BASE10NUM": [
    "80",
    "304",
    "0",
    "140",
    "358",
    "0"
  ],
  "cs_method": [
    "GET"
  ],
  "cs_uri_stem": [
    "/css/rss.xslt"
  ],
  "cs_uri_query": [
    "-"
  ],
  "sc_status": [
    "304"
  ],
  "sc_winstatus": [
    "0"
  ],
  "sc_bytes": [
    "140"
  ],
  "cs_bytes": [
    "358"
  ],
  "time_taken": [
    "0"
  ],
  "cs_version": [
    "HTTP/1.1"
  ],
  "cs_host": [
    "www.mvpboss1004.com"
  ],
  "cs_useragent": [
    "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1;+Trident/4.0;+InfoPath.2;+360SE)"
  ],
  "cs_referer": [
    "-"
  ]
}

———————grokdebug 本地化安裝完成————————–

第二部分 web訪問形式
最近在使用ELK對日志進行集中管理,因為涉及到日志的規則經常要用到http://grokdebug.herokuapp.com/進行調試,
但是因為國內網絡的特殊原因網站用到的js文件無法訪問,所以經常要使用科學上網才能進行調試,
幸好程序已經在github上開源出來了,使得在本地搭建調試環境得以實現

1.Ruby的安裝

yum -y install  openssl-devel gcc
wget https://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.7.tar.gz
tar zxf ruby-2.1.7.tar.gz
cd ruby-2.1.7
./configure –prefix=/usr/local/ruby2.1.7
make && make install
echo ‘export PATH=/usr/local/ruby2.1.7/bin:$PATH’>>/etc/profile
source /etc/profile
說明:別使用ruby最新的2.2或者2.3的版本,可能出現部分組件無法安裝

2.RubyGems工具安裝

wget http://rubygems.global.ssl.fastly.net/rubygems/rubygems-2.6.2.tgz
tar zxf rubygems-2.6.2.tgz
cd rubygems-2.6.2
ruby setup.rb
3.替換gem源,又是由于網絡環境的問題,訪問官方源非常慢
gem sources –add https://ruby.taobao.org/ –remove https://rubygems.org/
gem sources -l

Grokbug的安裝
[[email protected] grokbug]# pwd
/usr/local/grokbug

mkdir /usr/local/grokbug
cd /usr/local/grokbug
wget https://codeload.github.com/nickethier/grokdebug/zip/master
unzip master
mv grokdebug-master/* .
rm -rf grokdebug-master/

完整安裝
gem install bundler
gem install cabin -v=0.5.0
gem install haml -v=3.1.7
gem install jls-grok -v=0.10.10
gem install json -v=1.7.5
gem install kgio -v=2.8.0
gem install rack -v=1.4.1
gem install rack-protection -v=1.2.0
gem install raindrops -v=0.11.0 
gem install shotgun -v=0.9
gem install tilt -v=1.3.3
gem install sinatra -v=1.3.3
gem install unicorn -v=4.6.3

[[email protected] grokbug]# gem install haml -v=3.1.7
3.3
gem install sinatra -v=1.3.3
Fetching: haml-3.1.7.gem (100%)ching: haml-3.1.7.gem
Successfully installed haml-3.1.7
Parsing documentation for haml-3.1.7
Installing ri documentation for haml-3.1.7
Done installing documentation for haml after 1 seconds
1 gem installed
[[email protected] grokbug]# gem install jls-grok -v=0.10.10
Fetching: jls-grok-0.10.10.gem (100%)
Successfully installed jls-grok-0.10.10
Parsing documentation for jls-grok-0.10.10
Installing ri documentation for jls-grok-0.10.10
Done installing documentation for jls-grok after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install json -v=1.7.5
Fetching: json-1.7.5.gem (100%)
Building native extensions.  This could take a while…
Successfully installed json-1.7.5
Parsing documentation for json-1.7.5
Installing ri documentation for json-1.7.5
Done installing documentation for json after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install kgio -v=2.8.0
Fetching: kgio-2.8.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed kgio-2.8.0
Parsing documentation for kgio-2.8.0
Installing ri documentation for kgio-2.8.0
Done installing documentation for kgio after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install rack -v=1.4.1
Fetching: rack-1.4.1.gem (100%)
Successfully installed rack-1.4.1
Parsing documentation for rack-1.4.1
Installing ri documentation for rack-1.4.1
Done installing documentation for rack after 1 seconds
1 gem installed
[[email protected] grokbug]# gem install rack-protection -v=1.2.0
Fetching: rack-protection-1.2.0.gem (100%)
Successfully installed rack-protection-1.2.0
Parsing documentation for rack-protection-1.2.0
Installing ri documentation for rack-protection-1.2.0
Done installing documentation for rack-protection after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install raindrops -v=0.11.0 
Fetching: raindrops-0.11.0.gem (100%)
Building native extensions.  This could take a while…
Successfully installed raindrops-0.11.0
Parsing documentation for raindrops-0.11.0
Installing ri documentation for raindrops-0.11.0
Done installing documentation for raindrops after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install shotgun -v=0.9
Fetching: shotgun-0.9.gem (100%)
Successfully installed shotgun-0.9
Parsing documentation for shotgun-0.9
Installing ri documentation for shotgun-0.9
Done installing documentation for shotgun after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install tilt -v=1.3.3
Fetching: tilt-1.3.3.gem (100%)
Successfully installed tilt-1.3.3
Parsing documentation for tilt-1.3.3
Installing ri documentation for tilt-1.3.3
Done installing documentation for tilt after 0 seconds
1 gem installed
[[email protected] grokbug]# gem install sinatra -v=1.3.3
Fetching: sinatra-1.3.3.gem (100%)
Successfully installed sinatra-1.3.3
Parsing documentation for sinatra-1.3.3
Installing ri documentation for sinatra-1.3.3
Done installing documentation for sinatra after 3 seconds
1 gem installed
[[email protected] grokbug]# gem install unicorn -v=4.6.3
Fetching: unicorn-4.6.3.gem (100%)
Building native extensions.  This could take a while…
GemWrappers: Can not wrap not executable file: unicorn
Successfully installed unicorn-4.6.3
Parsing documentation for unicorn-4.6.3
Installing ri documentation for unicorn-4.6.3
Done installing documentation for unicorn after 0 seconds
1 gem installed
[[email protected] grokbug]#

———–啟動—
[[email protected] grokdebug]# nohup: ignoring input and appending output to ‘nohup.out’

[1]+  Exit 10                 nohup bundle exec unicorn -p 8089 -c ./unicorn
[[email protected] grokdebug]#

[[email protected] grokdebug]# !net
netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:8089 —啟動正常           0.0.0.0:*               LISTEN      48016/unicorn maste
       
[[email protected] grokdebug]#

訪問頁面
http://192.168.142.138:8089/

 

替換jqurey頁面
7.替換Google的jquery源
cd views
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js#//lib.sinaapp.com/js/jquery/1.8.1/jquery.min.js#g’ index.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js#//lib.sinaapp.com/js/jquery-ui/1.9.2/jquery-ui.min.js#g’ index.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js#//lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js#g’ patterns.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/ui-lightness/jquery-ui.css#//lib.sinaapp.com/js/jquery-ui/1.9.0/themes/ui-lightness/jquery-ui.css#g’ layout.haml
sed -i ‘s#//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js#//lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js#g’ discover.haml

———-unicorn
[[email protected] ~]# unicorn
-bash: unicorn: command not found

參考 http://gems.ruby-china.org/
[[email protected] grokbug]# gem install rails

^CERROR:  Interrupted
[[email protected] grokbug]# gem sources –add https://gems.ruby-china.org/ –remove https://ruby.taobao.org/
source https://gems.ruby-china.org/ already present in the cache
https://ruby.taobao.org/ removed from sources
[[email protected] grokbug]#
[[email protected] grokbug]#
[[email protected] grokbug]#
[[email protected] grokbug]# gem install rails
Fetching: concurrent-ruby-1.0.5.gem (100%)
Successfully installed concurrent-ruby-1.0.5
Fetching: i18n-0.9.0.gem (100%)
Successfully installed i18n-0.9.0
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.3.gem (100%)

 

[[email protected] grokbug]# gem update ruby
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
Updating installed gems
Nothing to update
[[email protected] grokbug]# psych -v
-bash: psych: command not found
[[email protected] grokbug]# yaml -v
-bash: yaml: command not found
[[email protected] grokbug]# gem list psych
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).

*** LOCAL GEMS ***

Error: Nothing to do

 

[[email protected] grokbug]# curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz

 

Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: Signature made Mon 11 Sep 2017 04:59:21 AM CST using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <[email protected]>"
gpg:                 aka "Michal Papis <[email protected]>"
gpg:                 aka "[jpeg image of size 5015]"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified ‘/usr/local/rvm/archives/rvm-1.29.3.tgz’

Upgrading the RVM installation in /usr/local/rvm/
Upgrade of RVM in /usr/local/rvm/ is complete.

Upgrade Notes:

  * No new notes to display.
————-bash: rvm: command not found

[[email protected] grokbug]# rvm
-bash: rvm: command not found

[[email protected] grokbug]# find / -name rvm
/usr/local/rvm/scripts/rvm

[[email protected] grokbug]# source /usr/local/rvm/scripts/rvm ——-解決

永久解決
將 source /usr/local/rvm/scripts/rvm 加入~/.bash_profile文件
[[email protected] grokbug]# rvm
Ruby enVironment Manager 1.29.3 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

Usage:
 

 
 
 
  執行命令
 

 

 
  —————rvm ruby 安裝標準方法-
 
  https://ruby-china.org/wiki/rvm-guide

文章出自:CCIE那點事 http://www.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文鏈接:http://www.qdxgqk.live/?p=3663轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
  • 相關文章
  • 為您推薦
  • 各種觀點
?
暫時還木有人評論,坐等沙發!
發表評論

您必須 [ 登錄 ] 才能發表留言!

?
?
萌宠夺宝游戏