07-31
						0
					
					mysql主从数据库 docker环境
1.配置主库
master.cnf
[mysqld]
# 同一局域网内注意要唯一
server-id=100
# 开启二进制日志功能,可以随便取
log-bin=mysql-bin查看二进制日志是否开启 
SHOW GLOBAL VARIABLES LIKE '%log%';
查看主节点的server id
SHOW GLOBAL VARIABLES LIKE '%server%';
创建有复制权限的用户slave
CREATE USER 'slave'@'%' IDENTIFIED BY '123456';
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'%' IDENTIFIED by '123456';
刷新配置
FLUSH PRIVILEGES;
查看File和Position字段的值
show master status;2.配置从库
slave.cnf
[mysqld]
server-id=101
#开启二进制日志功能,以备Slave作为其它Slave的Master时使用
log-bin=mysql-slave-bin
#relay_log配置中继日志
relay_log=edu-mysql-relay-bin停止主从复制
stop slave;
设置主数据库信息
change master to master_host='172.17.0.5', master_user='slave', master_password='123456', master_port=3306, master_log_file='mysql-bin.000001', master_log_pos=856, master_connect_retry=30;
启动主从复制
start slave;
查看主从同步状态
show slave status;设置从库只读
# 开启只读
show global variables like "%read_only%";
# 对所有用户生效,包括super用户(不建议使用)
flush tables with read lock;
# 只对普通用户生效,如slave用户
set global read_only=1;
show global variables like "%read_only%";
# 关闭只读
unlock tables;
set global read_only=0;Docker配置
创建 /app/docker_files/mysql 文件夹
docker-compose.yml 配置文件 放在 /app/docker_files目录下
version: '3'
services:    
  db-master:
    build: './mysql'
    image: 'db-server:1.0'
    container_name: 'db-master'
    ports:
      - "3366:3306"
    volumes:
      - "/app/docker_files/mysql/conf/master.cnf:/etc/mysql/conf.d/master.cnf"
      - "/app/docker_files/mysql/data:/var/lib/mysql"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: qwe123!@#
    command: ["mysqld", "--server-id=1", "--log-bin=mysql-bin"]
    networks:
      - lnmp  
  db-slave:
    build: './mysql'
    image: 'db-server:1.0'
    container_name: 'db-slave'
    ports:
      - "3307:3306"
    volumes:
      - "/app/docker_files/mysql/conf/slave.cnf:/etc/mysql/conf.d/slave.cnf"
      - "/app/docker_files/mysql/slave-data:/var/lib/mysql"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: qwe123!@#
    command: ["mysqld", "--server-id=2"]
    networks:
      - lnmp  
networks:
  lnmp:
    driver: bridge 
07-06
						0
					
					Gogs
官网
https://gogs.io/ 编辑并设置服务
[Unit]
Description=Gogs
After=syslog.target
After=network.target
#After=mariadb.service mysql.service mysqld.service postgresql.service memcached.service redis.service
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=root
Group=root
WorkingDirectory=/www/wwwroot/git.aqrboyblog.top/gogs
ExecStart=/www/wwwroot/git.aqrboyblog.top/gogs/gogs web
Restart=always
Environment=USER=root HOME=/www/wwwroot/git.aqrboyblog.top
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target刷新server
systemctl daemon-reload启动服务
systemctl start gogs.service07-05
						0
					
					laravel
1.创建一个名为laravel的laravel项目
composer create-project laravel/laravel --prefer-dist ./QZ_20_0712命令解释:
composer:表示执行该程序;
create-project :创建项目
laravel/laravel:需要创建的项目名称;
–prefer-dist:优先下载压缩包方式,而不是直接从GitHub上下载源码
2.php artisan
(1)数据表
//创建迁移 建表
php artisan make:migration create_demo_table
//重建数据库,在原本的迁移文件中增加字段后执行
php artisan migrate:refresh
//数据表迁移
php artisan migrate
//数据表回滚
php artisan migrate:rollback(2)功能列表
php artisan list(3)make 列表
  make:cast             Create a new custom Eloquent cast class
  make:channel          Create a new channel class
  make:command          Create a new Artisan command
  make:component        Create a new view component class
  make:controller       Create a new controller class
  make:event            Create a new event class
  make:exception        Create a new custom exception class
  make:export           Create a new export class
  make:factory          Create a new model factory
  make:import           Create a new import class
  make:job              Create a new job class
  make:listener         Create a new event listener class
  make:mail             Create a new email class
  make:middleware       Create a new middleware class
  make:migration        Create a new migration file
  make:model            Create a new Eloquent model class
  make:notification     Create a new notification class
  make:observer         Create a new observer class
  make:policy           Create a new policy class
  make:provider         Create a new service provider class
  make:request          Create a new form request class
  make:resource         Create a new resource
  make:rule             Create a new validation rule
  make:seeder           Create a new seeder class
  make:test             Create a new test class06-13
						0
					
					Docker
1.安装Docker
//Centos
yum install docker 2.docker 基础命令
//启动docker
systemctl start docker
//关闭docker
systemctl stop docker
//重启docker
systemctl restart docker
//docker设置随服务启动而自启动
systemctl enable docker
//查看docker 运行状态
systemctl status docker3.docker 镜像命令
//查看自己服务器中docker 镜像列表
docker images
//搜索镜像
docker search 镜像名
docker search --filter=STARS=9000 mysql 搜索 STARS >9000的 mysql 镜像
//拉取镜像 
docker pull 镜像名 
docker pull 镜像名:tag
//删除镜像
#删除一个
docker rmi -f 镜像名/镜像ID
#删除多个 其镜像ID或镜像用用空格隔开即可 
docker rmi -f 镜像名/镜像ID 镜像名/镜像ID 镜像名/镜像ID
#删除全部镜像  -a 意思为显示全部, -q 意思为只显示ID
docker rmi -f $(docker images -aq)
//强制删除镜像
docker image rm 镜像名称/镜像ID
4.docker 容器命令
//查看正在运行容器列表
docker ps
//查看所有容器 -----包含正在运行 和已停止的
docker ps -a
//运行一个容器
# -it 表示 与容器进行交互式启动 -d 表示可后台运行容器 (守护式运行)  --name 给要运行的容器 起的名字  /bin/bash  交互路径
docker run -it -d --name 要取的别名 镜像名:Tag /bin/bash 
 
                            