ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
#### MegaCLI ##### [感谢《天高任鸟飞》的整理](http://blog.chinaunix.net/uid-25135004-id-3139293.html "感谢《天高任鸟飞》") >个人理解:MegaCLI我一般用来查看和监控,如果真的涉及到硬盘操作,我会使用"MegaRaid_Server_Manager",有兴趣的同学可以了解下,基本原理是在服务器安装服务,启动端口。在Windows上部署管理软件,我处理过硬盘替换后没有加入RAID的情况,需要手动清理RAID信息并加入。 ```shell #硬盘型号 /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep 'Inquiry Data' # 硬盘错误 /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep 'Count' # 硬盘状态(在线,下线) /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep 'Firmware state' ``` 监控脚本框架,发现后调用接口报警 ```shell #!/bin/bash #check raid disk status MEGACLI="/opt/MegaRAID/MegaCli/MegaCli64 " $MEGACLI -pdlist -aALL | grep "Firmware state" | awk -F : '{print $2}' | awk -F , '{print $1}' >/tmp/fireware.log $MEGACLI -pdlist -aALL | grep -E "Media Error|Other Error" | awk -F : '{print $2}' >/tmp/disk.log for i in `cat < /tmp/disk.log` do if [ $i -ne 0 ] then curl "http://xxxxxxB&state=ALARM&description=raid_disk_error" fi done for i in `cat < /tmp/fireware.log` do if [ $i != Online ] then curl "http://xxxxxxstate=ALARM&description=raid_disk_offline" fi done ``` #### CetnOS 6 部署gem ``` yum install libyaml-devel libyaml #需要gem 1.9版本,yum 一般只到1.8 cd /opt/ wget https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p551.tar.gz tar xzf ruby-1.9.3-p551.tar.gz && cd ruby-1.9.3-p551 ./configure --enable-shared make && make install # 修改源 gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ ``` #### FPM制作rpm包 ``` # 安装fpm yum install ruby-devel rubygems-devel openssl-devel rpm-build # gem部署请查看上一章节 gem install fpm ``` 制作nginx包 ``` # 安装依赖 yum install openssl-devel pcre-devel pcre gcc zlib -y ./configure --prefix=/usr/local/nginx --user=nobody --group=nobody --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-pcre --add-module=/opt/lnmp/nginx-http-concat-master --add-module=/opt/lnmp/echo-nginx-module-0.61 --add-module=/opt/lnmp/ngx_http_substitutions_filter_module-master --add-module=/opt/lnmp/nginx-plugin-master make ``` 这里要注意了,不要正常make install 这里需要安装到一个打包目录,fpm会根据编译参数去安装 ``` mkdir /opt/rpm_tmp/ make install DESTDIR=/opt/rpm_tmp/ ``` 准备脚本 ``` # 卸载脚本 # cat /tmp/remove_after.sh #!/bin/bash rm -rf /usr/local/nginx ``` #### Nodejs 12.14部署 ``` cd /opt/ wget https://nodejs.org/dist/v12.14.0/node-v12.14.0-linux-x64.tar.xz xz -d node-v12.14.0-linux-x64.tar.xz tar xf node-v12.14.0-linux-x64.tar mv node-v12.14.0-linux-x64 /usr/local/ ln -s node-v12.14.0-linux-x64 nodejs ln -s /usr/local/nodejs/bin/node /usr/bin/node ln -s /usr/local/nodejs/bin/npm /usr/bin/npm # 修改taobao源 npm config set registry https://registry.npm.taobao.org # 升级npm npm install -g npm # 安装淘宝cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org ln -s /usr/local/nodejs/bin/cnpm /usr/bin/cnpm ``` #### Centos7 puppeteer依赖 ``` # centos6比较折腾,放弃了 yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc ``` #### Ruby 2.5.1部署 ``` wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz tar xvf ruby-2.5.1.tar.gz cd ruby-2.5.1/ ./configure -prefix=/usr/local/ruby make make install cp /usr/local/ruby/bin/ruby /usr/local/bin/ cp /usr/local/ruby/bin/gem /usr/local/bin/ # 移除默认源 gem sources --remove https://rubygems.org/ gem sources -a https://mirrors.aliyun.com/rubygems/ ``` #### 安装redis-dump(依赖Rube) ``` gem install redis-dump -V ``` #### 安装VNC server > VNC Server主要用来安装Oracle和Weblogic等需要图形界面安装的软件(有随时可以连接的需求) 当然,直接开启Centos操作系统下的远程桌面也可以,限制是用户需要服务器登录后才行(虚拟机下这样玩) YUM安装 ```shell yum install tigervnc-server ``` Centos 6 操作 ```shell # 配置VNC Server vim /etc/sysconfig/vncservers # 单用户设置如下:(端口:5901) VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp " # 多用户设置如下 VNCSERVERS="1:root 2:oracle" VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp " # VNC密码设置 #root 用户下,设置登录vnc密码** vncpasswd #oracle用户下,切换到oracle用户下,设置登录vnc密码 su – oracle vncpasswd # 启动 service vncserver start service vncserver restart service vncserver stop ``` Centos 7 操作 ``` cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service # 修改配置文件[service]段 (以root用户为例, 把<USER>改为root) [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :' ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver :1 -geometry 1280x720 -depth 24" PIDFile=/root/.vnc/%H%i.pid (这里的%H%i 不用改,vnc用来生成PIDFile文件名,保证路径存在就可以了) ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :' # 更新systemctl systemctl daemon-reload # 设置vnc远程连接密码 vncpasswd #启动vnc服务 (如报错,根据提示查看状态) systemctl start vncserver@:1.service # 设置为自动启动 systemctl enable vncserver@:1.service ``` #### NTP服务部署 YUM安装 ```shell yum install ntp ntpdate -y ``` 修改配置文件/etc/ntp.conf 删除后添加以下内容 ```shell server 202.120.2.101 #当外部时间不可用时,使用本地时间。 server 127.127.1.0 iburst local clock #允许更新的IP地址段 restrict 192.168.0.1 mask 255.255.255.0 nomodify ``` 启动ntp服务 **Centos 7 ** ```shell systemctl start ntpd systemctl enable ntpd.service ``` **Centos 6 ** ```shell /etc/init.d/ntpd chkconfig ntpd on ``` ```shell #### 验证服务 ntpq -p ``` 增加crond ```shell 0 */2 * * * /usr/sbin/ntpdate 202.120.2.101 > /dev/null 2>&1 ```