首先是下载,下载官方的二进制包, 下载地址 (支持Linux、Darwin、Freebsd和Windows)。哈哈:

  1. wget https://s3.amazonaws.com/bitly-downloads/nsq/nsq-1.0.0-compat.linux-amd64.go1.8.tar.gz

解压:

  1. tar -xzf nsq-1.0.0-compat.linux-amd64.go1.8.tar.gz

然后建立目录:

  1. mkdir -p /home/vagrant/nsq-1.0.0-compat.linux-amd64.go1.8/bin/config
  2. cd /home/vagrant/nsq-1.0.0-compat.linux-amd64.go1.8/bin/config

建立配置文件dmin.cnf,内容如下:

  1. ## log verbosity level: debug, info, warn, error, or fatal
  2. log-level = "info"
  3. ## <addr>:<port> to listen on for HTTP clients
  4. http_address = "0.0.0.0:4171"
  5. ## graphite HTTP address
  6. graphite_url = ""
  7. ## proxy HTTP requests to graphite
  8. proxy_graphite = false
  9. ## prefix used for keys sent to statsd (%s for host replacement, must match nsqd)
  10. statsd_prefix = "nsq.%s"
  11. ## format of statsd counter stats
  12. statsd_counter_format = "stats.counters.%s.count"
  13. ## format of statsd gauge stats
  14. statsd_gauge_format = "stats.gauges.%s"
  15. ## time interval nsqd is configured to push to statsd (must match nsqd)
  16. statsd_interval = "60s"
  17. ## HTTP endpoint (fully qualified) to which POST notifications of admin actions will be sent
  18. notification_http_endpoint = ""
  19. ## nsqlookupd HTTP addresses
  20. nsqlookupd_http_addresses = [
  21. "127.0.0.1:4161"
  22. ]
  23. ## nsqd HTTP addresses (optional)
  24. #nsqd_http_addresses = [
  25. # "127.0.0.1:4151"
  26. #]

建立nsqd.cnf,内容如下:

  1. ## log verbosity level: debug, info, warn, error, or fatal
  2. log-level = "info"
  3. ## unique identifier (int) for this worker (will default to a hash of hostname)
  4. # id = 5150
  5. ## <addr>:<port> to listen on for TCP clients
  6. tcp_address = "0.0.0.0:4150"
  7. ## <addr>:<port> to listen on for HTTP clients
  8. http_address = "0.0.0.0:4151"
  9. ## <addr>:<port> to listen on for HTTPS clients
  10. # https_address = "0.0.0.0:4152"
  11. ## address that will be registered with lookupd (defaults to the OS hostname)
  12. # broadcast_address = ""
  13. ## cluster of nsqlookupd TCP addresses
  14. nsqlookupd_tcp_addresses = [
  15. "127.0.0.1:4160"
  16. ]
  17. ## duration to wait before HTTP client connection timeout
  18. http_client_connect_timeout = "2s"
  19. ## duration to wait before HTTP client request timeout
  20. http_client_request_timeout = "5s"
  21. ## path to store disk-backed messages
  22. # data_path = "/var/lib/nsq"
  23. ## number of messages to keep in memory (per topic/channel)
  24. mem_queue_size = 10000
  25. ## number of bytes per diskqueue file before rolling
  26. max_bytes_per_file = 104857600
  27. ## number of messages per diskqueue fsync
  28. sync_every = 2500
  29. ## duration of time per diskqueue fsync (time.Duration)
  30. sync_timeout = "2s"
  31. ## duration to wait before auto-requeing a message
  32. msg_timeout = "60s"
  33. ## maximum duration before a message will timeout
  34. max_msg_timeout = "15m"
  35. ## maximum size of a single message in bytes
  36. max_msg_size = 1024768
  37. ## maximum requeuing timeout for a message
  38. max_req_timeout = "1h"
  39. ## maximum size of a single command body
  40. max_body_size = 5123840
  41. ## maximum client configurable duration of time between client heartbeats
  42. max_heartbeat_interval = "60s"
  43. ## maximum RDY count for a client
  44. max_rdy_count = 2500
  45. ## maximum client configurable size (in bytes) for a client output buffer
  46. max_output_buffer_size = 65536
  47. ## maximum client configurable duration of time between flushing to a client (time.Duration)
  48. max_output_buffer_timeout = "1s"
  49. ## UDP <addr>:<port> of a statsd daemon for pushing stats
  50. # statsd_address = "127.0.0.1:8125"
  51. ## prefix used for keys sent to statsd (%s for host replacement)
  52. statsd_prefix = "nsq.%s"
  53. ## duration between pushing to statsd (time.Duration)
  54. statsd_interval = "60s"
  55. ## toggle sending memory and GC stats to statsd
  56. statsd_mem_stats = true
  57. ## message processing time percentiles to keep track of (float)
  58. e2e_processing_latency_percentiles = [
  59. 1.0,
  60. 0.99,
  61. 0.95
  62. ]
  63. ## calculate end to end latency quantiles for this duration of time (time.Duration)
  64. e2e_processing_latency_window_time = "10m"
  65. ## path to certificate file
  66. tls_cert = ""
  67. ## path to private key file
  68. tls_key = ""
  69. ## set policy on client certificate (require - client must provide certificate,
  70. ## require-verify - client must provide verifiable signed certificate)
  71. # tls_client_auth_policy = "require-verify"
  72. ## set custom root Certificate Authority
  73. # tls_root_ca_file = ""
  74. ## require client TLS upgrades
  75. tls_required = false
  76. ## minimum TLS version ("ssl3.0", "tls1.0," "tls1.1", "tls1.2")
  77. tls_min_version = ""
  78. ## enable deflate feature negotiation (client compression)
  79. deflate = true
  80. ## max deflate compression level a client can negotiate (> values == > nsqd CPU usage)
  81. max_deflate_level = 6
  82. ## enable snappy feature negotiation (client compression)
  83. snappy = true

建立lookupd.cnf, 内容如下:

  1. ## log verbosity level: debug, info, warn, error, or fatal
  2. log-level = "info"
  3. ## <addr>:<port> to listen on for TCP clients
  4. tcp_address = "0.0.0.0:4160"
  5. ## <addr>:<port> to listen on for HTTP clients
  6. http_address = "0.0.0.0:4161"
  7. ## address that will be registered with lookupd (defaults to the OS hostname)
  8. # broadcast_address = ""
  9. ## duration of time a producer will remain in the active list since its last ping
  10. inactive_producer_timeout = "300s"
  11. ## duration of time a producer will remain tombstoned if registration remains
  12. tombstone_lifetime = "45s"

然后运行如下命令:

  1. mkdir -p /home/vagrant/nsqlog
  2. cd /home/vagrant/nsq-1.0.0-compat.linux-amd64.go1.8/bin
  3. nohup ./nsqd -config=/home/vagrant/nsq-1.0.0-compat.linux-amd64.go1.8/bin/config/nsqd.cnf >> /home/vagrant/nsqlog/nsqd.log 2>&1 &
  4. nohup ./nsqlookupd -config= /home/vagrant/nsq-1.0.0-compat.linux-amd64.go1.8/bin/config/lookupd.cnf >> /home/vagrant/nsqlog/nsqlookupd.log 2>&1 &
  5. nohup ./nsqadmin -config=/home/vagrant/nsq-1.0.0-compat.linux-amd64.go1.8/bin/config/admin.cnf >> /home/vagrant/nsqlog/nsqadmin.log 2>&1 &

成功。至此,可以登录http://192.168.33.10:4171 查看后台了。
如此简单。
这是配置
参考:http://ju.outofmemory.cn/entry/271510

分类: web

标签:   nsq