赞
踩
# 安装gcc
yum install gcc-c++
# 安装PCRE pcre-devel
yum install -y pcre pcre-devel
# 安装zlib
yum install -y zlib zlib-devel
# 安装Open SSL
yum install -y openssl openssl-devel
# 下载
https://www.oracle.com/java/technologies/downloads/#java8
# 安装
rpm -ivh jdk-8u401-linux-x64.rpm
# 或
yum install jdk-8u401-linux-x64.rpm
# 查看java的安装路径:readlink -f $(which java)
export JAVA_HOME=java的安装目录(配置到bin的父目录即可)
export PATH=$JAVA_HOME/bin:$PATH
# centos7会默认安装mariadb,会影响mysql安装,需要将其删除。
rpm -aq | grep mariadb
# 有的话将其删除
rpm -e --nodeps <mariadb_package>
# 此处建议下载完整的rpm bundle包,不然安装时可能会因缺少依赖而报错
https://downloads.mysql.com/archives/community/
tar -xvf mysql-8.0.26-1.el7.x86_64.rpm-bundle.tar
yum localinstall mysql-community-*.rpm
systemctl start mysqld
systemctl enable mysqld
# 找到mysql的初始密码
grep 'temporary password' /var/log/mysqld.log
# 使用初始密码进行连接
mysql -u root -p
# 修改初始密码,注意:密码需由大写字母、小写字母、数字和特殊字符共同组成
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
# 连接mysql后执行:
# 更新root用户权限
ALTER USER 'root'@'%' IDENTIFIED BY 'password';
# 授予root用户所有权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;
wget http://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz
cd nginx-1.14.0
./configure --prefix=/usr/local/nginx
make
make install
ln -s /usr/local/nginx /opt/nginx
创建一个 systemd 服务文件 /etc/systemd/system/nginx.service
:
vim /etc/systemd/system/nginx.service
将以下内容粘贴到 nginx.service
文件中:
[Unit]
Description=Nginx Server
After=network.target
[Service]
Type=forking
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/opt/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
# 重新加载Systemd 管理器配置
systemctl daemon-reload
# 启动nginx服务
systemctl start nginx.service
# 开启开机启动
systemctl enable nginx.service
systemctl status nginx.service
# 或通过浏览器访问本机ip,出现nginx欢迎界面
cd /opt
rm -rf nginx-1.14.*
下载 Redis:
首先,你需要下载 Redis 5.0.6 版本的源码。你可以从 Redis 官网或者通过 wget
命令来下载到任意目录,如:/opt目录:
wget http://download.redis.io/releases/redis-5.0.6.tar.gz
解压 Redis:
解压下载的 tar.gz 文件:
tar xzf redis-5.0.6.tar.gz
编译 Redis:
编译 Redis 前需要确保已执行预置步骤安装了gcc工具:
cd redis-5.0.6
make
安装 Redis:
将编译后的 Redis 安装到 /usr/local/redis
目录中:
make PREFIX=/usr/local/redis install
创建软链接:
创建一个指向 /usr/local/redis/bin
的软链接在 /opt/redis
:
ln -s /usr/local/redis/bin /opt/redis
将路径配置到环境变量
vim /etc/profile
export PATH=$PATH:/opt/redis
source /etc/profile
设置开机启动:
创建一个 systemd 服务文件 /etc/systemd/system/redis.service
:
vim /etc/systemd/system/redis.service
将以下内容粘贴到 redis.service
文件中:
[Unit]
Description=Redis Server
After=network.target
[Service]
Type=forking
ExecStart=/opt/redis/redis-server /etc/redis/redis.conf
ExecStop=/opt/redis/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
配置 Redis:
通常,Redis 的配置文件位于源码的 redis.conf
。将这个配置文件复制到合适的目录,例如 /etc/redis/
:
mkdir /etc/redis
cp redis.conf /etc/redis/redis.conf
配置redis后台启动
vim /etc/redis.conf
# 搜索daemonize将daemonize no改为daemonize yes
daemonize yes
# 搜索notify-keyspace-events将其配置为notify-keyspace-events Ex
notify-keyspace-events Ex
# 配置远程可以访问,使其可以通过客户端工具连接:
# 1、注释掉bind 127.0.0.1
# 2、关闭保护模式:
protected-mode no
启动 Redis 服务并设置开机自启:
重新加载Systemd 管理器配置
systemctl daemon-reload
查看Redis服务状态
systemctl status redis.service
设置 Redis 服务开机自启:
systemctl enable redis.service
验证 Redis 是否在运行:
检查 Redis 服务的状态:
systemctl status redis.service
尝试通过redis客户端连接到redis服务
redis-cli ping
# 返回pong 则说明服务正常
返回/opt目录删除redis压缩文件和解压后的文件
rm -rf redis-*
下载解压kafka压缩包
# 下载
https://kafka.apache.org/downloads
# 解压
tar -zxvf kafka_2.12-3.2.0.tgz -C /usr/local/kafka
创建软链接
ln -s /usr/local/kafka/kafka_2.12-3.2.0 /opt/kafka
修改配置
cd /opt/kafka/config
vim server.properties
# 搜索listeners,将其配置为:
listeners=PLAINTEXT://127.0.0.1:9092
# 搜索log.dirs,将其配置为:
log.dirs=/usr/local/kafka/kafka-logs
# 搜索zookeeper.connect,将其配置为:
zookeeper.connect=127.0.0.1:2181
配置开机启动
配置zookeeper开机启动
创建一个 systemd 服务文件 /etc/systemd/system/zookeeper.service
:
vim /etc/systemd/system/zookeeper.service
将以下内容粘贴到 zookeeper.service
文件中:
[Unit]
Description=Apache Zookeeper server
Documentation=http://zookeeper.apache.org
Requires=network.target
After=network.target
[Service]
Type=simple
ExecStart=/opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties
ExecStop=/opt/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal
Environment="JAVA_HOME=/usr/lib/jvm/jdk-1.8-oracle-x64"
[Install]
WantedBy=multi-user.target
配置kafka开机启动
创建一个 systemd 服务文件 /etc/systemd/system/kafka.service
:
vim /etc/systemd/system/kafka.service
将以下内容粘贴到 kafka.service
文件中:
[Unit]
Description=Apache Kafka Server
Documentation=http://kafka.apache.org/documentation.html
Requires=zookeeper.service
After=zookeeper.service
[Service]
Type=simple
ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties
ExecStop=/opt/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal
Environment="JAVA_HOME=/usr/lib/jvm/jdk-1.8-oracle-x64"
[Install]
WantedBy=multi-user.target
启用并启动服务
systemctl daemon-reload
systemctl enable zookeeper.service
systemctl start zookeeper.service
systemctl enable kafka.service
systemctl start kafka.service
检查服务状态
systemctl status zookeeper.service
systemctl status kafka.service
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。