一、准备工作 |
---|
-1. OS 类型
ubuntu-12.04-server-i386
0.openssh-server安装(可选)
sudo install openssh-server
1.gcc 安装
sudo apt-get install gcc
//检查版本
sudo gcc -v
2.g++ 安装
sudo apt-get install g++
//检查版本
sudo g++ -v
3.make 安装
sudo apt-get install make
//检查版本
make -v
二、配置ruby开发环境 |
---|
1.从ftp://ftp.ruby-lang.org/pub/ruby/1.9/下载安装包ruby-1.9.3-p484.tar.gz 安装包并下载到本地
sudo wget [http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p484.tar.gz]
//如果没有wget,就安装
sudo apt-get install wget
2.解压并安装
sudo tar -zxf ruby-1.9.3-p484.tar.gz
sudo apt-get install libyaml-dev
sudo apt-get install zlib1g zlib1g-dev
sudo apt-get install libxml2 libxml2-dev libxslt1-dev
sudo apt-get install openssl libssl-dev libssl0.9.8
cd ruby-1.9.3-p484
sudo ./configure --prefix=/usr/local/ruby
sudo make && sudo make install
3.配置Ruby环境变量
修改文件内容
sudo vi /etc/environment
PATH="/usr/local/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
4.刷新环境变量
source /etc/environment
sudo ln -s /usr/local/ruby/bin/ruby /usr/bin/ruby
sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem
ruby -v
三、nats及依赖组件安装 |
---|
1.安装 eventmachine(两个版本都要安装)
gem install eventmachine --version=0.12.10
gem install eventmachine --version=1.0.0
2.安装nats
gem install nats
3.检查thin 版本
sudo thin -v
//thin 版本要求:1.4.1<=thin version < 1.6' 不在此范围的版本则卸载重新安装thin,不然启动nats时会报eventmachine版本冲突
//卸载thin
sudo gem uninstall thin -v 1.6.2
//安装thin
sudo gem install thin -v 1.4.1
4.启动nats-server
sudo cd /usr/local/ruby/bin
sudo ./nats-server start
["Starting nats-server version 0.4.28 on port 4222"|"Starting nats-server version 0.4.28 on port 4222"]
//或者创建nats软链接
sudo ln -s /usr/local/ruby/bin/nats-server /usr/bin/nats-server
启动nats
sudo nats-server start
["Starting nats-server version 0.4.28 on port 4222"|"Starting nats-server version 0.4.28 on port 4222"]
5.测试nats
sudo telnet localhost 4222
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^\]'.
INFO {"server_id":"acd3000ee8e1358ab94b4907b7","host":"0.0.0.0","port":4222,"version":"0.4.28","auth_required":false,"ssl_required":false,"max_payload":1048576}
四、使用各种语言编写客户端访问nats |
---|
JAVA 待解.....
Ruby 待解.....
Go 待解.....