【红包雨功能的】环境部署(弹性伸缩、负载均衡、Redis读写分离、云服务器部署)(四)

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 Tair(兼容Redis),内存型 2GB
简介: 【红包雨功能的】环境部署(弹性伸缩、负载均衡、Redis读写分离、云服务器部署)

2. 安装MySQL

#准备目录
mkdir -p /opt/db
cd /opt/db/
### 安装 MySQL 5.6:
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
rpm -ivh mysql-community-release-el6-5.noarch.rpm
yum repolist all | grep mysql
yum install mysql-community-server -y
#启动mysql
systemctl start mysqld
#初始化mysql,一路yes即可,要记住自己新设置的密码
mysql_secure_installation
#创建初始数据库&授予权限
mysql -uroot -p
create database db_wordpress character set utf8 collate utf8_bin;
grant all on db_wordpress.* to user_wp@'localhost' identified by '123456';
grant all on db_wordpress.* to user_wp@'%' identified by '123456';

3. WordPress安装

#下载 
mkdir -p /opt/WP
cd /opt/WP
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar -xzvf latest-zh_CN.tar.gz
#把word_press代码复制到 /var/www/html 下,/var/www/html是php的网站目录
cd /var/www/html
cp -rf /opt/WP/wordpress/* /var/www/html/
###########配置 wordpress 访问 MYSQL
cd /var/www/html/
cp wp-config-sample.php wp-config.php
vim wp-config.php
##内容如下,注意修改为自己之前安装的MySQL的账号密码以及端口号
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the installation.
 * You don't have to use the web site, you can copy this file to "wp-config.php"
 * and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * Database settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/documentation/article/editing-wp-config-php/
 *
 * @package WordPress
 */
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'db_wordpress' );
/** Database username */
define( 'DB_USER', 'user_wp' );
/** Database password */
define( 'DB_PASSWORD', '123456' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         ' ,kh+tKQ!*XlrMd)M)3}nn(i(Y+Kke[3KuaTMmuz B($EzqUix_v6X)Cn7QI{]+q' );
define( 'SECURE_AUTH_KEY',  'LiK0-P)]}09@hK%M#9Guiu}Q3]{c{3OTep9r8GFT4lH1tVL7hKQ4f4)YKna~L~Z8' );
define( 'LOGGED_IN_KEY',    'HQAx9M`N<lRusI8]MFDis$}K4)ek-YhK{tN%|Nlh&?:_JGDuU:],hxC}gB}8`7h(' );
define( 'NONCE_KEY',        '$.2`/+0)K#jaZ)V=wVW9j<?NbuCf3xQt*Hsv<|1ShflY:`zi,q{QUdE{A-8r. _m' );
define( 'AUTH_SALT',        'wWMitjd2mt&5P;H+&w_U6!r*3+fh8V[1#}^@km;xVoD7sr1W<k:%O@=Kbr=y&a2 ' );
define( 'SECURE_AUTH_SALT', 'u&!>mA2hpl%}7P%M!*=xHQ*x)XN|dVBJCUQz[wQNyhT}mmk+3-`h(!.].B3ZOkwK' );
define( 'LOGGED_IN_SALT',   '6h:Qh U@ME,-putJ}ViEi{#m=R9~j(YbzihIU)8lL3=@Q$V,<u#+HZ_*t)z7C[ra' );
define( 'NONCE_SALT',       'G.wRp$]0)lOlHc(_&BiB>f~2BcLpM}kIjqU[ fDT|?|B]W3=Ez,:RZT%)v&W@w_>' );
/**#@-*/
/**
 * WordPress database table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';
/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/documentation/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
  define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

访问:http://47.99.217.185 初始化WordPress;

后台地址:http://47.99.217.185/wp-login.php

博客地址:http://47.99.217.185

4. Docker安装

1. 安装

#卸载旧版本Docker
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
#配置docker源
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#安装新版Docker,  docker compose; 允许写一个yaml配置文件,写清楚用哪些镜像启动哪些容器。
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
#启动 & 开机自启
sudo systemctl enable docker --now
#配置镜像加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

2. 常用命令

#docker常用命令
docker exec -it 容器id bash
#启动
docker compose -f xxx.yaml up -d 
#得到volume 的具体位置
docker volume inspect 你的volume名字 
#列出docker所有挂载的卷
docker volume ls

3. MySQL、Redis安装

安装MySQL和Redis的compose文件

services:
  mysql:
    image: 'mysql:latest'
    restart: always
    environment:
      - 'MYSQL_DATABASE=mydatabase'
      - 'MYSQL_PASSWORD=secret'
      - 'MYSQL_ROOT_PASSWORD=verysecret'
      - 'MYSQL_USER=myuser'
    volumes:
      - /opt/mysql:/etc/mysql/conf.d #只要在外部的/opt/mysql目录下随便放一个 xx.cnf 文件,mysql自动把他当成配置文件
    ports:
      - '33066:3306'
  redis:
    image: redis:latest
    volumes:
      - /opt/redis/redis.conf:/usr/local/etc/redis/redis.conf
    command: redis-server /usr/local/etc/redis/redis.conf
    restart: always
    ports:
      - '7379:6379'

允许root远程访问(新版MySQL无需设置)

#mysql开启远程连接
docker exec -it 你的mysql容器id bash
mysql -uroot -p你的密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
#修改mysql配置文件,在[mysqld]下面加上一句话
bind-address    = 0.0.0.0
#后台启动jar应用,并且把所有日志都写到 log.txt
nohup java -jar your-jar-file.jar > log.txt 2>&1 &

5. 1Panel

1. 简介

1Panel 是一个现代化、开源的 Linux 服务器运维管理面板。适合小型公司快速运维需求。

2. 安装

curl -sSL https://resource.fit2cloud.com/1panel/package/quick_start.sh -o quick_start.sh && sh quick_start.sh

根据引导创建,安装完成后记得放行防火墙

相关实践学习
2分钟自动化部署人生模拟器
本场景将带你借助云效流水线Flow实现人生模拟器小游戏的自动化部署
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情:&nbsp;https://www.aliyun.com/product/ecs
相关文章
|
2天前
|
域名解析 弹性计算 应用服务中间件
使用域名访问部署在ECS上的网站
使用域名访问部署在ECS上的网站
|
1天前
|
弹性计算 Ubuntu Linux
一键部署OpenWebUI+Ollama到阿里云ECS,轻松运行DeepSeek!(保姆级教程)
在当今数据驱动的时代,快速部署和管理大模型成为企业的关键需求。阿里云提供了一键部署OpenWebUI+Ollama的便捷方案,支持本地大模型运行和管理。用户也可以选择连接阿里云百炼的在线模型。
一键部署OpenWebUI+Ollama到阿里云ECS,轻松运行DeepSeek!(保姆级教程)
|
5天前
|
人工智能 负载均衡 数据可视化
阿里云出手了,DeepSeek服务器拒绝繁忙,免费部署DeepSeek模型671B满血版
阿里云推出免费部署DeepSeek模型671B满血版服务,通过百炼大模型平台,用户无需编码,最快5分钟、最低0元即可完成部署。平台提供100万免费Token,支持DeepSeek-R1和DeepSeek-V3等多款模型调用,有效解决服务器繁忙问题。新手零基础也能轻松上手,享受高效稳定的API调用和自动弹性扩展功能。教程涵盖开通服务、获取API-KEY及配置Chatbox客户端等步骤,详细指引助您快速实现DeepSeek自由。
72 18
|
7天前
|
人工智能 负载均衡 数据可视化
阿里云出手了,基于百炼一键部署DeepSeek满血版,告别服务器繁忙1
阿里云百炼平台推出一键部署DeepSeek-R1满血版671B模型,提供100万免费Token,无需编码,新手5分钟内即可完成部署。通过Chatbox客户端配置API,轻松实现模型调用,解决服务器繁忙问题,支持自动弹性扩展,降低硬件成本。详情及教程见阿里云百炼官网。
168 5
|
2天前
|
弹性计算 Ubuntu Docker
在ECS上使用百炼部署满血版deepseek r1
在ECS上使用百炼部署满血版deepseek r1
|
3月前
|
弹性计算 人工智能 Serverless
阿里云ACK One:注册集群云上节点池(CPU/GPU)自动弹性伸缩,助力企业业务高效扩展
在当今数字化时代,企业业务的快速增长对IT基础设施提出了更高要求。然而,传统IDC数据中心却在业务存在扩容慢、缩容难等问题。为此,阿里云推出ACK One注册集群架构,通过云上节点池(CPU/GPU)自动弹性伸缩等特性,为企业带来全新突破。
|
1月前
|
SQL 弹性计算 分布式计算
阿里云 EMR 发布托管弹性伸缩功能,支持自动调整集群大小,最高降本60%
阿里云开源大数据平台 E-MapReduce 重磅推出托管弹性伸缩功能,基于 EMR 托管弹性伸缩功能,您可以指定集群的最小和最大计算限制,EMR 会持续对与集群上运行的工作负载相关的关键指标进行采样,自动调整集群大小,以获得最佳性能和资源利用率。
140 15
|
弹性计算 缓存 运维
【运维知识进阶篇】用阿里云部署kod可道云网盘(DNS解析+CDN缓存+Web应用防火墙+弹性伸缩)(三)
【运维知识进阶篇】用阿里云部署kod可道云网盘(DNS解析+CDN缓存+Web应用防火墙+弹性伸缩)(三)
287 0
|
9月前
|
弹性计算 监控 开发工具
【阿里云弹性计算】实战教程:如何高效利用阿里云ECS弹性伸缩应对业务高峰
【5月更文挑战第20天】本文介绍了如何使用阿里云ECS弹性伸缩服务应对业务高峰。通过自动调整云资源规模,弹性伸缩在流量增加时扩展实例,流量减少时收缩实例,实现成本与性能的优化。步骤包括开通服务、创建伸缩组、设定规则和监控指标。文中还提供了一个Python脚本示例,并强调了优化策略,如应用无状态设计、考虑冷却时间和结合云监控。通过实践和调整,企业可以有效应对业务波动。
189 5
|
弹性计算 缓存 运维
【运维知识进阶篇】用阿里云部署kod可道云网盘(DNS解析+CDN缓存+Web应用防火墙+弹性伸缩)(二)
【运维知识进阶篇】用阿里云部署kod可道云网盘(DNS解析+CDN缓存+Web应用防火墙+弹性伸缩)(二)
229 0