python 基础

基础

元组

  • 不可变性:元组一旦创建就不能修改,这使得元组在某些情况下比列表更安全。
  • 存储:可以存储不同类型的数据。
  • 性能:由于元组的不可变性,它们通常比列表有更快的访问速度。
  • 用途:适合用于存储不需要修改的数据集合,如函数返回多个值时。
  • 语法:使用逗号 , 来定义,圆括号 ()可省略。
1
2
3
# best_language = ('python',)
best_language = 'python','cs'
print(best_language)

py3笔记

RAID 磁盘阵列

RAID

一种将多个硬盘驱动器组合成一个逻辑单元的数据存储虚拟化技术

RAID0

不适合存放重要数据

  • 特点:将数据分散存储在多个硬盘上,没有冗余。
  • 优势:提高读写速度,因为数据分布在多个硬盘上。
  • 缺点:没有数据冗余,一个硬盘损坏会导致所有数据丢失。

network网络问题定位

定位丢包,错包情况

watch more /proc/net/dev用于定位丢包,错包情况,以便看网络瓶颈,重点关注drop(包被丢弃)和网络包传送的总量,不要超过网络上限:

  • 最左边的表示接口的名字,Receive表示收包,Transmit表示发送包;
  • bytes:表示收发的字节数;
  • packets:表示收发正确的包量;
  • errs:表示收发错误的包量;
  • drop:表示收发丢弃的包量;

wiki.js

https://github.com/Requarks/wiki?tab=readme-ov-file

install

https://docs.requarks.io/install/docker

1
2
3
4
5
6
7
8
MySQL root@localhost:wiki> SHOW VARIABLES like "auto_increment%";
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 2 |
| auto_increment_offset | 2 |
+--------------------------+-------+

auto_increment_offset : AUTO_INCREMENT列值的起点,也就是初始值。取值范围是1 .. 65535

auto_increment_increment : 控制列中的值的增量值,也就是步长。其默认值是1,取值范围是1 .. 65535

https://github.com/requarks/wiki/issues/1485

Incorrect groups auto-increment configuration! Should start at 0 and increment by 1. Contact your database administrator.

MySQL wikijs@localhost:wiki> truncate groups
You’re about to run a destructive command.
Do you want to proceed? (y/n): y
Your call!
(1701, ‘Cannot truncate a table referenced in a foreign key constraint (wiki.usergroups, CONSTRAINT usergroups_groupid_foreign)’)

#SET FOREIGN_KEY_CHECKS=0;

/etc/my.cnf 设置

ansible galaxy

http://www.ansible.com.cn/docs/galaxy.html

galaxy

https://galaxy.ansible.com/ui/search/

1
2
3
4
5
6
ansible-galaxy search                   在galaxy上搜索角色
ansible-galaxy install 从galaxu上下载角色
-r 从文件中安装多个角色
-p 指定安装路径
ansible-galaxy init 创建自定义角色
ansible-galaxy list 查看角色

#从文件中下载角色到指定路径

ansible-galaxy install -r galaxyroles.yml -p /home/greg/ansible/roles/

cat galaxyroles.yml

- src: http://materials/ phpinfo.tar
name: phpinfo

ansible galaxy

http://www.ansible.com.cn/docs/galaxy.html

galaxy

https://galaxy.ansible.com/ui/search/

1
2
3
4
5
6
ansible-galaxy search                   在galaxy上搜索角色
ansible-galaxy install 从galaxu上下载角色
-r 从文件中安装多个角色
-p 指定安装路径
ansible-galaxy init 创建自定义角色
ansible-galaxy list 查看角色

#从文件中下载角色到指定路径

ansible-galaxy install -r galaxyroles.yml -p /home/greg/ansible/roles/

cat galaxyroles.yml

- src: http://materials/ phpinfo.tar
name: phpinfo

gitlab 使用

安装

https://docs.gitlab.com/ee/install/docker.html

volume目录

1
mkdir  -p  /mnt/oss/gitlab/{config,logs,data}
docker-compose.yml
docker-compose.yml
version: '3.6'
services:
  web:
    image: 'gitlab/gitlab-ce:16.6.2-ce.0'
    restart: always
    container_name: gitlab
    # hostname: 'gitlab-ce' #hostname标签是设置容器的主机名
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.ui.k8s.cn:18443'
        letsencrypt['enable'] = false
        gitlab_rails['gitlab_ssh_host'] = 'gitlab.ui.k8s.cn'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
        gitlab_rails['gravatar_enabled'] = true
        #### For HTTPS
        gitlab_rails['gravatar_ssl_url'] = "https://seccdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"
        #### Use this line instead for HTTP
        # gitlab_rails['gravatar_plain_url'] = "http://cdn.libravatar.org/avatar/%{hash}?s=%{size}&d=identicon"

#gitlab_rails['initial_root_password'] = 'c123456;'
#复制crt证书到挂载目录 nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.ui.k8s.cn.crt" nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.ui.k8s.cn.key"
#配置http自动跳转到https协议的地址; nginx['redirect_http_to_https'] = true
nginx['enable'] = true nginx['client_max_body_size'] = '250m' #配置监听容器内的443端口,注意不是外面主机的443端口 nginx['listen_port'] = 443
nginx['ssl_protocols'] = "TLSv1.1 TLSv1.2" nginx['logrotate_frequency'] = "weekly" nginx['logrotate_rotate'] = 52 nginx['logrotate_compress'] = "compress" nginx['logrotate_method'] = "copytruncate" nginx['logrotate_delaycompress'] = "delaycompress"
nginx['proxy_set_headers'] = { "X-Forwarded-Proto" => "https", "X-Forwarded-Ssl" => "on", }
nginx['custom_error_pages'] = { '404' => { 'title' => 'Example title', 'header' => 'Example header', 'message' => 'Example message' } }
# gitlab_rails['smtp_enable'] = true # gitlab_rails['smtp_address'] = "smtp.example.com" # gitlab_rails['smtp_port'] = 587 # gitlab_rails['smtp_user_name'] = "no-reply@example.com" # gitlab_rails['smtp_password'] = "changeMeToSomethingGood" # gitlab_rails['smtp_domain'] = "example.com" # gitlab_rails['smtp_authentication'] = "login" # gitlab_rails['smtp_enable_starttls_auto'] = true ports: - '8980:80' - '18443:443' - '2224:22' volumes: - '/mnt/oss/gitlab/config:/etc/gitlab' - '/mnt/oss/gitlab/logs:/var/log/gitlab' - '/mnt/oss/gitlab/data:/var/opt/gitlab' - '/mnt/oss/gitlab/certs:/etc/gitlab/ssl' shm_size: '256m'
gitlab-runner: image: 'gitlab/gitlab-runner:v16.9.0' restart: unless-stopped container_name: 'gitlab-runner' depends_on: - web privileged: true extra_hosts: - "gitlab.ui.k8s.cn:192.168.122.1" # 添加主机名 volumes: - /mnt/oss/gitlab/runner/config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock - /mnt/oss/gitlab/certs/gitlab.ui.k8s.cn.crt:/home/gitlab-runner/gitlab.ui.k8s.cn.crt

修改密码

载入天数...载入时分秒... ,