系统版本:RockyLinux 8.6
安装方式:非容器化单机部署
安装版本:mysql 8.0.32 redis 6.2.11 rabbitmq 3.11.11 elasticsearch 6.7.1
前置条件:时间同步、关闭selinux、主机名、主机解析host
环境说明:PC电脑+VMware Workstation
非容器化中间件单机部署参考
1. Mysql
- 下载离线二进制包:https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
- 解压后移动二进制文件
xz -d mysql-8.0.32-linux-glibc2.12-x86_64.tar.xz
tar -xf mysql-8.0.32-linux-glibc2.12-x86_64.tar
mv mysql-8.0.32-linux-glibc2.12-x86_64 /usr/local/mysql
- 创建相关文件夹目录
mkdir /var/lib/mysql
mkdir -p /usr/local/mysql/log
mkdir /usr/local/mysql/data
- 配置环境变量
# 编辑~/.bash_profile这个文件
# PATH新增内容/usr/local/mysql/bin后重新进入终端即可
- 创建用户组信息及授权相关目录
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /var/lib/mysql
- 创建启动配置文件
#vi /etc/my.cnf,内容如下:
[mysql]
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock
[mysqld]
port = 3306
socket=/var/lib/mysql/mysql.sock
basedir=/usr/local/mysql
character-set-server=utf8mb4
default-storage-engine=INNODB
innodb_buffer_pool_size = 200M
max_allowed_packet=16M
explicit_defaults_for_timestamp=1
log-output=FILE
general_log = 0
general_log_file=/usr/local/mysql/log/mysql-general.err
slow_query_log = ON
slow_query_log_file=/usr/local/mysql/log/mysql-query.err
long_query_time=10
log-error=/usr/local/mysql/log/mysql-error.err
default-authentication-plugin=mysql_native_password
- 初始化数据库
#初始化数据库
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/#查看root密码
tail -100 /usr/local/mysql/log/mysql-error.err
- 配置 mysqld 启动服务
# vi /usr/lib/systemd/system/mysqld.service 内容如下:
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 65536
LimitNPROC = 65536
- 启动服务
systemctl daemon-reload
systemctl enable mysqld --now
systemctl status mysqld
- 开启端口3306
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload
- 验证连接性
解决:mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
ln -s /usr/lib64/libtinfo.so.6.1 /usr/lib64/libtinfo.so.5# 本地连接测试一下
mysql -uroot -p
- 修改密码、创建用户信息
alter user 'root'@'localhost' identified by '1qaz2WSX';
create user 'root'@'%' identified by '1qaz2WSX';
grant all on *.* to 'root'@'%' with grant option;
flush privileges;
- 再验证一下远程连接
2. Redis
- 下载源码包:http://download.redis.io/releases/redis-6.2.11.tar.gz
- 解压进入
tar -xf redis-6.2.11.tar.gz
cd redis-6.2.11/
- 编译安装
编译安装前提需要:gcc-c++ 、make 环境(已准备离线包)
# 注意执行目录切换
rpm -ivh make-4.2.1-11.el8.x86_64.rpm
rpm -Uvh *.rpm
编译环境准备好了以后,再次进入编译目录
cd redis-6.2.11
make && make install
- 创建服务配置文件
# 编译安装后的二进制文件位于:/usr/local/bin
cd /usr/local/bin# 复制配置文件(配置文件在编译安装的目录下)
cp /home/package/redis-6.2.11/redis.conf ./
# vi redis.conf,修改配置项:后台运行,设置密码,bind地址即可
bind 0.0.0.0
daemonize yes
requirepass 1qaz2WSX
- 启动服务
redis-server redis.conf
- 配置防火墙策略并验证远程连接
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --reload
3. RabbitMQ
- 准备离线RPM包:erlang-25.0-1.el8.x86_64.rpm、rabbitmq-server-3.11.11-1.el8.noarch.rpm
- 直接安装即可
rpm -ivh erlang-25.0-1.el8.x86_64.rpm
rpm -ivh rabbitmq-server-3.11.11-1.el8.noarch.rpm
- 运行配置 rabbitmq
systemctl enable rabbitmq-server --now# 创建用户绑定vhost
rabbitmqctl add_user admin edoc2
rabbitmqctl set_permissions -p / admin ".*" ".*" ".*"
rabbitmqctl set_user_tags admin administrator
rabbitmqctl delete_user guest
- 开启web端管理界面
### 开启web端界面管理,监听15672端口
rabbitmq-plugins enable rabbitmq_management### 重启服务生效,访问验证
systemctl restart rabbitmq-server
- 设置防火墙策略
### 15672 web端管理界面
### 25672 集群管理端口
### 5672 AMQP端口,用于客户端应用程序的连接建立firewall-cmd --permanent --add-port=15672/tcp
firewall-cmd --permanent --add-port=5672/tcp
firewall-cmd --reload
- 访问web端验证