[Advanced Operation and Maintenance Knowledge] Use Alibaba Cloud to deploy kod Kedao cloud network disk (configured Redis+MySQL+NAS+OSS)

This article continues to use kod Kedao cloud network disk as an example to familiarize everyone with Alibaba Cloud products. This article introduces Redis, MySQL, NAS, and OSS. Without further ado, let’s get started.

Table of contents

Redis

1. Purchase Reids master-slave version

2. Configure kod to connect to the Redis intranet interface without a secret key 

3. Apply for public network access connection

4. Create username and password

MySQL

1. Purchase msyql master-slave version

2. Configure username and password

3. Test the connectivity with mysql through the ECS host

4. The kod business is modified from the built-in database to mysql

5. Apply for public network access

6. Remotely test the connection to the mysql public network address in the virtual machine

7. Improve the master-slave configuration to a read-write separation version, obtain the proxy address, and conduct connection testing through ECS.

NAS

1. Purchase a NAS and mount it to ESC’s /mnt

OSS

1. Create bucket

2. Create a sub-account

3. Authorize sub-account to manage bucket

4. Add oss ​​backend storage to oss storage to upload images for testing


Redis

1. Purchase Reids master-slave version

62c1e0895848431a96dac32416aeac8b.png

756c6d31c7b04643b3d4bc7169ee8c09.png

481183aff15e4ff8888d4acfb7c56228.png

2. Configure kod to connect to the Redis intranet interface without a secret key 

eab12de697454ffe8bb662e068a5b852.png

 30edbbe393a8409084c5f5539f3bfcce.png

6cefd2d6958447f19063ebc7ca12edf7.png5e2837485b454fcc9999db3defef13da.png 

06b2a6b6440a4c36b88a1c0b9482da75.png

 Use the 5555 port forwarded by our load balancing to connect to web01

[root@web01 ~]# yum -y install redis
[root@web01 ~]# redis-cli -h r-xxxx.redis.rds.aliyuncs.com    成功连接
r-xxxx.redis.rds.aliyuncs.com:6379> keys *
(empty list or set)

 6c30d58e74344c53a8ca3a385fc14bcc.png

326c58aaed18401eacbcb9ebedc3b9bb.png

Refresh the web page. Because there are two web pages for load balancing, this operation needs to be performed twice. Keys * query, successful!

1cc992c0b9a040129f26a9781ea477de.png

3. Apply for public network access connection

211b08a671334d91a4a718333ec0379e.png4. Create username and password

Remotely connect to the public network Redis interface address on the virtual machine and use keys *verification+

We cannot use the web to connect to the public IP here because our web cannot connect to the network and can only connect to redis via the private network, so we connect to the web on the virtual machine.

[root@Web01 ~]# redis-cli -h r-xxxx.redis.rds.aliyuncs.com
r-xxxx.redis.rds.aliyuncs.com:6379> keys *
(error) ERR illegal address: 123.112.17.24:9913

#将本机IP加入白名单

r-xxxx.redis.rds.aliyuncs.com:6379> keys *
(error) NOAUTH Authentication required.

#使用密码连接

[root@Web01 ~]# redis-cli -h r-xxx.redis.rds.aliyuncs.com -a 'username:password' #后面跟账号和密码
r-0jla7au49dwd2jnp2rpd.redis.rds.aliyuncs.com:6379> keys *

#成功显示

MySQL

1. Purchase msyql master-slave version

I made the wrong purchase here. You need to buy the high-availability version directly.

db9e9d835833445b82c11acbebe815be.png

fd49db33ec3547f1b879b8161006abbc.pngeb4d3f01cfac40e39a35d872eaf78467.png

d9a8759274064f3bba880d8275f61939.png

2. Configure username and password

56a22fab689942d99105a92e1d942c0a.png

3. Test the connectivity with mysql through the ECS host

mysql host list, network details, copy private network, which is the domain name of our LAN

[root@web01 ~]# ping rm-xxxx.mysql.rds.aliyuncs.com

[root@web01 ~]# yum -y install mariadb-server.x86_64

[root@web01 ~]# mysql -h rm-xxxx.mysql.rds.aliyuncs.com -u'username' -p'password'
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 59
Server version: 5.7.40-log Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| __recycle_bin__    |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

MySQL [(none)]> 

4. The kod business is modified from the built-in database to mysql

Because I just deleted redis in Alibaba Cloud, an error will be reported when accessing it directly. We need to delete the contents of the configuration file of the kod database first.

60040da1ab1644cfa178137eb8c2e196.png

Just delete the relevant redis information. Note that both web01 and web02 need to be deleted.

[root@web02 ~]# cat /code/kod/config/setting_user.php
<?php 
$config['database'] = array (
  'DB_TYPE' => 'sqlite3',
  'DB_NAME' => USER_SYSTEM.'kGdiwtmrh4ZW.php',
  'DB_SQL_LOG' => true,
  'DB_FIELDS_CACHE' => true,
  'DB_SQL_BUILD_CACHE' => false,
);
$config['cache']['sessionType'] = 'file';
$config['cache']['cacheType'] = 'file';

Configuration on the website is the same as redis. It needs to be done twice, but the second time it will prompt that it cannot be executed, so we scp to another web after doing it once. Be careful not to confuse the target file with the source file. Otherwise it will need to be done again.

f934cb36b5ac4bc1b8f6bc47b3aa06cc.png

[root@web01 config]# cat /code/kod/config/setting_user.php
<?php 
$config['database'] = array (
  'DB_TYPE' => 'mysqli',
  'DB_HOST' => 'rm-xxxx.mysql.rds.aliyuncs.com',
  'DB_PORT' => 3306,
  'DB_USER' => 'username',
  'DB_PWD' => 'password',
  'DB_NAME' => 'kodbox',
  'DB_SQL_LOG' => true,
  'DB_FIELDS_CACHE' => true,
  'DB_SQL_BUILD_CACHE' => false,
);

$config['cache']['sessionType'] = 'file';
$config['cache']['cacheType'] = 'file';

[root@web01 config]# scp setting_user.php 172.18.3.150:/code/kod/config/setting_user.php
[email protected]'s password: 
setting_user.php                                                      100%  399     1.2MB/s   00:00 

5. Apply for public network access

410d8b34da0a49c6aa11397db8bd00f1.png

Uncheck here 

9023c16c69d8482fbd778765b2e5356e.png6. Remotely test the connection to the mysql public network address in the virtual machine

[root@Web01 ~]# mysql -uusername -pPassword -h rm-xxxx.mysql.rds.aliyuncs.com
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3449
Server version: 5.7.40-log Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| __recycle_bin__    |
| kodbox             |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.01 sec)

MySQL [(none)]>

7. Improve the master-slave configuration to a read-write separation version, obtain the proxy address, and conduct connection testing through ECS.

I bought the wrong one just now. Let’s change the configuration to the high-availability version first. 

53a12fe6a2a44cb88951e649a22bf2f7.png

3daa6e3481ce474e86329347ee7e2f2d.png

ccfcf304efbc4409a669b5d5c05a17ed.png

High availability configuration, here shows read and write separation.8bc374ade4fd45f69a9846b91a1c5a97.png

7919499d700e477e82cff87431949c54.png 7f75693a89064a2b8ce903baaab65154.png

 Purchase a read-only instancece9b24bb95ea4b61bd42899faceef9ae.png

 9c53ac462ea3443687e0900c5f01291f.png72de9ce3613a4f41a8a2fc2ec9acda3f.png

3e357ddfcab74bdab7119c50fe9a3c4d.png

3e7bdd1083a6400a8e7c2d218817ceb1.png

Set up the proxy terminal and click OK directly.

ae3485a79d3c440fb294fc215582161d.png

55bb3ae777ff4cbf8b52d69f72b0d4c5.png

 Copy connection address

4df6ec51b65e4716acdf7364593066c6.png

That is this address 

2192b8aca0fe4e42ab20012add453b2e.png

 Try to log in, there is no problem. You need to change the mysql address of the configuration file in the project to this before it can be used. This will not be demonstrated again.

[root@web01 config]# mysql -umysql_db01 -pMysqldb01 -h jxjkffytkozbenzpd27c-rw4rm.rwlb.rds.aliyuncs.com
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 268436052
Server version: 5.7.40-log Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| __recycle_bin__    |
| kodbox             |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.01 sec)

MySQL [(none)]> 

NAS

1. Purchase a NAS and mount it to ESC’s /mnt

80809bd2d01d427594efaf951353f223.png

adfbaaa82f8b41d9b47ec2712fd5ade1.png

3a2437329bce44a2966fee8c1fbd1c0a.pngcfe14b26a0714aca9be1828a7a494508.png e47d77e4a684492a828543b0be9e9740.png

Add to ECS 

d7495fd2f2ca4678933629876ac268cf.png

Mount both web1 and web2 

f7dc91d59b5e48a9b808ccea95355946.png

[root@web01 config]# df -h
Filesystem                                         Size  Used Avail Use% Mounted on
devtmpfs                                           461M     0  461M   0% /dev
tmpfs                                              471M     0  471M   0% /dev/shm
tmpfs                                              471M  500K  471M   1% /run
tmpfs                                              471M     0  471M   0% /sys/fs/cgroup
/dev/vda1                                           20G  3.3G   16G  18% /
tmpfs                                               95M     0   95M   0% /run/user/0
29d8604a9d7-bwb8.cn-wulanchabu.nas.aliyuncs.com:/   10P     0   10P   0% /mnt

[root@web02 ~]# df -h
Filesystem                                         Size  Used Avail Use% Mounted on
devtmpfs                                           461M     0  461M   0% /dev
tmpfs                                              471M     0  471M   0% /dev/shm
tmpfs                                              471M  492K  471M   1% /run
tmpfs                                              471M     0  471M   0% /sys/fs/cgroup
/dev/vda1                                           20G  3.4G   16G  19% /
tmpfs                                               95M     0   95M   0% /run/user/0
29d8604a9d7-bwb8.cn-wulanchabu.nas.aliyuncs.com:/   10P     0   10P   0% /mnt

Create a file in the virtual machine and successfully display it on the cloud disk

[root@web01 mnt]# touch 1.txt

30bf0b378aa54a47b84879e7ba3d031c.png

OSS

1. Create bucket

77c9af725ab54560a80c1edbb03ff526.png

91df5c3331734d2b8b2bf7f8ee364914.pngca3e29bd8e484ba9bbb2b463c04d67b2.png

 8de244bed48545878bf90f0dba91b0c8.png

 d2482f875fbd417c84e9c913d4c9fc2c.png

2. Create a sub-account

Enter bucket-->Permission Control-->Access Control RAM--> Access Control RAM-->Go to RAM Console--User: Create User

dbf9bbda669b48fda8ec0cf3fb2eca02.png

 97e530b4767d46198f0697ff27fbd608.png

e2ac40c3c9a141358f190538b3240ebd.png

3. Authorize sub-account to manage bucket

f98e619ba97249ee9a26ef7f205ee8dc.png

 2f9c5e258e8c4365bbbfa0adf9283b78.png

e94ac7ea81934a92b981ff68aeab9d87.png

 Collect information to configure kod

bcb626a11d294a3db22f23ae3f1e4926.png

 

deb9714a8b5240e59fc14bbddd15eb86.png

f448f9058c6548dc996f7366eb7c2ba6.png

Fill in the corresponding data and click Save after filling in. Since there are two webs, this operation also requires two steps.

050fb9fbf4884d8590bd6cfbb6f5fb9a.png

4. Add oss ​​backend storage to oss storage to upload images for testing

0901873771b74cad8edb4d55f3dc34e0.png

The browser uploads it and Alibaba Cloud displays it successfully. 

a5d6f7d87e7e4aaaa03dfd5b46e5c904.png

bf3c5472524a4222b3a3be5f5a56685b.png

 You can also perform image processing. After uploading the image, you can add a watermark, similar to the watermark in the lower right corner of Baidu images.

23e8288e5bd14b78b630fa5ae2baf179.png


My name is Koten. I have 10 years of operation and maintenance experience. I continue to share operation and maintenance tips. Thank you for reading and paying attention!

 

Guess you like

Origin blog.csdn.net/qq_37510195/article/details/130348736