Contents
1 环境准备
需要安装jave,maven.mysql
1.1 安装maven,配置阿里源
yum install -y maven
cat /etc/maven/settings.xml
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
1.2 安装mysql
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
rpm -ivh mysql57-community-release-el7-10.noarch.rpm
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-20221
yum -y install mysql-community-server
systemctl start mysqld.service
grep 'temporary password' /var/log/mysqld.log
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Suixiaofeng!1';
grant all on cachecloud_open.* to cachecloud_open@'%' identified by '123456!Aa';
1.3 安装java
rpm -qa | grep java
2 部署cachecloud
git clone https://github.com/sohutv/cachecloud.git
cd /root/cachecloud/cachecloud-web/sql
导入数据库
create database cachecloud_open;
source 3.2.sql
修改配置
[root@cachecloud cachecloud]# cat cachecloud-web/src/main/resources/application-online.yml
spring:
application:
name: cloud.cachecloud-web.open.online
import: classpath:spring/spring.xml
server:
port: 8080
domain: 0.0.0.0:8080
cachecloud:
primary:
url: jdbc:mysql://127.0.0.1:3306/cachecloud_open?useUnicode=true&characterEncoding=UTF8&autoReconnect=true&connectTimeout=3000&socketTimeout=10000&serverTimezone=Asia/Shanghai
user: cachecloud_open
password: 123456!Aa
initialPoolSize: 10
maxPoolSize: 50
redis:
main:
host: 127.0.0.1
port: 6379
password:
web:
clients: 127.0.0.1
aof:
rewrite:
ignore-appIds:
maven打包
mvn clean compile install -Ponline
[root@cachecloud cachecloud]# mkdir /opt/cachecloud-web
mv cachecloud-web/target/cachecloud-web.war /opt/cachecloud-web/
cd /opt/cachecloud-web/
/root/cachecloud/cachecloud-web/target/classes/application-online.yml application-open.yml
nohup java -jar -Dspring.profiles.active=open cachecloud-web.war &
访问web
http://192.168.10.51:8080
界面如下
3 部署迁移工具机器
\#!/bin/bash
############################################################################
# @desc:
# - 1. install redis-shake;
# - 2. @usage: sh redisShake-install.sh [username]
###########################################################################
set -o nounset
set -o errexit
# install redis-shake
installRedisShake() {
local redisShakeDir="/opt/cachecloud/redis-shake-2.0.3"
local redisShakeTarGz="redis-shake-v2.0.3.tar.gz"
mkdir -p ${redisShakeDir} && cd ${redisShakeDir}
wget https://github.com/alibaba/RedisShake/releases/download/release-v2.0.3-20200724/${redisShakeTarGz} && tar zxvf ${redisShakeTarGz} --strip-component=2
if [[ $? == 0 ]]; then
echo -e "\033[41;36m OK: ${redisShakeTarGz} is installed, exit. \033[0m"
chown -R $1:$2 ${redisShakeDir}
return
fi
echo -e "\033[41;36m ERROR: ${redisShakeTarGz} is NOT installed, exit. \033[0m"
}
# main entrance
username="cachecloud-open"
password="cachecloud-open"
if [[ $# > 0 && -n "$1" ]]; then
username="$1"
echo -e "\033[41;36m please input password for user: ${username} \033[0m"
stty -echo
read password
stty echo
fi
echo -e "\033[41;36m use username: ${username} \033[0m"
installRedisShake "${username}" "${password}"
4 添加机器
(1). 运行脚本:
cachecloud 项目中的 cachecloud-init.sh 脚本是用来初始化服务器的 cachecloud 环境,主要工作如下:
(a). 创建 cachecloud 项目用户:因为 cachecloud 项目的部分功能 (redis 启动、服务器监控) 是通过 ssh 完成的,所以这里的用户和密码要和项目中的相对应,具体详见第三节。
(b). 创建 cachecloud 项目的工作目录、数据目录、配置目录、日志目录、redis 安装目录、临时目录等等。(/opt/cachecloud/data、/opt/cachecloud/conf、/opt/cachecloud/logs、/opt/cachecloud/redis、/tmp/cachecloud)
(c). 安装最新的 release 版本的 Redis
(2). 脚本执行
(a). 使用 root 登录目标服务器。
(b). 将 cachecloud-init.sh 脚本拷贝到目标服务器当前用户目录下。
(c). 执行 sh cachecloud-init.sh ${yourusername}
(d). 两次确认密码
(e). 一路安装直到成功。
(3). 建议和警告
(a). 请在 root 用户下执行初始化脚本,因为初始化脚本涉及到了用户的创建等较高的权限。
(b). 出于安全的考虑,所选的机器最好不要有外网 IP 地址。
(c). 用户名和密码最好不要用 cachecloud, 密码尽可能复杂。
(d). 机器的 ssh 端口最好是 22。
(e). 请确保 /opt/ 有足够的硬盘空间,因为 /opt/cachecloud/data 要存储 RDB 和 AOF 的持久化文件,如果硬盘过小,会造成持久化失败。 (如果硬盘确实很小,建议建立一个软链接到 /opt/cachecloud/data, 且保证软链接的目录也是 username 用户,一定要保证 /opt /cachecloud 的目录结构)
(f). 脚本中目前使用的是 redis-3.0.6,如有需要请自行替换,建议使用 3.0 release 以后的版本。
(4). 添加机器
进入管理员界面 (http://ip:port/manage/total/list),进入机器管理,点击添加机器,添加机器信息是开通应用的基础。
参考
https://www.bbsmax.com/A/Gkz18r6ZdR/
https://www.cnblogs.com/yjt1993/p/14808887.html
https://github.com/sohutv/cachecloud/wiki
- 我的微信
- 这是我的微信扫一扫
-
- 我的微信公众号
- 我的微信公众号扫一扫
-