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
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
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
1. Purchase a NAS and mount it to ESC’s /mnt
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
2. Configure kod to connect to the Redis intranet interface without a secret key
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)
Refresh the web page. Because there are two web pages for load balancing, this operation needs to be performed twice. Keys * query, successful!
3. Apply for public network access connection
4. 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.
2. Configure username and password
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.
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.
[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
Uncheck here
6. 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.
High availability configuration, here shows read and write separation.
Purchase a read-only instance
Set up the proxy terminal and click OK directly.
Copy connection address
That is this address
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
Add to ECS
Mount both web1 and web2
[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
OSS
1. Create bucket
2. Create a sub-account
Enter bucket-->Permission Control-->Access Control RAM--> Access Control RAM-->Go to RAM Console--User: Create User
3. Authorize sub-account to manage bucket
Collect information to configure kod
Fill in the corresponding data and click Save after filling in. Since there are two webs, this operation also requires two steps.
4. Add oss backend storage to oss storage to upload images for testing
The browser uploads it and Alibaba Cloud displays it successfully.
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.
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!