华为云的php,mysql,redis的原版安装
ECS中安装mysql配置的命令
1. 通过下面的命令安装mysql:
cd /opt
wget https://hciecloud.obs.cn-north-4.myhuaweicloud.com/MySQL-5.6.45-1.el6.x86_64.rpm-bundle.tar
mkdir mysql_install
tar -xvf MySQL-5.6.45-1.el6.x86_64.rpm-bundle.tar -C mysql_install
cd mysql_install
yum -y remove mariadb*
yum install -y MySQL-shared-compat-5.6.45-1.el6.x86_64.rpm
yum install -y MySQL-server-5.6.45-1.el6.x86_64.rpm
yum install -y MySQL-client-5.6.45-1.el6.x86_64.rpm
yum install -y MySQL-devel-5.6.45-1.el6.x86_64.rpm
yum install -y MySQL-shared-5.6.45-1.el6.x86_64.rpm
2. 修改配置Mysql文件
通过以下整段命令新增my.cnf配置文件:
cat << EOF >> /etc/my.cnf
[mysqld]
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
lower_case_table_names = 1
innodb_strict_mode = 1
sql_mode =
symbolic-links=0
character_set_server = utf8
log-bin = mysql-bin
binlog_format=row
server-id = 2
expire_logs_days = 10
slave_skip_errors = 1062
innodb_strict_mode = 0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EOF
通过以下命令确认mysql配置文件:
cat /etc/my.cnf
3. 在Ecs上启动mysql
通过以下命令启动mysql:
systemctl start mysql
4. 在Ecs-mysql上修改mysql密码
1、编写脚本mysql_pass.sh
vi mysql_pass.sh
#!/bin/bash
# 安装expect插件
yum install -y expect
# 修改密码为Huawei@123@
pass=`awk -F"[ :]+" 'NR==1{print $NF}' /root/.mysql_secret`
/bin/expect << EOF
spawn /usr/bin/mysql -h127.0.0.1 -uroot -p`echo -e $pass`
expect "mysql>"
send "SET PASSWORD FOR root@localhost=PASSWORD('Huawei@123@');"
send "\n"
expect "mysql>"
send 'flush privileges\n'
expect "mysql>"
send 'quit\n'
interact
EOF
2、增加可执行权限并执行脚本
chmod +x mysql_pass.sh
./mysql_pass.sh
3、使用修改后的密码登录
mysql –u root -pHuawei@123@
5设置数据库访问权限
在mysql>界面输入以下命令为同步账户授予复制权限:
/usr/bin/mysql -h127.0.0.1 -uroot -pHuawei@123@
grant all privileges on *.* to root@"%" identified by "Huawei@123@";
flush privileges;
修改完毕通过以下命令退出mysql:
quit
ECS部署PHP56的配置命令
wget https://hcie-lab-2020.obs.cn-north-4.myhuaweicloud.com/remi-release-7.rpm
rpm -ivh remi-release-7.rpm
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mysqlnd php-gd php-redis
ECS部署PHP72的配置命令
yum -y install php72w php72w-pdo php72w-mysqlnd php72w-opcache php72w-xml php72w-gd php72w-mcrypt php72w-devel php72w-intl php72w-mbstring php72w-bcmath php72w-json php72w-iconv
ECS-mysql缓存Redis部署
1. 在Ecs-mysql上继续部署redis
通过以下命令安装redis:
yum install -y redis
2. 设置redis密码
通过以下命令修改redis配置文件,如果配置错误请通过vi手动修改配置文件:
echo -e 'requirepass Huawei@123@' >> /etc/redis.conf
tail -5 /etc/redis.conf
3. 修改redis端口监听ip
记录ip地址:
ifconfig |grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'
通过以下命令修改redis监听地址:
sed -i "s/bind 127.0.0.1/bind $(ifconfig |grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}')/g" /etc/redis.conf
通过以下命令确认监听端口的IP地址是否正确:
grep bind /etc/redis.conf | grep -v '#'
4. 通过以下命令重启redis
systemctl restart redis
感谢大家的支持,关注,评论,点赞!