后端开发时,使用`云(azure)中间件`(mysql & redis)

222 阅读1分钟

mysql

创建mysql 云服务[Azure Database for MySQL](Azure Service)

创建mysql 云服务(暂略)

将 MySQL Workbench 与 Azure Database for MySQL 灵活服务器配合使用

FAQ(mysql):

A: 连接不上怎么办,可能是你没有设置允许接入的client 公网IP(可以百度 ip 获取),将获取的公网ip 地址设置在以下rule 里。 并且简单起见,一并关掉ssl
ssl 延伸阅读: SSL connection is required. Please specify SSL options and retry | Why does connection to my MySQL server in Azure fail if my app does not have SSL enabled? | Step 3: Enforcing SSL connections in Azure
Q: 详见下图: image.png

At last,测试连接: image.png

在 ubuntu 上测试:
apt install mysql-client
mysql -h${HOST} -u${username} -p${password}
show databases;

redis

创建redis 云服务[Azure Cache for Redis](Azure Service)

官网 - 如何配置 Azure Redis 缓存
官网 - 如何配置 Azure Redis 缓存(mirror with above)

FAQ(redis):

A: 连接不上怎么办,可能是你没有设置允许接入的client 公网IP(可以百度 ip 获取),将获取的公网ip 地址设置在以下rule 里。
Q: 详见下图: image.png

A: 设置完以上后,连接可能会报Connect to redis server time out.,可能是开启了ssl, 关掉即可。
Q: 详见下图: image.png

A: 设置完以上后,连接可能会报NOAUTH Authentication required.,那是azure 需要认证密码(没有用户,只有密码的认证);输入错的密码会报WRONGPASS invalid username-password pairNOAUTH Authentication required 解决办法
Q: 密码在以下位置可以找到: image.png

注意⚠️: azure 中的redis 必须设置有密码,而且不能修改,参考: ***** 【Azure Redis 缓存】由Azure Redis是否可以自定义密码而引申出Azure PaaS的Redis服务是否可以和自建的Redis进行主从配置呢?

At last,测试连接: image.png

在 ubuntu 上测试:
[Ubuntu安装redis客户端工具及简单使用](https://blog.csdn.net/chyercn/article/details/119978652)
apt-get install redis-tools
redis-cli -h ${host} -p ${port}
ping