分类 运维 下的文章

一、安装docker
yum install docker
service docker start
chkconfig docker on

docker images

二、清除既往数据
杀死所有正在运行的容器
docker kill $(docker ps -a -q)

删除所有已经停止的容器
docker rm $(docker ps -a -q)

删除所有镜像
docker rmi $(docker images -q)

其他命令
docker stop mysql-server
docker rm mysql-server
docker ps
docker images

三、安装mysql
https://hub.docker.com/r/mysql/mysql-server/
docker pull mysql/mysql-server:5.7.22-1.1.5

四、配置mysql
docker启动
docker run -it --name mysql-server -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=zabbix -e MYSQL_PASSWORD=zabbix -e MYSQL_DATABASE=zabbix -d mysql/mysql-server:5.7.22-1.1.5 --character-set-server=utf8 --collation-server=utf8_general_ci

进入shell
docker exec -it mysql-server bash

修改配置
yum install vim -y
vim /etc/my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password

修改权限
select host, user from mysql.user;
GRANT ALL PRIVILEGES ON . TO 'zabbix'@'%';
flush privileges;

重启
exit
docker restart mysql-server

修改密码
docker exec -it mysql-server bash
mysqladmin -uroot -proot password root
mysqladmin -uzabbix -pzabbix password zabbix

五、确认mysql
docker logs mysql-server
mysql -uzabbix -h 47.74.242.58 -pzabbix

六、安装zabbix-server
https://hub.docker.com/r/zabbix/
docker pull zabbix/zabbix-server-mysql:centos-3.4.*

七、配置zabbix-server
docker run --name zabbix-server -p 10051:10051 -e DB_SERVER_HOST="47.74.242.58" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e MYSQL_DATABASE='zabbix' -d zabbix/zabbix-server-mysql:latest

八、确认zabbix-server
docker ps
docker logs zabbix-server
docker exec -it zabbix-server bash

九、安装zabbix-web
https://hub.docker.com/r/zabbix/zabbix-web-nginx-mysql/
docker pull zabbix/zabbix-web-nginx-mysql:centos-3.4-latest

十、配置zabbix-web
docker run --name zabbix-web -p 80:80 --link mysql-server:mysql-server --link zabbix-server:zabbix-server -e DB_SERVER_HOST="47.74.242.58" -e MYSQL_USER="zabbix" -e MYSQL_PASSWORD="zabbix" -e ZBX_SERVER_HOST="47.74.242.58" -e PHP_TZ="Asia/Shanghai" -d zabbix/zabbix-web-nginx-mysql:centos-3.4-latest

十一、登录
Admin/zabbix

十二、客户端配置
windows
下载
https://www.zabbix.com/download_agents

修改
zabbix_agentd.win.conf

Server=svn.wisq.cn(服务器)
ServerActive=svn.wisq.cn(服务器)
Hostname=127.0.0.1(最好是本机IP)

安装服务
cd C:zabbix
zabbix_agentd.exe -i -c zabbix_agentd.win.conf

启动服务
services.msc

10053错误

linux
https://www.zabbix.com/download
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install zabbix-agent
rpm -ql zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf

配置防火墙
vi /etc/sysconfig/iptables
-A INPUT -s 58.48.186.194 -m state --state NEW -m tcp -p tcp --dport 10050:10051 -j ACCEPT
-A INPUT -s 58.48.186.194 -m state --state NEW -m udp -p udp --dport 10050:10051 -j ACCEPT

安装中文语言包
yum reinstall kde-l10n-Chinese -y
yum reinstall glibc-common -y
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
locale -a

增加中文字体
从主机复制到容器sudo docker cp host_path containerID:container_path
从容器复制到主机sudo docker cp containerID:container_path host_path
docker cp msyh.ttf zabbix-web:/usr/share/zabbix/fonts
cd /usr/share/zabbix/fonts
vim /usr/share/zabbix/include/defines.inc.php

docker cp zabbix-web:/usr/share/zabbix/include/defines.inc.php defines.inc.php

拷贝出来替换如下两处(DejaVuSans.ttf或graphfont.ttf)
define('ZBX_GRAPH_FONT_NAME','msyh'); // font file name
define('ZBX_FONT_NAME', msyh');

docker cp defines.inc.php zabbix-web:/usr/share/zabbix/include/defines.inc.php

安装邮件告警
yum install sendmail -y
yum install mailx -y
service sendmail restart
service mailx restart

十三、备份及回复
docker ps
容器保存为镜像
docker commit -p mysql-server mysql-server
docker commit -p zabbix-server zabbix-server
docker commit -p zabbix-web zabbix-web
docker images

镜像保存到本地
docker save -o mysql-server.tar mysql-server
docker save -o zabbix-server.tar zabbix-server
docker save -o zabbix-web.tar zabbix-web

加载本地镜像
docker load -i mysql-server.tar

1 添加icon
build/usr/themes/default/header.php中添加

< link rel="shortcut icon" href="/usr/themes/default/favicon.ico"type="image/x-icon" />

2 添加外链
新页面中添加

<script>window.location.href = "https://baidu.com"</script>

或者打开新的窗口

<script>window.open('https://baidu.com')</script>

1 更新yum
yum update -y

2 新建用户
useradd -d /home/huchangyi -m huchangyi

修改用户密码
passwd huchangyi

3 安装ftp
yum install vsftpd
systemctl enable vsftpd
systemctl restart vsftpd

4 安装php
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php72w
yum -y install php72w-common php72w-fpm php72w-opcache php72w-gd php72w-mysqlnd php72w-mbstring php72w-pecl-redis php72w-pecl-memcached php72w-devel php72w-embedded php72w-cli php72w-pdo php72w-xml
systemctl enable php-fpm
systemctl restart php-fpm

5 安装nginx
yum list |grep nginx
yum install nginx
systemctl enable nginx
systemctl restart nginx

6 安装mysql
查看最新的源
https://dev.mysql.com/downloads/repo/yum/

下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装mysql-community-release-el7-5.noarch.rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql57-community-release-el7-11.noarch.rpm

安装这个包后,会获得两个mysql的yum repo源
/etc/yum.repos.d/mysql-community.repo
/etc/yum.repos.d/mysql-community-source.repo

安装
yum -y install mysql-server

重置mysql密码
mysql -u root
use mysql;
delete from user where user=”;
update user set password=password(‘huchangyi′) where user=’root’;
GRANT ALL ON . TO root@’%’;
FLUSH PRIVILEGES;
select user,host,password from user;
exit;

重启
systemctl restart mysqld
systemctl enable mysqld

7 下载wordpress
cd /home/huchangyi
wget https://cn.wordpress.org/latest-zh_CN.zip
解压
unzip huchangyi.zip

8 配置nginx
vim /etc/nginx/conf.d/huchangyi.conf
内容如下:
server {

listen 80;
#listen 443 ssl;
server_name  huchangyi.com wp.huchangyi.com;
#ssl_certificate   /etc/nginx/conf.d/214616336130727.pem;
#ssl_certificate_key  /etc/nginx/conf.d/214616336130727.key;
#ssl_session_timeout 5m;
#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#ssl_prefer_server_ciphers on;

#charset koi8-r;
#access_log  /var/log/nginx/host.access.log  main;

location / {
    root   /home/huchangyi/wordpress;
    index  index.html index.htm index.php;
    if (!-d $request_filename){
    set $rule_0 1$rule_0;
    }
    if ($rule_0 = "1"){
    rewrite ^/(.*)/$ /$1 permanent;
    }
    if (!-d $request_filename){
    set $rule_1 1$rule_1;
    }
    if (!-f $request_filename){
    set $rule_1 2$rule_1;
    }
    if ($rule_1 = "21"){
    rewrite ^/ /index.php last;
    }
}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {
    root           /home/huchangyi/wordpress;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
    }

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}

}