个人学习笔记(1)

举报
Lim_QgyG 发表于 2022/07/10 22:33:52 2022/07/10
【摘要】 lnmpwget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpmrpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpmyum -y install nginxsystemctl start nginxsyste...

lnmp

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum -y install nginx
systemctl start nginx
systemctl enable nginx
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
systemctl start mysqld
systemctl enable mysqld
grep 'temporary password' /var/log/mysqld.log   # 获取密码
mysql_secure_installation
show variables like "vali%";
set global validate_password_mixed_case_count=0
set global validate_password_policy=0;
​
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w-tidy php70w-common php70w-devel php70w-pdo php70w-mysql php70w-gd php70w-ldap php70w-mbstring php70w-mcrypt php70w-fpm
php -v
systemctl start php-fpm
systemctl enable php-fpm
cat > /etc/nginx/conf.d/default.conf < EOF
server {
    listen       80;
    server_name  localhost;
​
    location / {
        root   /usr/share/nginx/html;
        index index.php index.html index.htm;
    }
​
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
​
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        include        fastcgi_params;
    }
​
}
EOF
systemctl reload nginx
cat > /usr/share/nginx/html/info.php << EOF
<?php
 phpinfo();
?>
EOF
curl http://localhost/info.php


配置源

rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://files-cdn.cnblogs.com/files/lemanlai/CentOS-7.repo.sh
curl -o /etc/pki/rpm-gpg/RPM-GPG-KEY-7 https://mirror.tuna.tsinghua.edu.cn/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
yum install epel-release -y
yum clean all
yum makecache fast
yum install nmap telnet curl wget vim lrzsz bind-utils -y
yum install -y yum-utils device-mapper-persistent-data lvm2
curl -o /etc/yum.repos.d/docker-ce.repo https://files-cdn.cnblogs.com/files/lemanlai/docker-ce.repo.sh
yum clean all
yum makecache fast
yum -y install docker-ce
systemctl enable docker
systemctl start docker
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl daemon-reload
systemctl restart docker
# 如果docker要运行多个进程可以privileged=true
docker run -d -it -p 10000:3306 --name db1 --privileged=true cf49811e3cdb /usr/sbin/init
docker run -d -it -p 10001:3306 --name db2 --privileged=true cf49811e3cdb /usr/sbin/init


SNAT转发 综合练习

# 可以参考 https://support.huaweicloud.com/usermanual-ecs/ecs_03_0705.html
​
echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sysctl -p
路由表新增路由0.0.0.0/0 服务器
取消弹性网卡的 源/目的检查
iptables -t nat -I POSTROUTING -s 192.168.100.0/24 -j SNAT --to-source  192.168.100.100
​
# 远程执行
yum install expect -y
cat > ssh.exp << EOF
#!/usr/bin/expect
spawn ssh root@192.168.100.100 "ifconfig"
expect {
        "(yes/no)" {send "yes\r"; exp_continue}
        "password:" {send "Cloud!@34\r"}
}
interact
EOF
expect ssh.exp 192.168.100.101
​
DNAT
iptables -t nat -A PREROUTING -d 172.16.100.209 -p tcp -m tcp --dport 80 -j DNAT --to-destination 172.16.100.173:80
# -d 目的ip --dport 目的端口  --to-destination 来源
iptables -t nat -A PREROUTING -d 172.16.100.149 -p tcp --dport 80 -j DNAT --to-destination 10.247.13.225:80

NGINX配置

echo "zhenxing-100-nginx" >> /usr/share/nginx/html/index.html
​
# wordpress图片位置在wp-config.php中的
define('UPLOADS', ''.'/share');

API

eip

创建CreatePublicip

绑定和解绑UpdatePublicip需要eip的id

  • 绑定的话需要带端口号

  • 解绑无需端口


mysql主从

日常

# 主
vim /etc/my.cnf
[mysqld]
log_bin=log-bin
server_id=1
​
systemctl restart mariadb
mysql -uroot -p000000
grant replication slave on *.* to "lqy"@"%" identified by "000000";
flush privileges;
show master status;
​
# 从
vim /etc/my.cnf
[mysqld]
server_id=2
​
systemctl restart mariadb
mysql -uroot -p000000
change master to master_host='172.17.0.2',master_user='lqy',master_password='000000',master_log_file='log-bin.000002',master_log_pos=245;
start slave;
show slave status\G;

gtid主从

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
systemctl start mysqld
systemctl enable mysqld
grep 'temporary password' /var/log/mysqld.log   # 获取密码
mysql_secure_installation
vim /etc/my.cnf
[mysqld]
server_id=2
​
systemctl restart mysqld
change master to master_host='172.17.0.2',master_user='lqy',master_password='000000',master_log_file='log-bin.000002',master_log_pos=245;
start slave;
show slave status\G;
stop slave;
set global enforce_gtid_consistency=on;
set @@GLOBAL.GTID_MODE = OFF_PERMISSIVE;
start slave;
show slave status\G;


切换数据库**

# 导出
mysqldump -h 127.0.0.1 -u root -p wordpress > /root/mysql.sql # -p后面不加密码 wordpress是数据库的名称 如果指定-d 就只导出表格式 不导数据
​
# 导入
mysql -uroot -p000000
source /root/mysql.sql
​
# 修改配置文件 连接一下就行
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。