自动化运维平台BigOps

能解决什么问题

一、统一认证

已经整合了Zabbix、Jira、Confluence、Jenkins和Gitlab,如果你现在也在使用这些开源软件,那么恭喜你,可以和BigOps无缝整合,只需要打个Patch即可轻松接入。

二、如果你已经有了LDAP,可以接入你的认证系统

三、个人桌面,为每个用户定制自己的桌面,千人千面,相当每个人拥有了一个MAC OS的操作系统。

四、消息,管理员可以给普通用户发消息,系统也可以给管理员或者普通用户发消息。

六、资源管理(CMDB),主机配置全自动化更新,准确率99%,并可以进行资产的全生命周期管理。

资源使用模型和实例的方式进行管理,随心所欲定制资源表单。
资源实例,支持导入、导出、,自定义显示列,批量修改和删除等操作
资源详情,清晰的显示资源所有信息及变更信息,主机和硬件可以自动化更新,无需人工参与。
七、强大的IP地址管理,让你轻松掌握IP使用情况
八、主机自动发现,自动发现公有云和指定网段新接入的主机。
九、公有云导入,支持阿里云、腾讯云、Ucloud、金山云自动导入和手动导入
十、hostmin,包括主机系统管理和系统备份等
十一、全面整合Zabbix
自动和zabbix主机关联
十二、监控大屏、包括主机状态、IP状态和zbx接口
已开发的功能还包括会话管理、硬件端口管理、硬件位置管理、用户权限、主机系统管理、主机系统备份等功能、等等20多个功能等你慢慢发掘。

官网http://www.bigops.com/
http://docs.bigops.com/ke-hu-an-li.html
源码地址https://github.com/yunweibang

环境准备

硬件配置

建议物理内存8G+、CPU 4 cores+、硬盘20G+。

操作系统

CentOS 7 x86 64位

服务对应端口

在这里插入图片描述

2个域名

sso.xxxx.com,用于统一认证

work.xxxx.com,用于主站

如果没有注册域名,需要给服务器和笔记本都配置hosts。

Linux位置/etc/hosts。

Windows位置C:\Windows\System32\drivers\etc\hosts,如果不能直接编辑,可以先拷贝到桌面,编辑完在拷贝回原位置。

配置内容,例如:

10.10.100.39 sso.bigops.com (换成你服务器IP和你自己的域名)

10.10.100.39 work.bigops.com (换成你服务器IP和你自己的域名)

切记2个域名都要设置!切记!切记!切记!

切记服务器和你的笔记本都要设置!切记!切记!切记!

[root@bigops ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.100.39 sso.bigops.com
10.10.100.39 work.bigops.com
127.0.0.1 bigops

主机名可以ping通
查看主机名

hostname

ping主机名

ping xxxxxxx

如果能ping通就是正常,如果ping不通就需要在/etc/hosts里加一行

127.0.0.1 xxxxxxx(换成你服务器的主机名)

[root@bigops ~]# ping bigops
PING bigops (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.029 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.034 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.035 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.093 ms
[root@bigops ~]# ping  sso.bigops.com
PING sso.bigops.com (10.10.100.39) 56(84) bytes of data.
64 bytes from sso.bigops.com (10.10.100.39): icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from sso.bigops.com (10.10.100.39): icmp_seq=2 ttl=64 time=0.094 ms
64 bytes from sso.bigops.com (10.10.100.39): icmp_seq=3 ttl=64 time=0.034 ms
[root@bigops ~]# ping work.bigops.com
PING work.bigops.com (10.10.100.39) 56(84) bytes of data.
64 bytes from sso.bigops.com (10.10.100.39): icmp_seq=1 ttl=64 time=0.028 ms
64 bytes from sso.bigops.com (10.10.100.39): icmp_seq=2 ttl=64 time=0.034 ms
64 bytes from sso.bigops.com (10.10.100.39): icmp_seq=3 ttl=64 time=0.032 ms

初始化环境

[root@bigops ~]# cd ~
[root@bigops ~]# wget -O centos_init_env.sh https://raw.githubusercontent.com/yunweibang/bigops-install/master/centos_init_env.sh
[root@bigops ~]#sh centos_init_env.sh
---------------------------------
Successful initialization
---------------------------------
#!/bin/sh

alias rm=rm
alias cp=cp
alias mv=mv

#关闭selinux
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

#修改yum超时时间
sed -i '/timeout=.*/d' /etc/yum.conf
echo 'timeout=60' >>/etc/yum.conf

#关闭防火墙
if [ -f /usr/bin/systemctl ];then
    systemctl disable iptables
    systemctl stop iptables
    systemctl disable firewalld
    systemctl stop firewalld
else
    chkconfig --level 345 iptables off
    service iptables stop
fi

#关闭NOZEROCONF
sed -i '/NOZEROCONF.*/d' /etc/sysconfig/network
echo "NOZEROCONF=yes" >> /etc/sysconfig/network

#关闭NM
sed -i 's#.*NM_CONTROLLED=.*#NM_CONTROLLED="no"#g' /etc/sysconfig/network-scripts/ifcfg-*

#删除mcelog
rm -f /etc/cron.hourly/mcelog.cron

#关闭发邮件
if [ -z "$(egrep MAILCHECK /etc/profile)" ];then
    echo 'unset MAILCHECK'>>/etc/profile
fi
sed -i "s/^MAILTO=.*/MAILTO=\"\"/g" /etc/crontab

#关闭远程sudo执行命令需要输入密码和没有终端不让执行命令问题
sed -i 's/Defaults *requiretty/#Defaults requiretty/g' /etc/sudoers
sed -i 's/Defaults *!visiblepw/Defaults   visiblepw/g' /etc/sudoers
yum -y install wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#rpm -Uvh --force https://buildlogs.centos.org/c7.1708.00/centos-release/20170830155132/7-4.1708.el7.centos.x86_64/centos-release-7-4.1708.el7.centos.x86_64.rpm
if [ $? != 0 ];then
    echo ---------------------------------
    echo "cannot access raw.githubusercontent.com"
    echo ---------------------------------
    exit
fi
#wget -O /etc/yum.repos.d/epel.repo https://raw.githubusercontent.com/yunweibang/yum.repos.d/master/epel.repo
yum  -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget -O /etc/yum.repos.d/remi.repo https://raw.githubusercontent.com/yunweibang/yum.repos.d/master/remi.repo
wget -O /etc/yum.repos.d/nginx.repo https://raw.githubusercontent.com/yunweibang/yum.repos.d/master/nginx.repo
yum -y update
yum -y install ansible apr apr-devel apr-util autoconf automake bison bzip2 clang curl dos2unix expat-devel \
freerdp freerdp-devel fping flex gcc gcc-c++ g++ git \
java-1.8.0-openjdk java-1.8.0-openjdk-devel java-1.8.0-openjdk-headless java-1.8.0-openjdk-accessibility \
kde-l10n-Chinese libssh2 libssh2-devel libtool* libpcap-dev masscan make \
net-tools nginx ntpdate nmap ntsysv nodejs npm openssl openssl-devel openssl-libs pam-devel perl perl-devel \
subversion subversion-devel sysstat systemd-devel screen tomcat-native traceroute vim zlib-devel


if [ -f /usr/bin/systemctl ];then
    for i in $(systemctl list-unit-files|egrep 'enabled'|awk '{print $1}'|egrep -v '\.target$|@\.');do
        systemctl disable $i
    done
    systemctl enable mysqld.service
    systemctl enable nginx.service
    systemctl enable php-fpm.service
    systemctl enable postfix.service
    systemctl enable bigweb.service
    systemctl enable bigserver.service
    systemctl enable gitlab-runner.service
    systemctl enable gitlab-runsvdir.service
    systemctl enable zabbix-agent.service
    systemctl enable zabbix-server.service
    systemctl enable es.service
    systemctl enable kibana.service
    systemctl enable es-head.service
    systemctl enable cerebro.service
systemctl enable auditd.service
    systemctl enable crond.service
    systemctl enable rhel-autorelabel.service
    systemctl enable rhel-configure.service
    systemctl enable rhel-loadmodules.service
    systemctl enable rhel-readonly.service
    systemctl enable rsyslog.service
    systemctl enable sshd.service
    systemctl set-default multi-user.target
    echo 'LANG="zh_CN.UTF-8"'>/etc/locale.conf
    wget -O /etc/systemd/system.conf https://raw.githubusercontent.com/yunweibang/bigops-install/master/system.conf
else
    for i in $(ls /etc/rc3.d/S*|cut -c 15-|egrep -v local);do
        chkconfig --level 345 $i off
    done
    chkconfig --level 345 mysqld on
    chkconfig --level 345 nginx on
    chkconfig --level 345 php-fpm on
    chkconfig --level 345 postfix on
    chkconfig --level 345 bigweb on
    chkconfig --level 345 bigserver on
    chkconfig --level 345 gitlab-runner on
    chkconfig --level 345 gitlab-runsvdir on
    chkconfig --level 345 zabbix-agent on
    chkconfig --level 345 zabbix-server on
    chkconfig --level 345 es on
    chkconfig --level 345 kibana on
    chkconfig --level 345 es-head on
    chkconfig --level 345 cerebro on

    chkconfig --level 345 sysstat on
    chkconfig --level 345 network on
    chkconfig --level 345 rsyslog on
    chkconfig --level 345 haldaemon on
    chkconfig --level 345 crond on
    chkconfig --level 345 auditd on
    chkconfig --level 345 messagebus on
    chkconfig --level 345 udev-post on
    chkconfig --level 345 sshd on
    sed -i 's/^id:.*/id:3:initdefault:/g' /etc/inittab
 yum -y groupinstall chinese-support
    echo 'LANG="zh_CN.UTF-8"'>/etc/sysconfig/i18n
    echo 'SUPPORTED="zh_CN.UTF-8:zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"'>>/etc/sysconfig/i18n
    echo 'SYSFONT="lat0-sun16"'>>/etc/sysconfig/i18n
fi

rm -f /etc/security/limits.d/*
wget -O /etc/security/limits.conf https://raw.githubusercontent.com/yunweibang/bigops-install/master/limits.conf
wget -O /etc/security/limits.d/90-nproc.conf https://raw.githubusercontent.com/yunweibang/bigops-install/master/90-nproc.conf

wget -O /etc/sysctl.conf https://raw.githubusercontent.com/yunweibang/bigops-install/master/sysctl.conf

sed -i '/ \/ .* defaults /s/defaults/defaults,noatime,nodiratime,nobarrier/g' /etc/fstab
sed -i 's/tmpfs.*/tmpfs\t\t\t\/dev\/shm\t\ttmpfs\tdefaults,nosuid,noexec,nodev 0 0/g' /etc/fstab

cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

if [ -z "$(grep ntpdate /var/spool/cron/root)" ];then
    echo '* */6 * * * /usr/sbin/ntpdate -u pool.ntp.org && /sbin/hwclock --systohc > /dev/null 2>&1'>>/var/spool/cron/root
fi

wget -O /bin/clean_mail.sh https://raw.githubusercontent.com/yunweibang/bigops-install/master/clean_mail.sh
if [ -f /bin/clean_mail.sh ];then
    if [ -z "$(grep /bin/clean_mail.sh /var/spool/cron/root)" ];then
        echo '* */6 * * * /bin/sh /bin/clean_mail.sh > /dev/null 2>&1'>>/var/spool/cron/root
    fi
fi

for i in $(ls /sys/class/net|egrep -v 'lo|usb') ; do ethtool -K $i tso off; done
for i in $(ls /sys/class/net|egrep -v 'lo|usb') ; do ethtool -K $i gso off; done
for i in $(ls /sys/class/net|egrep -v 'lo|usb') ; do ethtool -K $i gro off; done

wget -O /etc/ansible/ansible.cfg https://raw.githubusercontent.com/yunweibang/bigops-install/master/ansible.cfg

if [ -e /usr/lib/jvm/java ];then
    sed -i '/^export JAVA_HOME=.*/g' /etc/profile
    sed -i '/^export PATH=$JAVA_HOME.*/g' /etc/profile
    sed -i '/^export CLASSPATH=.*/g' /etc/profile
    echo 'export JAVA_HOME=/usr/lib/jvm/java'>>/etc/profile
    echo 'export PATH=$JAVA_HOME/bin:$PATH:/usr/local/sbin:/usr/local/bin'>>/etc/profile
    echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'>>/etc/profile
fi
sed -ie '/^$/{N;/\n$/D};' /etc/profile
source /etc/profile

if [ -d /usr/local/lib ];then
    echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
    ldconfig
fi

if [ -d /usr/local/lib ];then
    echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
    ldconfig
fi

if [ ! -f /usr/bin/systemctl ];then
    yum -y install telnet-server telnet xinetd
    wget -O /etc/xinetd.d/telnet https://raw.githubusercontent.com/yunweibang/bigops-install/master/telnet
    chkconfig telnet on
    chkconfig xinetd on
    service xinetd start
    if [ -f /etc/securetty ];then
        mv /etc/securetty /etc/securetty.bak
    fi
    cd ~
    if [ -z "$(openssl version|egrep 1.0.2s)" ];then
        if [ ! -f openssl-1.0.2s.tar.gz ];then
            wget -c https://www.openssl.org/source/openssl-1.0.2s.tar.gz
        fi
        if [ -d openssl-1.0.2s ];then
            rm -rf openssl-1.0.2s
        fi
        tar zxvf openssl-1.0.2s.tar.gz
        cd openssl-1.0.2s
        ./config --prefix=/usr shared zlib
        make clean && make && make install
        if [ $? != 0 ];then
            echo ---------------------------------
            echo "install openssl, failed"
            echo ---------------------------------
            exit
      fi
     cd ~
        rm -rf openssl-1.0.2s
    fi

    cd ~
    if [ -z "$(strings /usr/sbin/sshd | grep OpenSSH_8.0p1)" ];then
        if [ ! -f openssh-8.0p1.tar.gz ];then
            wget -c https://cloudflare.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
        fi
        if [ -d openssh-8.0p1 ];then
            rm -rf openssh-8.0p1
        fi
        tar zxvf openssh-8.0p1.tar.gz
        cd openssh-8.0p1
        chmod -R 0600 /etc/ssh/
        ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords --without-openssl-header-check
        make clean && make && make install
        if [ $? != 0 ];then
            echo ---------------------------------
            echo "install openssh, failed"
            echo ---------------------------------
            exit
        fi
        cp -f ssh_config /etc/ssh/ssh_config
        echo 'StrictHostKeyChecking no' >>/etc/ssh/ssh_config
        echo 'UserKnownHostsFile=/dev/null'>>/etc/ssh/ssh_config
        cp -f sshd_config /etc/ssh/sshd_config
        sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
        sed -i 's/^GSSAPIAuthentication/#GSSAPIAuthentication no/g' /etc/ssh/sshd_config
        sed -i 's/^GSSAPICleanupCredentials/#GSSAPICleanupCredentials no/g' /etc/ssh/sshd_config
        if [ ! -z $(/usr/sbin/sshd -t -f /etc/ssh/sshd_config) ];then
            echo ---------------------------------
            echo 'install openssh failed, please run /usr/sbin/sshd -t -f /etc/ssh/sshd_config'
            echo ---------------------------------
            exit
        fi
        cd ~
        rm -rf openssh-8.0p1
    fi
fi

sed -i 's/^[ ]*StrictHostKeyChecking.*/StrictHostKeyChecking no/g' /etc/ssh/ssh_config

export JAVA_HOME=/usr/lib/jvm/java
export PATH=$JAVA_HOME/bin:$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/lib64:/lib64
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

cd ~
if [ ! -f /usr/local/apr/lib/libtcnative-1.a ];then
    if [ ! -f apr-1.6.5.tar.gz ];then
        wget -c http://archive.apache.org/dist/apr/apr-1.6.5.tar.gz
    fi
    if [ -d apr-1.6.5 ];then
        rm -rf apr-1.6.5
    fi
    tar zxvf apr-1.6.5.tar.gz
    cd apr-1.6.5
    ./configure --prefix=/usr/local/apr
    make clean && make && make install
    if [ $? != 0 ];then
        echo ---------------------------------
        echo "install apr, failed"
        echo ---------------------------------
        exit
    fi

    cd ~
    rm -rf apr-1.6.5

    if [ ! -f apr-util-1.6.1.tar.gz ];then
        wget -c http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.gz
    fi
    if [ -d apr-util-1.6.1 ];then
        rm -rf apr-util-1.6.1
    fi
    tar zxvf apr-util-1.6.1.tar.gz
    cd apr-util-1.6.1
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    make clean && make && make install
    if [ $? != 0 ];then
        echo ---------------------------------
        echo "install apr-util, failed"
        echo ---------------------------------
        exit
    fi

    cd ~
    rm -rf apr-util-1.6.1

    if [ ! -f tomcat-native-1.2.23-src.tar.gz ];then
        wget -c http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-connectors/native/1.2.23/source/tomcat-native-1.2.23-src.tar.gz
    fi
    if [ -d tomcat-native-1.2.23-src ];then
        rm -rf tomcat-native-1.2.23-src
    fi
    tar zxvf tomcat-native-1.2.23-src.tar.gz
    cd tomcat-native-1.2.23-src/native/
    ./configure --with-apr=/usr/local/apr --with-java-home=/usr/lib/jvm/java
    make clean && make && make install
    if [ $? != 0 ];then
        echo ---------------------------------
        echo "install tomcat-native, failed"
        echo ---------------------------------
        exit
    fi
fi

medusainst(){
    cd ~
    if [ ! -f libssh2-1.8.2.tar.gz ];then
        wget -c https://github.com/yunweibang/bigops-install/raw/master/soft/libssh2-1.8.2.tar.gz
    fi
    if [ -d libssh2-1.8.2 ];then
        rm -rf libssh2-1.8.2
    fi
    tar zxvf libssh2-1.8.2.tar.gz
    cd libssh2-1.8.2
    ./configure
    make clean && make && make install
    if [ $? != 0 ];then
        echo ---------------------------------
        echo "install libssh2, failed"
        echo ---------------------------------
        exit
    fi  
    cp -fs /usr/local/lib/libssh2.* /lib/
    cp -fs /usr/local/lib/libssh2.* /lib64/
    
    cd ~
    if [ ! -f medusa-2.2.tar.gz ];then
        wget -c https://github.com/yunweibang/bigops-install/raw/master/soft/medusa-2.2.tar.gz
    fi  
    if [ -d medusa-2.2 ];then
        rm -rf medusa-2.2
    fi  
    tar zxvf medusa-2.2.tar.gz
    cd medusa-2.2
    ./configure --enable-module-ssh=yes
    make clean && make && make install
    if [ $? != 0 ];then
        echo ---------------------------------
        echo "install medusa, failed"
        echo ---------------------------------
        exit
    fi  
    if [ -f /usr/local/bin/medusa ];then
        ln -sf /usr/local/bin/medusa /usr/bin/medusa
    fi  
    
}

if [ ! -f /usr/bin/medusa ];then
    medusainst
else
    if [ -z "$(/usr/bin/medusa -d|grep ssh.mod)" ];then
        medusainst
    fi
    if [ -z "$(/usr/bin/medusa -V|grep v2.2)" ];then
        medusainst
    fi
fi
if [ -z "$(/usr/bin/nmap -V|grep 7.80)" ];then
    cd ~
    if [ ! -f nmap-7.80.tgz ];then
        wget -c https://github.com/yunweibang/bigops-install/raw/master/soft/nmap-7.80.tgz
    fi
    if [ -d nmap-7.80 ];then
        rm -rf nmap-7.80
    fi
    tar zxvf nmap-7.80.tgz
    cd nmap-7.80
    ./configure
    make clean && make && make install
    if [ $? != 0 ];then
        echo ---------------------------------
        echo "install nmap, failed"
        echo ---------------------------------
        exit
    fi
    if [ -f /usr/local/bin/nmap ];then
        ln -sf /usr/local/bin/nmap /usr/bin/nmap
    fi
fi

if [ ! -f /usr/bin/jq-linux64 ];then
    wget -O /usr/bin/jq-linux64 https://github.com/yunweibang/bigops-install/raw/master/soft/jq-linux64
    chmod 777 /usr/bin/jq-linux64
fi
if [ -z "$(/usr/bin/jq-linux64 -V|grep ^jq-1.6)" ];then
    wget -O /usr/bin/jq-linux64 https://github.com/yunweibang/bigops-install/raw/master/soft/jq-linux64
    chmod 777 /usr/bin/jq-linux64
fi
ln -sf /usr/bin/jq-linux64 /usr/bin/jq

if [ ! -d /opt/ngxlog/ ];then
    mkdir /opt/ngxlog
fi
if [ -d openssl-1.0.2s ];then
    rm -rf openssl-1.0.2s
fi
if [ -d openssh-8.0p1 ];then
    rm -rf openssh-8.0p1
fi
if [ -d apr-1.6.5 ];then
    rm -rf apr-1.6.5
fi
if [ -d apr-util-1.6.1 ];then
    rm -rf apr-util-1.6.1
fi
if [ -d tomcat-native-1.2.23-src ];then
    rm -rf tomcat-native-1.2.23-src
fi
if [ -d libssh2-1.8.2 ];then
    rm -rf libssh2-1.8.2
fi
if [ -d medusa-2.2 ];then
    rm -rf medusa-2.2
fi
if [ -d nmap-7.80 ];then
    rm -rf nmap-7.80
fi

echo
echo ---------------------------------
echo 'Successful initialization'
echo ---------------------------------
echo

关闭ipv6(可选)

编辑/etc/default/grub,在GRUB_CMDLINE_LINUX的值里添加ipv6.disable=1

[root@bigops ~]# vim /etc/default/grub 
添加下面内容
GRUB_CMDLINE_LINUX="ipv6.disable=1 crashkernel=auto rhgb quiet idle=halt biosdevname=0 net.ifnames=0 console=tty0 console=ttyS0,115200n8 noibrs"

再运行命令
[root@bigops ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
[root@bigops ~]# reboot

重启系统

[root@bigops ~]# reboot

查看openssh版本是否大于5.6

[root@bigops ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017

获取安装包

百度盘

地址:https://pan.baidu.com/s/1y8JyQJIUWnzDiH0fX2EpcQ

密码:76cm

解压安装包

把下载的bigops-1.0.3.tar.gz文件放到/opt目录,然后解压

[root@bigops opt]# tar -xf bigops-1.0.3.tar.gz 

安装MySQL 5.7

编译安装mysql

检查是否有安装mysql数据库

[root@bigops ~]# rpm -qa |grep mysql
[root@bigops ~]# rpm -qa | grep mariadb
[root@bigops ~]# yum -y  remove `rpm -qa | grep mariadb`

解决依赖

[root@bigops ~]# yum install -y  gcc-c++ ncurses-devel perl-Data-Dumperpython-devel openssl openssl-devel
[root@bigops ~]#yum -y install perl perl-devel autoconf
[root@bigops ~]#yum -y install zlib zlib-devel cmake ncurses ncurses-devel bison bison-devel

安装boost
如果安装的MySQL5.7及以上的版本,在编译安装之前需要安装boost,因为高版本mysql需要boots库的安装才可以正常运行。否则会报CMake Error at cmake/boost.cmake:81错误
下载boost

[root@bigops ~]# wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
[root@bigops ~]#tar -xf boost_1_59_0.tar.gz  -C /usr/local/
[root@bigops ~]# mv /usr/local/boost_1_59_0/ /usr/local/boost

在预编译安装MySQL时要加上-DWITH_BOOST=/usr/local/boost
下载mysql

[root@bigops ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.28.tar.gz 

解压到指定目录

[root@bigops ~]# tar -xf mysql-5.7.28.tar.gz -C /usr/local && cd /usr/local/src/mysql-5.7.28

创建mysql运行用户

[root@bigops mysql-5.7.28]# useradd -M -s /sbin/nologin mysql  
 **预编译**
[root@bigops mysql-5.7.28]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  \
> -DWITH_BOOST=/usr/local/boost \
> -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_EXTRA_CHARSETS=all \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DWITH_INNODB_MEMCACHED=1 \
> -DWITH_DEBUG=OFF \
> -DWITH_ZLIB=bundled \
> -DENABLED_LOCAL_INFILE=1 \
> -DENABLED_PROFILING=ON \
> -DMYSQL_MAINTAINER_MODE=OFF \
> -DMYSQL_TCP_PORT=3306  \
> -DMYSQL-USER=mysql

编译&安装

[root@bigops mysql-5.7.28]# make -j `grep processor /proc/cpuinfo | wc -l` && make install

配置文件

[root@bigops mysql-5.7.28]# mkdir -p /usr/local/mysql/{data,tmp,run}
[root@bigops mysql-5.7.28]# chown -R mysql.mysql /usr/local/mysql/
[root@bigops ~]# vim /etc/my.cnf 

[client]
default-character-set=utf8mb4
port=3306
socket=/usr/local/mysql/run/mysql.sock

[mysql]
default-character-set=utf8mb4

[mysqld]
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
init_connect='SET collation_connection = utf8_unicode_ci'

datadir=/usr/local/mysql/data
socket=/usr/local/mysql/run/mysql.sock
port = 3306

lower_case_table_names=0
#skip-grant-tables

skip_ssl
explicit_defaults_for_timestamp=1

#open_files_limit=65535

back_log = 1024
host_cache_size=0

skip-external-locking
skip-name-resolve

max_allowed_packet = 512M

table_open_cache = 1000
table_definition_cache = 1024
table_open_cache_instances = 64

sort_buffer_size = 4M
join_buffer_size = 4M

read_buffer_size = 128M
read_rnd_buffer_size = 128M

thread_cache_size = 768
thread_stack = 512K
 
 tmp_table_size = 32M
max_heap_table_size = 32M

interactive_timeout=2147483
wait_timeout=2147483

max_connections=5000
max_connect_errors=100000

expire_logs_days=2

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

innodb_data_file_path=ibdata1:10M:autoextend
innodb_buffer_pool_size=2G
innodb_log_file_size=512M
innodb_log_buffer_size=8M
innodb_log_files_in_group=3
innodb_flush_log_at_trx_commit=1
innodb_flush_method=O_DIRECT
innodb_file_per_table=1
innodb_open_files=1000
innodb_lock_wait_timeout=120
innodb_thread_concurrency=0

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

#[safe_mysqld]
#log-error=/usr/local/mysql/tmp/mysqld.log
#pid-file=/usr/local/mysql/run/mysqld.pid
                                             

优化MySQL,修改/etc/my.cnf里innodb_buffer_pool_size的值,用命令计算:

说明:BigOps系统占用4G,所以innodb_buffer_pool_size等于总内存减去4G后的70%到80%

[root@bigops ~]# free -g|egrep -i ^mem|awk '{if($2<7) print "memory is too small";else print int(($2-4)*0.8)"G"}'
8G

比如上面命令返回8G,就这样设置:
innodb_buffer_pool_size=8G

修改启动脚本

[root@bigops ~]# cp /usr/local/src/mysql-5.7.28/support-files/mysql.server /etc/init.d/mysqld
[root@bigops ~]# vim /etc/init.d/mysqld 
//更改启动脚本中指定mysql位置
 basedir=
datadir=
#修改为
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

初始化数据库

[root@bigops ~]# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --initialize-insecure
2019-11-14T08:06:24.443956Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
 100 200 300 400 500
 100 200 300 400 500
 100 200 300 400 500
2019-11-14T08:06:27.482847Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-11-14T08:06:27.581551Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-11-14T08:06:27.647980Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a8a56070-06b5-11ea-9e2f-000c292ea40a.
2019-11-14T08:06:27.649304Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-11-14T08:06:27.748872Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

配置mysql服务

添加到系统服务

[root@bigops ~]# chkconfig --add mysqld

设置开机自启

[root@bigops ~]# chkconfig mysqld on
[root@bigops ~]# service mysqld start

设置环境变量

[root@bigops mysql-5.7.28]# vim /etc/profile
添加下面的内容到最后
export PATH=/usr/local/mysql/bin:$PATH
保存退出
[root@bigops mysql-5.7.28]# source /etc/profile

登录服务,设置密码

[root@localhost mysql-5.7.28]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.28 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password for root@localhost =password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

退出用新密码登录

mysql> exit
Bye
[root@localhost mysql-5.7.28]# mysql -uroot -p'Admin123!@#'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

修改root@localhost密码,your_password改成你的密码
mysql> grant all privileges on *.* to "root"@"localhost" identified with mysql_native_password by'123456';
Query OK, 0 rows affected, 2 warnings (0.00 sec)

mysql>use mysql;
添加root@127.0.0.1用户,your_password改成你的密码。重要!重要!重要!
mysql> grant all privileges on *.* to "root"@"127.0.0.1" identified with mysql_native_password by'123456';
    
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> create database bigops;
Query OK, 1 row affected (0.01 sec)

重启MySQL

安装nginx

编译安装Nginx

安装包下载,开源的软件包,选择稳定版本既可

[root@bigops ~]# wget  http://nginx.org/download/nginx-1.16.1.tar.gz
[root@bigops ~]# wget https://ftp.pcre.org/pub/pcre/pcre-8.37.tar.gz

解压安装包

[root@bigops ~]# tar -xf pcre-8.37.tar.gz -C /usr/local/src/
[root@bigops ~]# tar -xf nginx-1.16.1.tar.gz -C /usr/local/src/

编译

[root@bigops ~]# cd /usr/local/src/nginx-1.16.1/
[root@bigops nginx-1.16.1]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-pcre=/usr/local/src/pcre-8.37

安装

[root@bigops nginx-1.16.1]# make -j `grep processor /proc/cpuinfo | wc -l` && make install

创建用于运行的用户nginx

[root@bigops nginx-1.16.1]# useradd -M -s /sbin/nologin -u 1500  nginx
[root@bigops nginx-1.16.1]# vim /usr/local/nginx/conf/nginx.conf
user  nginx  nginx;  #程序运行的属主与属组
....
....
......

启动nginx

[root@bigops nginx-1.16.1]# /usr/local/nginx/sbin/nginx 
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

查看进程

[root@bigops nginx-1.16.1]# ps -aux |grep nginx
root       1065  0.0  0.0  46448     4 ?        Ss   15:18   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx      1066  0.0  0.0  46856   224 ?        S    15:18   0:00 nginx: worker process
root      83631  0.0  0.0 112712   964 pts/0    S+   16:54   0:00 grep --color=auto nginx

配置环境变量

[root@bigops nginx-1.16.1]# vim /etc/profile
export PATH=/usr/local/nginx/sbin:$PATH
[root@bigops nginx-1.16.1]# source /etc/profile

安装bigops

运行安装脚本
[root@bigops ~]# cd /opt/bigops-1.0.3/install/
[root@bigops install]# sh install.sh

根据提示填写相关信息,设置完后服务会自动启动。

dbhost不要填localhost,填127.0.0.1或对应IP

[root@bigops install]# sh install.sh 

数据库设置
----------------------------------
please input sso url, default sso.bigops.com
>sso.bigops.com
please input home url, default work.bigops.com
>work.bigops.com
please input db host, default 127.0.0.1
>127.0.0.1
please input db port, default 3306
>3306
please input db name, default bigops
>bigops
please input db user, default root
>root
please input db pass
>123456
Do you really want to drop the 'bigops' database [y/N] y   #删除已有的数据库   
Database "bigops" dropped
test command
mysql -uroot -p123456 -h127.0.0.1 -P3306    #测试命令,用于排错

出现下面的信息就安装成功了

已创建的库和表,用于排错
----------------------------------
Display installed database
+-------------------+
| Database (bigops) |
+-------------------+
| bigops            |
+-------------------+
+--------------------------------+
| Tables_in_bigops (%egistered%) |
+--------------------------------+
| RegexRegisteredService         |
| RegexRegisteredServiceProperty |
| RegisteredServiceImplContact   |
| RegisteredServiceImpl_Props    |
| RegisteredService_Contacts     |
+--------------------------------+
---------------------------------
database connection error, exit
test the current configuration command: mysql -uroot -p123456 -h127.0.0.1 -P3306 -e "use bigops"
check the database configuration file: /opt/bigops/config/bigops.properties
---------------------------------

start bigserver ......

---------------------------------
installation success
---------------------------------

BigOps系统会被安装到/opt/bigops目录

检查数据库大小写敏感
bigops库这几个表名必须驼峰命名(大小写组合),如果表名都是小写就有问题
在这里插入图片描述

检查服务是否启动

[root@bigops install]# ps -aux |grep java
root      5761  0.4  0.9 5016036 148308 pts/1  Sl   02:59   0:03 /opt/bigops/java/bin/java -jar -Xms1G -Xmx1G /opt/bigops/bin/bigserver.jar
root      5935  0.0  0.0 112728   968 pts/1    S+   03:12   0:00 grep --color=auto java

检查Nginx域名是否配置正确

[root@bigops install]# cat /etc/nginx/conf.d/sso.conf
[root@bigops install]# cat /etc/nginx/conf.d/work.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rio520

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值