├── ico ├── tubiam.md ├── min-bibei.svg ├── min-awesome.svg ├── min-oss.svg ├── facebook.svg ├── linkedin.svg ├── gitter.svg ├── min-free.svg ├── min-tuijian.svg ├── min-hot.svg ├── twitter-tweet.svg ├── twitter-follow.svg ├── twitter.svg ├── hexo.svg ├── zhihu.svg ├── alipay.svg ├── alipay-1.svg ├── group.svg ├── npm.svg ├── min-app-store.svg ├── google+.svg ├── email.svg ├── qqweibo.svg ├── weibo.svg ├── 58.svg ├── xunlei.svg └── csdn.svg ├── img ├── gen (1).svg ├── readme.md ├── 1.PNG ├── 2.PNG ├── 3.PNG ├── 4.PNG ├── timg.jpg ├── 返回顶部.png ├── 12222.jpg.jpeg ├── 1542158208547.jpg ├── 1542158223641.jpg ├── 1542158235833.jpg ├── 56445805cee8f.jpg ├── 20170430170428338.png ├── 20170430170510093.png ├── 68747470733a2f2f73312e617831782e636f6d2f323031382f31302f30382f694a6e354a552e6a7067.jpg └── 68747470733a2f2f73312e617831782e636f6d2f323031382f31302f30382f694a7579744b2e6a7067.jpg ├── Redis ├── 优化 │ └── readme.md ├── 排错 │ └── readme.md ├── 安装 │ ├── readme.md │ └── install_redis.sh ├── readme.md ├── 配置 │ ├── redis.conf │ ├── jiandan_redis.conf │ ├── tongyong_redis.conf │ ├── readme.md │ ├── redis-common.conf │ ├── moren_redis.conf │ └── tongyong_redis1.conf ├── 命令 │ └── readme.md ├── 介绍 │ └── readme.md └── install_redis.sh ├── openvpn ├── readme └── openvpn-install-2.3.10-I601-x86_64.zip ├── zaji └── README.MD ├── Gitlab ├── readme.md ├── jksample │ ├── index.jsp │ └── META-INF │ │ ├── MANIFEST.MF │ │ └── maven │ │ └── cn.xsshome │ │ └── jksample │ │ ├── pom.properties │ │ └── pom.xml └── install_gitlab.sh ├── Haproxy └── readme.md ├── Jenkins ├── readme.md └── install_jenkins.sh ├── Nginx ├── proxy │ ├── readme.md │ ├── upstream.conf │ ├── test.conf │ ├── proxy.conf │ ├── www.baibai.com.conf │ └── nginx.conf ├── readme.md ├── install_nginx.sh └── 内核参数优化 ├── work ├── readme.md ├── wiki.sh ├── samba.sh └── 云盘 ├── maven+nexus ├── readme.md └── maven + nexus.sh ├── mogodb ├── readme.md └── install_MongoDB.sh ├── yum ├── readme.md └── yum 私有仓库.sh ├── Centos7 ├── man tcp ├── README.md ├── systemctl ├── Nginx做web服务器linux内核参数优化 ├── test内核 └── 内核高并发 ├── sonar ├── readme.md └── install_sonar.sh ├── jenkins-gitlab-maven-tomcat ├── readme.md ├── getlab-jenkins └── jenkins-gitlab.sh ├── xunfeng ├── readme.md └── xunfeng.sh ├── Jdk ├── readme.md ├── openjdk.sh └── install_jdk.sh ├── cobbler ├── Readme ├── cobbler报错.bash ├── cobbler介绍.bash ├── CentOS-7.4-x86_64.ks ├── CentOS-6.9-x86_64.cfg └── 面试相关理论知识 ├── initCentos7 ├── readme.md └── install_initC7.sh ├── PhpMyAdmin ├── readme.md └── install_phpmyadmin.sh ├── 安装物理机linux ├── readme.md └── 真实安装linux.sh ├── monitor ├── man tcp ├── 单机命令 └── 时间与挂载 ├── Zabbix ├── readme.md ├── conf │ ├── readme.md │ └── my.cnf ├── zabbix-agent ├── 忘记zabbix密码 ├── onealter ├── 乱码和数据库字符集问题 └── install_zabbix.sh ├── 返回顶部.png ├── 笔试 ├── readme.md └── linux笔试1.sh ├── Php ├── phptimezone.sh ├── readme.md └── install_php.sh ├── kvm-web管理 └── readme.md ├── shell scrip ├── README.MD ├── code 200 ├── log.sh └── colors.sh ├── Mysql ├── my.conf优先级 ├── testmysql.sh ├── readme.md ├── mysql_sec_pw ├── mysql_备份.sh ├── install_mysql.sh ├── install_mysql-5.7.sh ├── mysql_backup_innobackupex.sh └── MYSQL_master_slave_gtid.sh ├── Tomcat ├── tomcat 安全配置.docx ├── install_tomcat.sh ├── tomcat.sh ├── 注意点配置.sh └── readme.md ├── Rsync-Sersync ├── rsync-3.1.1.tar.gz ├── sersync2.5.4_64bit_binary_stable_final.tar.gz ├── readme.md ├── install_sersync.sh └── install_rsync.sh ├── Elastic6.6 └── readme.md ├── LDAP └── readme.md ├── nginx-tomcat-redis-session会话保存方案 └── readme.md ├── k8s └── readme.md ├── Lvs-dr ├── readme.md └── install_lvs.sh ├── Nsf ├── install_cnfs.sh ├── install_snfs.sh └── readme.md ├── openstack ├── README.MD ├── Centos7-c-memcached.bash ├── Centos7-c-rabbitmq.bash ├── Centos7-c-dashboard.bash ├── Centos7-c-mysql.bash ├── Centos7-c-etcd .bash ├── Centos7-j-neutron.bash ├── Centos7-j-nova.bash ├── Centos7-c-huanjing .bash └── Centos7-j-huanjing .bash ├── url └── README.MD ├── Grafana ├── readme.md └── Grafana ├── command ├── 远程执行脚本screen别忘了 ├── 被入侵的那点事 └── 恢复还在运行文件的那些事 ├── mysql_xbk备份脚本 ├── backup.conf ├── readme.md └── resume_xbk.sh ├── docs └── index.rst ├── Centos-bug └── readme.md └── readme.md /ico/tubiam.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /img/gen (1).svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Redis/优化/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Redis/排错/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /openvpn/readme: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /zaji/README.MD: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Gitlab/readme.md: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /Haproxy/readme.md: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /Jenkins/readme.md: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /Nginx/proxy/readme.md: -------------------------------------------------------------------------------- 1 | 代理 2 | -------------------------------------------------------------------------------- /img/readme.md: -------------------------------------------------------------------------------- 1 | 自己用的一些图片 2 | -------------------------------------------------------------------------------- /work/readme.md: -------------------------------------------------------------------------------- 1 | 工作中可能会用到 2 | -------------------------------------------------------------------------------- /maven+nexus/readme.md: -------------------------------------------------------------------------------- 1 | 打包java 2 | -------------------------------------------------------------------------------- /mogodb/readme.md: -------------------------------------------------------------------------------- 1 | 貌似可以生产用 2 | -------------------------------------------------------------------------------- /yum/readme.md: -------------------------------------------------------------------------------- 1 | yum 私有仓库 2 | 3 | -------------------------------------------------------------------------------- /Centos7/man tcp: -------------------------------------------------------------------------------- 1 | yum install man-pages 2 | -------------------------------------------------------------------------------- /sonar/readme.md: -------------------------------------------------------------------------------- 1 | 7.9一下可以用mysql,1.8jdk 2 | -------------------------------------------------------------------------------- /jenkins-gitlab-maven-tomcat/readme.md: -------------------------------------------------------------------------------- 1 | 主要的步骤 2 | -------------------------------------------------------------------------------- /xunfeng/readme.md: -------------------------------------------------------------------------------- 1 | 官方的安装步骤有点坑 这里是我成功的 2 | 3 | -------------------------------------------------------------------------------- /Jdk/readme.md: -------------------------------------------------------------------------------- 1 | 严重吃版本 是oracle 不是openjdk 他俩 2 | -------------------------------------------------------------------------------- /cobbler/Readme: -------------------------------------------------------------------------------- 1 | ks是7.X 和6.X的 可以安装 2 | 平台是7.X的 3 | -------------------------------------------------------------------------------- /initCentos7/readme.md: -------------------------------------------------------------------------------- 1 | 会重启 只是简单的一些优化 不一定全用的上。 2 | -------------------------------------------------------------------------------- /PhpMyAdmin/readme.md: -------------------------------------------------------------------------------- 1 | 现在版本比较单一 不频繁更换数据库可以用这套配置 多版本正在弄 2 | -------------------------------------------------------------------------------- /安装物理机linux/readme.md: -------------------------------------------------------------------------------- 1 | 真实机 安装 2 | 3 | 4 | -------------------------------------------------------------------------------- /Jdk/openjdk.sh: -------------------------------------------------------------------------------- 1 | yum install java-1.8.0-openjdk-devel -y 2 | -------------------------------------------------------------------------------- /monitor/man tcp: -------------------------------------------------------------------------------- 1 | 发现 没有man tcp 2 | yum -y install man-pages 3 | -------------------------------------------------------------------------------- /Zabbix/readme.md: -------------------------------------------------------------------------------- 1 | 4.0版的zabbix 做了基本的调整 一些安装的坑以踩了 就是下载有些慢 2 | -------------------------------------------------------------------------------- /monitor/单机命令: -------------------------------------------------------------------------------- 1 | nload 看网卡 2 | htop 好看 和top t m 3 | 4 | 5 | -------------------------------------------------------------------------------- /img/1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/1.PNG -------------------------------------------------------------------------------- /img/2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/2.PNG -------------------------------------------------------------------------------- /img/3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/3.PNG -------------------------------------------------------------------------------- /img/4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/4.PNG -------------------------------------------------------------------------------- /返回顶部.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/返回顶部.png -------------------------------------------------------------------------------- /img/timg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/timg.jpg -------------------------------------------------------------------------------- /img/返回顶部.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/返回顶部.png -------------------------------------------------------------------------------- /笔试/readme.md: -------------------------------------------------------------------------------- 1 | ##### 2 | 记录一些大厂的笔试题 留着以后自己用 3 | 让人看了下 说太简单了 连入门都达不到 是个人就会 你是认真的么 4 | -------------------------------------------------------------------------------- /Php/phptimezone.sh: -------------------------------------------------------------------------------- 1 | ntpdate time.windows.com 2 | timedatectl set-timezone Asia/Shanghai 3 | -------------------------------------------------------------------------------- /img/12222.jpg.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/12222.jpg.jpeg -------------------------------------------------------------------------------- /kvm-web管理/readme.md: -------------------------------------------------------------------------------- 1 | 适合小企业管理kvm虚拟机 大企业 docker+ k8s openstack 有点夕阳了 k8s火的一笔 微服务大行其道 2 | -------------------------------------------------------------------------------- /Centos7/README.md: -------------------------------------------------------------------------------- 1 | ![](https://img.shields.io/badge/%E6%89%AF%E6%B7%A1-systemctl-brightgreen.svg) 2 | -------------------------------------------------------------------------------- /Zabbix/conf/readme.md: -------------------------------------------------------------------------------- 1 | 一些配置 有nginx php mysql 的配置文件 可以做一下修改就拿来用 注意自己的cpu核心数 和内存大小 做一些调整就行 。 2 | -------------------------------------------------------------------------------- /img/1542158208547.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/1542158208547.jpg -------------------------------------------------------------------------------- /img/1542158223641.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/1542158223641.jpg -------------------------------------------------------------------------------- /img/1542158235833.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/1542158235833.jpg -------------------------------------------------------------------------------- /img/56445805cee8f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/56445805cee8f.jpg -------------------------------------------------------------------------------- /shell scrip/README.MD: -------------------------------------------------------------------------------- 1 | ![](https://img.shields.io/badge/%E7%AC%94%E8%AF%95-shell-brightgreen.svg) 2 | -------------------------------------------------------------------------------- /Mysql/my.conf优先级: -------------------------------------------------------------------------------- 1 | 也就是先读取/etc/my.cnf,再读取/etc/mysql/my.cnf,接着读取安装目录下面的my.cnf,最后读取/home/USERNMAE下面的my.cnf. 2 | -------------------------------------------------------------------------------- /Tomcat/tomcat 安全配置.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/Tomcat/tomcat 安全配置.docx -------------------------------------------------------------------------------- /img/20170430170428338.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/20170430170428338.png -------------------------------------------------------------------------------- /img/20170430170510093.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/20170430170510093.png -------------------------------------------------------------------------------- /Gitlab/jksample/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World! 4 | baibai

5 | 6 | 7 | -------------------------------------------------------------------------------- /Redis/安装/readme.md: -------------------------------------------------------------------------------- 1 |
分为单机版和主从复制和集群版
2 | #`建议复制粘贴 脚本是在windows下编写的非自动安装脚本` 3 | 4 | 集群详见codis安装 5 | 6 | -------------------------------------------------------------------------------- /Nginx/proxy/upstream.conf: -------------------------------------------------------------------------------- 1 | upstream www.baibai.com.pool 2 | { 3 | server 10.0.3.96:80 weight=10 max_fails=3; 4 | } 5 | -------------------------------------------------------------------------------- /Rsync-Sersync/rsync-3.1.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/Rsync-Sersync/rsync-3.1.1.tar.gz -------------------------------------------------------------------------------- /Elastic6.6/readme.md: -------------------------------------------------------------------------------- 1 | 6.6 2 | 包括 filebeat -logstash--redis--logstash--elasticsearch--kibana 3 | 架构的简单实现 都是日志json 的 和java 的 4 | -------------------------------------------------------------------------------- /LDAP/readme.md: -------------------------------------------------------------------------------- 1 | 主要在护网行动中被打击的很大 想好好学一学基础的东西不想在弄高大上的东西了 架构师恩、、、、还是叫我背锅侠把 2 | LDAP和kerberos的统一账户管理和认证 3 | LDAP Account Manager (LAM) 新的 4 | -------------------------------------------------------------------------------- /nginx-tomcat-redis-session会话保存方案/readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Mysql/testmysql.sh: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /Zabbix/zabbix-agent: -------------------------------------------------------------------------------- 1 | [root@localhost zabbix_agentd.d]# vi listenport.conf 2 | 3 | UserParameter=login-user,netstat -ant |grep LISTEN|wc -l 4 | 5 | 6 | -------------------------------------------------------------------------------- /k8s/readme.md: -------------------------------------------------------------------------------- 1 | 额都写好好了 但atom编辑器脑抽 给我弄没了 有时间到服务器里 history下来看看还能cat多少 我都疯了 还好 服务是测试环境的 2 | kubeadm 证书一年到期问题一定要注意 3 | 没有研发 就几个运维 还是别踏坑了 4 | 5 | -------------------------------------------------------------------------------- /openvpn/openvpn-install-2.3.10-I601-x86_64.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/openvpn/openvpn-install-2.3.10-I601-x86_64.zip -------------------------------------------------------------------------------- /Nginx/proxy/test.conf: -------------------------------------------------------------------------------- 1 | location /admin { 2 | proxy_pass http://www.baibai.com.pool; 3 | proxy_cache_valid any 0s; 4 | add_header Cache-Control no-store; 5 | } 6 | -------------------------------------------------------------------------------- /Lvs-dr/readme.md: -------------------------------------------------------------------------------- 1 | nat模式本身就是瓶颈 用的了lvs的都不差那几个公网ip 不想去探讨就有两个公网ip(不在同一段)用的上lvs的并发可想而知 后端还的有7层的 nginx就不错 2 | 如果并发不是太大用nginx做负载均衡也相当好了 注意session就好和把复用内核参数打开,快速回收就别开了 3 | -------------------------------------------------------------------------------- /Nsf/install_cnfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y rpcbind nfs-utils 3 | systemctl start rpcbind 4 | mkdir /baibai 5 | mount -t nfs 10.0.3.26:/data /baibai 6 | -------------------------------------------------------------------------------- /Mysql/readme.md: -------------------------------------------------------------------------------- 1 | 这个是二进制安装的 的dos2unix 一下 环境变量source 一下没做好 配置还没有优化 2 | 分为5.6和5.7的安装 因为是非DBA出身建议用官方编译好的二进制包 my.cnf 配置文件写的符合生产一点 如果有DBA那就用编译会好一些毕竟编译的性能会高一点但相对的二进制满足一般的生产环境。 3 | -------------------------------------------------------------------------------- /Rsync-Sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/Rsync-Sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz -------------------------------------------------------------------------------- /openstack/README.MD: -------------------------------------------------------------------------------- 1 | ![](https://img.shields.io/badge/openstack-%E4%B8%80%E9%94%AE%E9%83%A8%E7%BD%B2-yellowgreen.svg) 2 | 3 | 现在比较粗 但能运行 是R版的 dos2unix 一下 待细化优化脚本 4 | -------------------------------------------------------------------------------- /Gitlab/jksample/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Archiver-Version: Plexus Archiver 3 | Created-By: Apache Maven 4 | Built-By: root 5 | Build-Jdk: 1.8.0_222 6 | 7 | -------------------------------------------------------------------------------- /Gitlab/jksample/META-INF/maven/cn.xsshome/jksample/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven 2 | #Fri Aug 30 10:13:51 CST 2019 3 | version=0.0.1 4 | groupId=cn.xsshome 5 | artifactId=jksample 6 | -------------------------------------------------------------------------------- /Php/readme.md: -------------------------------------------------------------------------------- 1 | php 安装 先写初步 2 | ini调优 。。。 3 | opcache调优。。。 4 | fast.cgi调优 。。。。 5 | 写成shell 脚本和说明文档 6 | 现在这个版本是5.6的 7 | 这周在部署个7的版本 8 | 还有7的版本 7的改变很大 而且不向下兼容。。。。。 9 | 10 | 脚本慢慢完善 11 | -------------------------------------------------------------------------------- /Redis/readme.md: -------------------------------------------------------------------------------- 1 | **`脚本是在Windows下写的 不是自动脚本建议复制粘贴部署在Centos7+上的`** 2 | - [ ] 安装 3 | - [ ] 配置 4 | - [ ] 优化 5 | - [ ] 安全 6 | - [x] 面试 7 | - [x] 介绍 8 | - [ ] 排错 9 | - [x] 命令 10 | 11 | * 版本:bate/v1 12 | -------------------------------------------------------------------------------- /url/README.MD: -------------------------------------------------------------------------------- 1 | # github 用到的 2 | 3 | ![](https://img.shields.io/badge/github-%E6%89%AF%E6%B7%A1-brightgreen.svg) 4 | 5 | https://shields.io/#/ 6 | 7 | https://imgchr.com/ 8 | 9 | “#”+空格 是标题 10 | -------------------------------------------------------------------------------- /img/68747470733a2f2f73312e617831782e636f6d2f323031382f31302f30382f694a6e354a552e6a7067.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/68747470733a2f2f73312e617831782e636f6d2f323031382f31302f30382f694a6e354a552e6a7067.jpg -------------------------------------------------------------------------------- /img/68747470733a2f2f73312e617831782e636f6d2f323031382f31302f30382f694a7579744b2e6a7067.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justbaibai/linux-shell/HEAD/img/68747470733a2f2f73312e617831782e636f6d2f323031382f31302f30382f694a7579744b2e6a7067.jpg -------------------------------------------------------------------------------- /shell scrip/code 200: -------------------------------------------------------------------------------- 1 | 2 | wget -q -S www.baidu.com 2>&1|grep 200|awk '{print $2}' 3 | wget --spider -nv www.baidu.com 2>&1|awk '{print $5}' 4 | curl -I -s www.baidu.com|grep 200|awk '{print $2}' 5 | curl -I -o /dev/null -m 10 -s -w %{http_code} www.baidu.com 6 | -------------------------------------------------------------------------------- /Zabbix/忘记zabbix密码: -------------------------------------------------------------------------------- 1 | 数据库在手天下我有 2 | use zabbix; 3 | select * from users; 4 | select name,passwd from users; 5 | echo -n baibai | openssl md5 6 | (stdin)= 56d662e6060d8b64929ba4859146f0be 7 | update users set passwd='56d662e6060d8b64929ba4859146f0be' where userid = '1'; 8 | -------------------------------------------------------------------------------- /cobbler/cobbler报错.bash: -------------------------------------------------------------------------------- 1 | 69 67 80 端口起来没有 2 | 3 | 4 | /etc/cobbler/dhcp.template 这个别写错了 看看是不是一个段的 5 | rsync会报错 6 | 7 | 8 | /etc/cobbler/settings 9 | check 会报错 10 | 11 | 12 | tftp没开 会报错pex32 什么的 13 | 14 | 15 | ks配置文件错了 还会没有boot aru什么的 16 | 17 | 18 | -------------------------------------------------------------------------------- /Redis/配置/redis.conf: -------------------------------------------------------------------------------- 1 | include /home/public/redis-sdp/redis-common.conf 2 | port 6379 3 | bind 10.0.3.40 4 | protected-mode no 5 | requirepass baibai 6 | maxmemory 1G 7 | pidfile /var/run/redis.pid 8 | logfile /var/log/redis/redis6379.log 9 | dir /usr/local/data 10 | dbfilename dump-6379.rdb 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /work/wiki.sh: -------------------------------------------------------------------------------- 1 | create database mm_wiki; 2 | grant all privileges on mm_wiki.* to baibai@'127.0.0.1' identified by 'baibai'; 3 | wget https://github.com/phachon/mm-wiki/releases/download/v0.1.4/mm-wiki-v0.1.4-linux-amd64.tar.gz -P /usr/local/src/ 4 | ./install --port=80 5 | http://ip 6 | 7 | nohup ./mm-wiki --conf conf/mm-wiki.conf& 8 | -------------------------------------------------------------------------------- /Grafana/readme.md: -------------------------------------------------------------------------------- 1 | zabbix 高颜值显示 嘻嘻 没用mysql 我yum安装的 偷懒嘻嘻 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Zabbix/onealter: -------------------------------------------------------------------------------- 1 | 2 | 配置-应用-zabbix 3 | vi /etc/zabbix/zabbix_server.conf 4 | 查看AlertScriptsPath 5 | cd /usr/local/zabbix/share/zabbix/alertscripts/ 6 | wget http://www.onealert.com/agent/release/oneitsm_zabbix_release-1.2.0.tar.gz 7 | tar -zxf oneitsm_zabbix_release-1.2.0.tar.gz 8 | cd oneitsm/bin 9 | bash install.sh 给的那个 10 | #的重新启动zabbix才行 要不然不识别 11 | /etc/init.d/zabbix_server restart 12 | -------------------------------------------------------------------------------- /shell scrip/log.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ##### 3 | #Usage: 4 | #shell_log baibai 5 | ############ 6 | # 7 | # /var/log/baibai.log 8 | #2019-12-17:09-22-39 : baibai : SUCESS 9 | #### 10 | LOG_DATE=$(date "+%Y-%m-%d:%H-%M-%S") 11 | LOG_DIR=/var/log 12 | LOG_NAME=baibai 13 | 14 | shell_log(){ 15 | LOG_INFO=$1 16 | echo "$LOG_DATE : $LOG_INFO : SUCESS " >>${LOG_DIR}/${LOG_NAME}.log 17 | } 18 | 19 | shell_log baibai 20 | -------------------------------------------------------------------------------- /Redis/命令/readme.md: -------------------------------------------------------------------------------- 1 | /usr/local/redis/bin/redis-cli -h 10.0.3.118
2 | auth baibai
3 | /usr/local/redis/bin/redis-cli -h 10.0.3.118 -a baibai shutdown
4 | 常见命令 5 | 6 | 查看信息:info。 7 | 8 | 删除所有数据库内容:flushall。 9 | 10 | 刷新数据库:flushdb。 11 | 12 | 看所有键:KEYS *,使用select num可以查看键值数据。 13 | 14 | 设置变量:set test “who am i”。 15 | 16 | config set dir dirpath 设置路径等配置。 17 | 18 | config get dirfilename 获取路径及数据配置信息。 19 | 20 | save 保存。 21 | 22 | get 变量,查看变量名称。 23 | -------------------------------------------------------------------------------- /Redis/配置/jiandan_redis.conf: -------------------------------------------------------------------------------- 1 | daemonize yes 2 | pidfile /var/run/redis.pid 3 | logfile /var/log/redis/redis6379.log 4 | port 6379 5 | bind 10.0.3.40 6 | timeout 2 7 | loglevel verbose 8 | databases 16 9 | #save 900 1 10 | #save 300 10 11 | #save 60 10000 12 | #dbfilename rdbfile.rdb 13 | dir /usr/local/rdbfile 14 | maxclients 2000 15 | maxmemory 1G 16 | #maxmemory-policy noeviction 17 | appendonly yes 18 | appendfilename appendonly.aof 19 | slowlog-log-slower-than 10000 20 | -------------------------------------------------------------------------------- /command/远程执行脚本screen别忘了: -------------------------------------------------------------------------------- 1 | (1)创建新会话: 2 | 3 | screen -S han 4 | vim test 5 | # 若要终止会话:退出vim->键入Ctrl-d 6 | 7 | screen vim test # 直接指定在screen会话中运行的程序。这种情况下,退出vim即终止会话 8 |   (2)在(1)中会话未终止时,键入Ctrl-a d,将detach该会话。 9 | 10 |   (3)使用screen -ls查询所有会话: 11 | 12 | [root@localhost ~]# screen -ls 13 | There is a screen on: 14 | 3985.han (Detached) 15 | 1 Socket in /var/run/screen/S-root. 16 |   可见会话当前状态是Detached的。 17 | 18 |   (4)恢复会话: 19 | 20 | screen -r 3985 # 回到detach前的状态 21 | -------------------------------------------------------------------------------- /Nsf/install_snfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y nfs-utils rpcbind 3 | mkdir /data 4 | chown -R nfsnobody.nfsnobody /data 5 | echo " 6 | /data 10.0.3.0/24(rw,sync,all_squash,anonuid=65534,anongid=65534) 7 | ">/etc/exports 8 | cat >> /etc/sysctl.conf << EOF 9 | net.core.wmem_default = 8388608 10 | net.core.rmem_default = 8388608 11 | net.core.rmem_max = 16777216 12 | net.core.wmem_max = 16777216 13 | EOF 14 | sysctl -p 15 | service rpcbind start 16 | service nfs start 17 | -------------------------------------------------------------------------------- /Nginx/readme.md: -------------------------------------------------------------------------------- 1 | 更细致化的配置 2 | 注明编译参数和配置适合哪个版本 3 | 配置包括 反向代理 缓存 web 一些优化 和关注cve linux优化和采坑 单独一个目录 。。。。。 4 | 坑1 5 | 6 | Nginx的location是单独的,所以上例里静态文件没有root指向,这个时候root会被认为是默认的路径 7 | ginx设置缓存expires后返回404找不到文件的原因 8 | 在location里 写上根目录的绝对路径 以前没注意到 今天公司要部署一个文件管理务器(Kodexplorer)的时候发现的。本来挺简单的一件事 部署上提示js 压缩损害了我就把nginx的压缩关了 还是不好使。没办法用默认给种尝试还是不行,之后用nginx默认的conf就好用了 之后看了一下我用的conf发现跟js有关的就有个expires指令 ,之后注释了好了,但图片加载不出来 404 我又上传了几张图片发现一不显示 也报404 文件没找到 123.txt都能找到 之后分析可能是location你不指定 root的路径他会找默认路径 。还在踏坑中。 9 | -------------------------------------------------------------------------------- /command/被入侵的那点事: -------------------------------------------------------------------------------- 1 | 2 | 3 | 当服务器被一个sb或一群sb入侵者或者自动sb程序入侵了的时 你会发现各种资源100% 或带宽满了 估计就是采矿或者发送垃圾邮件,发 DoS 攻击。 4 | 你会发现服务器奇慢无比 5 | 6 | 7 | w 8 | whois 9 | 先干掉哪个sb 10 | netstate -uplnt 有没有外没不认识的ip 11 | 12 | last 13 | /var/log/wtmp 14 | 15 | /var/log/secure 16 | 没有才叫恐怖那 嘻嘻 lsof 恢复回来 希望他不是被清空 17 | 18 | history看看 wget 或 curl 命令来下载那些sb的程序了。 19 | ~/.bash_history 20 | 21 | top 一下看看 那些用资源用的比较多 用losf 和 strace -p pid 22 | 23 | ps aux 或 ef 24 | 25 | 简单处理一下 你会感觉还是上一台waf好了 起码能防住部分sb 26 | 27 | -------------------------------------------------------------------------------- /安装物理机linux/真实安装linux.sh: -------------------------------------------------------------------------------- 1 | 1按下键盘TAB键将最下面的vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet 改为 vmlinuz initrd=initrd.img linux dd quiet 2 | 3 | 2查看U盘启动盘的名称比如:sda,sdb,sdc ps:label一列会显示Centos7等字样的 4 | 5 | 3重启后到第三步界面按下TAB键 6 | 7 | 4将vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet 改为 vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb1 quiet ps:sdb1就是你看到的启动盘名称 8 | 9 | 5别忘了net.ifnames=0 biosdevname=0 10 | 11 | 12 | -------------------------------------------------------------------------------- /Nginx/proxy/proxy.conf: -------------------------------------------------------------------------------- 1 | proxy_temp_path /data/cdn_cache/proxy_temp_dir; 2 | proxy_cache_path /data/cdn_cache/proxy_cache_dir levels=1:2 keys_zone=cache_one:50m inactive=1d max_size=1g; 3 | proxy_connect_timeout 5; 4 | proxy_read_timeout 60; 5 | proxy_send_timeout 90; 6 | proxy_buffer_size 16k; 7 | proxy_buffers 4 64k; 8 | proxy_busy_buffers_size 128k; 9 | proxy_temp_file_write_size 128k; 10 | proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_404; 11 | #include /usr/local/nginx/conf.d/proxy.conf 12 | -------------------------------------------------------------------------------- /ico/min-bibei.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Redis/配置/tongyong_redis.conf: -------------------------------------------------------------------------------- 1 | daemonize yes 2 | pidfile /var/run/redis.pid 3 | logfile /var/log/redis/redis6379.log 4 | port 6379 5 | bind 10.0.3.40 6 | tcp-backlog 32768 7 | tcp-keepalive 300 8 | maxclients 128 9 | timeout 0 10 | loglevel notice 11 | databases 16 12 | requirepass "123" 13 | dir /usr/local/data 14 | auto-aof-rewrite-percentage 100 15 | auto-aof-rewrite-min-size 128mb 16 | maxmemory 1G 17 | maxmemory-policy noeviction 18 | appendonly yes 19 | appendfsync everysec 20 | appendfilename appendonly.aof 21 | slowlog-log-slower-than 10000 22 | 23 | -------------------------------------------------------------------------------- /Tomcat/install_tomcat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget -P /usr/local/src http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.50/bin/apache-tomcat-8.5.50.tar.gz 3 | cd /usr/local/src && tar xf apache-tomcat-8.5.50.tar.gz 4 | mv /usr/local/src/apache-tomcat-8.5.50 /usr/local/apache-tomcat-8.5.50 5 | ln -s /usr/local/apache-tomcat-8.5.50/ /usr/local/tomcat 6 | echo " 7 | #!/bin/sh 8 | PATH=\$PATH:/usr/local/tomcat/bin 9 | ">>/etc/profile.d/tomcat.sh 10 | 11 | useradd tomcat 12 | passwd tomcat 13 | chown -R tomcat.tomcat /usr/local/apache-tomcat-8.5.50 14 | source /etc/profile.d/tomcat.sh 15 | 16 | -------------------------------------------------------------------------------- /mysql_xbk备份脚本/backup.conf: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # mysql 用户名 3 | user=bkpuser 4 | # mysql 密码 5 | password=123456 6 | # 备份路径 7 | backup_dir=bak 8 | # 备份压缩打包目录 9 | gzip_dir=backup_gzip 10 | # innobackupex 命令路径 11 | innobackupex_bin=/usr/bin/innobackupex 12 | # 打包文件保留多少天 13 | backup_gz_keep_day=140 14 | #MYSQLADMIN的路径 15 | MYSQLADMIN=/usr/local/mysql/bin/mysqladmin 16 | #xbk 备份时候的信息 17 | backup_log=backup.log 18 | #错误日志 19 | error_log=backup.err.log 20 | #mysql配置文件 21 | mycnf=/etc/my.cnf 22 | #临时存放的路径 23 | temp_dir=temp 24 | 25 | log_dir=log 26 | socket=/tmp/mysql.sock 27 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | 说明 2 | =============== 3 | 4 | .. note:: Obviously, the excellent `Uni-form`_ has been selected as the base model for the design of the forms. 5 | 6 | 7 | 8 | **API documentation** 9 | If you are looking for information on a specific function, class or method, this part of the documentation is f 10 | 11 | 12 | 13 | Jumpserver 文档 14 | ====================================== 15 | 16 | 目录: 17 | 18 | .. toctree:: 19 | :maxdepth: 2 20 | 21 | introduce 22 | step_by_step 23 | admin_guide 24 | user_guide 25 | development 26 | contributor 27 | contact 28 | snapshot 29 | faq 30 | change_log 31 | 32 | -------------------------------------------------------------------------------- /Tomcat/tomcat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | usage(){ 5 | 6 | echo "Usage: $0 [start|stop]" 7 | } 8 | 9 | start_tomcat(){ 10 | 11 | /usr/local/tomcat/bin/startup.sh 12 | 13 | } 14 | 15 | stop_tomcat(){ 16 | 17 | TPID=$(ps -ef|grep java|grep -v 'grep'|awk '{print $2}') 18 | 19 | kill -9 $TPID 20 | sleep 5; 21 | 22 | TSTAT=$(ps -ef|grep java|grep -v 'grep'|awk '{print $2}') 23 | if [ -z $TSTAT ];then 24 | echo "tomcat stop" 25 | else 26 | kill -9 $TSTAT 27 | fi 28 | 29 | } 30 | 31 | 32 | main(){ 33 | 34 | case $1 in 35 | start) 36 | start_tomcat;; 37 | stop) 38 | stop_tomcat;; 39 | *) 40 | usage; 41 | esac 42 | } 43 | main $1; 44 | -------------------------------------------------------------------------------- /Redis/配置/readme.md: -------------------------------------------------------------------------------- 1 | 配置分为简单,默认,通用,和网络中的生产环境可用 2 | * 简单:jiandan_redis.conf 拿着就能用 请注意相关路径 和内存用量大小。 3 | * 默认:就是安装后默认生成的文件。 4 | * 通用:在简单配置上加了一些配置。 5 | 6 |
7 | 8 | 可以把变化的抽象出一个配置文件,把不变的定义成公共配置 9 | 在用include 包含进来 10 | 比如说redis.conf 就可以包含redis-common.conf文件配置 11 | 12 | 13 | fsync()调用告诉操作系统将数据真实的写入磁盘而不是放到缓冲区中,一些操作系统会真实的执行请求,还有一些操作系统只会尽力的尝试。 14 | 15 | Redis支持3种不同的模式: 16 | no:不即时同步,由操作系统控制何时刷写到磁盘上,这种模式速度最快; 17 | always:每次只写日志,速度较慢,但最安全; 18 | everysec:每秒钟同步一次,折中的方案。 19 | 20 | 默认的模式是“everysec”,它通常是在速度和数据安全之间折中的方法。如果你可以控制操作系统在Redis需要的时候去刷写缓冲区那可以使用“no”模式,能够提供更好的性能(但如果你能接受一些数据丢失,可以考虑默认的持久化模式–快照方式),相反,使用“always”模式很慢,但是它比“everysec”模式要安全一点。 21 | 22 | 如果不确定,就使用“everysec”。 23 | -------------------------------------------------------------------------------- /openstack/Centos7-c-memcached.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install memcached python-memcached -y >/dev/null 2>&1 3 | if [ $? -eq 0 ]; then 4 | echo "memcached install is ok" 5 | else 6 | echo "memcached install is not ok" 7 | fi 8 | sleep 5s 9 | sed -i "s#127.0.0.1,::1#127.0.0.1,::1,baibaic#g" /etc/sysconfig/memcached 10 | 11 | cp /etc/sysconfig/memcached{,.bak} 12 | 13 | systemctl enable memcached.service >/dev/null 2>&1 14 | systemctl start memcached.service >/dev/null 2>&1 15 | if [ $? -eq 0 ]; then 16 | echo "service is ok" 17 | else 18 | echo "service is not ok" 19 | fi 20 | 21 | netstat -utpnl|grep memcache 22 | echo "if have 11211 port memcache is ok" 23 | -------------------------------------------------------------------------------- /monitor/时间与挂载: -------------------------------------------------------------------------------- 1 | top 2 | cpu t 3 | men m 4 | crt timeout 5 | 选项 会话 终端 发送协议 6 | 7 | 8 | timedatectl status 显示当前时间信息 9 | set-time 设定当前时间 10 | set-timezone 设定当前时区 11 | set-local-rtc 设定bios时间 12 | 13 | ntpdate time.windows.com 14 | timedatectl set-timezone Asia/Shanghai 15 | hwclock 16 | ntpdate -u ntp.api.bz 17 | fdisk命令参数介绍 18 | 19 | p、打印分区表。 20 | 21 | n、新建一个新分区。 22 | 23 | d、删除一个分区。 24 | 25 | m、输出菜单 26 | 27 | q、退出不保存。 28 | 29 | w、把分区写进分区表,保存并退出 30 | 之后要partprobe 通知内核要不然的reboot 31 | partprobe 32 | mkfs.xfs /dev/sda4 33 | df -hT 34 | mount /dev/sda4 /data 35 | gdisk 36 | -------------------------------------------------------------------------------- /Redis/安装/install_redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget http://download.redis.io/releases/redis-5.0.4.tar.gz -P /usr/local/ 3 | cd /usr/local/ 4 | tar xf redis-5.0.4.tar.gz&&cd redis-5.0.4 5 | make 6 | make install PREFIX=/usr/local/redis 7 | #或者带版本号ln -s 软连接 8 | #这个以后升级的时候只要修改软连接的指向就行了 9 | #或者直接用 10 | cd src/ 11 | echo 'vm.overcommit_memory = 1' >>/etc/sysctl.conf 12 | sysctl vm.overcommit_memory=1 13 | echo never > /sys/kernel/mm/transparent_hugepage/enabled 14 | cp /usr/local/redis-5.0.4/redis.conf /usr/local/redis/bin/ 15 | /usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf 16 | /usr/local/redis/bin/redis-cli -h 10.0.3.118 17 | auth baibai 18 | /usr/local/redis/bin/redis-cli -h 10.0.3.118 -a baibai shutdown 19 | -------------------------------------------------------------------------------- /work/samba.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum -y install samba samba-client samba-common 3 | mkdir write-read only-read 4 | cd /etc/samba/ 5 | cp -a smb.conf smb.conf.bak 6 | chmod 777 -R write-read/ 7 | chmod 755 -R only-read/ 8 | chown -R nobody.nobody smb 9 | 10 | vim /etc/samba/smb.conf 11 | netbios name=SHAREDOCS 12 | server string=Samba Server 13 | security = user 14 | map to guest = Bad User 15 | [SHAREDOCS] 16 | path=/smb/docs/ 17 | writable=yes 18 | browseable=yes 19 | public= yes 20 | guest ok=yes 21 | readable = yes 22 | available = yes 23 | create mode= 0664 24 | directory mode= 0775 25 | 26 | 27 | 28 | 29 | systemctl enable smb 30 | systemctl restart smb 31 | systemctl statue firewalld 32 | -------------------------------------------------------------------------------- /Redis/介绍/readme.md: -------------------------------------------------------------------------------- 1 | redis是一个key-value存储系统。和Memcached类似,它支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和hash(哈希类型)。这些数据类型都支持push/pop、add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,redis支持各种不同方式的排序。与memcached一样,为了保证效率,数据都是缓存在内存中。区别的是redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了master-slave(主从)同步。
2 | Redis 是一个高性能的key-value数据库。 redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。它提供了Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang等客户端,使用很方便。
3 | Redis支持主从同步。数据可以从主服务器向任意数量的从服务器上同步,从服务器可以是关联其他从服务器的主服务器。这使得Redis可执行单层树复制。存盘可以有意无意的对数据进行写操作。由于完全实现了发布/订阅机制,使得从数据库在任何地方同步树时,可订阅一个频道并接收主服务器完整的消息发布记录。同步对读取操作的可扩展性和数据冗余很有帮助。
4 | redis的官网地址,非常好记,是redis.io。(特意查了一下,域名后缀io属于国家域名,是british Indian Ocean territory,即英属印度洋领地) 5 | -------------------------------------------------------------------------------- /Jdk/install_jdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -P /usr/local/src https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz 3 | cd /usr/local/src && tar xf jdk-8u191-linux-x64.tar.gz 4 | mv /usr/local/src/jdk1.8.0_191 /usr/local/jdk1.8.0_191 5 | ln -s /usr/local/jdk1.8.0_191/ /usr/local/jdk 6 | 7 | echo "#!/bin/bash 8 | JAVA_HOME=/usr/local/jdk 9 | JRE_HOME=/usr/local/jdk/jre 10 | PATH=\$PATH:\$JAVA_HOME/bin 11 | CLASSPATH=\$JAVA_HOME/jre/lib/ext:\$JAVA_HOME/lib/tools.jar 12 | export JAVA_HOME JRE_HOME PATH CLASSPATH 13 | 14 | " >> /etc/profile.d/jdk.sh 15 | #chmod a+x /etc/profile.d/jdk.sh 16 | source /etc/profile.d/jdk.sh 17 | -------------------------------------------------------------------------------- /PhpMyAdmin/install_phpmyadmin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget -P /usr/local/src https://files.phpmyadmin.net/phpMyAdmin/4.8.3/phpMyAdmin-4.8.3-all-languages.tar.gz 3 | cd /usr/local/src && tar xf phpMyAdmin-4.8.3-all-languages.tar.gz 4 | /bin/mv phpMyAdmin-4.8.3-all-languages /usr/local/nginx/html/phpMyAdmin 5 | /bin/cp /usr/local/nginx/html/phpMyAdmin/{config.sample.inc.php,config.inc.php} 6 | sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" /usr/local/nginx/html/phpMyAdmin/config.inc.php 7 | sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" /usr/local/nginx/html/phpMyAdmin/config.inc.php 8 | chown -R nginx.nginx /usr/local/nginx/html/phpMyAdmin 9 | sed -i "s@\$cfg\['AllowArbitraryServer'\] = false;@\$cfg\['AllowArbitraryServer'\] = true;@" /usr/local/nginx/html/phpMyAdmin//libraries/config.default.php 10 | -------------------------------------------------------------------------------- /ico/min-awesome.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Mysql/mysql_sec_pw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dbrootpwd=123456 3 | /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by \"${dbrootpwd}\" with grant option;" 4 | /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by \"${dbrootpwd}\" with grant option;" 5 | /usr/local/mysql/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.user where Password='';" 6 | /usr/local/mysql/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.db where User='';" 7 | /usr/local/mysql/bin/mysql -uroot -p${dbrootpwd} -e "delete from mysql.proxies_priv where Host!='localhost';" 8 | /usr/local/mysql/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" 9 | #/usr/local/mysql/bin/mysql -uroot -p${dbrootpwd} -e "reset master;"主从 10 | /usr/local/mysql/bin/mysql -uroot -p${dbrootpwd} -e "flush privileges;" 11 | -------------------------------------------------------------------------------- /ico/min-oss.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /cobbler/cobbler介绍.bash: -------------------------------------------------------------------------------- 1 | #Cobbler是一个Linux服务器快速网络安装的服务,而且在经过调整也可以支持网络安装windows。 2 | 3 | #该工具使用python开发,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS,TFTP、RSYNC以及yum仓库、构造系统ISO镜像。 4 | 5 | #Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。 6 | 7 | #Cobbler是较早前的kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理。 8 | 9 | #Cobbler用处 10 | 11 | #使用Cobbler,您无需进行人工干预即可安装机器。Cobbler设置一个PXE引导环境(它还可以使用yaboot支持PowerPC),并 控制与安装相关的所有方面,比如网络引导服务(DHCP和TFTP)与存储库镜像。当希望安装一台新机器时,Cobbler可以: 12 | 13 | #1)使用一个以前定义的模板来配置DHCP服务(如果启用了管理DHCP)。 14 | 15 | #2)将一个存储库(yum或rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统。 16 | 17 | #3)在DHCP配置文件中为需要安装的机器创建一个条目,并使用指定的参数(IP和MAC)。 18 | 19 | #4)在TFTP服务目录下创建适当的PXE文件。 20 | 21 | #5)重新启动DHCP服务来反应新的更改。 22 | 23 | #6)重新启动机器以开始安装(如果电源管理已启动)。 24 | 25 | #http://cobbler.github.io/ 官方网站 26 | 27 | #最好在centos7 上安装 centos6上 cobbler-web yum 不上 python2.6 的。。。自己去踩吧。 -------------------------------------------------------------------------------- /mysql_xbk备份脚本/readme.md: -------------------------------------------------------------------------------- 1 | backup_gzip 2 | 3 | │   ├── full_2020-01-14-15-54-16.tar.gz 4 | 5 | │   └── incr0_2020-01-14-15-57-56.tar.gz 6 | 7 | ├── bak 8 | 9 | │   ├── full 10 | 11 | │   │   12 | 13 | ├── bin 14 | 15 | │   └── backup_xb.sh 16 | 17 | ├── conf 18 | 19 | │   ├── backup.conf 20 | 21 | │   └── test.sh 22 | 23 | ├── log 24 | 25 | │   └── xtrabackup_time.txt 26 | 27 | └── temp 28 | 29 | ├── 2020-01-14-15-54-16-tempfile.txt 30 | 31 | ├── 2020-01-14-15-57-56-tempfile.txt 32 | 33 | ├── baibai.txt 34 | 35 | ├── last_del_old.log 36 | 37 | ├── lock.txt 38 | 39 | ├── tempfile.txt 40 | 41 | └── test.txt 42 | 43 | 0 0 * * * sh /root/test/bin/backup_xb.sh >/dev/null 2>&1 44 | 45 | 默认7天为一个周期 一个全备 6 个增量 压缩文件可以定义删除时间 根据情况都可以修改 46 | 47 | 用着还行 可能体量比较小 但比mysqldunp 好用 在网上看了看 自己有填了点 感觉还行。 48 | 49 | 目录自动生成 上面是简单的结构 50 | 51 | -------------------------------------------------------------------------------- /Redis/配置/redis-common.conf: -------------------------------------------------------------------------------- 1 | daemonize yes 2 | tcp-backlog 32768 3 | tcp-keepalive 300 4 | maxclients 128 5 | timeout 0 6 | loglevel notice 7 | databases 16 8 | maxmemory-policy noeviction 9 | appendonly yes 10 | appendfsync everysec 11 | appendfilename appendonly.aof 12 | slowlog-log-slower-than 10000 13 | no-appendfsync-on-rewrite yes 14 | auto-aof-rewrite-percentage 100 15 | auto-aof-rewrite-min-size 128mb 16 | lua-time-limit 5000 17 | slowlog-max-len 128 18 | notify-keyspace-events "" 19 | hash-max-ziplist-entries 512 20 | hash-max-ziplist-value 1024 21 | list-max-ziplist-entries 512 22 | list-max-ziplist-value 64 23 | set-max-intset-entries 512 24 | zset-max-ziplist-entries 128 25 | zset-max-ziplist-value 64 26 | activerehashing yes 27 | client-output-buffer-limit normal 0 0 0 28 | client-output-buffer-limit slave 256mb 64mb 60 29 | client-output-buffer-limit pubsub 32mb 8mb 60 30 | hz 10 31 | aof-rewrite-incremental-fsync yes 32 | -------------------------------------------------------------------------------- /Mysql/mysql_备份.sh: -------------------------------------------------------------------------------- 1 | mysqldump -uroot -p123456 -A -R -E --triggers --master-data=2 --single-transaction --set-gtid-purged=OFF >/temp/full.mysqldump 2 | 3 | 4 | create table t_100w(id int,num int,k1 char(2),k2 char(4),dt timestamp); 5 | delimiter // 6 | create procedure rand_data(in num int) 7 | begin 8 | declare str char(62) default 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; 9 | declare str2 char(2); 10 | declare str4 char(4); 11 | DECLARE i INT DEFAULT 0; 12 | WHILE i < num DO 13 | SET str2 = concat(substring(str, 1+FLOOR(RAND()*61),1),substring(str, 1+FLOOR(RAND()*61),1)); 14 | SET str4 = concat(substring(str, 1+FLOOR(RAND()*61),2),substring(str, 1+FLOOR(RAND()*61),2)); 15 | SET i = i +1; 16 | insert into t_100w values (i,floor(rand()*num),str2,str4,now()); 17 | end while; 18 | end; 19 | // 20 | delimiter; 21 | 22 | call rand_data(1000000); 23 | 24 | select count(*) from ht.t_100w; 25 | 26 | -------------------------------------------------------------------------------- /Rsync-Sersync/readme.md: -------------------------------------------------------------------------------- 1 | 二、rsync+inotify-tools与rsync+sersync架构的区别? 2 | 3 | 1、rsync+inotify-tools 4 | 5 | a、inotify只能记录下被监听的目录发生了变化(增,删,改)并没有把具体是哪个文件或者哪个目录发生了变化记录下来; 6 | 7 | b、rsync在同步的时候,并不知道具体是哪个文件或目录发生了变化,每次都是对整个目录进行同步,当数据量很大时,整个目录同步非常耗时(rsync要对整个目录遍历查找对比文件),因此效率很低 8 | 9 | 2、rsync+sersync 10 | 11 | a、sersync可以记录被监听目录中发生变化的(增,删,改)具体某个文件或目录的名字; 12 | 13 | b、rsync在同步时,只同步发生变化的文件或目录(每次发生变化的数据相对整个同步目录数据来说很小,rsync在遍历查找对比文件时,速度很快),因此效率很高。 14 | 15 | 16 | 17 | 同步过程: 18 | 19 | 1. 在同步服务器上开启sersync服务,sersync负责监控配置路径中的文件系统事件变化; 20 | 21 | 2. 调用rsync命令把更新的文件同步到目标服务器; 22 | 23 | 3. 需要在主服务器配置sersync,在同步目标服务器配置rsync server(注意:是rsync服务) 24 | 25 | 同步过程和原理: 26 | 27 | 1. 用户实时的往sersync服务器上写入更新文件数据; 28 | 29 | 2. 此时需要在同步主服务器上配置sersync服务; 30 | 31 | 3. 在另一台服务器开启rsync守护进程服务,以同步拉取来自sersync服务器上的数据; 32 | 33 | 通过rsync的守护进程服务后可以发现,实际上sersync就是监控本地的数据写入或更新事件;然后,在调用rsync客户端的命令,将写入或更新事件对应的文件通过rsync推送到目标服务器 34 | 35 | 36 | 服务器A(主服务器) 37 | 服务器B(从服务器/备份服务器) 38 | rsync默认TCP端口为873 39 | 40 | B 上开resyc daemon 41 | A sersync 42 | -------------------------------------------------------------------------------- /cobbler/CentOS-7.4-x86_64.ks: -------------------------------------------------------------------------------- 1 | lang en_US 2 | keyboard us 3 | text 4 | timezone --utc Asia/Shanghai 5 | rootpw --iscrypted $default_password_crypted 6 | text 7 | install 8 | url --url=$tree 9 | bootloader --location=mbr 10 | zerombr 11 | clearpart --all --initlabel 12 | part /boot --fstype xfs --size 200 --ondisk sda 13 | part swap --size 1024 --ondisk sda 14 | part / --fstype xfs --size 1 --grow --ondisk sda 15 | $SNIPPET('network_config') 16 | reboot 17 | firewall --disabled 18 | # Network information 19 | $SNIPPET('network_config') 20 | selinux --disabled 21 | skipx 22 | %pre 23 | $SNIPPET('log_ks_pre') 24 | $SNIPPET('kickstart_start') 25 | $SNIPPET('pre_install_network_config') 26 | # Enable installation monitoring 27 | $SNIPPET('pre_anamon') 28 | %end 29 | %packages 30 | @base 31 | @core 32 | tree 33 | nmap 34 | sysstat 35 | lrzsz 36 | dos2unix 37 | telnet 38 | iptraf 39 | ncurses-devel 40 | openssl-devel 41 | zlib-devel 42 | OpenIPMI-tools 43 | screen 44 | %end 45 | %post 46 | systemctl disable postfix.service 47 | %end 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ico/facebook.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Facebook 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Nginx/install_nginx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y pcre-devel wget openssl-devel openssl zlib-devel gcc gcc-c++ dos2unix 3 | wget -P /usr/local/src/ http://nginx.org/download/nginx-1.14.1.tar.gz 4 | useradd -s /sbin/nologin -M nginx 5 | cd /usr/local/src/ && tar xf nginx-1.14.1.tar.gz 6 | sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION "8.8.8"@' /usr/local/src/nginx-1.14.1/src/core/nginx.h 7 | sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER "baibai/" NGINX_VERSION@' /usr/local/src/nginx-1.14.1/src/core/nginx.h 8 | sed -i 's@Server: nginx@Server: baibai@' /usr/local/src/nginx-1.14.1/src/http/ngx_http_header_filter_module.c 9 | cd /usr/local/src/nginx-1.14.1 && ./configure --prefix=/usr/local/nginx-1.14.1 --user=nginx --group=nginx --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-pcre --with-pcre-jit 10 | make && make install ||exit 1 11 | sleep 3 12 | echo "install nginx is ok" 13 | ln -s /usr/local/nginx-1.14.1/ /usr/local/nginx 14 | -------------------------------------------------------------------------------- /Mysql/install_mysql.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget -P /usr/local/src http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz 3 | cd /usr/local/src && tar xf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz 4 | mv /usr/local/src/mysql-5.6.43-linux-glibc2.12-x86_64 /usr/local/mysql-5.6.43 5 | useradd -s /sbin/nologin -M mysql 6 | chown -R mysql.mysql /usr/local/mysql-5.6.43/* 7 | yum -y install autoconf libaio-devel 8 | cp /usr/local/mysql-5.6.43/support-files/my-default.cnf /etc/my.cnf 9 | /usr/local/mysql-5.6.43/scripts/mysql_install_db --basedir=/usr/local/mysql-5.6.43/ --datadir=/usr/local/mysql-5.6.43/data/ --user=mysql 10 | #/usr/local/mysql-5.6.43/bin/mysqld_safe& 11 | cp /usr/local/mysql-5.6.43/support-files/mysql.server /etc/init.d/mysqld 12 | chmod +x /etc/init.d/mysqld 13 | ln -s /usr/local/mysql-5.6.43/ /usr/local/mysql 14 | echo "export PATH=/usr/local/mysql/bin:\$PATH" >> /etc/profile.d/mysql.sh 15 | cat >> /etc/profile << EOF 16 | # mariadb path 17 | PATH=\$PATH:/usr/local/mysql/bin 18 | export PATH 19 | EOF 20 | echo "ok" 21 | . /etc/profile 22 | source /etc/profile.d/mysql.sh 23 | -------------------------------------------------------------------------------- /Redis/install_redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget http://download.redis.io/releases/redis-5.0.4.tar.gz -P /usr/local/ 3 | cd /usr/local/ 4 | tar xf redis-5.0.4.tar.gz 5 | make 6 | make install PREFIX=/usr/local/redis 7 | 或者直接用 8 | cd src/ 9 | 10 | cp /usr/local/redis-5.0.4/redis.conf /usr/local/redis/bin/ 11 | /usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf 12 | /usr/local/redis/bin/redis-cli -h 10.0.3.118 13 | auth baibai 14 | /usr/local/redis/bin/redis-cli -h 10.0.3.118 -a baibai shutdown 15 | 16 | 17 | 18 | 现在redis的漏洞比较多,大多数就是因为密码太简单导致的,所以把redis密码改一下,在redis.conf里,建议改成如下的样子: 19 | 20 | bind 内网IP地址 127.0.0.1 10.0.3.118 ###仅允许内网和本机访问 21 | protected-mode yes ###保护模式开启 22 | port 6379 ###端口默认为6379,按需修改 23 | daemonize yes ###守护模式开启 24 | pidfile /usr/local/redis/redis.pid ###指定pid文件路径和文件名 25 | logfile "/usr/local/redis/redis.log" ###指定日志文件路径和文件名 26 | dbfilename redis.rdb ###指定数据文件RDB文件名 27 | dir /usr/local/redis/ ###指定数据文件RDB文件的存放路径 28 | requirepass 『YOURPASSWORD』 ###设置访问密码,提升密码强度 29 | -------------------------------------------------------------------------------- /Centos7/systemctl: -------------------------------------------------------------------------------- 1 | 2 | 3 | /usr/lib/systemd/system 4 | 5 | vi baibai.service 6 | 7 | [Unit] 8 | Description=baibai test # 描述性说明。 9 | After=network.target 10 | 11 | [Service] 12 | Type=forking #后台运行 13 | ExecStart=/bin/sh /baibaistart.sh #ExecStart=指令 参数 14 | ExecReload=/bin/sh /baibaireload.sh 15 | ExecStop=/bin/sh /baibaistop.sh 16 | Privatetmp=true #开启独立的空间 17 | [Install] 18 | WantedBy=multi-user.target #多用户级别 19 | 20 | 21 | 22 | #notify,同样地,与simple相似的配置。顾名思义,该设置会在守护进程启动的时候发送推送消息(通过sd_notify(3))给systemd。 23 | #simple,这是默认的Type,当Type和BusName配置都没有设置,指定了ExecStart设置后,simple就是默认的Type设置。simple使用ExecStart创建的进程作为服务的主进程。在此设置下systemd会立即启动服务,如果该服务要启动其他服务(simple不会forking),它们的通讯渠道应当在守护进程启动之前被安装好(e.g. sockets,通过sockets激活)。 24 | #forking,如果使用了这个Type,则ExecStart的脚本启动后会调用fork()函数创建一个进程作为其启动的一部分。当一切初始化完毕后,父进程会退出。子进程会继续作为主进程执行。这是传统UNIX主进程的行为。如果这个设置被指定,建议同时设置PIDFile选项来指定pid文件的路径,以便systemd能够识别主进程。 25 | 比较典型的情况是单元A要求在单元B启动之后再启动。这种设置是通过Unit下面的Requires、After、Before、Wants来调整的。 26 | Requires=B 27 | After=B 28 | 29 | 这段设置表明了A的启动依赖于B,同时有要求在B启动之后启动自己。设置十分简介。需要注意的是,依赖关系通常用在服务(Service)而不是目标(Target)上。 30 | 31 | 32 | systemctl enable xxx.service 开机自启动 33 | 34 | 35 | systemctl list-units --type=service : 列出正在运行的服务 36 | 37 | -------------------------------------------------------------------------------- /Gitlab/install_gitlab.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y git 3 | git clone https://gitlab.com/xhang/gitlab.git 4 | cat gitlab/VERSION #11.5.6 安装相同版本的 5 | yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python 6 | gitlab_version=$(cat gitlab/VERSION) 7 | wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-${gitlab_version}-ce.0.el7.x86_64.rpm 8 | rpm -ihv gitlab-ce-${gitlab_version}-ce.0.el7.x86_64.rpm 9 | gitlab-ctl reconfigure 10 | sed -i "s#external_url\s'http://gitlab.example.com'#external_url 'http://10.0.3.64'#g" /etc/gitlab/gitlab.rb 11 | gitlab-ctl reconfigure 12 | gitlab-ctl restart 13 | gitlab-ctl stop 14 | #head -1 /opt/gitlab/version-manifest.txt 15 | cd /root/gitlab 16 | git diff v${gitlab_version} v${gitlab_version}-zh > ../${gitlab_version}-zh.diff 17 | yum install patch -y 18 | cd /root 19 | patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < ${gitlab_version}-zh.diff #一顿回车 20 | gitlab-ctl start 21 | gitlab-ctl reconfigure 22 | 23 | gitlab修改用户密码 24 | >sudo gitlab-rails console production 25 | 26 | > user=User.where(name: "root").first 27 | 28 | > user.password=12345678 29 | 30 | > user.save! 31 | 32 | > quit 33 | -------------------------------------------------------------------------------- /sonar/install_sonar.sh: -------------------------------------------------------------------------------- 1 | wget -P /usr/local/src/ https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.9.1.zip 2 | 7.9 以下可以用 mysql 7.9是长期支持版本但不支持mysql 3 | 4 | 我用的是7.7的 5 | useradd sonar 6 | passwd sonar 7 | sysctl -w vm.max_map_count=262144 8 | sysctl -w fs.file-max=65536 9 | 10 | CREATE DATABASE sonar DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 11 | CREATE USER 'sonar' IDENTIFIED BY 'sonar'; 12 | GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; 13 | GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar'; 14 | FLUSH PRIVILEGES; 15 | jdk 16 | yum install -y java-1.8.0-openjdk-devel.x86_64 17 | 18 | sonar.jdbc.username=sonar 19 | sonar.jdbc.password=sonar 20 | sonar.jdbc.url=jdbc:mysql://xxx.xxx.xxx.xxx:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance 21 | conf/ 22 | 23 | 7.9的 24 | <-- Wrapper Stopped 25 | 11jdk 26 | 27 | [root@localhost ~]# adduser qube 28 | [root@localhost ~]# passwd qube 29 | echo 262144 >/proc/sys/vm/max_map_count 30 | 31 | 扫描器 32 | sonarscanner 33 | wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.0.0.1744-linux.zip 34 | -------------------------------------------------------------------------------- /Tomcat/注意点配置.sh: -------------------------------------------------------------------------------- 1 | tomcat 启动慢 2 | vim /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/lib/security/java.security 3 | 有两种解决办法: 4 | 5 | 1)在Tomcat环境中解决 6 | 7 | 可以通过配置JRE使用非阻塞的Entropy Source。 8 | 9 | 在catalina.sh中加入这么一行: 10 | # In addition, if "file:/dev/random" or "file:/dev/urandom" is 11 | # specified, the "NativePRNG" implementation will be more preferred than 12 | # SHA1PRNG in the Sun provider. 13 | # 14 | 15 | 16 | JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" 17 | 即可。 18 | 19 | 加入后再启动Tomcat,整个启动耗时迅速下降。 20 | 21 | 2)在JVM环境中解决 22 | 23 | 打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容: 24 | 25 | securerandom.source=file:/dev/urandom 26 | 替换成 27 | 28 | securerandom.source=file:/dev/./urandom 29 | 30 | 31 | 要让tomcat支持软连接,需要在tomcat配置文件conf/context.xml里追加allowLinking="true"(tomcat8开始配置有变),具体如下配置: 32 | 33 | 34 | 35 | 36 | 37 | Tomcat 7的方案 38 | 修改 /conf/context.xml 文件,将这个: 39 | 40 | 41 | 改为: 42 | 43 | 44 | Tomcat 8&9的方案 45 | 同样是修改 /conf/context.xml 文件,在这个里面: 46 | 47 | ... 48 | 49 | 50 | 增加一行这个: 51 | 52 | 53 | 变成这样: 54 | 55 | 56 | ... 57 | 58 | -------------------------------------------------------------------------------- /openstack/Centos7-c-rabbitmq.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #RabbitMQ #消息队列 4 | yum -y install erlang socat rabbitmq-server >/dev/null 2>&1 5 | 6 | if [ $? -eq 0 ]; then 7 | echo " rabbitmq is ok" 8 | else 9 | exho "rabbitmq is not ok" 10 | fi 11 | #启动 rabbitmq ,端口5672 12 | systemctl enable rabbitmq-server.service >/dev/null 2>&1 13 | systemctl start rabbitmq-server.service >/dev/null 2>&1 14 | rabbitmq-plugins enable rabbitmq_management >/dev/null 2>&1 #启动web插件端口15672 15 | if [ $? -eq 0 ]; then 16 | echo "rabbitmq-plugins is ok" 17 | else 18 | echo "rabbitmq-plugins is not ok" 19 | sleep 5s 20 | fi 21 | 22 | 23 | #添加用户及密码 24 | #rabbitmqctl add_user admin admin 25 | #rabbitmqctl set_user_tags admin administrator 26 | rabbitmqctl add_user openstack openstack 27 | rabbitmqctl set_permissions openstack ".*" ".*" ".*" 28 | rabbitmqctl set_user_tags openstack administrator 29 | systemctl restart rabbitmq-server.service >/dev/null 2>&1 30 | netstat -antp|grep '5672' 31 | 32 | sleep 5s 33 | 34 | echo "http://10.0.3.111:15672 is ok or not ok" 35 | 36 | # rabbitmq-plugins list #查看支持的插件 37 | # lsof -i:15672 38 | #访问RabbitMQ,访问地址是http://ip:15672 39 | #默认用户名密码都是guest,浏览器添加openstack用户到组并登陆测试 40 | 41 | # #------------------ -------------------------------------------------------------------------------- /Mysql/install_mysql-5.7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wget -P /usr/local/src http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz 4 | cd /usr/local/src && tar xf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz 5 | mv /usr/local/src/mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql-5.7.25 6 | useradd -s /sbin/nologin -M mysql 7 | chown -R mysql.mysql /usr/local/mysql-5.7.25/* 8 | yum -y install autoconf libaio-devel 9 | #cp /usr/local/mysql-5.7.25/support-files/my-default.cnf /etc/my.cnf 10 | /usr/local/mysql-5.7.25/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql-5.7.25/ --datadir=/usr/local/mysql-5.7.25/data/ --user=mysql 11 | #/usr/local/mysql-5.6.43/bin/mysqld_safe& 12 | cp /usr/local/mysql-5.7.25/support-files/mysql.server /etc/init.d/mysqld 13 | chmod +x /etc/init.d/mysqld 14 | ln -s /usr/local/mysql-5.7.25/ /usr/local/mysql 15 | echo "export PATH=/usr/local/mysql/bin:\$PATH" >> /etc/profile.d/mysql.sh 16 | cat >> /etc/profile << EOF 17 | #/usr/local/mysql/bin/mysql_secure_installation 18 | #grep 'temporary password' /usr/local/mysql-5.7.25/data/mysql-error.log 19 | # mariadb path 20 | PATH=\$PATH:/usr/local/mysql/bin 21 | export PATH 22 | EOF 23 | echo "ok" 24 | . /etc/profile 25 | source /etc/profile.d/mysql.sh 26 | -------------------------------------------------------------------------------- /openstack/Centos7-c-dashboard.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install openstack-dashboard -y 3 | 4 | if [ $? -eq 0 ]; then 5 | echo "openstack-dashboard install is OK" 6 | else 7 | echo "openstack-dashboard install is NOT OK" 8 | exit 2 9 | fi 10 | 11 | 12 | cp -a /etc/openstack-dashboard/local_settings{,.bak} 13 | 14 | SetFile=/etc/openstack-dashboard/local_settings 15 | 16 | 17 | 18 | sed -i "/ALLOWED_HOSTS/cALLOWED_HOSTS = ['*', ]" $SetFile 19 | 20 | sed -i '/ULTIDOMAIN_SUPPORT/cOPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True' $SetFile 21 | 22 | sed -i "s@^#OPENSTACK_KEYSTONE_DEFAULT@OPENSTACK_KEYSTONE_DEFAULT@" $SetFile 23 | 24 | sed -i "s#127.0.0.1:11211#10.0.3.111:11211#" $SetFile 25 | 26 | sed -in '154,159s/#//' $SetFile 27 | 28 | sed -in '161,165s/.*/#&/' $SetFile 29 | 30 | sed -i 's#_member_#user#g' $SetFile 31 | 32 | sed -i 's#OPENSTACK_HOST = "127.0.0.1"#OPENSTACK_HOST = "10.0.3.111"#' $SetFile 33 | 34 | sed -in '317,322s/True/False/' $SetFile 35 | 36 | sed -i "323i 'enable_lb': False," $SetFile 37 | 38 | sed -in '64,70s/#//' $SetFile 39 | 40 | sed -i '69d' $SetFile 41 | 42 | sed -i '65d' $SetFile 43 | 44 | 45 | systemctl restart httpd.service memcached.service 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /maven+nexus/maven + nexus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | maven: 4 | /etc/maven 5 | conf/setting.xml 6 | 打开 Maven 的配置文件(windows机器一般在maven安装目录的conf/settings.xml),在标签中添加 mirror 子节点: 7 | 157 8 | 9 | aliyunmaven 10 | * 11 | Nexus aliyun 12 | https://maven.aliyun.com/repository/public 13 | 14 | 15 | mvn -v 看家目录 16 | mvn package 17 | mvn clean 18 | 19 | 31 | 32 | aliyunmaven 33 | * 34 | Nexus aliyun 35 | https://maven.aliyun.com/repository/public 36 | 37 | 38 | -------------------------------------------------------------------------------- /jenkins-gitlab-maven-tomcat/getlab-jenkins: -------------------------------------------------------------------------------- 1 | Deploy Keys 2 | 可以拉不可以推 enable 3 | 两个项目以上 4 | settings - repository-deploy keys 在privately点enable 5 | 6 | 如果是内网的话vim /etc/sysconfig/jenkins用root 7 | 要不然就Jenkins-凭据-系统-全局凭据 (unrestricted) 选ssh私钥 8 | 9 | 不改就用http的 在gitlab上的账号有权限就行 10 | 11 | 做免密要 之后执行shell 就ok了 12 | 13 | 备份jekins 14 | tar zcvf jenkins.tar.gz /var/lib/jenkins/ 15 | 16 | 插件:安版本发布 git parameter plugin 17 | 一般上选着 git parameter 18 | Branches to build 19 | 在源码管理上选${Tag} 20 | 21 | 触发远程构建 (例如,使用脚本) 里的 在gitlab里的hook也填一样的 22 | 插件:Build Authorization Token Root 23 | 插件:gitlab 24 | Build when a change is pushed to GitLab. GitLab webhook URL: http://10.0.3.12:8080/project/baibai_frist 25 | webhook 26 | http://ip/buildByToken/build?job=baibai_frist&token=XXXX 27 | GitLab: System Hooks 28 | jenkins:触发远程构建 (例如,使用脚本) Build when a change is pushed to GitLab. GitLab webhook URL: http://10.0.3.12:8080/project/baibai_frist 29 | 选上面这两个 30 | 31 | 32 | java 33 | yum install -y maven 34 | mvn -version 35 | 36 | Maven Integration plugin 37 | SSH plugin 38 | Pulish Over SSH 39 | 在configure里面配置 40 | hosname 写ip 41 | 42 | 43 | 44 | Jenkins使用Git SCM的时候有一项源码库浏览器的设置,起初不知道有何用,只是看了说明大概知道是会对每次build生成changes,然后并没有告诉怎么设置,选择一种浏览器后要填一个URL,然后就各种百度谷歌没找到答案 45 | -------------------------------------------------------------------------------- /Zabbix/乱码和数据库字符集问题: -------------------------------------------------------------------------------- 1 | 控制面板-->字体-->选择一种中文字库例如“楷体”(simkai.ttf)放到里面 2 | [root@localhost fonts]# pwd 3 | /usr/local/nginx/html/fonts 4 | [root@localhost fonts]# ls 5 | DejaVuSans.ttf 6 | sed -i 's/DejaVuSans/simkai/g' /usr/local/nginx/html/include/defines.inc.php 7 | /usr/local/nginx/html/include/defines.inc.php 8 | 9 | 字符集真心是坑啊 建议在my.cnf里开始安mysql就设置好 10 | 写中文报错 应该是字符集不同 注意拉丁和utf8 11 | SHOW VARIABLES LIKE '%char%'; 12 | 一、character_set_client 13 |   主要用来设置客户端使用的字符集。 14 | 15 | 二、character_set_connection 16 |   主要用来设置连接数据库时的字符集,如果程序中没有指明连接数据库使用的字符集类型则按照这个字符集设置。 17 | 18 | 三、character_set_database 19 |   主要用来设置默认创建数据库的编码格式,如果在创建数据库时没有设置编码格式,就按照这个格式设置。 20 | 21 | 四、character_set_filesystem 22 |   文件系统的编码格式,把操作系统上的文件名转化成此字符集,即把 character_set_client转换character_set_filesystem, 默认binary是不做任何转换的。 23 | 24 | 五、character_set_results 25 |   数据库给客户端返回时使用的编码格式,如果没有指明,使用服务器默认的编码格式。 26 | 27 | 六、character_set_server 28 |   服务器安装时指定的默认编码格式,这个变量建议由系统自己管理,不要人为定义。 29 | 30 | 七、character_set_system 31 |   数据库系统使用的编码格式,这个值一直是utf8,不需要设置,它是为存储系统元数据的编码格式。 32 | 33 | 八、character_sets_dir 34 |   这个变量是字符集安装的目录。 35 | 36 | 在启动mysql后,我们只关注下列变量是否符合我们的要求 37 | character_set_client 38 | character_set_connection 39 | character_set_database 40 | character_set_results 41 | character_set_server 42 | 下列三个系统变量我们不需要关心,不会影响乱码等问题 43 | character_set_filesystem 44 | character_set_system 45 | character_sets_dir 46 | -------------------------------------------------------------------------------- /Centos-bug/readme.md: -------------------------------------------------------------------------------- 1 | NMI watchdog: BUG: soft lockup - CPU#0 stuck for 24s! [chronyd:500] 2 | 网上找的不一定好使 3 | 起因 4 | 5 | 近期在服务器跑大量高负载程序,造成cpu soft lockup。如果确认不是软件的问题。 6 | 解决办法: 7 | #追加到配置文件中 8 | 9 | echo 30 > /proc/sys/kernel/watchdog_thresh 10 | 11 | #查看 12 | [root@git-node1 data]# tail -1 /proc/sys/kernel/watchdog_thresh 13 | 30 14 | 15 | #临时生效 16 | sysctl -w kernel.watchdog_thresh=30 17 | #内核软死锁(soft lockup)bug原因分析 18 | Soft lockup名称解释:所谓,soft lockup就是说,这个bug没有让系统彻底死机,但是若干个进程(或者kernel thread)被锁死在了某个状态(一般在内核区域),很多情况下这个是由于内核锁的使用的问题。 19 | 20 | 21 | 22 | 23 | 软件看门狗分为两种,用于检测soft lockup的普通软狗(基于时钟中断),以及检测hard lockup的NMI狗(基于NMI中断)。 24 | 注1:时钟中断优先级小于NMI中断 25 | 注2:lockup,是指某段内核代码占着CPU不放。Lockup严重的情况下会导致整个系统失去响应。 26 | soft lockup 和 hard lockup,它们的唯一区别是 hard lockup 发生在CPU屏蔽中断的情况下。 27 | 软狗 28 | 单个cpu检测线程是否正常调度。 29 | 一般软狗的正常流程如下(假设软狗触发的时间为20s) 30 | 31 | 32 | 33 | 可能产生软狗的原因: 34 | 1.频繁处理硬中断以至于没有时间正常调度 35 | 2.长期处理软中断 36 | 3.对于非抢占式内核,某个线程长时间执行而不触发调度 37 | 4.以上all 38 | 39 | NMI watchdog 40 | 单个CPU检测中断是否能够正常上报 41 | 当CPU处于关中断状态达到一定时间会被判定进入hard lockup 42 | 43 | 44 | 45 | 46 | 47 | 可能产生NMI狗的原因: 48 | 1.长期处理某个硬中断 49 | 2.长时间在禁用本地中断下处理 50 | 51 | NMI狗机制也是用一个percpu的hrtimer来喂狗,为了能够及时检测到hard lockup状态,在比中断优先级更高的NMI上下文进行检测。 52 | -------------------------------------------------------------------------------- /ico/linkedin.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Linkedin 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ico/gitter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | GITTER 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /initCentos7/install_initC7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y wget vim dos2unix lrzsz bash-completion* 3 | mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 4 | curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 5 | mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup 6 | mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup 7 | wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 8 | setenforce 0 9 | sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config 10 | sed -i 's/#GSSAPIAuthentication\ no/GSSAPIAuthentication\ no/g' /etc/ssh/sshd_config 11 | sed -i 's/GSSAPIAuthentication\ yes/#GSSAPIAuthentication\ yes/g' /etc/ssh/sshd_config 12 | sed -i 's/#UseDNS\ yes/UseDNS\ no/g' /etc/ssh/sshd_config 13 | systemctl restart sshd 14 | echo '* - nofile 65535' >> /etc/security/limits.conf 15 | 16 | echo "net.ipv4.tcp_fin_timeout = 20 17 | net.ipv4.tcp_syncookies = 1 18 | net.ipv4.tcp_keepalive_time = 60 19 | net.ipv4.tcp_tw_reuse = 1 20 | net.ipv4.ip_local_port_range = 10000 65000 21 | net.core.netdev_max_backlog = 32768 22 | net.core.somaxconn = 32768 23 | net.ipv4.tcp_max_syn_backlog = 8192 24 | net.ipv4.tcp_max_tw_buckets = 9000 25 | ">>/etc/sysctl.conf 26 | sysctl -p 27 | 28 | echo " 29 | DefaultLimitCORE=infinity 30 | DefaultLimitNOFILE=65535 31 | DefaultLimitNPROC=65535 32 | " >>/etc/systemd/system.conf 33 | systemctl disable firewalld 34 | systemctl stop firewalld 35 | echo "start reboot" 36 | sleep 5s 37 | reboot 38 | -------------------------------------------------------------------------------- /Rsync-Sersync/install_sersync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | wget -P /usr/local/src https://github.com/justbaibai/linux-shell/blob/master/Rsync-Sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz 3 | mv /usr/local/src/GNU-Linux-x86/ /usr/local/sersync 4 | cp confxml.xml{,.bak} 5 | mv sersync2 sersync 6 | 7 | 8 | nohup /usr/local/sersync/sersync -r -d -o /usr/local/sersync/confxml.xml >/usr/local/sersync/rsync.log 2>&1 & 9 | #源服务器同步目录 10 | 目标服务器IP地址 目标服务器rsync同步目录模块名称 11 | 同步参数 12 | 目标服务器rsync同步用户名 目标服务器rsync同步用户的密码在源服务器的存放路径 13 | 脚本运行失败日志记录 14 | #设置为true,每隔600分钟执行一次全盘同步 15 | sed -i 's###g' $sedir/confxml.xml 16 | 17 | sed -i 's###g' $sedir/confxml.xml 18 | 19 | sed -i 's###g' $sedir/confxml.xml 20 | #!/bin/sh 21 | 22 | sersync="/usr/local/sersync/sersync2" 23 | 24 | confxml="/usr/local/sersync/confxml.xml" 25 | 26 | status=$(ps aux |grep 'sersync2'|grep -v 'grep'|wc -l) 27 | 28 | if [ $status -eq 0 ]; 29 | 30 | then 31 | 32 | $sersync -d -r -o $confxml & 33 | 34 | else 35 | 36 | exit 0; 37 | 38 | fi 39 | -------------------------------------------------------------------------------- /xunfeng/xunfeng.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo TZ\='Asia/Shanghai'\; export TZ >> ~/.bash\_profile && source ~/.bash\_profile 3 | yum install gcc libffi-devel python-devel openssl-devel libpcap-devel git -y 4 | wget https://sec.ly.com/mirror/get-pip.py --no-check-certificate 5 | python get-pip.py 6 | pip install -U pip 7 | git clone 8 | cd 9 | pip install -r requirements.txt -i https://pypi.doubanio.com/simple/ 10 | echo " 11 | [mongodb-org] 12 | name=MongoDB Repository 13 | baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/3.2/x86_64/ 14 | gpgcheck=0 15 | enabled=1 16 | ">>/etc/yum.repos.d/mongodb-org-3.2.repo 17 | yum install -y mongodb-org 18 | #netstat -antlp | grep 27017 19 | # systemctl start mongod 20 | #service mongod restart 21 | mongo 22 | > use xunfeng 23 | > db.createUser({user:'admin',pwd:'admin',roles:[{role:'dbOwner',db:'xunfeng'}]}) 24 | > exit 25 | cd db 26 | mongorestore -h 127.0.0.1 --port 27017 -d xunfeng . 27 | service mongod stop 28 | 修改系统数据库配置脚本 Config.py: 29 | 30 | class Config(object): 31 | ACCOUNT = 'admin' 32 | PASSWORD = 'admin' 33 | 修改 PASSWORD 字段内的密码, 设置成你的密码。 34 | 35 | class ProductionConfig(Config): 36 | DB = '127.0.0.1' 37 | PORT = 27017 38 | DBUSERNAME = 'admin' 39 | DBPASSWORD = 'admin' 40 | DBNAME = 'xunfeng' 41 | 1.在Centos7下 yum安装mongo后,查看 /etc/mongod.conf 默认db的路径的 /var/lib/mongo 而Run.sh 中定义的路径为 /var/lib/mongodb 导致启动后无法认证通过,修改该路径即可 42 | 把run.sh 改成/var/lib/mongo 43 | 2. 推送的插件:SHIRO 反序列化漏洞 安装失败:pip install cryptography 44 | 安装cryptography后插件成功安装。 45 | sh Run.sh 46 | -------------------------------------------------------------------------------- /openstack/Centos7-c-mysql.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | yum install mariadb mariadb-server python2-PyMySQL -y >/dev/null 2>&1 4 | 5 | if [ $? -eq 0 ]; then 6 | echo "install mysql is OK" 7 | else 8 | echo "install mysql is NOT OK" 9 | fi 10 | sleep 5s 11 | 12 | #cp /etc/my.cnf.d/openstack.cnf{,bak} 13 | 14 | echo "# 15 | [mysqld] 16 | bind-address = 0.0.0.0 17 | default-storage-engine = innodb 18 | innodb_file_per_table 19 | max_connections = 4096 20 | collation-server = utf8_general_ci 21 | character-set-server = utf8 22 | #">>/etc/my.cnf.d/openstack.cnf 23 | 24 | 25 | #启动数据库服务 26 | systemctl enable mariadb.service >/dev/null 2>&1 27 | systemctl start mariadb.service >/dev/null 2>&1 28 | if [ $? -eq 0 ]; then 29 | echo "mysql start ok" 30 | else 31 | echo "mysql not ok" 32 | fi 33 | 34 | netstat -antp|grep mysqld 35 | DBPass=123456 36 | #mysql_secure_installation 37 | #密码 123456 38 | 39 | [[ -f /usr/bin/expect ]] || { yum install expect -y >/dev/null 2>&1; } #若没expect则安装 40 | /usr/bin/expect << EOF 41 | set timeout 30 42 | spawn mysql_secure_installation 43 | expect { 44 | "enter for none" { send "\r"; exp_continue} 45 | "Y/n" { send "Y\r" ; exp_continue} 46 | "password:" { send "$DBPass\r"; exp_continue} 47 | "new password:" { send "$DBPass\r"; exp_continue} 48 | "Y/n" { send "Y\r" ; exp_continue} 49 | eof { exit } 50 | } 51 | EOF 52 | 53 | sleep 3s 54 | 55 | mysql -u root -p$DBPass -e "show databases;" 56 | [ $? = 0 ] || { echo "mariadb init is not ok";exit; } 57 | 58 | echo "mysql is init ok" 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /Nginx/proxy/www.baibai.com.conf: -------------------------------------------------------------------------------- 1 | server 2 | { 3 | listen 80; 4 | server_name www.baibai.com; 5 | access_log logs/www.baibai.com-access.log main; 6 | location ~ .*\.(git|jpg|png|html|htm|htm|css|js|ico|swf|pdf|txt)$ 7 | { 8 | proxy_redirect off; 9 | proxy_next_upstream http_502 http_503 http_504 http_404 error timeout invalid_header; 10 | proxy_set_header Host $host; 11 | proxy_set_header X-real-ip $remote_addr; 12 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 13 | proxy_pass http://www.baibai.com.pool; 14 | 15 | proxy_cache cache_one; 16 | proxy_cache_key "$host$request_uri"; 17 | add_header Cache "$upstream_cache_status"; 18 | proxy_cache_valid 200 304 301 302 8h; 19 | proxy_cache_valid 404 1m; 20 | proxy_cache_valid any 2d; 21 | 22 | } 23 | 24 | 25 | location / 26 | { 27 | proxy_redirect off; 28 | proxy_next_upstream http_502 http_504 http_404 error timeout invalid_header; 29 | proxy_set_header Host $host; 30 | proxy_set_header X-real-ip $remote_addr; 31 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 32 | proxy_pass http://www.baibai.com.pool; 33 | client_max_body_size 40m; 34 | client_body_buffer_size 128k; 35 | proxy_connect_timeout 60; 36 | proxy_send_timeout 60; 37 | proxy_read_timeout 60; 38 | proxy_buffer_size 64k; 39 | proxy_buffers 4 64k; 40 | proxy_busy_buffers_size 128k; 41 | } 42 | 43 | include /usr/local/nginx/conf.d/test.conf; 44 | } 45 | -------------------------------------------------------------------------------- /Rsync-Sersync/install_rsync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y rsync 3 | useradd -s /sbin/nologin -M rsync 4 | mkdir /backup 5 | chown -R rsync.rsync /backup/ 6 | echo " 7 | uid = rsync 8 | gid = rsync 9 | use chroot = no 10 | max connections = 200 11 | timeout = 300 12 | pid file = /var/run/rsyncd.pid 13 | lock file = /var/run/rsync.lock 14 | log file = /var/log/rsyncd.log 15 | ignore errors 16 | read only = false 17 | list = false 18 | hosts allow = 10.0.3.0/24 19 | hosts deny = 0.0.0.0/32 20 | auth users = baibai 21 | secrets file = /etc/rsync.password 22 | [backup] 23 | comment = "this is for test " 24 | path = /backup" >/etc/rsyncd.conf 25 | echo "baibai:baibai" > /etc/rsync.password 26 | chmod 600 /etc/rsyncd.conf 27 | chmod 600 /etc/rsync.password 28 | rsync --daemon 29 | #cat /var/run/rsyncd.pid | xargs kill -9 30 | #pkill rsync 31 | 32 | #服务端26 客户端40 下面的命令在客户端执行 把客户端的、/etc/hosts 推到服务端的back/下 33 | #rsync -avz /etc/hosts baibai@10.0.3.26::backup --password-file=/etc/rsync.password 从客户端推到服务端 34 | #rsync -avz baibai@10.0.3.26::backup /t --password-file=/etc/rsync.password 把服务端的内容拉到本地 35 | #利用rsync客户端同步数据(非常重要) 36 | # rsync -avz /tmp/ rsync_backup@172.16.1.41::backup/ --password-file=/etc/rsync.password  37 | # 说明:/tmp/ 表示同步tmp目录下内容,但不包含目录本身 38 | # rsync -avz /tmp rsync_backup@172.16.1.41::backup/ --password-file=/etc/rsync.password  39 | # 说明:/tmp 表示同步tmp目录下内容及目录本身 40 | 41 | 42 | 43 | #客户端只要密码 用户:密码 44 | #echo "baibai" > /etc/rsync.password 45 | #chmod 600 /etc/rsync.password 46 | 47 | #Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST] 48 | #Push: rsync [OPTION...] SRC... [USER@]HOST::DEST 49 | -------------------------------------------------------------------------------- /openstack/Centos7-c-etcd .bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install etcd -y >/dev/null 2>&1 3 | if [ $? -eq 0 ]; then 4 | echo "etcd install is ok" 5 | else 6 | echo "etcd install is not ok" 7 | fi 8 | sleep 5s 9 | cp /etc/etcd/etcd.conf{,.bak} 10 | 11 | echo ' 12 | #[Member] 13 | ETCD_DATA_DIR="/var/lib/etcd/default.etcd" 14 | ETCD_LISTEN_PEER_URLS="http://10.0.3.111:2380" 15 | ETCD_LISTEN_CLIENT_URLS="http://10.0.3.111:2379" 16 | ETCD_NAME="baibaic" 17 | #[Clustering] 18 | ETCD_INITIAL_ADVERTISE_PEER_URLS="http://10.0.3.111:2380" 19 | ETCD_ADVERTISE_CLIENT_URLS="http://10.0.3.111:2379" 20 | ETCD_INITIAL_CLUSTER="baibaic=http://10.0.3.111:2380" 21 | ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01" 22 | ETCD_INITIAL_CLUSTER_STATE="new" 23 | '>/etc/etcd/etcd.conf 24 | 25 | systemctl enable etcd >/dev/null 2>&1 26 | systemctl start etcd >/dev/null 2>&1 27 | 28 | systemctl status etcd 29 | 30 | netstat -lntup|grep etcd 31 | sleep 2s 32 | echo "etcd is ok" 33 | 34 | 35 | 36 | #name 节点名称 37 | #data-dir 指定节点的数据存储目录 38 | #listen-peer-urls 监听URL,用于与其他节点通讯 39 | #listen-client-urls 对外提供服务的地址:比如 http://ip:2379,http://127.0.0.1:2379 ,客户端会连接到这里和 etcd 交互 40 | #initial-advertise-peer-urls 该节点同伴监听地址,这个值会告诉集群中其他节点 41 | #initial-cluster 集群中所有节点的信息,格式为 node1=http://ip1:2380,node2=http://ip2:2380,… 。注意:这里的 node1 是节点的 --name 指定的名字;后面的 ip1:2380 是 --initial-advertise-peer-urls 指定的值 42 | #initial-cluster-state 新建集群的时候,这个值为 new ;假如已经存在的集群,这个值为 existing 43 | #initial-cluster-token 创建集群的 token,这个值每个集群保持唯一。这样的话,如果你要重新创建集群,即使配置和之前一样,也会再次生成新的集群和节点 uuid;否则会导致多个集群之间的冲突,造成未知的错误 44 | #advertise-client-urls 对外公告的该节点客户端监听地址,这个值会告诉集群中其他节点 45 | -------------------------------------------------------------------------------- /Grafana/Grafana: -------------------------------------------------------------------------------- 1 | 2 | wget https://dl.grafana.com/oss/release/grafana-5.4.2-1.x86_64.rpm 3 | yum install initscripts fontconfig -y 4 | sudo yum localinstall grafana-5.4.2-1.x86_64.rpm 5 | service grafana-server start 6 | grafana-cli plugins install alexanderzobnin-zabbix-app 7 | service grafana-server restart 8 | 9 | http://ip/zabbix/api_jsonrpc.php 10 | 用api 11 | grafana-cli plugins install grafana-piechart-panel 12 | --------------------------------------------------- 13 | 安装其他图形插件 14 | grafana-cli plugins install grafana-clock-panel 15 | #钟表形展示 16 | grafana-cli plugins install briangann-gauge-panel 17 | #字符型展示 18 | grafana-cli plugins install natel-discrete-panel 19 | #服务器状态 20 | grafana-cli plugins install vonage-status-panel 21 | 22 | 如下设置变量"group",其中query的匹配原则 23 | * returns all groups 24 | *.* returns all hosts (from all groups) 25 | Servers.* returns all hosts in group Servers 26 | Servers.*.* returns all applications in group Servers 27 | Servers.*.*.* returns all items from hosts in group Servers 28 | 29 | --------------------------------------------------------------------------------------------------------------------------------------------- 30 | 温馨提示:如果是针对某一个主机群组的模板,group的Query可以不需填写*,可以直接写明组名。比如: 31 | group 32 | Query:* 33 | 34 | host 35 | Query:$group.* 36 | 37 | application 38 | Query: $group.$host.* 39 | 40 | iteams 41 | Query: $group.$host.$application.* 42 | 43 | 44 | Variables > New 45 | name 如上 46 | Data zabbix refresh On Dash load 47 | 48 | Query:如上 49 | 50 | mu 51 | incl 两个选对号 52 | -------------------------------------------------------------------------------- /Php/install_php.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install libjpeg-turbo-devel libmcrypt-devel mhash mcrypt libxslt-devel zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel libcurl-devel libiconv-devel libevent-devel -y 3 | #wget -P /usr/local/src http://www.php.net/distributions/php-5.6.38.tar.gz 4 | wget -P /usr/local/src http://mirrors.sohu.com/php/php-5.6.38.tar.gz 5 | cd /usr/local/src && tar xf php-5.6.38.tar.gz 6 | cd /usr/local/src/php-5.6.38 && ./configure --enable-ctype --enable-sockets --enable-mbstring --with-gettext --with-config-file-path=/usr/local/php-5.6.38/etc --with-config-file-scan-dir=/usr/local/php-5.6.38/etc/php.d --prefix=/usr/local/php-5.6.38 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --enable-ftp --enable-opcache --with-fpm-user=nginx --with-fpm-group=nginx 7 | make && make install 8 | ln -s /usr/local/php-5.6.38/ /usr/local/php 9 | cp /usr/local/php-5.6.38/etc/php-fpm.conf.default /usr/local/php-5.6.38/etc/php-fpm.conf 10 | cp /usr/local/src/php-5.6.38/php.ini-production /usr/local/php/etc/php.ini 11 | #--enable-intl --with-ldap 可选有的应用需要 12 | # yum install openldap-devel libicu-devel -y 13 | #cp -frp /usr/lib64/libldap* /usr/lib/ 14 | 15 | -------------------------------------------------------------------------------- /Centos7/Nginx做web服务器linux内核参数优化: -------------------------------------------------------------------------------- 1 | Nginx做web服务器linux内核参数优化 2 | 3 | Nginx提供web服务时Linux内核参数调整是必不可少的,其中在优化方面就需要我们格外的注意。在下面就是对Linux内核参数优化的详细介绍,希望大家有所收获。 4 | 5 | 关于Linux内核参数的优化: 6 | 7 | net.ipv4.tcp_max_tw_buckets = 6000 8 | 9 | timewait的数量,默认是180000。 10 | 11 | net.ipv4.ip_local_port_range = 1024 65000 12 | 13 | 允许系统打开的端口范围。 14 | 15 | net.ipv4.tcp_tw_recycle = 1 16 | 17 | 启用timewait快速回收。 18 | 19 | net.ipv4.tcp_tw_reuse = 1 20 | 21 | 开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接。 22 | 23 | net.ipv4.tcp_syncookies = 1 24 | 25 | 开启SYN Cookies,当出现SYN等待队列溢出时,启用cookies来处理。 26 | 27 | net.core.somaxconn = 262144 28 | 29 | web应用中listen函数的backlog默认会给我们内核参数的net.core.somaxconn限制到128,而Nginx内核参数定义的NGX_LISTEN_BACKLOG默认为511,所以有必要调整这个值。 30 | 31 | net.core.netdev_max_backlog = 262144 32 | 33 | 每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。 34 | 35 | net.ipv4.tcp_max_orphans = 262144 36 | 37 | 系统中最多有多少个TCP套接字不被关联到任何一个用户文件句柄上。如果超过这个数字,孤儿连接将即刻被复位并打印出警告信息。这个限制仅仅是为了防止简单的DoS攻击,不能过分依靠它或者人为地减小这个值,更应该增加这个值(如果增加了内存之后)。 38 | 39 | net.ipv4.tcp_max_syn_backlog = 262144 40 | 41 | 记录的那些尚未收到客户端确认信息的连接请求的最大值。对于有128M内存的系统而言,缺省值是1024,小内存的系统则是128。 42 | 43 | net.ipv4.tcp_timestamps = 0 44 | 45 | 时间戳可以避免序列号的卷绕。一个1Gbps的链路肯定会遇到以前用过的序列号。时间戳能够让内核接受这种“异常”的数据包。这里需要将其关掉。 46 | 47 | net.ipv4.tcp_synack_retries = 1 48 | 49 | 为了打开对端的连接,内核需要发送一个SYN并附带一个回应前面一个SYN的ACK。也就是所谓三次握手中的第二次握手。这个设置决定了内核放弃连接之前发送SYN+ACK包的数量。 50 | 51 | net.ipv4.tcp_syn_retries = 1 52 | 53 | 在内核放弃建立连接之前发送SYN包的数量。 54 | 55 | net.ipv4.tcp_fin_timeout = 1 56 | 57 | 如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间。对端可以出错并永远不关闭连接,甚至意外当机。缺省值是60秒。2.2 内核的通常值是180秒,你可以按这个设置,但要记住的是,即使你的机器是一个轻载的WEB服务器,也有因为大量的死套接字而内存溢出的风险,FIN- WAIT-2的危险性比FIN-WAIT-1要小,因为它最多只能吃掉1.5K内存,但是它们的生存期长些。 58 | 59 | net.ipv4.tcp_keepalive_time = 30 60 | 61 | 当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时。 62 | -------------------------------------------------------------------------------- /Redis/配置/moren_redis.conf: -------------------------------------------------------------------------------- 1 | grep "^[^$|#]" /usr/local/redis-5.0.4/redis.conf 2 | 3 | bind 127.0.0.1 4 | protected-mode yes 5 | port 6379 6 | tcp-backlog 511 7 | timeout 0 8 | tcp-keepalive 300 9 | daemonize no 10 | supervised no 11 | pidfile /var/run/redis_6379.pid 12 | loglevel notice 13 | logfile "" 14 | databases 16 15 | always-show-logo yes 16 | save 900 1 17 | save 300 10 18 | save 60 10000 19 | stop-writes-on-bgsave-error yes 20 | rdbcompression yes 21 | rdbchecksum yes 22 | dbfilename dump.rdb 23 | dir ./ 24 | replica-serve-stale-data yes 25 | replica-read-only yes 26 | repl-diskless-sync no 27 | repl-diskless-sync-delay 5 28 | repl-disable-tcp-nodelay no 29 | replica-priority 100 30 | lazyfree-lazy-eviction no 31 | lazyfree-lazy-expire no 32 | lazyfree-lazy-server-del no 33 | replica-lazy-flush no 34 | appendonly no 35 | appendfilename "appendonly.aof" 36 | appendfsync everysec 37 | no-appendfsync-on-rewrite no 38 | auto-aof-rewrite-percentage 100 39 | auto-aof-rewrite-min-size 64mb 40 | aof-load-truncated yes 41 | aof-use-rdb-preamble yes 42 | lua-time-limit 5000 43 | slowlog-log-slower-than 10000 44 | slowlog-max-len 128 45 | latency-monitor-threshold 0 46 | notify-keyspace-events "" 47 | hash-max-ziplist-entries 512 48 | hash-max-ziplist-value 64 49 | list-max-ziplist-size -2 50 | list-compress-depth 0 51 | set-max-intset-entries 512 52 | zset-max-ziplist-entries 128 53 | zset-max-ziplist-value 64 54 | hll-sparse-max-bytes 3000 55 | stream-node-max-bytes 4096 56 | stream-node-max-entries 100 57 | activerehashing yes 58 | client-output-buffer-limit normal 0 0 0 59 | client-output-buffer-limit replica 256mb 64mb 60 60 | client-output-buffer-limit pubsub 32mb 8mb 60 61 | hz 10 62 | dynamic-hz yes 63 | aof-rewrite-incremental-fsync yes 64 | rdb-save-incremental-fsync yes 65 | -------------------------------------------------------------------------------- /work/云盘: -------------------------------------------------------------------------------- 1 | 系统设置 2 | css 3 | .copyright-content{display:none} 4 | 5 | 9 | 10 | 11 | location ~ .*.(php|php5)$ { 12 | root /data; 13 | fastcgi_pass 127.0.0.1:9000; 14 | fastcgi_index index.php; 15 | fastcgi_cache one; 16 | # proxy_cache cache_one; 17 | include fastcgi.conf; 18 | 19 | } 20 | 21 | 22 | location / { 23 | root /data; 24 | index index.html index.htm index.php; 25 | } 26 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ 27 | { 28 | #proxy_cache cache_one; 29 | # proxy_cache_valid 200 302 24h; 30 | root /data; 31 | # proxy_cache_valid 301 30d; 32 | 33 | #proxy_cache_valid any 5m; 34 | expires 10d; 35 | } 36 | location ~ .*\.(js|css)?$ 37 | { 38 | root /data; 39 | expires 1h; 40 | } 41 | location /NginxStatus { 42 | stub_status on; 43 | access_log on; 44 | auth_basic "NginxStatus"; 45 | auth_basic_user_file confpasswd; 46 | } 47 | 48 | wget http://static.kodcloud.com/update/download/kodexplorer4.40.zip 49 | -------------------------------------------------------------------------------- /openstack/Centos7-j-neutron.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | yum install openstack-neutron-linuxbridge ebtables ipset -y >/dev/null 2>&1 4 | 5 | if [ $? -eq 0 ]; then 6 | echo "neutron install is OK" 7 | else 8 | echo "neutron install is NOT OK" 9 | exit 2 10 | fi 11 | 12 | cp /etc/neutron/neutron.conf{,.bak} 13 | echo '# 14 | [DEFAULT] 15 | transport_url = rabbit://openstack:openstack@10.0.3.111 16 | auth_strategy = keystone 17 | 18 | [keystone_authtoken] 19 | www_authenticate_uri = http://10.0.3.111:5000 20 | auth_url = http://10.0.3.111:5000 21 | memcached_servers = 10.0.3.111:11211 22 | auth_type = password 23 | project_domain_name = default 24 | user_domain_name = default 25 | project_name = service 26 | username = neutron 27 | password = neutron 28 | [oslo_concurrency] 29 | lock_path = /var/lib/neutron/tmp 30 | #'>/etc/neutron/neutron.conf 31 | 32 | cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak} 33 | echo '# 34 | [linux_bridge] 35 | physical_interface_mappings = provider:eth0 36 | [vxlan] 37 | enable_vxlan = false 38 | [securitygroup] 39 | enable_security_group = true 40 | firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver 41 | #'>/etc/neutron/plugins/ml2/linuxbridge_agent.ini 42 | 43 | cp /etc/nova/nova.conf{,.nebak} 44 | echo '# 45 | [neutron] 46 | url = http://10.0.3.111:9696 47 | auth_url = http://10.0.3.111:5000 48 | auth_type = password 49 | project_domain_name = default 50 | user_domain_name = default 51 | region_name = RegionOne 52 | project_name = service 53 | username = neutron 54 | password = neutron 55 | #'>>/etc/nova/nova.conf 56 | systemctl restart openstack-nova-compute.service >/dev/null 2>&1 57 | systemctl enable neutron-linuxbridge-agent.service >/dev/null 2>&1 58 | systemctl start neutron-linuxbridge-agent.service >/dev/null 2>&1 59 | 60 | -------------------------------------------------------------------------------- /Lvs-dr/install_lvs.sh: -------------------------------------------------------------------------------- 1 | 1、为什么所有RS上都要配置VIP因为当调度器把请求转发给对应RS时,并没有修改报文目的IP,因此请求报文目的IP仍为VIP,所以如果RS没有配置VIP,那么报文到达RS后就会被丢弃。 2 | 2、为什么所有RS要设置arp_ignore=1和arp_announce=2arp_ignore=1:只响应目的IP地址为接收网卡上的本地地址的arp请求因为我们在RS上都配置了VIP,因此此时是存在IP冲突的,当外部客户端向VIP发起请求时,会先发送arp请求,此时调度器和RS都会响应这个请求。如果某个RS响应了这个请求,则之后该客户端的请求就都发往该RS,并没有经过LVS,因此也就没有真正的负载均衡,LVS也就没有存在的意义。因此我们需要设置RS不响应对VIP的arp请求,这样外部客户端的所有对VIP的arp请求才会都解析到调度器上,然后经由LVS的调度器发往各个RS。系统默认arp_ignore=0,表示响应任意网卡上接收到的对本机IP地址的arp请求(包括环回网卡上的地址),而不管该目的IP是否在接收网卡上。也就是说,如果机器上有两个网卡设备A和B,即使在A网卡上收到对B IP的arp请求,也会回应。而arp_ignore设置成1,则不会对B IP的arp请求进行回应。由于lo肯定不会对外通信,所以如果只有一个对外网口,其实只要设置这个对外网口即可,不过为了保险,很多时候都对all也进行设置。arp_announce=2:网卡在发送arp请求时使用出口网卡IP作为源IP当RS处理完请求,想要将响应发回给客户端,此时想要获取目的IP对应的目的MAC地址,那么就要发送arp请求。arp请求的目的IP就是想要获取MAC地址的IP,那arp请求的源IP呢?自然而然想到的是响应报文的源IP地址,但也不是一定是这样,arp请求的源IP是可以选择的,而arp_announce的作用正是控制这个地址如何选择。系统默认arp_announce=0,也就是源ip可以随意选择。这就会导致一个问题,如果发送arp请求时使用的是其他网口的IP,达到网络后,其他机器接收到这个请求就会更新这个IP的mac地址,而实际上并不该更新,因此为了避免arp表的混乱,我们需要将arp请求的源ip限制为出口网卡ip,因此需要设置arp_announce=2。 3 | 3、为什么RS上的VIP要配置在lo上由上可知,只要RS上的VIP不响应arp请求就可以了,因此不一定要配置在lo上,也可以配置在其他网口。由于lo设备不会直接接收外部请求,因此只要设置机器上的出口网卡不响应非本网卡上的arp请求接口。但是如果VIP配置在其他网口上,除了上面的配置,还需要配置该网口不响应任何arp请求,也就是arp_ignore要设置为8。 4 | 4、为什么RS上lo配置的VIP掩码为32位这是由于lo设备的特殊性导致, 如果lo绑定192.168.0.200/24,则该设备会响应该网段所有IP(192.168.0.1~192.168.0.254) 的请求,而不是只响应192.168.0.200这一个地址。 5 | 5、为什么调度器与RS要在同一网段中根据DR模式的原理,调度器只修改请求报文的目的mac,也就是转发是在二层进行,因此调度器和RS需要在同一个网段,从而ip_forward也不需要开启。 6 | dr 7 | ifconfig eth0:0 10.0.3.115 netmask 255.255.255.255 broadcast 10.0.3.115 up 8 | ipvsadm -a -t 10.0.3.115:80 -r 10.0.3.167:80 -g 9 | 10 | rs 11 | ifconfig lo:0 10.0.3.115 netmask 255.255.255.255 broadcast 10.0.3.115 up 12 | route add -host 10.0.3.115 dev lo 13 | echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore 14 | echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce 15 | echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore 16 | echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce 17 | -------------------------------------------------------------------------------- /Gitlab/jksample/META-INF/maven/cn.xsshome/jksample/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | cn.xsshome 5 | jksample 6 | war 7 | 0.0.1 8 | jksample 9 | http://maven.apache.org 10 | 11 | 12 | 3.0.1 13 | 2.2 14 | 15 | 1.2 16 | 1.1.2 17 | 18 | 19 | 20 | 21 | javax.servlet 22 | javax.servlet-api 23 | ${servlet.version} 24 | provided 25 | 26 | 27 | javax.servlet.jsp 28 | jsp-api 29 | ${jsp-api.version} 30 | provided 31 | 32 | 33 | 34 | javax.servlet 35 | jstl 36 | ${jstl.version} 37 | 38 | 39 | taglibs 40 | standard 41 | ${standard.version} 42 | 43 | 44 | 45 | jksample 46 | 47 | 48 | -------------------------------------------------------------------------------- /ico/min-free.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Redis/配置/tongyong_redis1.conf: -------------------------------------------------------------------------------- 1 | #redis conf 详细解释 2 | #创建redis数据目录,配置文件目录,日志目录 3 | mkdir -p /data/redis/data/config/ 4 | mkdir -p /data/redis/data/logs/ 5 | #创建主库的配置文件,暂时只配置这些,其他先默认 6 | vim /data/redis/data/config/redis_6379.conf 7 | #允许后台运行 8 | daemonize yes 9 | #设置端口,最好是非默认端口 10 | port 6379 11 | #绑定登录IP,安全考虑,最好是内网 12 | bind * 13 | #命名并指定当前redis的PID路径,用以区分多个redis 14 | pidfile "/data/redis/data/config/redis_6379.pid" 15 | #命名并指定当前redis日志文件路径 16 | logfile "/data/redis/data/logs/redis_6379.log" 17 | #指定RDB文件名,用以备份数据到硬盘并区分不同redis,当使用内存超过可用内存的45%时触发快照功能 18 | dbfilename "dump_6379.rdb" 19 | #指定当前redis的根目录,用来存放RDB/AOF文件 20 | dir "/data/redis/data" 21 | #当前redis的认证密钥,redis运行速度非常快,这个密码要足够强大, 22 | #所有codis-proxy集群相关的redis-server认证密码必须全部一致 23 | requirepass "123" 24 | #当前redis的最大容量限制,建议设置为可用内存的45%内,最高能设置为系统可用内存的95%, 25 | #可用config set maxmemory 去在线修改,但重启失效,需要使用config rewrite命令去刷新配置文件 26 | #注意,使用codis集群,必须配置容量大小限制,不然无法启动 27 | maxmemory 100000kb 28 | #LRU的策略,有四种,看情况选择 29 | maxmemory-policy allkeys-lru 30 | #如果做故障切换,不论主从节点都要填写密码且要保持一致 31 | masterauth "123" 32 | 33 | #创建从库的配置文件,暂时只配置这些,其他先默认 34 | vim /data/redis/data/config/redis_6380.conf 35 | #允许后台运行 36 | daemonize yes 37 | #设置端口,最好是非默认端口 38 | port 6380 39 | #绑定登录IP,安全考虑,最好是内网 40 | bind * 41 | #命名并指定当前redis的PID路径,用以区分多个redis 42 | pidfile "/data/redis/data/config/redis_6380.pid" 43 | #命名并指定当前redis日志文件路径 44 | logfile "/data/redis/data/logs/redis_6380.log" 45 | #指定RDB文件名,用以备份数据到硬盘并区分不同redis,当使用内存超过可用内存的45%时触发快照功能 46 | dbfilename "dump_6380.rdb" 47 | #指定当前redis的根目录,用来存放RDB/AOF文件 48 | dir "/data/redis/data" 49 | #当前redis的认证密钥,redis运行速度非常快,这个密码要足够强大 50 | #所有codis-proxy集群相关的redis-server认证密码必须全部一致 51 | requirepass "123" 52 | #当前redis的最大容量限制,建议设置为可用内存的45%内,最高能设置为系统可用内存的95%, 53 | #可用config set maxmemory 去在线修改,但重启失效,需要使用config rewrite命令去刷新配置文件 54 | #注意,使用codis集群,必须配置容量大小限制,不然无法启动 55 | maxmemory 100000kb 56 | #LRU的策略,有四种,看情况选择 57 | maxmemory-policy allkeys-lru 58 | #如果做故障切换,不论主从节点都要填写密码且要保持一致 59 | masterauth "123" 60 | #配置主节点信息 61 | slaveof 10.0.2.5 6379 62 | -------------------------------------------------------------------------------- /ico/min-tuijian.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ico/min-hot.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ico/twitter-tweet.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Tweet 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /ico/twitter-follow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Follow 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /command/恢复还在运行文件的那些事: -------------------------------------------------------------------------------- 1 | [root@localhost log]# lsof |grep deleted 2 | rsyslogd 560 root 4w REG 8,3 291881 8615196 /var/log/messages (deleted) 3 | rsyslogd 560 root 9w REG 8,3 396 8615198 /var/log/maillog (deleted) 4 | in:imjour 560 575 root 4w REG 8,3 291881 8615196 /var/log/messages (deleted) 5 | in:imjour 560 575 root 9w REG 8,3 396 8615198 /var/log/maillog (deleted) 6 | rs:main 560 576 root 4w REG 8,3 291881 8615196 /var/log/messages (deleted) 7 | rs:main 560 576 root 9w REG 8,3 396 8615198 /var/log/maillog (deleted) 8 | tuned 831 root 7u REG 8,3 4096 8395495 /tmp/ffii9KQbf (deleted) 9 | gmain 831 1013 root 7u REG 8,3 4096 8395495 /tmp/ffii9KQbf (deleted) 10 | tuned 831 1014 root 7u REG 8,3 4096 8395495 /tmp/ffii9KQbf (deleted) 11 | tuned 831 1015 root 7u REG 8,3 4096 8395495 /tmp/ffii9KQbf (deleted) 12 | tuned 831 1016 root 7u REG 8,3 4096 8395495 /tmp/ffii9KQbf (deleted) 13 | [root@localhost log]# lsof |grep /var/log/messages 14 | rsyslogd 560 root 4w REG 8,3 291881 8615196 /var/log/messages (deleted) 15 | in:imjour 560 575 root 4w REG 8,3 291881 8615196 /var/log/messages (deleted) 16 | rs:main 560 576 root 4w REG 8,3 291881 8615196 /var/log/messages (deleted) 17 | [root@localhost log]# cat /proc/560/fd/4 >/var/log/messages 18 | [root@localhost log]# diff 一下 没问题 19 | cp -a 不行 20 | 21 | 22 | 我见过最多的还是他两 23 | 嘻嘻 还是看一下 24 | -rw-------. 1 root root 4042 Dec 14 13:11 secure 25 | -rw-rw-r--. 1 root utmp 6144 Dec 14 13:11 wtmp 26 | 文件在不在吧 27 | 应给给 > 清空了 嘻嘻 28 | 这就是 大文件rm 还占空间 29 | rm 一下删 不了那么多 就 for 一下 30 | 31 | 32 | -------------------------------------------------------------------------------- /ico/twitter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Twitter 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Mysql/mysql_backup_innobackupex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #wget https://www.percona.com/downloads/percona-toolkit/3.0.13/binary/redhat/7/x86_64/percona-toolkit-3.0.13-1.el7.x86_64.rpm 3 | #yum localinstall -y percona-toolkit-3.0.13-1.el7.x86_64.rpm 4 | 由于新的MySQL重做日志和数据字典格式,8.0版本只支持mysql8.0和percona8.0 5 | 早于mysql8.0的版本需要使用xtrabackup2.4备份和恢复. 6 | wget https://www.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.13/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.13-1.el7.x86_64.rpm 7 | yum localinstall -y percona-xtrabackup-24-2.4.13-1.el7.x86_64.rpm 8 | 9 | mysql> create user 'bkpuser'@'localhost' identified by '123456'; 10 | 11 | mysql> grant reload,lock tables,process,replication client on *.* to 'bkpuser'@'localhost'; 12 | 13 | mysql> flush privileges; 14 | mkdir -p /var/lib/mysql 15 | ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock 16 | /usr/local/mysql/bin/mysqlbinlog -v --base64-output=DECODE-ROWS mysql-bin.000864|grep -C 10 -i drop 17 | 18 | 产生这个问题的原因是因为我在my.cnf中的client选项组中添加了 19 | default-character-set=utf8 20 | 21 | 要解决这个bug的方法还是有的, 22 | 一种方法是使用:--no-defaults 23 | 24 | mysqlbinlog --no-defaults -v --base64-output=DECODE-ROWS mysql-bin.000001 25 | --start-datetime:从二进制日志中读取指定等于时间戳或者晚于本地服务器的时间 26 | --stop-datetime:从二进制日志中读取指定小于时间戳或者等于本地服务器的时间 取值和上述一样 27 | --start-position:从二进制日志中读取指定position 事件位置作为开始。 28 | --stop-position:从二进制日志中读取指定position 事件位置作为事件截至 29 | mysqlbinlog --no-defaults --start-position='1085' --stop-position='1235' mysql-bin.000*|mysql -uroot -p 30 | 31 | 32 | 33 | 34 | innobackupex --defaults-file=/etc/my.cnf --user=$user --password=$pwd --no-timestamp --incremental /backup/xtra_inc_$dt --incremental-basedir=/backup/xtra_base_$lastday > /tmp/$log 2>&1 35 | innobackupex --defaults-file=/etc/my.cnf --user=bkpuser --password=123456 /bak 36 | 37 | innobackupex --apply-log /root/xtrabackup/ 38 | innobackupex --copy-back /root/xtrabackup 39 | 40 | innobackupex --copy-back /bak/2019-04-03_03-10-03/ 41 | chown -R mysql.mysql /usr/local/mysql/* 42 | /usr/local/mysql/bin/mysqlbinlog --start-position='1002' mysql-bin.000* 43 | yum update trousers 44 | -------------------------------------------------------------------------------- /mysql_xbk备份脚本/resume_xbk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | innobackupex --defaults-file=/etc/my.cnf --user=backup --password=123456 --databases=zabbix /data/backup/ 3 | innobackupex --apply-log /data/backup/2018-05-21_15-02-53/ 4 | innobackupex --copy-back /data/backup/2018-05-21_15-02-53/ 5 | chown -R mysql.mysql /var/lib/mysql/* 6 | 7 | innobackupex --apply-log --redo-only /data/backup/2018-05-21_15-02-53/ 8 | innobackupex --apply-log --redo-only --user-memory=1G /data/backup/2018-05-21_15-02-53/ --incremental-dir=/data/backup/increment_data/2018-05-21_15-21-11/ 9 | innobackupex --apply-log /data/backup/2018-05-21_15-02-53/ --incremental-dir=/data/backup/increment_data/2018-05-21_15-30-13/ 10 | 增量备份的恢复应按照备份的顺利逐个逐个replay,需要使用--apply-log --redo-only选项。 11 | 仅仅最后一个增量备份不需要使用–redo-only选项。 12 | 如果仅有一个增量 全备用 --apply-log --redo-only选项 增量用 --apply-log 13 | 14 | innobackupex --apply-log --redo-only BASE-DIR 15 | innobackupex --apply-log --redo-only BASE-DIR --incremental-dir=INCREMENTAL-DIR-1 16 | innobackupex --apply-log BASE-DIR --incremental-dir=INCREMENTAL-DIR-2 17 | innobackupex --copy-back /backup/mysql/full/ 18 | chown -R mysql.mysql /var/lib/mysql/ 19 | 20 | tar xf incr0_2020-01-14-15-57-56.tar.gz 21 | ls 22 | tar xf full_2020-01-14-15-54-16.tar.gz 23 | ls 24 | innobackupex --apply-log --redo-only full/ 25 | innobackupex --apply-log full/ --incremental-dir=incr0 26 | innobackupex --copy-back full/ 27 | cd /usr/local/mysql-5.7.25/ 28 | cd /usr/local/mysql/data/ 29 | ll 30 | chown -R mysql.mysql /usr/local/mysql-5.7.25/* 31 | ll 32 | /etc/init.d/mysqld start 33 | mysql -uroot -p 34 | cd 35 | cd bakmysql/ 36 | ls 37 | ll 38 | /usr/local/mysql/bin/mysqlbinlog --no-defaults --start-position='726' --stop-position='2821' mysql-bin.000*|mysql -uroot -p 39 | 追加二进制日志 40 | xtrabackup_binlog_info 41 | /usr/local/mysql/bin/mysqlbinlog --no-defaults -v --base64-output=DECODE-ROWS mysql-bin.000007 42 | 43 | mysql> create user 'bkpuser'@'localhost' identified by '123456'; 44 | 45 | mysql> grant reload,lock tables,process,replication client on *.* to 'bkpuser'@'localhost' 46 | -------------------------------------------------------------------------------- /shell scrip/colors.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ######### 4 | #Usage: 5 | ########################### 6 | #source /root/colors.sh 7 | #green hhhhhhhhhddfsdfdls 8 | #red_blink 123123123 9 | #black_red werwerw:wq 10 | 11 | 12 | ####### 13 | CBEGIN="\033[" 14 | CEND="\033[0m" 15 | ###color set 16 | GREEN="32m" 17 | RED="31m" 18 | BLUE="34m" 19 | BLACK="30m" 20 | YELLOW="33m" 21 | WHITE="37m" 22 | PURPLE="35m" 23 | ###background 24 | B_GREEN="42;" 25 | B_RED="41;" 26 | B_BLUE="44;" 27 | B_BLACK="40;" 28 | B_YELLOW="43;" 29 | B_WHTLE="47;" 30 | B_PURPLE="45;" 31 | #### 32 | Blink="5;" 33 | High_Light="1;" 34 | Under_Line="4;" 35 | 36 | green(){ 37 | word=$1 38 | /bin/echo -e "$CBEGIN$GREEN $word $CEND" 39 | } 40 | 41 | red(){ 42 | word=$1 43 | /bin/echo -e "$CBEGIN$RED $word $CEND" 44 | } 45 | 46 | 47 | blue(){ 48 | word=$1 49 | /bin/echo -e "$CBEGIN$BLUE $word $CEND" 50 | } 51 | 52 | 53 | black(){ 54 | word=$1 55 | /bin/echo -e "$CBEGIN$BLACK $word $CEND" 56 | } 57 | 58 | 59 | yellow(){ 60 | word=$1 61 | /bin/echo -e "$CBEGIN$YELLOW $word $CEND" 62 | } 63 | 64 | 65 | white(){ 66 | word=$1 67 | /bin/echo -e "$CBEGIN$WHITE $word $CEND" 68 | } 69 | 70 | 71 | purple(){ 72 | word=$1 73 | /bin/echo -e "$CBEGIN$PURPLE $word $CEND" 74 | } 75 | 76 | 77 | white_black(){ 78 | word=$1 79 | /bin/echo -e "$CBEGIN$B_LACK$WHITE $word $CEND" 80 | } 81 | 82 | 83 | black_red(){ 84 | word=$1 85 | /bin/echo -e "$CBEGIN$B_RED$BLACK $word $CEND" 86 | } 87 | 88 | 89 | red_blink(){ 90 | word=$1 91 | /bin/echo -e "$CBEGIN$Blink$RED $word $CEND" 92 | } 93 | 94 | 95 | blue_green(){ 96 | word=$1 97 | /bin/echo -e "$CBEGIN$B_GREEN$BLUE $word $CEND" 98 | } 99 | 100 | blue_yellow(){ 101 | word=$1 102 | /bin/echo -e "$CBEGIN$B_YELLOW$BLUE $word $CEND" 103 | } 104 | 105 | black_blue(){ 106 | word=$1 107 | /bin/echo -e "$CBEGIN$B_BLUE$BLACK $word $CEND" 108 | } 109 | 110 | black_purple(){ 111 | word=$1 112 | /bin/echo -e "$CBEGIN$B_PURPLE$BLACK $word $CEND" 113 | } 114 | 115 | blue_white(){ 116 | word=$1 117 | /bin/echo -e "$CBEGIN$B_WHITE$BLUE $word $CEND" 118 | } 119 | 120 | red_under_line(){ 121 | word=$1 122 | /bin/echo -e "$CBEGIN$Under_Line$RED $word $CEND" 123 | } 124 | 125 | 126 | -------------------------------------------------------------------------------- /Centos7/test内核: -------------------------------------------------------------------------------- 1 | 整参数和不调整差别非常大,默认参数都设置比较小,在大并发,高负载时基本不能满足。调整之后,问题基本解决。 2 | vi /etc/sysctl.conf 编辑sysctl.conf 3 | net.ipv4.ip_local_port_range = 1024 65000 4 | net.ipv4.tcp_timestamps=1 5 | kernel.core_uses_pid = 1 6 | net.ipv4.tcp_syncookies=1 7 | net.ipv4.tcp_syn_retries=1 8 | net.ipv4.tcp_synack_retries=1 9 | net.ipv4.tcp_tw_recycle=1 10 | net.ipv4.tcp_tw_reuse=1 11 | net.ipv4.tcp_fin_timeout=5 12 | net.ipv4.route.gc_timeout=20 13 | net.ipv4.tcp_keepalive_time=20 14 | net.ipv4.tcp_max_syn_backlog= 655360 15 | net.ipv4.ip_conntrack_max = 655360 16 | 先简单介绍下 背景吧 17 | 通 过webbench压nginx+memcache时,被压的服务器nginx,memcache的cpu使用非常低,而且服务器负载也很小,但是 webbench的结果却不乐观,失败非常多,通过分析,压力根本没到nginx和memcache,可能在服务器级就挡住了压力,并且发现/var /log/message里面有关于ip_conntrack_max(一个连接hash表)满了的报错,然后顺藤摸瓜,通过查看linux的man tcp 手册,一个参数一个参数的研究,终于总结了上面的一些配置,解决了问题。 18 | 19 | 现象:/var/log/message里面有关于ip_conntrack_max 如ip_conntrack: table full, dropping packet. 20 | 解决方法: 21 | 观察链接跟踪表是(/proc/net/ip_conntrack) 22 | IP_conntrack 表示连接跟踪数据库(conntrack database),代表NAT机器跟踪连接的数目,连接跟踪表能容纳多少记录是被一个变量控制的,他可由内核中的ip- sysctl函数配置。每一个跟踪连接表会占用350字节的内核存储空间,时间一长就会把默认的空间填满,那么默认空间时多少?我以redhat为例在内 存为64MB的机器上时4096,内存为128MB是 8192,内存为256MB是16376,那末就能在/proc/sys/net/ipv4/ip_conntrack_max里查看、配置。 23 | 针对于我们的业务模式,比较重要的是 24 | net.ipv4.ip_local_port_range = 1024 65000 表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为1024到65000。 25 | net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭; 26 | net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。 27 | net.ipv4.ip_conntrack_max = 655360 28 | net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 21600 29 | 这个值是控制 红色数字 这个时间的,其他相关参数都在/proc/sys/net/ipv4/netfilter目录下 30 | cat /proc/net/ip_conntrack 31 | udp 17 21 src=192.168.0.18 dst=211.147.6.3 sport=24889 dport=53 packets=1 bytes=71 src=211.147.6.3 dst=192.168.0.18 sport=53 dport=24889 packets=1 bytes=152 use=1 32 | tcp 6 52 ESTABLISHED src=192.168.0.18 dst=192.168.0.17 sport=52318 dport=3306 packets=44 bytes=2474 src=192.168.0.17 dst=192.168.0.18 sport=3306 dport=52318 packets=43 bytes=2716 [ASSURED] use=1 33 | 34 | 35 | vi /etc/modprobe.conf 36 | options ip_conntrack hashsize=855360 更改 conntrack_buckets 37 | =========================================================== 38 | =========================================================== 39 | -------------------------------------------------------------------------------- /ico/hexo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Hexo 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Zabbix/install_zabbix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y libdbi-dbd-mysql net-snmp-devel curl-devel net-snmp libcurl-devel libxml2-devel 3 | wget -P /usr/local/src https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.3/zabbix-4.0.3.tar.gz 4 | groupadd zabbix 5 | useradd -g zabbix zabbix 6 | /usr/local/mysql/bin/mysql -uroot -p123456 -e "create database zabbix ;" 7 | /usr/local/mysql/bin/mysql -uroot -p123456 -e "grant all on zabbix.* to zabbix@'%' identified by 'zabbix';" 8 | /usr/local/mysql/bin/mysql -uroot -p123456 -e "grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';" 9 | /usr/local/mysql/bin/mysql -uroot -p123456 -e "flush privileges;" 10 | cd /usr/local/src && tar xf zabbix-4.0.3.tar.gz 11 | cd /usr/local/src/zabbix-4.0.3 && ./configure --prefix=/usr/local/zabbix-4.0.3 --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 12 | #zabbix 端开启java监听的功能,在编译安装的zabbix里面使用--zabbix-java开启,rpm安装的要安装zabbix-java-gateway包,此包要和zabbix server版本相对应。 13 | make && make install 14 | ln -s /usr/local/zabbix-4.0.3/ /usr/local/zabbix 15 | cd /usr/local/src/zabbix-4.0.3/database/mysql 16 | mysql -uzabbix -pzabbix zabbix < schema.sql 17 | mysql -uzabbix -pzabbix zabbix < images.sql 18 | mysql -uzabbix -pzabbix zabbix < data.sql 19 | sed -i 's@# ListenIP=0.0.0.0@ListenIP=0.0.0.0@g' /usr/local/zabbix/etc/zabbix_server.conf 20 | 21 | 22 | rm -fr /usr/local/nginx/html/* 23 | cd /usr/local/src/zabbix-4.0.3/frontends/php/ 24 | cp -a . /usr/local/nginx/html/ 25 | chown -R nginx.nginx /usr/local/nginx/html/* 26 | 27 | cd /usr/local/src/zabbix-4.0.3/misc/init.d/ 28 | cp fedora/core/zabbix_server /etc/init.d/ 29 | cp fedora/core/zabbix_agentd /etc/init.d/ 30 | #vim /etc/init.d/zabbix_server 31 | #BASEDIR=/usr/local/zabbix #找到此行,并修改 32 | #vim /etc/init.d/zabbix_agentd 33 | #BASEDIR=/usr/local/zabbix #找到此行,并修改 34 | sed -i 's# *.BASEDIR=\/usr\/local# BASEDIR=\/usr\/local\/zabbix#g' /etc/init.d/zabbix_server 35 | sed -i 's# *.BASEDIR=\/usr\/local# BASEDIR=\/usr\/local\/zabbix#g' /etc/init.d/zabbix_agentd 36 | #/tmp/zabbix_server.log 日志 37 | /usr/local/zabbix/sbin/zabbix_server -c /usr/local/zabbix/etc/zabbix_server.conf 38 | mkdir /var/lib/mysql 39 | ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock 40 | /etc/rc.d/init.d/mysqld restart 41 | -------------------------------------------------------------------------------- /openstack/Centos7-j-nova.bash: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #install first reboot 4 | 5 | yum install -y openstack-nova-compute >/dev/null 2>&1 6 | if [ $? -eq 0 ];then 7 | echo "nova-compute install is ok" 8 | else 9 | echo "nova-compute install is not ok" 10 | fi 11 | 12 | 13 | [[ `egrep -c '(vmx|svm)' /proc/cpuinfo` = 0 ]] && { Kvm=qemu; } || { Kvm=kvm; } 14 | echo "use $Kvm" 15 | 16 | 17 | /usr/bin/cp /etc/nova/nova.conf{,.bak} 18 | #egrep -v '^$|#' /etc/nova/nova.conf 19 | echo '# 20 | [DEFAULT] 21 | enabled_apis = osapi_compute,metadata 22 | transport_url = rabbit://openstack:openstack@10.0.3.111 23 | my_ip = 10.0.3.112 24 | use_neutron = True 25 | firewall_driver = nova.virt.firewall.NoopFirewallDriver 26 | #compute_driver = libvirt.LibvirtDriver 27 | 28 | [api] 29 | auth_strategy = keystone 30 | 31 | 32 | [keystone_authtoken] 33 | auth_url = http://10.0.3.111:5000/v3 34 | memcached_servers = 10.0.3.111:11211 35 | auth_type = password 36 | project_domain_name = default 37 | user_domain_name = default 38 | project_name = service 39 | username = nova 40 | password = nova 41 | 42 | 43 | [vnc] 44 | enabled = true 45 | server_listen = 0.0.0.0 46 | server_proxyclient_address = $my_ip 47 | novncproxy_base_url = http://10.0.3.111:6080/vnc_auto.html 48 | 49 | 50 | 51 | 52 | 53 | [glance] 54 | api_servers = http://10.0.3.111:9292 55 | 56 | 57 | [oslo_concurrency] 58 | lock_path = /var/lib/nova/tmp 59 | 60 | 61 | [placement] 62 | region_name = RegionOne 63 | project_domain_name = Default 64 | project_name = service 65 | auth_type = password 66 | user_domain_name = Default 67 | auth_url = http://10.0.3.111:5000/v3 68 | username = placement 69 | password = placement 70 | 71 | 72 | [libvirt] 73 | virt_type = qemu 74 | #'>/etc/nova/nova.conf >/dev/null 2>&1 75 | 76 | if [ $? -eq 0 ];then 77 | echo "nova-compute conf is ok" 78 | else 79 | echo "nova-compute conf is not ok" 80 | fi 81 | #sed -i 's#10.0.3.111:6080#10.2.10.20:6080#' /etc/nova/nova.conf 82 | 83 | #启动 84 | systemctl enable libvirtd.service openstack-nova-compute.service >/dev/null 2>&1 85 | systemctl start libvirtd.service openstack-nova-compute.service 86 | 87 | if [ $? -eq 0 ];then 88 | echo "nova-compute all install is ok" 89 | else 90 | echo "nova-compute all install is not ok" 91 | fi -------------------------------------------------------------------------------- /Jenkins/install_jenkins.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | yum install -y java-1.8.0-openjdk wget 3 | wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo && rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key &&yum clean all && yum makecache && yum install -y jenkins && systemctl start jenkins 4 | wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.150.1-1.1.noarch.rpm 5 | #我用清华大学的源了 不知道官网为毛打不开 可能我人品不行 万能的长城防火前 6 | yum localinstall -y jenkins-2.150.1-1.1.noarch.rpm 7 | systemctl start jenkins 8 | cat /var/lib/jenkins/secrets/initialAdminPassword 9 | #安装目录/var/lib/jenkins 10 | #配置文件 /etc/sysconfig/jenkins 11 | #日志目录 /var/log/jenkins 12 | jenkins This Jenkins instance appears to be offline. 13 | 先找到配置,再将https的修改为http 14 | vim /var/lib/jenkins/hudson.model.UpdateCenter.xml 15 | /jenkins/pluginManager/advanced/ 16 | http://updates.jenkins-ci.org/download/plugins/ 17 | 或换成这个https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/stable/update-center.json 18 | 19 | 相关配置 20 | 21 | # Jenkins安装目录 22 | 23 | /var/lib/jenkins 24 | 25 | # Jenkins配置文件地址 26 | 27 | cat /etc/sysconfig/jenkins 28 | 29 | # 三个比较重要的配置 30 | 31 | JENKINS_HOME是Jenkins的主目录,Jenkins工作的目录都放在这里,Jenkins储存文件的地址,Jenkins的插件,生成的文件都在这个目录下。 32 | 33 | JENKINS_USER是Jenkins的用户,拥有$JENKINS_HOME和/var/log/jenkins的权限。 34 | 35 | JENKINS_PORTJENKINS_PORT是Jenkins的端口,默认端口是8080。 36 | 37 | 报错解决如下: 38 | 39 | jenkins报错:Problem accessing /jenkins/. Reason: HTTP ERROR 404 40 | 41 | 这是一个Jenkins的Bug。临时解决方法是:在浏览器中手工输入:http://: 42 | 43 | 不要访问"/jenkins"这个路径。 44 | 45 | jenkins 报错: office This jenkins instance appears to be offline. 46 | 47 | [root@caosm98 ~]# cat /var/lib/jenkins/hudson.model.UpdateCenter.xml 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | default 56 | 57 | http://updates.jenkins.io/update-center.json 58 | 59 | 60 | 61 | https 改成http 62 | 63 | 需要重启jenkins 64 | 1.停留在可选插件那个页面,不要关闭页面。 65 | 66 | 67 | 68 | 2.然后再打开一个新的窗口,输入网址http://localhost:8080/pluginManager/advanced,输入网址打开后滑动到页面下方,最底下有个【升级站点】,把其中的链接改成这个http的链接 http://updates.jenkins.io/update-center.json。 69 | 70 | 71 | 72 | 73 | http://localhost:8080/pluginManager/advanced 74 | https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/stable/update-center.json 75 | -------------------------------------------------------------------------------- /yum/yum 私有仓库.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd /etc/yum.repos.d/ 3 | mkdir bak 4 | mv CentOS* bak 5 | curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 6 | wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 7 | wget -O /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 8 | reposync -r docker-ce-stable 9 | yum repolist 10 | yum install createrepo yum-utils -y 11 | mkdir /data 12 | .同步镜像到本地 13 | 显示所有仓库 14 | reposync -r base 15 | reposync -r extras 16 | reposync -r updates 17 | reposync -r epel 18 | reposync -r docker-ce-stable 19 | #createrepo --update 20 | #reposync -r base -p /data #将已经配置好的阿里仓库镜像内的rpm包拉到本地,base为本地已经配 21 | 22 | 23 | cd base 24 | createrepo ./ 25 | cd ../extras 26 | createrepo ./ 27 | cd ../updates 28 | createrepo ./ 29 | cd ../epel 30 | createrepo ./ 31 | cd ../docker-ce-stable 32 | createrepo ./ 33 | 34 | 35 | 36 | server { 37 | listen 80; 38 | server_name localhost; 39 | root /yumrepo; 40 | #charset koi8-r; 41 | 42 | #access_log logs/host.access.log main; 43 | 44 | location / { 45 | autoindex on; 46 | autoindex_exact_size off; 47 | autoindex_localtime on; 48 | } 49 | 50 | vim /cron/repository.sh #编写同步脚本 51 | reposync -r base -p /mirrors/Packege -d #来删除本地老旧 52 | reposync -r base -p /mirrors/Packege 53 | crontab -e #添加定时任务 54 | 0 0 1 * * sh /cron/repository.sh #每月1日0时更新yum仓库 55 | 56 | 57 | /etc/yum.repos.d 58 | mkdir bak 59 | mv * bak 60 | yum clean all 61 | 62 | yum makecache 63 | vim /etc/yum.repos.d/baibai.repo 64 | 65 | [base] 66 | name=CentOS-Base(GDS) 67 | baseurl=http://10.0.3.163/base 68 | path=/ 69 | enabled=1 70 | gpgcheck=0 71 | 72 | [updates] 73 | name=CentOS-Updates(GDS) 74 | baseurl=http://10.0.3.163/updates 75 | path=/ 76 | enabled=1 77 | gpgcheck=0 78 | 79 | [extras] 80 | name=CentOS-Extras(GDS) 81 | baseurl=http://10.0.3.163/extras 82 | path=/ 83 | enabled=1 84 | gpgcheck=0 85 | 86 | vim /etc/yum.repos.d/baibai-epel.repo 87 | [epel] 88 | name=CentOS-Epel(GDS) 89 | baseurl=http://10.0.3.163/epel 90 | path=/ 91 | enabled=1 92 | gpgcheck=0 93 | 94 | [docker] 95 | name=CentOS-docker(GDS) 96 | baseurl=http://10.0.3.163/docker-ce-stable 97 | path=/ 98 | enabled=1 99 | gpgcheck=0 100 | 101 | -------------------------------------------------------------------------------- /Nsf/readme.md: -------------------------------------------------------------------------------- 1 | 客户端 和服务端 2 | #管理 3 | showmount -e localhost #显示共享信息 4 | exportfs -ar #重新加载exprots文件,使新的挂载参数生效 5 | 6 | cat /var/lib/nfs/etab 7 | 8 | 9 | 10 | #客户端同样需要启动portmap,centos6之后是rpcbind 11 | 12 | yum install -y rpcbind nfs-utils 13 | #nfs-utils 可以不安装 showmount用不了 14 | service (portmap|rpcbind) start 15 | 16 | #showmount -e (ip) #扫描服务器共享信息 17 | 18 | #挂载服务器共享目录到本地,挂载参数可控 19 | #mount -t nfs -o rw,ro,bg,fg,nosuid,nodev,noexec,soft,hard,intr,rsize=,wsize= 10.0.3.26:/data /baibai 20 | #mount -t nfs -o nosuid,noexec,nodev,noatime,nodiratime,rsize=131072,wsize=131072 172.16.1.31:/data/ /upload #优化参数 21 | mkdir baibai 22 | mount -t nfs 10.0.3.26:/data /baibai 23 | #cat /proc/mounts 查看挂载参数 24 | #autofs自动挂载 25 | #主要配置文件 auto.master 26 | #vi /etc/auto.master 27 | ##/home /etc/auto.nfs #auto.nfs文件名为自定义 28 | 29 | #具体配置文件 auto.nfs 30 | #vi /etc/auto.nfs 31 | 32 | #public -rw,bg,soft,rsize=2048,wsize=2048 10.0.8.2:/data/pub 33 | #software -ro,bg,soft,rsize=2048,wsize=2048 10.0.8.2:/data/software 34 | #…… 35 | #当试图读取本机的/home/public目录时,本机就会自动去挂载10.0.8.2上的/data/public目录,挂载的参数就是以"-"开头的那几个参数。而超过一定时间不使用,系统又会自动卸载这个远程挂载。 36 | 37 | #service autofs start 38 | 39 | 40 | umount.nfs -fl /baibai 41 | 网不好 的 客户端卡主 42 | mount -t nfs -o soft,intr,timeo=30,retry=3 10.0.3.26:/data /baibai 43 | 44 | A)访问权限 45 | 46 | ro:设置输出目录只读。 47 | 48 | rw:设置输出目录读写。 49 | 50 | B)用户映射 51 | 52 | root_squash:将root用户映射为来宾账号(nfsnoboydy用户),默认启用。 53 | 54 | no_root_squash:不映射客户端root账号为来宾账号,也就意味着客户端root具有服务端root的用户权限。 55 | 56 | all_squash:将远程访问的所有普通用户及所属组都映射为匿名用户或用户组(nfsnobody)。 57 | 58 | no_all_squash:与all_squash取反(默认设置); 59 | 60 | anonuid=501:指定映射的账号UID。 61 | 62 | anongid=501:指定映射的账号GID。 63 | 64 | C)其他 65 | 66 | secure:限制客户端只能从小于1024的tcp/ip端口连接nfs服务器(默认设置)。 67 | 68 | insecure:允许客户端从大于1024的tcp/ip端口连接服务器。 69 | 70 | sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性。 71 | 72 | async:将数据先保存在内存缓冲区中,必要时才写入磁盘,默认使用。 73 | 74 | wdelay:检查是否有相关的写操作,如果有则将这些写操作一起执行,这样可以提高效率(默认设置)。 75 | 76 | no_wdelay:若有写操作则立即执行,应与sync配合使用。 77 | 78 | subtree:若输出目录是一个子目录,则nfs服务器将检查其父目录的权限(默认设置)。 79 | 80 | no_subtree:即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率。 81 | 82 | 83 | 挂载的参数 84 | suid与nosuid:开放或取消SUID功能,默认为suid 85 | rw,ro:指定可读写或只读,默认为rw 86 | dev,nodev:是否可以保留装置文件的特殊功能,默认为dev 87 | exec,noexec:是否具有可执行权限,默认为exec 88 | user,nouser:是否具有进行挂载与卸载的功能,默认为nouser 89 | auto,noauto:指mount-a时会不会被挂载的项目,如不需要可设为noauto,默认为auto 90 | 91 | fg,bg:前台执行或后台执行,默认为fg 92 | soft,hard:是否在挂载时持续呼叫,默认为hard,建议用soft 93 | intr:加上它,若使用hard方式时,RPC呼叫可以被中断 94 | rsize,wsize:写缓冲区与读缓冲区,可提高性能,很重要 95 | -------------------------------------------------------------------------------- /Tomcat/readme.md: -------------------------------------------------------------------------------- 1 | 再看! 2 | 再最前面加就行 3 | 4 | 在一些规模稍大的应用中,Java虚拟机(JVM)的内存设置尤为重要,想在项目中取得好的效率,GC(垃圾回收)的设置是第一步。 5 | 6 | PermGen space:全称是Permanent Generation space.就是说是永久保存的区域,用于存放Class和Meta信息,Class在被Load的时候被放入该区域Heap space:存放Instance。 7 | 8 | GC(Garbage Collection)应该不会对PermGen space进行清理,所以如果你的APP会LOAD很多CLASS的话,就很可能出现PermGen space错误 9 | 10 | Java Heap分为3个区 11 | 1.Young 12 | 2.Old 13 | 3.Permanent 14 | 15 | Young保存刚实例化的对象。当该区被填满时,GC会将对象移到Old区。Permanent区则负责保存反射对象,本文不讨论该区。 16 | 17 | JVM的Heap分配可以使用-X参数设定, 18 | 19 | -Xms 20 | 初始Heap大小 21 | 22 | -Xmx 23 | java heap最大值 24 | 25 | -Xmn 26 | young generation的heap大小 27 | 28 | JVM有2个GC线程 29 | 第一个线程负责回收Heap的Young区 30 | 第二个线程在Heap不足时,遍历Heap,将Young 区升级为Older区 31 | 32 | Older区的大小等于-Xmx减去-Xmn,不能将-Xms的值设的过大,因为第二个线程被迫运行会降低JVM的性能。 33 | 为什么一些程序频繁发生GC? 34 | 35 | 有如下原因: 36 | 1.程序内调用了System.gc()或Runtime.gc()。 37 | 2.一些中间件软件调用自己的GC方法,此时需要设置参数禁止这些GC。 38 | 3.Java的Heap太小,一般默认的Heap值都很小。 39 | 4.频繁实例化对象,Release对象 此时尽量保存并重用对象,例如使用StringBuffer()和String()。 40 | 41 | 如果你发现每次GC后,Heap的剩余空间会是总空间的50%,这表示你的Heap处于健康状态,许多Server端的Java程序每次GC后最好能有65%的剩余空间 42 | 43 | 经验之谈: 44 | 45 | 1.Server端JVM最好将-Xms和-Xmx设为相同值。为了优化GC,最好让-Xmn值约等于-Xmx的1/3。 46 | 2.一个GUI程序最好是每10到20秒间运行一次GC,每次在半秒之内完成。 47 | 48 | 注意: 49 | 50 | 1.增加Heap的大小虽然会降低GC的频率,但也增加了每次GC的时间。并且GC运行时,所有的用户线程将暂停,也就是GC期间,Java应用程序不做任何工作。 51 | 2.Heap大小并不决定进程的内存使用量。进程的内存使用量要大于-Xmx定义的值,因为Java为其他任务分配内存,例如每个线程的Stack等。 52 | 53 | Stack的设定 54 | 每个线程都有他自己的Stack。 55 | 56 | -Xss 57 | 每个线程的Stack大小 58 | 59 | Stack的大小限制着线程的数量。如果Stack过大就好导致内存溢漏。-Xss参数决定Stack大小,例如-Xss1024K。如果Stack太小,也会导致Stack溢漏。 60 | 61 | 62 | 63 | 主要通过以下的几个jvm参数来设置堆内存的: 64 | 65 | -Xmx512m 最大总堆内存,一般设置为物理内存的1/4 66 | -Xms512m 初始总堆内存,一般将它设置的和最大堆内存一样大,这样就不需要根据当前堆使用情况而调整堆的大小了 67 | -Xmn192m 年轻带堆内存,sun官方推荐为整个堆的3/8 68 | 堆内存的组成 总堆内存 = 年轻带堆内存 + 年老带堆内存 + 持久带堆内存 69 | 年轻带堆内存 对象刚创建出来时放在这里 70 | 年老带堆内存 对象在被真正会回收之前会先放在这里 71 | 持久带堆内存 class文件,元数据等放在这里 72 | -XX:PermSize=128m 持久带堆的初始大小 73 | -XX:MaxPermSize=128m 持久带堆的最大大小,eclipse默认为256m。如果要编译jdk这种,一定要把这个设的很大,因为它的类太多了。 74 | 75 | 76 | 32G 内存配置示例: 77 | 78 | JAVA_OPTS="$JAVA_OPTS -Xms10g -Xmx10g -XX:PermSize=1g -XX:MaxPermSize=2g -Xshare:off -Xmn1024m 79 | 80 | 81 | 32G 内存配置示例: 82 | 83 | 86 | 87 | jmap -heap 20274 88 | java.lang.RuntimeException: unknown CollectedHeap type : class sun.jvm.hotspot.gc_interface.CollectedHeap 89 | 安装debuginfo,去网站http://debuginfo.centos.org/7/x86_64里面找匹配当前的openjdk的版本,小版本号也要匹配上。然后使用wget命令下载 90 | 91 | -------------------------------------------------------------------------------- /ico/zhihu.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 知乎 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /openstack/Centos7-c-huanjing .bash: -------------------------------------------------------------------------------- 1 | #!bin/sh 2 | 3 | #安装 4 | yum -y install wget vim net-tools tree openssh >/dev/null 2>&1 5 | 6 | if [ $? -eq 0 ]; then 7 | echo "tools is OK" 8 | else 9 | echo "tools is NOT OK" 10 | fi 11 | sleep 5s 12 | 13 | 14 | #更换阿里源 15 | mv /etc/yum.repos.d/CentOS-Base.repo{,.bak} 16 | wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1 17 | if [ $? -eq 0 ]; then 18 | echo "aliyun yum is OK" 19 | else 20 | echo "aliyun yum is NOT OK" 21 | fi 22 | sleep 5s 23 | 24 | 25 | #安装OpenStack库 26 | yum install centos-release-openstack-rocky -y >/dev/null 2>&1 27 | #生成缓存 28 | #yum clean all && yum makecache 29 | 30 | if [ $? -eq 0 ]; then 31 | echo "centos-release-openstack-rocky OK" 32 | else 33 | echo "centos-release-openstack-rocky OK" 34 | fi 35 | sleep 5s 36 | 37 | #OpenStack客户端 38 | yum install python-openstackclient openstack-selinux python2-PyMySQL openstack-utils -y >/dev/null 2>&1 #OpenStack客户端 39 | #yum install openstack-utils -y #openstack工具 40 | 41 | if [ $? -eq 0 ]; then 42 | echo "OpenStack clien OK" 43 | else 44 | echo "OpenStack clien NOT OK" 45 | fi 46 | sleep 5s 47 | 48 | #关闭selinux、防火墙 49 | systemctl stop firewalld.service 50 | systemctl disable firewalld.service >/dev/null 2>&1 51 | 52 | if [ $? -eq 0 ]; then 53 | echo "firewall OK" 54 | else 55 | echo "firewall NOT OK" 56 | fi 57 | sleep 5s 58 | 59 | firewall-cmd --state 60 | sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config 61 | sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config 62 | grep --color=auto '^SELINUX' /etc/selinux/config 63 | setenforce 0 64 | 65 | 66 | #vi /etc/hosts 67 | echo "10.0.3.111 baibaic baibaic.com" >> /etc/hosts 68 | echo "10.0.3.112 baibaij baibaij.com" >> /etc/hosts 69 | 70 | #cat /etc/hosts 71 | 72 | 73 | 74 | echo "baibaic" > /etc/hostname 75 | hostname baibaic 76 | 77 | #cat /etc/hostname 78 | 79 | yum install chrony -y >/dev/null 2>&1 80 | 81 | if [ $? -eq 0 ]; then 82 | echo "chrony OK" 83 | else 84 | echo "chrony NOT OK" 85 | fi 86 | 87 | #vi /etc/chrony.conf 88 | #allow 10.0.0.0/24 89 | sed -i 's@#allow 192.168.0.0/16@allow 10.0.0.0/24@g' /etc/chrony.conf 90 | 91 | 92 | timedatectl set-timezone Asia/Shanghai 93 | 94 | systemctl enable chronyd.service 95 | systemctl restart chronyd.service 96 | timedatectl set-timezone Asia/Shanghai 97 | chronyc sources 98 | 99 | echo "all ok then reboot " 100 | 101 | 102 | -------------------------------------------------------------------------------- /ico/alipay.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Alipay 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ico/alipay-1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 我要捐赠 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ico/group.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 加入QQ群 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Mysql/MYSQL_master_slave_gtid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 基于msql gtid 主从复制 3 | 先在主库上全备 4 | 参考innobackupex 5 | 6 | 7 | 主库配置: 8 | 9 | gtid_mode=on 10 | enforce_gtid_consistency=on 11 | #log_slave_updates=1 12 | 主库 13 | server_id: 设置MySQL实例的server_id,每个server_id不能一样 14 | gtid_mode=ON: MySQL实例开启GTID模式 15 | enforce_gtid_consitency=ON:使用GTID模式复制时,需要开启参数,用来保证数据的一致性。 16 | log-bin: MySQL必须要开启binlog 17 | #binlog_format=mixed: binlog格式为row 18 | #skip-slave-start=1(可选): 当SLAVE数据库启动的时候,SLAVE不会启动复制 19 | log-slave-updates=true //在从服务器进入主服务器传入过来的修改日志所使用,在Mysql5.7之前主从架构上使用gtid模式的话,必须使用此选项,在Mysql5.7取消了,会增加系统负载。 20 | master_info_repository=TABLE 21 | relay_log_info_repository=TABLE //指定中继日志的存储方式,默认是文件,这样配置是使用了 两个表,是INNODB存储引擎,好处是当出现数据库崩溃时,利用INNODE事务引擎的特点,对这两个表进行恢复,以保证从服务器可以从正确位置恢复数据。 22 | #sync-master-info=1      //同步master_info,任何事物提交以后都必须要把事务提交以后的二进制日志事件的位置对应的文件名称,记录到master_info中,下次启动自动读取,保证数据无丢失 23 | slave-parallel-workers=2      //设定从服务器的启动线程数,0表示不启动 24 | grant replication client,replication slave on *.* to baibai@'10.0.3.%' identified by 'baibai'; //ip段与账号密码 25 | flush privileges; //刷新权限 26 | 27 | 从库 28 | 29 | gtid_mode=on 30 | enforce_gtid_consistency=on 31 | log_slave_updates=1 决定SLAVE从Master接收到更新且执行是否记录到SLAVE的binlog中 32 | binlog_format=mixed 33 | master_info_repository=TABLE 34 | relay_log_info_repository=TABLE //指定中继日志的存储方式,默认是文件,这样配置是使用了 两个表,是INNODB存储引擎,好处是当出现数据库崩溃时,利用INNODE事务引擎的特点,对这两个表进行恢复,以保证从服务器可以从正确位置恢复数据。 35 | slave-parallel-workers=2 //开启线程数,0就表示禁用线程 36 | 37 | change master to master_host='10.0.3.118',master_user='baibai',master_password='baibai',master_auto_position=1; 38 | start slave; 39 | show slave status\G 40 | io sql 是不是两个ok 41 | 42 | 43 | 主从 binlog_format 设置关系 44 | 1. 主库是row,从库必须是row/mixed。如果是statement,主库有变更时,从库报如下错误(无论什么变更都报错,如insert/update/delete/alter等): 45 | Last_Error: Error executing row event: 'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.' 46 | 47 | 2. 主库是statement,从库可以是任意模式(statement/mixed/row),但可能造成数据不一致,故不建议使用。 48 | 49 | 3. 主库是mixed,从库必须是row/mixed格式。如果从库是statement,主库一般情况下修改数据,从库不报错。特殊情况下,则从库报如下错误。 50 | Last_Error: Error executing row event: 'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.' 51 | 52 | 以上所说的一般情况是:主库将binlog记录为statement格式。 53 | 以上所说的特殊情况是:主库将binlog记录为row格式。具体为以下几种: 54 | (1) 当时用UUID()函数时 55 | (2) 当一个或多个拥有AUTO_INCREMENT列的表被更新同时有‘trigger’或者‘stored function’被调用时 56 | (3) 执行INSERT DELAYED时 57 | (4) 当视图里的某一部分需要row-based复制(例如UUID())时,创建该视图的语句被改为row-based 58 | (5) 使用用户自定义函数(UDF)时 59 | (6) 当某语句被判定为row-based,并且执行它的session需要用到临时表,则session下的所有子语句都将以ROW格式记录 60 | (7) 当使用USER(),CURRENT_USER()或者 CURRENT_USER 61 | (8) 当语句引用了一个或多个system variables。 62 | (9) 当使用LOAD_FILE() 63 | -------------------------------------------------------------------------------- /openstack/Centos7-j-huanjing .bash: -------------------------------------------------------------------------------- 1 | #!bin/sh 2 | 3 | #安装 4 | yum -y install wget vim net-tools tree openssh >/dev/null 2>&1 5 | 6 | if [ $? -eq 0 ]; then 7 | echo "tools is OK" 8 | else 9 | echo "tools is NOT OK" 10 | fi 11 | sleep 5s 12 | 13 | 14 | #更换阿里源 15 | mv /etc/yum.repos.d/CentOS-Base.repo{,.bak} 16 | wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1 17 | if [ $? -eq 0 ]; then 18 | echo "aliyun yum is OK" 19 | else 20 | echo "aliyun yum is NOT OK" 21 | fi 22 | sleep 5s 23 | 24 | 25 | #安装OpenStack库 26 | yum install centos-release-openstack-rocky -y >/dev/null 2>&1 27 | #生成缓存 28 | #yum clean all && yum makecache 29 | 30 | if [ $? -eq 0 ]; then 31 | echo "centos-release-openstack-rocky OK" 32 | else 33 | echo "centos-release-openstack-rocky OK" 34 | fi 35 | sleep 5s 36 | 37 | #OpenStack客户端 38 | yum install python-openstackclient openstack-selinux python2-PyMySQL openstack-utils -y >/dev/null 2>&1 #OpenStack客户端 39 | #yum install openstack-utils -y #openstack工具 40 | 41 | if [ $? -eq 0 ]; then 42 | echo "OpenStack clien OK" 43 | else 44 | echo "OpenStack clien NOT OK" 45 | fi 46 | sleep 5s 47 | 48 | #关闭selinux、防火墙 49 | systemctl stop firewalld.service 50 | systemctl disable firewalld.service >/dev/null 2>&1 51 | 52 | if [ $? -eq 0 ]; then 53 | echo "firewall OK" 54 | else 55 | echo "firewall NOT OK" 56 | fi 57 | sleep 5s 58 | 59 | firewall-cmd --state 60 | sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config 61 | sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config 62 | grep --color=auto '^SELINUX' /etc/selinux/config 63 | setenforce 0 64 | 65 | 66 | #vi /etc/hosts 67 | echo "10.0.3.111 baibaic baibaic.com" >> /etc/hosts 68 | echo "10.0.3.112 baibaij baibaij.com" >> /etc/hosts 69 | 70 | #cat /etc/hosts 71 | 72 | 73 | 74 | echo "baibaij" > /etc/hostname 75 | hostname baibaij 76 | 77 | #cat /etc/hostname 78 | 79 | yum install chrony -y >/dev/null 2>&1 80 | 81 | if [ $? -eq 0 ]; then 82 | echo "chrony OK" 83 | else 84 | echo "chrony NOT OK" 85 | fi 86 | 87 | #vi /etc/chrony.conf 88 | #allow 10.0.0.0/24 89 | #sed -i 's@#allow 192.168.0.0/16@allow 10.0.0.0/24@g' /etc/chrony.conf 90 | sed -i 's@0.centos.pool.ntp.org@10.0.3.111@g' /etc/chrony.conf 91 | sed -i '4,6d' /etc/chrony.conf 92 | 93 | 94 | timedatectl set-timezone Asia/Shanghai 95 | 96 | systemctl enable chronyd.service 97 | systemctl restart chronyd.service 98 | timedatectl set-timezone Asia/Shanghai 99 | chronyc sources 100 | 101 | echo "all ok then reboot" 102 | 103 | sleep 10 104 | reboot 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /cobbler/CentOS-6.9-x86_64.cfg: -------------------------------------------------------------------------------- 1 | # kickstart template for Fedora 8 and later. 2 | # (includes %end blocks) 3 | # do not use with earlier distros 4 | 5 | #platform=x86, AMD64, or Intel EM64T 6 | # System authorization information 7 | #auth --useshadow --enablemd5 8 | authconfig --enableshadow --passalgo=sha512 9 | # System bootloader configuration 10 | bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet" 11 | # Partition clearing information 12 | clearpart --all --initlabel 13 | # Use text mode install 14 | text 15 | # Firewall configuration 16 | firewall --disabled 17 | # Run the Setup Agent on first boot 18 | firstboot --disable 19 | # System keyboard 20 | keyboard us 21 | # System language 22 | lang en_US 23 | # Use network installation 24 | url --url=$tree 25 | # If any cobbler repo definitions were referenced in the kickstart profile, include them here. 26 | $yum_repo_stanza 27 | # Network information 28 | $SNIPPET('network_config') 29 | # Reboot after installation 30 | reboot 31 | logging --level=info 32 | 33 | #Root password 34 | rootpw --iscrypted $default_password_crypted 35 | # SELinux configuration 36 | selinux --disabled 37 | # Do not configure the X Window System 38 | skipx 39 | # System timezone 40 | timezone Asia/Shanghai 41 | # Install OS instead of upgrade 42 | install 43 | # Clear the Master Boot Record 44 | zerombr 45 | # Allow anaconda to partition the system as needed 46 | #autopart 47 | part /boot --fstype=ext4 --asprimary --size=200 48 | part swap --asprimary --size=1024 49 | part / --fstype=ext4 --grow --asprimary --size=200 50 | 51 | %pre 52 | $SNIPPET('log_ks_pre') 53 | $SNIPPET('kickstart_start') 54 | $SNIPPET('pre_install_network_config') 55 | # Enable installation monitoring 56 | $SNIPPET('pre_anamon') 57 | %end 58 | 59 | %packages 60 | @base 61 | @compat-libraries 62 | @core 63 | @debugging 64 | @development 65 | @dial-up 66 | @hardware-monitoring 67 | @performance 68 | @server-policy 69 | sgpio 70 | device-mapper-persistent-data 71 | systemtap-client 72 | tree 73 | lrzsz 74 | telnet 75 | nmap 76 | dos2unix 77 | %end 78 | 79 | %post --nochroot 80 | $SNIPPET('log_ks_post_nochroot') 81 | %end 82 | 83 | %post 84 | $SNIPPET('log_ks_post') 85 | # Start yum configuration 86 | $yum_config_stanza 87 | # End yum configuration 88 | $SNIPPET('post_install_kernel_options') 89 | $SNIPPET('post_install_network_config') 90 | $SNIPPET('func_register_if_enabled') 91 | $SNIPPET('download_config_files') 92 | $SNIPPET('koan_environment') 93 | $SNIPPET('redhat_register') 94 | $SNIPPET('cobbler_register') 95 | # Enable post-install boot notification 96 | $SNIPPET('post_anamon') 97 | # Start final steps 98 | $SNIPPET('kickstart_done') 99 | # End final steps 100 | %end 101 | -------------------------------------------------------------------------------- /ico/npm.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | get this with npm 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Zabbix/conf/my.cnf: -------------------------------------------------------------------------------- 1 | # For advice on how to change settings please see 2 | # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html 3 | # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the 4 | # *** default location during install, and will be replaced if you 5 | # *** upgrade to a newer version of MySQL. 6 | [client] 7 | default-character-set = utf8 8 | 9 | [mysql] 10 | prompt="\u@\h \d>" 11 | no-auto-rehash 12 | default-character-set = utf8 13 | 14 | 15 | 16 | [mysqld] 17 | 18 | port = 3306 19 | user = mysql 20 | bind-address = 0.0.0.0 21 | socket = /tmp/mysql.sock 22 | basedir = /usr/local/mysql 23 | datadir = /usr/local/mysql/data 24 | #pid-file = /usr/local/mysql/data/mysql.pid 25 | server-id = 1 26 | init-connect = 'SET NAMES utf8' 27 | character-set-server = utf8 28 | skip-name-resolve 29 | explicit_defaults_for_timestamp=1 30 | back_log=300 31 | max_connections = 1000 32 | max_connect_errors = 6000 33 | open_files_limit = 65535 34 | table_open_cache = 128 35 | max_allowed_packet = 500M 36 | tmp_table_size = 64M 37 | read_buffer_size = 2M 38 | read_rnd_buffer_size = 8M 39 | sort_buffer_size = 8M 40 | join_buffer_size = 8M 41 | log_bin = mysql-bin 42 | binlog_format = mixed 43 | sync_binlog = 1 44 | expire_logs_days = 7 45 | log_error = /usr/local/mysql/data/mysql-error.log 46 | slow_query_log = 1 47 | long_query_time = 1 48 | slow_query_log_file = /usr/local/mysql/data/mysql-slow.log 49 | default_storage_engine = InnoDB 50 | innodb_file_per_table = 1 51 | innodb_open_files = 500 52 | innodb_buffer_pool_size = 5500M 53 | innodb_write_io_threads = 4 54 | innodb_read_io_threads = 4 55 | innodb_thread_concurrency = 0 56 | innodb_flush_log_at_trx_commit = 2 57 | innodb_log_buffer_size = 2M 58 | innodb_log_file_size = 200M 59 | innodb_lock_wait_timeout = 120 60 | wait_timeout = 1800 61 | #innodb_large_prefix = 1 62 | #innodb_file_format = Barracuda 63 | #innodb_file_format_max = Barracuda 64 | [mysqldump] 65 | quick 66 | max_allowed_packet = 500M 67 | # Remove leading # and set to the amount of RAM for the most important data 68 | # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 69 | # innodb_buffer_pool_size = 128M 70 | 71 | # Remove leading # to turn on a very important data integrity option: logging 72 | # changes to the binary log between backups. 73 | # log_bin 74 | 75 | # These are commonly set, remove the # and set as required. 76 | # basedir = ..... 77 | # datadir = ..... 78 | # port = ..... 79 | # server_id = ..... 80 | # socket = ..... 81 | 82 | # Remove leading # to set options mainly useful for reporting servers. 83 | # The server defaults are faster for transactions and fast SELECTs. 84 | # Adjust sizes as needed, experiment to find the optimal values. 85 | # join_buffer_size = 128M 86 | # sort_buffer_size = 2M 87 | # read_rnd_buffer_size = 2M 88 | 89 | sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 90 | -------------------------------------------------------------------------------- /ico/min-app-store.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /mogodb/install_MongoDB.sh: -------------------------------------------------------------------------------- 1 | echo never >> /sys/kernel/mm/transparent_hugepage/enabled 2 | echo never >> /sys/kernel/mm/transparent_hugepage/defrag 3 | cat /sys/kernel/mm/transparent_hugepage/enabled 4 | cat /sys/kernel/mm/transparent_hugepage/defrag 5 | wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.14.tgz --no-check-certificate 6 | tar xf mongodb-linux-x86_64-3.6.14.tgz 7 | mkdir -p /mongodb/conf /mongodb/log /mongodb/data 8 | useradd mongodb 9 | passwd mongodb 10 | cp -r /usr/local/src/mongodb-linux-x86_64-3.6.14/bin /mongodb 11 | chown -R mongodb.mongodb /mongodb 12 | su - mongodb 13 | 14 | echo 'export PATH=$PATH:/mongodb/bin' >>.bash_profile 15 | source .bash_profile 16 | 17 | echo 'export PATH=$PATH:/mongodb/bin' >>/etc/profile 18 | source /etc/profile 19 | 20 | ## 都可以 21 | 22 | vim /mongodb/conf/mongod.conf 23 | systemLog: 24 | destination: file 25 | path: "/mongodb/log/mongod.log" 26 | logAppend: true 27 | storage: 28 | journal: 29 | enabled: true 30 | dbPath: "/mongodb/data" 31 | processManagement: 32 | fork: true 33 | net: 34 | bindIp: 127.0.0.1,10.0.3.208 35 | port: 27017 36 | setParameter: 37 | enableLocalhostAuthBypass: false 38 | security: 39 | authorization: enabled 40 | 41 | mongod -f /mongodb/conf/mongod.conf --shutdown 42 | mongo -uroot -p ip/库名 43 | 44 | ps -ef | grep mongod 45 | cat /proc/13974/limits 46 | 47 | vi /etc/security/limits.conf 48 | mongod soft nofile 64000 49 | mongod hard nofile 64000 50 | mongod soft nproc 32000 51 | mongod hard nproc 32000 52 | #上面修改完还waring 改下面 53 | vim /etc/security/limits.d/90-nproc.conf 54 | * soft nproc 64000 55 | 56 | 57 | use admin 58 | db.createUser( 59 | { 60 | user: "baibai", 61 | pwd: "baibai", 62 | roles: [{ role: "root", db: "admin"}] 63 | } 64 | ) 65 | 66 | 67 | 68 | 69 | 生产配置 70 | systemLog: 71 | destination: file 72 | path: "/mongodb/log/mongod.log" 73 | logAppend: true 74 | storage: 75 | journal: 76 | enabled: true 77 | dbPath: "/mongodb/data" 78 | directoryPerDB: true 79 | wiredTiger: 80 | engineConfig: 81 | cacheSizeGB: 1 82 | directoryForIndexes: true 83 | collectionConfig: 84 | blockCompressor: zlib 85 | indexConfig: 86 | prefixCompression: true 87 | processManagement: 88 | fork: true 89 | net: 90 | bindIp: 127.0.0.1,10.0.3.208 91 | port: 27017 92 | replication: 93 | oplogSizeMB: 2048 94 | replSetName: my_repl 95 | setParameter: 96 | enableLocalhostAuthBypass: false 97 | security: 98 | authorization: enabled 99 | 100 | 101 | 102 | 103 | admin库 104 | config = {_id: "my_repl", members:[ 105 | {_id: 0, host: '你自己的ip'}, 106 | {_id: 0, host: '你自己的ip'} 107 | ]} 108 | rs.initiate(config) 109 | 110 | rs.status(); 111 | -------------------------------------------------------------------------------- /jenkins-gitlab-maven-tomcat/jenkins-gitlab.sh: -------------------------------------------------------------------------------- 1 | Deploy Keys 2 | 可以拉不可以推 enable 3 | 两个项目以上 4 | settings - repository-deploy keys 在privately点enable 5 | 6 | 如果是内网的话vim /etc/sysconfig/jenkins用root 7 | 要不然就Jenkins-凭据-系统-全局凭据 (unrestricted) 选ssh私钥 8 | 9 | 不改就用http的 在gitlab上的账号有权限就行 10 | 11 | 做免密要 之后执行shell 就ok了 12 | 13 | 备份jekins 14 | tar zcvf jenkins.tar.gz /var/lib/jenkins/ 15 | 16 | 插件:安版本发布 git parameter plugin 17 | 一般上选着 git parameter 18 | Branches to build 19 | 在源码管理上选${Tag} 20 | 21 | 触发远程构建 (例如,使用脚本) 里的 在gitlab里的hook也填一样的 22 | 插件:Build Authorization Token Root 23 | 插件:gitlab 24 | Build when a change is pushed to GitLab. GitLab webhook URL: http://10.0.3.12:8080/project/baibai_frist 25 | webhook 26 | http://ip/buildByToken/build?job=baibai_frist&token=XXXX 27 | GitLab: System Hooks 28 | jenkins:触发远程构建 (例如,使用脚本) Build when a change is pushed to GitLab. GitLab webhook URL: http://10.0.3.12:8080/project/baibai_frist 29 | 选上面这两个 30 | 31 | 32 | java 33 | yum install -y maven 34 | mvn -version 35 | 36 | Maven Integration plugin 37 | SSH plugin 38 | Pulish Over SSH 39 | 在configure里面配置 40 | hosname 写ip 41 | 42 | 43 | 调用顶端maven目标 44 | maven3 45 | clean package 46 | 47 | 执行shell 48 | case $Status in 49 | Deploy) 50 | scp target/*war tomcat@10.0.3.14:/usr/local/tomcat/webapps/ 51 | ;; 52 | RollBack) 53 | echo "test" 54 | ;; 55 | *) 56 | exit 57 | ;; 58 | esac 59 | 60 | Execute shell scrip 61 | chown -R tomcat:tomcat /usr/local/tomcat/webapps/* 62 | sh /home/tomcat/tomcat_start.sh restart 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | tomcat 启动慢 71 | vim /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/lib/security/java.security 72 | 有两种解决办法: 73 | 74 | 1)在Tomcat环境中解决 75 | 76 | 可以通过配置JRE使用非阻塞的Entropy Source。 77 | 78 | 在catalina.sh中加入这么一行: 79 | 80 | JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom" 81 | 即可。 82 | 83 | 加入后再启动Tomcat,整个启动耗时迅速下降。 84 | 85 | 2)在JVM环境中解决 86 | 87 | 打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容: 88 | 89 | securerandom.source=file:/dev/urandom 90 | 替换成 91 | 92 | securerandom.source=file:/dev/./urandom 93 | 94 | 95 | 要让tomcat支持软连接,需要在tomcat配置文件conf/context.xml里追加allowLinking="true"(tomcat8开始配置有变),具体如下配置: 96 | 97 | 98 | 99 | 100 | 101 | Tomcat 7的方案 102 | 修改 /conf/context.xml 文件,将这个: 103 | 104 | 105 | 改为: 106 | 107 | 108 | Tomcat 8&9的方案 109 | 同样是修改 /conf/context.xml 文件,在这个里面: 110 | 111 | ... 112 | 113 | 114 | 增加一行这个: 115 | 116 | 117 | 变成这样: 118 | 119 | 120 | ... 121 | 122 | 123 | 124 | 125 | 126 | Jenkins使用Git SCM的时候有一项源码库浏览器的设置,起初不知道有何用,只是看了说明大概知道是会对每次build生成changes,然后并没有告诉怎么设置,选择一种浏览器后要填一个URL,然后就各种百度谷歌没找到答案 127 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 请开始你的表演 2 | ![](https://img.shields.io/badge/linux-%E5%B8%B8%E8%A7%84%E4%B8%80%E9%94%AE%E8%84%9A%E6%9C%AC-green.svg) 3 | ![](https://img.shields.io/badge/baibai-love%20linux%20and%20sec-blue.svg) 4 | ![](https://img.shields.io/badge/%E7%89%9B%E9%80%BC-%E8%84%9A%E6%9C%AC-red.svg) 5 | ![](https://img.shields.io/badge/%E5%AE%89%E5%85%A8-%E8%84%9A%E6%9C%AC-ff69b4.svg) 6 | ![](https://img.shields.io/badge/python-%E5%AE%89%E5%85%A8%E5%92%8C%E8%BF%90%E7%BB%B4%E8%84%9A%E6%9C%AC-brightgreen.svg) 7 | ![](https://img.shields.io/badge/%E5%AE%89%E5%85%A8-%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1-yellow.svg) 8 | ![](https://img.shields.io/badge/all-%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99-yellowgreen.svg) 9 | ![](https://img.shields.io/badge/%E8%BF%90%E7%BB%B4-%E9%9D%A2%E8%AF%95%E5%92%8C%E7%AC%94%E8%AF%95%E9%A2%98%E6%B5%B7%E6%88%98%E6%9C%AF-lightgrey.svg) 10 | 11 | ## :email:Contact | 联系我: 12 | 13 | [![facebook](https://camo.githubusercontent.com/fa488d2b7f6862506b0b662e31742d5aaad5342c/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f66616365626f6f6b2e737667)]() 14 | [![qq](https://camo.githubusercontent.com/349da0d0ce5ea5ac31a8b5791498b36c1c505251/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f71712e737667)]() 15 | [![qq-group](https://camo.githubusercontent.com/69eb5b323203f279d93cd6ece3a70a4a9e0c8a59/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f67726f75702e737667)]() 16 | [![redhat](https://camo.githubusercontent.com/ae76f873ea25c1e886301f75be62d2f3329e4fe0/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f7265646861742e737667)]() 17 | [![wechat](https://camo.githubusercontent.com/013c283843363c72b1463af208803bfbd5746292/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f7765636861742e737667)]() 18 | [![weibo](https://camo.githubusercontent.com/7a7793cffd59f69a48da2f4169e6a8082a3abe51/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f776569626f2e737667)]() 19 | [![zhihu](https://camo.githubusercontent.com/0951d6e189dd4bb0c2cebfd8adefdcf34f03b2e0/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f7a686968752e737667)]() 20 | [![alipay](https://camo.githubusercontent.com/68acfcc1787dac4b9b474a5c2b44e64626511a69/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f616c697061792e737667)]() 21 | [![gitee](https://camo.githubusercontent.com/0c231595c32d70729e10155ae65894fb4c872058/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f67697465652e737667)]() 22 | [![twitter](https://camo.githubusercontent.com/f578ce3794aa505710c59152c3e406bd1382922e/687474703a2f2f6a617977636a6c6f76652e6769746875622e696f2f73622f69636f2f747769747465722e737667)]() 23 | 24 | 25 | ## :beers: | 贡献 26 | 27 | ## :busts_in_silhouette: | 贡献者 28 | :hankey: :poop: :shit: 29 | 30 | ## :lipstick: | 赞助 31 | 32 | 支付宝二维码暂时没有 :bug: 微信二维码暂时没有 :bug: 33 | 34 |

35 | 36 | 37 | 38 |

39 | 40 | 41 | 42 | 43 | 关于运维的东西 44 | -------------------------------------------------------------------------------- /ico/google+.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Google+ 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ico/email.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Email 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Nginx/proxy/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | #user nobody; 3 | worker_processes 1; 4 | 5 | #error_log logs/error.log; 6 | #error_log logs/error.log notice; 7 | #error_log logs/error.log info; 8 | 9 | #pid logs/nginx.pid; 10 | 11 | 12 | events { 13 | worker_connections 1024; 14 | } 15 | 16 | 17 | http { 18 | include mime.types; 19 | default_type application/octet-stream; 20 | 21 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 22 | '$status $body_bytes_sent "$http_referer" ' 23 | '"$http_user_agent" "$http_x_forwarded_for"'; 24 | 25 | #access_log logs/access.log main; 26 | 27 | sendfile on; 28 | #tcp_nopush on; 29 | 30 | #keepalive_timeout 0; 31 | keepalive_timeout 65; 32 | 33 | #gzip on; 34 | include /usr/local/nginx/conf.d/proxy.conf; 35 | include /usr/local/nginx/conf.d/www.baibai.com.conf; 36 | include /usr/local/nginx/conf.d/upstream.conf; 37 | # server { 38 | # listen 80; 39 | # server_name www.baibai.com; 40 | 41 | #charset koi8-r; 42 | 43 | #access_log logs/host.access.log main; 44 | 45 | # location / { 46 | # root html; 47 | # index index.html index.htm; 48 | # } 49 | 50 | #error_page 404 /404.html; 51 | 52 | # redirect server error pages to the static page /50x.html 53 | # 54 | # error_page 500 502 503 504 /50x.html; 55 | # location = /50x.html { 56 | # root html; 57 | #} 58 | 59 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80 60 | # 61 | #location ~ \.php$ { 62 | # proxy_pass http://127.0.0.1; 63 | #} 64 | 65 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 66 | # 67 | #location ~ \.php$ { 68 | # root html; 69 | # fastcgi_pass 127.0.0.1:9000; 70 | # fastcgi_index index.php; 71 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 72 | # include fastcgi_params; 73 | #} 74 | 75 | # deny access to .htaccess files, if Apache's document root 76 | # concurs with nginx's one 77 | # 78 | #location ~ /\.ht { 79 | # deny all; 80 | #} 81 | #} 82 | 83 | 84 | # another virtual host using mix of IP-, name-, and port-based configuration 85 | # 86 | #server { 87 | # listen 8000; 88 | # listen somename:8080; 89 | # server_name somename alias another.alias; 90 | 91 | # location / { 92 | # root html; 93 | # index index.html index.htm; 94 | # } 95 | #} 96 | 97 | 98 | # HTTPS server 99 | # 100 | #server { 101 | # listen 443 ssl; 102 | # server_name localhost; 103 | 104 | # ssl_certificate cert.pem; 105 | # ssl_certificate_key cert.key; 106 | 107 | # ssl_session_cache shared:SSL:1m; 108 | # ssl_session_timeout 5m; 109 | 110 | # ssl_ciphers HIGH:!aNULL:!MD5; 111 | # ssl_prefer_server_ciphers on; 112 | 113 | # location / { 114 | # root html; 115 | # index index.html index.htm; 116 | # } 117 | #} 118 | 119 | } 120 | -------------------------------------------------------------------------------- /ico/qqweibo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 腾讯微博 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ico/weibo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | WeiBo 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /笔试/linux笔试1.sh: -------------------------------------------------------------------------------- 1 | ###那些年我们为面试做的准备 2 | 3 | inode block 4 | 假设XXX产生的日志文件名为access_log,在XXX正在运行时,执行命令mv access_log access_log.bak,执行完后,请问新的XXX的日志会打印到哪里? 5 | 新的日志会在access_log.bak中,因为XXX启动时会找access_log文件,随时准备向文件中加入日志信息,虽然此时文件被改名,但是由于服务正在运行,因为它的inode节点的位置没有变,程序打开的fd仍然会指向原来那个inode 6 | 不会因为文件名的改变而改变.XXX会继续向已改名的文件中追加日志,但是若重启apache服务,系统会检查access_log文件是否存在,若不存在则创建. 7 | 在XXX运行时 rm -fr access_log 空间不会释放 正确的是>access_log 重定向 清空日志而不是在运行中删除日志 8 | ln 软硬链接 9 | 软链接可以跨文件系统 ,硬链接不可以。软链接可以对目录进行链接,硬链接不可以。 10 | 区别: 11 | 软链接文件的大小和创建时间和源文件不同。软链接文件只是维持了从软链接到源文件的指向关系(从jys.soft->jys可以看出),不是源文件的内容,大小不一样容易理解。 12 | 硬链接文件和源文件的大小和创建时间一样。硬链接文件的内容和源文件的内容一模一样,相当于copy了一份。 13 | 14 | 15 | 简单awk 16 | 在Shell环境下,如何查看远程Linux系统运行了多少时间? 17 | uptime | awk '{print $3}' 18 | 简单的几个命令 19 | uptime w last 20 | 21 | 22 | 处理以下文件内容,将域名取出并进行计数排序,如处理: http://www.baidu.com/more/ 23 | http://www.baidu.com/guding/more.html 24 | http://www.baidu.com/events/20060105/photomore.html 25 | http://hi.baidu.com/browse/ 26 | http://www.sina.com.cn/head/www20021123am.shtml 27 | http://www.sina.com.cn/head/www20041223am.shtml 28 | 29 | 得到如下结果: 30 | 域名的出现的次数 域名 31 | 3 www.baidu.com 32 | 2 www.sina.com.cn 33 | 1 hi.baidu.co 百度总喜欢这种题目,我上篇日志的site inurl也是,这个是统计域名的,还有一个说是统计文件名的,就是后面的index没有的就直接为空,这个用shell怎么实现还在思考中,想出来了再写 34 | cat file | sed -e ' s/http:\/\///' -e ' s/\/.*//' | uniq -c | sort -rn 35 | awk -F/ '{print $3}' file |uniq -c | sort -r |awk '{print $1"\t",$2}' 36 | 37 | 38 | 39 | 180.153.205.103 - - [03/Jul/2013:15:13:59 +0800] GET /wp-login.php?redirect_to=http%3A%2F%2Fdemo.catjia.com%2Fwp-admin%2Foptions-general.php&reauth=1 HTTP/1.1 200 2269 - Mozilla/4.0 - 40 | 101.226.51.227 - - [03/Jul/2013:15:14:07 +0800] GET /wp-admin/options-general.php?settings-updated=true HTTP/1.1 302 0 - Mozilla/4.0 - 41 | 101.226.51.227 - - [03/Jul/2013:15:14:07 +0800] GET /wp-login.php?redirect_to=http%3A%2F%2Fdemo.catjia.com%2Fwp-admin%2Foptions-general.php%3Fsettings-updated%3Dtrue&reauth=1 HTTP/1.1 200 2291 - Mozilla/4.0 - 42 | 43 | 44 | 统计 45 | awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' log/visit.log 46 | 2 180.153.205.103 47 | 10 101.226.33.200 48 | 1 180.153.114.199 49 | 1 113.110.176.131 50 | 2 101.226.51.227 51 | 52 | 53 | 对统计结果排序 54 | awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' log/visit.log | sort 55 | 1 113.110.176.131 56 | 1 180.153.114.199 57 | 10 101.226.33.200 58 | 2 101.226.51.227 59 | 2 180.153.205.103 60 | 61 | 62 | sort默认是升序的,10竟然没有排在最后,原来sort默认对一行的首字母进行排序 63 | 需要加入其它参数 -t 指定分隔符 -k 指定列 -g 按照常规数值排序 -n 根据字符串数值比较 64 | awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' log/visit.log | sort -t " " -k 1 -n 65 | 1 113.110.176.131 66 | 1 180.153.114.199 67 | 2 101.226.51.227 68 | 2 180.153.205.103 69 | 10 101.226.33.200 70 | 71 | 72 | 改为降序 -r 73 | awk '{a[$1]+=1;} END {for(i in a){print a[i]" "i;}}' log/visit.log | sort -t " " -k 1 -n -r 74 | 10 101.226.33.200 75 | 2 180.153.205.103 76 | 2 101.226.51.227 77 | 1 180.153.114.199 78 | 1 113.110.176.131 79 | 80 | 告诉我那些是进程后又问如何查看一个进程所使用的文件句柄? 81 | 82 | /proc/进程号/fd/的个数就行了 83 | 84 | ps aux | grep “nginx” | grep -v “grep” | wc -l 85 | 86 | /proc/sys 子目录的作用 87 | 88 | 该子目录的作用是报告各种不同的内核参数,并让您能交互地更改其中的某些。与 /proc 中所有其他文件不同,该目录中的某些文件可以写入 89 | 90 | sed '$!N;s/\n/ /g' test^C 91 | [root@kvm ~]# sed ':a;N;$!ba;s/\n/ /g' test 92 | 93 | sed 删除换行符 94 | 95 | sed ':label;N;s/\n/:/;b label' filename 96 | sed ':label;N;s/\n/:/;t label' filename 97 | 98 | 99 | 上面的两条命令可以实现将文件中的所有换行符替换为指定的字串,如命令中的冒号。命令的解释: 100 | 101 | :label; 这是一个标签,用来实现跳转处理,名字可以随便取(label),后面的b label就是跳转指令 102 | N; N是sed的一个处理命令,追加文本流中的下一行到模式空间进行合并处理,因此是换行符可见 103 | s/\n/:/; s是sed的替换命令,将换行符替换为冒号 104 | b label 或者 t label b / t 是sed的跳转命令,跳转到指定的标签处 105 | 106 | 107 | 108 | tr "\n" " " < file.txt 109 | 110 | a.将所有奇数行和偶数行合并,就是去奇数行的换行符了哦 111 | 112 | sed ‘$!N;s/\n/ /g’ test 113 | b.就是去第二行的了哦 114 | 115 | sed -n -e 2p -e 3p test | sed ‘$!N;s/\n/ /g’ test 116 | -------------------------------------------------------------------------------- /ico/58.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 58同城 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /cobbler/面试相关理论知识: -------------------------------------------------------------------------------- 1 | 使用 Cobbler,您无需进行人工干预即可安装机器。Cobbler 设置一个 PXE 引导环境(它还可使用yaboot 支持 PowerPC),并控制与安装相关的所有方面,比如网络引导服务(DHCP 和 TFTP)与存储库镜像。当希望安装一台新机器时,Cobbler 可以: 2 | 3 | 使用一个以前定义的模板来配置 DHCP 服务(如果启用了管理 DHCP) 4 | 5 | 将一个存储库(yum 或 rsync)建立镜像或解压缩一个媒介,以注册一个新操作系统 6 | 7 | 在 DHCP 配置文件中为需要安装的机器创建一个条目,并使用您指定的参数(IP 和 MAC 地址) 8 | 9 | 在 TFTFP 服务目录下创建适当的 PXE 文件 10 | 11 | 重新启动 DHCP 服务以反映更改 12 | 13 | 重新启动机器以开始安装(如果电源管理已启用) 14 | 15 | 16 | 17 | Cobbler加载 18 | 19 | Server端: 20 | 21 | 第一步,启动Cobbler服务 22 | 第二步,进行Cobbler错误检查,执行cobbler check命令 23 | 第三步,进行配置同步,执行cobbler sync命令 24 | 第四步,复制相关启动文件文件到TFTP目录中 25 | 第五步,启动DHCP服务,提供地址分配 26 | 第六步,DHCP服务分配IP地址 27 | 第七步,TFTP传输启动文件 28 | 第八步,Server端接收安装信息 29 | 第九步,Server端发送ISO镜像与Kickstart文件 30 | Client端: 31 | 32 | 第一步,客户端以PXE模式启动 33 | 第二步,客户端获取IP地址 34 | 第三步,通过TFTP服务器获取启动文件 35 | 第四步,进入Cobbler安装选择界面 36 | 第五步,客户端确定加载信息 37 | 第六步,根据配置信息准备安装系统 38 | 第七步,加载Kickstart文件 39 | 第八步,传输系统安装的其它文件 40 | 第九步,进行安装系统 41 | 42 | pxe 原理 43 | 事实上把PXE称作是一种引导方式而不是安装方式似乎更加准确,PXE(Pre-boot Execution Environment)是由Intel设计的协议,它可以使计算机通过网络启动,但是有一个前提条件是计算机的网卡必须具有引导功能,这个网卡中要有一个PXE客户端。当计算机POST自检成功以后,BIOS把网卡中ROM的PXE客户端调入内存执行,PXE客户端通过网络中的DHCP服务器获取一个IP地址,拿到IP地址以后PXE继续引导计算机与网络中的TFTP客户端建立连接,从而从TFTP服务器中获取开机引导文件之后请求并下载安装需要的文件。在这个过程中需要一台服务器来提供启动文件、安装文件、以及安装过程中的自动应答文件等。 44 | 原理介绍 45 | 46 | Client向PXE Server上的DHCP发送IP地址请求消息,DHCP检测Client是否合法(主要是检测Client的网卡MAC地址),如果合法则返回Client的IP地址,同时将启动文件pxelinux.0的位置信息一并传送给Client 47 | Client向PXE Server上的TFTP发送获取pxelinux.0请求消息,TFTP接收到消息之后再向Client发送pxelinux.0大小信息,试探Client是否满意,当TFTP收到Client发回的同意大小信息之后,正式向Client发送pxelinux.0 48 | Client执行接收到的pxelinux.0文件 49 | Client向TFTP Server发送针对本机的配置信息文件(在TFTP服务的pxelinux.cfg目录下,这是系统菜单文件,格式和isolinux.cfg格式一样,功能也是类似),TFTP将配置文件发回Client,继而Client根据配置文件执行后续操作。 50 | Client向TFTP发送Linux内核请求信息,TFTP接收到消息之后将内核文件发送给Client 51 | Client向TFTP发送根文件请求信息,TFTP接收到消息之后返回Linux根文件系统 52 | Client启动Linux内核 53 | Client下载安装源文件,读取自动化安装脚本 54 | 55 | 56 | Cobbler工作流程 57 | 58 | client裸机配置了从网络启动后,开机后会广播包请求DHCP服务器 (cobbler server)发送其分配好的一个IP 59 | DHCP服务器(cobbler server)收到请求后发送responese,包括其ip地址 60 | client裸机拿到ip后再向cobbler server发送请求OS引导文件的请求 61 | cobbler server告诉裸机OS引导文件的名字和TFTP server的ip和 port 62 | client裸机通过上面告知的TFTP server地址通信,下载引导文件 63 | client裸机执行执行该引导文件,确定加载信息,选择要安装的os, 期间会再向cobbler server请求kickstart文件和os image 64 | cobbler server发送请求的kickstart和os iamge 65 | client裸机加载kickstart文件 66 | client裸机接收os image,安装该os image 67 | 68 | 69 | Cobbler集成的服务 70 | PXE服务支持 71 | DHCP服务管理 72 | DNS服务管理(可选bind,dnsmasq) 73 | 电源管理 74 | Kickstart服务支持 75 | YUM仓库管理 76 | TFTP(PXE启动时需要) 77 | Apache(提供kickstart的安装源,并提供定制化的kickstart配置) 78 | 3.4配置目录 79 | 配置文件目录: 80 | /etc/cobbler 81 | /etc/cobbler/settings : cobbler 主配置文件 82 | /etc/cobbler/iso/: iso模板配置文件 83 | /etc/cobbler/pxe: pxe模板文件 84 | /etc/cobbler/power: 电源配置文件 85 | /etc/cobbler/user.conf: web服务授权配置文件 86 | /etc/cobbler/users.digest: web访问的用户名密码配置文件 87 | /etc/cobbler/dhcp.template : dhcp服务器的的配置末班 88 | /etc/cobbler/dnsmasq.template : dns服务器的配置模板 89 | /etc/cobbler/tftpd.template : tftp服务的配置模板 90 | /etc/cobbler/modules.conf : 模块的配置文件 91 | 数据目录: 92 | /var/lib/cobbler/config/: 用于存放distros,system,profiles 等信 息配置文件 93 | /var/lib/cobbler/triggers/: 用于存放用户定义的cobbler命令 94 | /var/lib/cobbler/kickstart/: 默认存放kickstart文件 95 | /var/lib/cobbler/loaders/: 存放各种引导程序  镜像目录 96 | /var/www/cobbler/ks_mirror/: 导入的发行版系统的所有数据 97 | /var/www/cobbler/images/ : 导入发行版的kernel和initrd镜像用于 远程网络启动 98 | /var/www/cobbler/repo_mirror/: yum 仓库存储目录 99 | 日志目录: 100 | /var/log/cobbler/installing: 客户端安装日志 101 | /var/log/cobbler/cobbler.log : cobbler日志 102 | 103 | 命令介绍 104 | cobbler commands介绍 105 | cobbler check 核对当前设置是否有问题 106 | cobbler list 列出所有的cobbler元素 107 | cobbler report 列出元素的详细信息 108 | cobbler sync 同步配置到数据目录,更改配置最好都要执行下 109 | cobbler reposync 同步yum仓库 110 | cobbler distro 查看导入的发行版系统信息 111 | cobbler system 查看添加的系统信息 112 | cobbler profile 查看配置信息 113 | 114 | /etc/cobbler/settings中重要的参数设置 115 | default_password_crypted: "$1$gEc7ilpP$pg5iSOj/mlxTxEslhRvyp/" 116 | manage_dhcp:1 117 | manage_tftpd:1 118 | pxe_just_once:1 119 | next_server:< tftp服务器的 IP 地址> 120 | server: 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /ico/xunlei.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 迅雷 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Centos7/内核高并发: -------------------------------------------------------------------------------- 1 | PS:在服务器硬件资源额定有限的情况下,最大的压榨服务器的性能,提高服务器的并发处理能力,是很多运维技术人员思考的问题。要提高Linux系统下的负载能力,可以使用nginx等原生并发处理能力就很强的web服务器,如果使用Apache的可以启用其Worker模式,来提高其并发处理能力。除此之外,在考虑节省成本的情况下,可以修改Linux的内核相关TCP参数,来最大的提高服务器性能。当然,最基础的提高负载问题,还是升级服务器硬件了,这是最根本的。 2 | 3 | Linux系统下,TCP连接断开后,会以TIME_WAIT状态保留一定的时间,然后才会释放端口。当并发请求过多的时候,就会产生大量的TIME_WAIT状态的连接,无法及时断开的话,会占用大量的端口资源和服务器资源。这个时候我们可以优化TCP的内核参数,来及时将TIME_WAIT状态的端口清理掉。 4 | 5 | 本文介绍的方法只对拥有大量TIME_WAIT状态的连接导致系统资源消耗有效,如果不是这种情况下,效果可能不明显。可以使用netstat命令去查TIME_WAIT状态的连接状态,输入下面的组合命令,查看当前TCP连接的状态和对应的连接数量: 6 | #netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’ 7 | 这个命令会输出类似下面的结果: 8 | LAST_ACK 16 9 | SYN_RECV 348 10 | ESTABLISHED 70 11 | FIN_WAIT1 229 12 | FIN_WAIT2 30 13 | CLOSING 33 14 | TIME_WAIT 18098 15 | 我们只用关心TIME_WAIT的个数,在这里可以看到,有18000多个TIME_WAIT,这样就占用了18000多个端口。要知道端口的数量只有65535个,占用一个少一个,会严重的影响到后继的新连接。这种情况下,我们就有必要调整下Linux的TCP内核参数,让系统更快的释放TIME_WAIT连接。 16 | 17 | 用vim打开配置文件:#vim /etc/sysctl.conf 18 | 19 | 在这个文件中,加入下面的几行内容: 20 | net.ipv4.tcp_syncookies = 1 21 | net.ipv4.tcp_tw_reuse = 1 22 | net.ipv4.tcp_tw_recycle = 1 23 | net.ipv4.tcp_fin_timeout = 30 24 | 25 | 输入下面的命令,让内核参数生效:#sysctl -p 26 | 27 | 简单的说明上面的参数的含义: 28 | 29 | net.ipv4.tcp_syncookies = 1 30 | #表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭; 31 | net.ipv4.tcp_tw_reuse = 1 32 | #表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭; 33 | net.ipv4.tcp_tw_recycle = 1 34 | #表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭; 35 | net.ipv4.tcp_fin_timeout 36 | #修改系統默认的 TIMEOUT 时间。 37 | 38 | 在经过这样的调整之后,除了会进一步提升服务器的负载能力之外,还能够防御小流量程度的DoS、CC和SYN攻击。 39 | 40 | 此外,如果你的连接数本身就很多,我们可以再优化一下TCP的可使用端口范围,进一步提升服务器的并发能力。依然是往上面的参数文件中,加入下面这些配置: 41 | net.ipv4.tcp_keepalive_time = 1200 42 | net.ipv4.ip_local_port_range = 10000 65000 43 | net.ipv4.tcp_max_syn_backlog = 8192 44 | net.ipv4.tcp_max_tw_buckets = 5000 45 | #这几个参数,建议只在流量非常大的服务器上开启,会有显著的效果。一般的流量小的服务器上,没有必要去设置这几个参数。 46 | 47 | net.ipv4.tcp_keepalive_time = 1200 48 | #表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟。 49 | net.ipv4.ip_local_port_range = 10000 65000 50 | #表示用于向外连接的端口范围。缺省情况下很小:32768到61000,改为10000到65000。(注意:这里不要将最低值设的太低,否则可能会占用掉正常的端口!) 51 | net.ipv4.tcp_max_syn_backlog = 8192 52 | #表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。 53 | net.ipv4.tcp_max_tw_buckets = 6000 54 | #表示系统同时保持TIME_WAIT的最大数量,如果超过这个数字,TIME_WAIT将立刻被清除并打印警告信息。默 认为180000,改为6000。对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量,但是对于 Squid,效果却不大。此项参数可以控制TIME_WAIT的最大数量,避免Squid服务器被大量的TIME_WAIT拖死。 55 | 56 | 内核其他TCP参数说明: 57 | net.ipv4.tcp_max_syn_backlog = 65536 58 | #记录的那些尚未收到客户端确认信息的连接请求的最大值。对于有128M内存的系统而言,缺省值是1024,小内存的系统则是128。 59 | net.core.netdev_max_backlog = 32768 60 | #每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。 61 | net.core.somaxconn = 32768 62 | #web应用中listen函数的backlog默认会给我们内核参数的net.core.somaxconn限制到128,而nginx定义的NGX_LISTEN_BACKLOG默认为511,所以有必要调整这个值。 63 | 64 | net.core.wmem_default = 8388608 65 | net.core.rmem_default = 8388608 66 | net.core.rmem_max = 16777216 #最大socket读buffer,可参考的优化值:873200 67 | net.core.wmem_max = 16777216 #最大socket写buffer,可参考的优化值:873200 68 | net.ipv4.tcp_timestsmps = 0 69 | #时间戳可以避免序列号的卷绕。一个1Gbps的链路肯定会遇到以前用过的序列号。时间戳能够让内核接受这种“异常”的数据包。这里需要将其关掉。 70 | net.ipv4.tcp_synack_retries = 2 71 | #为了打开对端的连接,内核需要发送一个SYN并附带一个回应前面一个SYN的ACK。也就是所谓三次握手中的第二次握手。这个设置决定了内核放弃连接之前发送SYN+ACK包的数量。 72 | net.ipv4.tcp_syn_retries = 2 73 | #在内核放弃建立连接之前发送SYN包的数量。 74 | #net.ipv4.tcp_tw_len = 1 75 | net.ipv4.tcp_tw_reuse = 1 76 | # 开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接。 77 | 78 | net.ipv4.tcp_wmem = 8192 436600 873200 79 | # TCP写buffer,可参考的优化值: 8192 436600 873200 80 | net.ipv4.tcp_rmem = 32768 436600 873200 81 | # TCP读buffer,可参考的优化值: 32768 436600 873200 82 | net.ipv4.tcp_mem = 94500000 91500000 92700000 83 | # 同样有3个值,意思是: 84 | net.ipv4.tcp_mem[0]:低于此值,TCP没有内存压力。 85 | net.ipv4.tcp_mem[1]:在此值下,进入内存压力阶段。 86 | net.ipv4.tcp_mem[2]:高于此值,TCP拒绝分配socket。 87 | 上述内存单位是页,而不是字节。可参考的优化值是:786432 1048576 1572864 88 | 89 | net.ipv4.tcp_max_orphans = 3276800 90 | #系统中最多有多少个TCP套接字不被关联到任何一个用户文件句柄上。 91 | 如果超过这个数字,连接将即刻被复位并打印出警告信息。 92 | 这个限制仅仅是为了防止简单的DoS攻击,不能过分依靠它或者人为地减小这个值, 93 | 更应该增加这个值(如果增加了内存之后)。 94 | net.ipv4.tcp_fin_timeout = 30 95 | #如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间。对端可以出错并永远不关闭连接,甚至意外当机。缺省值是60秒。2.2 内核的通常值是180秒,你可以按这个设置,但要记住的是,即使你的机器是一个轻载的WEB服务器,也有因为大量的死套接字而内存溢出的风险,FIN- WAIT-2的危险性比FIN-WAIT-1要小,因为它最多只能吃掉1.5K内存,但是它们的生存期长些。 96 | 97 | 经过这样的优化配置之后,你的服务器的TCP并发处理能力会显著提高。以上配置仅供参考,用于生产环境请根据自己的实际情况。 98 | -------------------------------------------------------------------------------- /ico/csdn.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Nginx/内核参数优化: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | # Close SELINUX 5 | setenforce 0 6 | sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config 7 | 8 | 9 | # /etc/security/limits.conf 10 | [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf 11 | sed -i '/^# End of file/,$d' /etc/security/limits.conf 12 | cat >> /etc/security/limits.conf < /etc/sysconfig/modules/iptables.modules; chmod +x /etc/sysconfig/modules/iptables.modules; } 27 | #modprobe nf_conntrack 28 | #modprobe nf_conntrack_ipv4 29 | #echo options nf_conntrack hashsize=131072 > /etc/modprobe.d/nf_conntrack.conf 30 | 31 | # /etc/sysctl.conf 32 | [ ! -e "/etc/sysctl.conf_bk" ] && /bin/mv /etc/sysctl.conf{,_bk} 33 | cat > /etc/sysctl.conf << EOF 34 | fs.file-max=1000000 35 | net.ipv4.tcp_max_tw_buckets = 6000 36 | #timewait的数量,默认是180000。超过这个数字立刻被清除并打印警告信息,避免被大量套接字拖死 37 | net.ipv4.tcp_sack = 1 38 | #使用 Selective ACK﹐它可以用来查找特定的遗失的数据报--- 因此有助于快速恢复状态。该文件表示是否启用有选择的应答(Selective Acknowledgment),这可以通过有选择地应答乱序接收到的报文来提高性能(这样可以让发送者只发送丢失的报文段)。(对于广域网通信来说这个选项应该启用,但是这会增加对 CPU 的占用。) 39 | net.ipv4.tcp_window_scaling = 1 40 | net.ipv4.tcp_rmem = 4096 87380 4194304 41 | 发送缓存设置 42 | 43 | #min:为TCP socket预留用于发送缓冲的内存最小值。每个tcp socket都可以在建议以后都可以使用它。默认值为4096(4K)。 44 | 45 | #default:为TCP socket预留用于发送缓冲的内存数量,默认情况下该值会影响其它协议使用的net.core.wmem_default 值,一般要低于net.core.wmem_default的值。默认值为16384(16K)。 46 | 47 | #max: 用于TCP socket发送缓冲的内存最大值。该值不会影响net.core.wmem_max,"静态"选择参数SO_SNDBUF则不受该值影响。默认值为131072(128K)。(对于服务器而言,增加这个参数的值对于发送数据很有帮助,在我的网络环境中,修改为了51200 131072 204800) 48 | net.ipv4.tcp_wmem = 4096 16384 4194304 49 | net.ipv4.tcp_max_syn_backlog = 16384 50 | net.core.netdev_max_backlog = 32768 51 | net.core.somaxconn = 32768 52 | net.core.wmem_default = 8388608 53 | net.core.rmem_default = 8388608 54 | net.core.rmem_max = 16777216 55 | net.core.wmem_max = 16777216 56 | net.ipv4.tcp_timestamps = 1 57 | net.ipv4.tcp_fin_timeout = 20 58 | net.ipv4.tcp_synack_retries = 2 59 | net.ipv4.tcp_syn_retries = 2 60 | net.ipv4.tcp_syncookies = 1 61 | #net.ipv4.tcp_tw_len = 1 62 | net.ipv4.tcp_tw_reuse = 1 63 | net.ipv4.tcp_mem = 94500000 915000000 927000000 64 | net.ipv4.tcp_max_orphans = 3276800 65 | net.ipv4.ip_local_port_range = 1024 65000 66 | net.nf_conntrack_max = 6553500 67 | net.netfilter.nf_conntrack_max = 6553500 68 | #net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60 69 | #net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120 70 | #net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120 71 | #net.netfilter.nf_conntrack_tcp_timeout_established = 3600 72 | EOF 73 | sysctl -p 74 | 75 | 76 | 个人建议 如下就够了 小公司 77 | net.ipv4.tcp_fin_timeout = 20-30 78 | 影响fin_wait-2的时间,主要防止对端出错并永远不关闭连接,甚至意外当机。 79 | 80 | net.ipv4.tcp_syncookies = 1 81 | 其实没啥大用 防止syn等待队列溢出 能防住一点syn攻击 82 | 83 | net.ipv4.tcp_keepalive_time = 30-1200 84 | 当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时。 85 | 86 | net.ipv4.tcp_tw_reuse = 1 87 | 开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接。这个的开 快速回收就不要开了 88 | 89 | net.ipv4.ip_local_port_range = 10000 65000 90 | 这个是你连别人 不是别人连你的 反向代理的时候用的上 有的用1024 我感觉10000保险点 就像网上很多都说要开快速回收一样 出问题不好复现 嘻嘻 91 | 92 | net.core.netdev_max_backlog = 32768 建议一半吧 不调问题也不大 93 | 每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目,对重负载服务器而言,该值需要调高一点。默认1024 94 | net.core.somaxconn = 32768 建议一半吧 不调问题也不大 95 | 用来限制监听(LISTEN)队列最大数据包的数量,超过这个数量就会导致链接超时或者触发重传机制。web应用中listen函数的backlog默认会给我们内核参数的net.core.somaxconn限制到128,而nginx定义的NGX_LISTEN_BACKLOG默认为511,所以有必要调整这个值。对繁忙的服务器,增加该值有助于网络性能 96 | 97 | net.ipv4.tcp_max_syn_backlog = 8192-65535 98 | 表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。 99 | net.ipv4.tcp_max_tw_buckets = 6000-36000 100 | 表示系统同时保持TIME_WAIT的最大数量,如果超过这个数字,TIME_WAIT将立刻被清除并打印警告信息。默 认为180000,改为6000。 101 | timewait的数量,默认是180000。超过这个数字立刻被清除并打印警告信息,避免被大量套接字拖死 102 | 103 | 看看是不是你改的 sysctl -p 让他生效 104 | cat /proc/sys/net/ipv4/tcp_max_tw_buckets 105 | 9000 106 | 107 | 108 | 109 | 110 | 111 | . /etc/profile 112 | --------------------------------------------------------------------------------