linux非root用户安装rabbitmq

元气小坏坏 提交于 2020-05-01 08:41:40

  因为rabbitmq是用erlang语言写的,所以装rabbitmq前第一步得先装erlang。

  我们到erlang官网https://www.erlang.org/downloads下载安装包,最新版本是22.0,下载时又被windows禁掉了,退而求其次,下21.3版本吧:

 

 

  下完后通过rz上传至wlf用户soft目录下,执行解压:

$ tar xvf otp_src_21.3.tar

  注意编译前需要借用root用户通过yum install命令先安装ncurses-devel和openssl-devel依赖,可以切换到root用户后执行:

yum install ncurses-devel 
yum install openssl-devel

  很遗憾,普通用户这里没法绕开root用户,除非你的机器之前已经用root安装过以上两个依赖了。通过以下命令可以查看本机是否已经存在这两个依赖:

$ rpm -qa | grep -E "ncurses-devel*|openssl-devel*"
ncurses-devel-5.9-13.20130511.el7.x86_64
openssl-devel-1.0.1e-60.el7.x86_64

  可以发现我这里之前已经装了。

  配置下目录前缀,通过make命令开始编译、安装,貌似编译时间有点久:

$ cd otp_src_21.3
$ ./configure --prefix=/home/wlf/erlang

  检查成功后编译、安装一条龙:

$ make && make install

  结束后通过bin/erl命令确认安装成功:

$ cd erlang/bin
$ erl Erlang
/OTP 21 [erts-10.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] Eshell V10.3 (abort with ^G) 1> halt() 1> .

  halt是退出系统的方法,别忘了下面的点。

  配置Erlang环境变量:

$ cd ~
$ vi .bash_profile

  在bash_profile最后加入export PATH=$PATH:/home/wlf/erlang/bin这一行:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

# Java_Home
JAVA_HOME=/home/wlf/jdk1.8.0_221
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JaVA_HOME

# erlang
export PATH=$PATH:/home/wlf/erlang/bin

  保存后让它生效:

$ source .bash_profile

   ------------------------------------------------------------------------分割线-------------------------------------------------------------------------------------------------------

  搞定了erlang,再开始搞rabbitmq。同理,先去官网http://www.rabbitmq.com/download.html下载安装包,我们选通过git下载linux二进制版本的:

 

 

   会有点慢,压缩包rabbitmq-server-generic-unix-3.7.18.tar.xz下好了通过rz上传到wlf的soft目录下,在soft目录下开始解压,需要分两步走,先解压xz,再解压tar:

$ xz -d rabbitmq-server-generic-unix-3.7.18.tar.xz 
$ cd ..
$ tar xvf soft/rabbitmq-server-generic-unix-3.7.18.tar

  rabbitmq是解压即可用的,但我们可以通过在配置文件来指定一些自定义设置,先进入配置目录:

cd rabbitmq_server-3.7.18/etc/rabbitmq/

  再通过vi新增rabbitmq.env.conf指定数据节点名称和路径

#node name
NODENAME=rabbit

#data dir
MNESIA_BASE=/home/wlf/rabbitmq_server-3.7.18/data

  同理,新增rabbitmq.conf指定端口等设置:

#listen port
listeners.tcp.default = 5673

#log dir
log.dir = /home/wlf/rabbitmq_server-3.7.18/logs

#open remote request
loopback_users = none

  配置完后记得手动创建日志目录logs。最后我们再次使用vi打开bash_profile配置下环境变量:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

# Java_Home
JAVA_HOME=/home/wlf/jdk1.8.0_221
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JaVA_HOME

# erlang
export PATH=$PATH:/home/wlf/otp_src_21.3/bin

# rabbitmq
export PATH=$PATH:/home/wlf/rabbitmq_server-3.7.18/sbin

  加上最后一行指定rabbitmq的执行目录之后,保存并用source命令让我们的配置生效。我们以后台进行方式启动rabbitmq:

$ rabbitmq-server -detatched

  ##  ##
  ##  ##      RabbitMQ 3.7.18. Copyright (C) 2007-2019 Pivotal Software, Inc.
  ##########  Licensed under the MPL.  See https://www.rabbitmq.com/
  ######  ##
  ##########  Logs: /home/wlf/rabbitmq_server-3.7.18/var/log/rabbitmq/rabbit.log
                    /home/wlf/rabbitmq_server-3.7.18/var/log/rabbitmq/rabbit_upgrade.log

              Starting broker...
 completed with 0 plugins.

  克隆会话登陆wlf,查看启动状态:

$ rabbitmqctl status
Status of node rabbit@wlf-test188 ...
[{pid,10114},
 {running_applications,
     [{rabbit,"RabbitMQ","3.7.18"},
      {mnesia,"MNESIA  CXC 138 12","4.15.6"},
      {sysmon_handler,"Rate-limiting system_monitor event handler","1.1.0"},
      {rabbit_common,
          "Modules shared by rabbitmq-server and rabbitmq-erlang-client",
          "3.7.18"},
      {ranch,"Socket acceptor pool for TCP protocols.","1.7.1"},
      {ssl,"Erlang/OTP SSL application","9.2"},
      {public_key,"Public key infrastructure","1.6.5"},
      {asn1,"The Erlang ASN1 compiler version 5.0.8","5.0.8"},
      {observer_cli,"Visualize Erlang Nodes On The Command Line","1.5.2"},
      {tools,"DEVTOOLS  CXC 138 16","3.1"},
      {os_mon,"CPO  CXC 138 46","2.4.7"},
      {recon,"Diagnostic tools for production use","2.5.0"},
      {xmerl,"XML parser","1.3.19"},
      {credentials_obfuscation,
          "Helper library that obfuscates sensitive values in process state",
          "1.1.0"},
      {jsx,"a streaming, evented json parsing toolkit","2.9.0"},
      {crypto,"CRYPTO","4.4.1"},
      {stdout_formatter,
          "Tools to format paragraphs, lists and tables as plain text",
          "0.2.2"},
      {inets,"INETS  CXC 138 49","7.0.6"},
      {lager,"Erlang logging framework","3.8.0"},
      {goldrush,"Erlang event stream processor","0.1.9"},
      {compiler,"ERTS  CXC 138 10","7.3.2"},
      {syntax_tools,"Syntax tools","2.1.7"},
      {sasl,"SASL  CXC 138 11","3.3"},
      {stdlib,"ERTS  CXC 138 10","3.8"},
      {kernel,"ERTS  CXC 138 10","6.3"}]},
 {os,{unix,linux}},
 {erlang_version,
     "Erlang/OTP 21 [erts-10.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:128] [hipe]\n"},
 {memory,
     [{connection_readers,0},
      {connection_writers,0},
      {connection_channels,0},
      {connection_other,0},
      {queue_procs,0},
      {queue_slave_procs,0},
      {plugins,11916},
      {other_proc,26385104},
      {metrics,195516},
      {mgmt_db,0},
      {mnesia,73328},
      {other_ets,2453808},
      {binary,160600},
      {msg_index,29040},
      {code,21581067},
      {atom,1131721},
      {other_system,13896508},
      {allocated_unused,13412720},
      {reserved_unallocated,0},
      {strategy,rss},
      {total,[{erlang,65918608},{rss,75112448},{allocated,79331328}]}]},
 {alarms,[]},
 {listeners,[{clustering,25672,"::"},{amqp,5673,"::"}]},
 {vm_memory_calculation_strategy,rss},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,10045002547},
 {disk_free_limit,50000000},
 {disk_free,132865421312},
 {file_descriptors,
     [{total_limit,65435},
      {total_used,2},
      {sockets_limit,58889},
      {sockets_used,0}]},
 {processes,[{limit,1048576},{used,231}]},
 {run_queue,1},
 {uptime,186},
 {kernel,{net_ticktime,60}}]

  可以看到启动成功,使用端口5673.

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!