在本文中,我们将带你了解CentOS一键安装Cacti1.2.3脚本在这篇文章中,我们将为您详细介绍CentOS一键安装Cacti1.2.3脚本的方方面面,并解答centos安装插件常见的疑惑,同时我
在本文中,我们将带你了解CentOS 一键安装Cacti 1.2.3脚本在这篇文章中,我们将为您详细介绍CentOS 一键安装Cacti 1.2.3脚本的方方面面,并解答centos安装插件常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的CentOS 6 升级到 CentOS 7、CentOS 6 和 CentOS 7 防火墙的关闭、CentOS 6, CentOS 7 安装mysql数据库、CentOS 6.6 系统升级到 CentOS 6.7。
本文目录一览:- CentOS 一键安装Cacti 1.2.3脚本(centos安装插件)
- CentOS 6 升级到 CentOS 7
- CentOS 6 和 CentOS 7 防火墙的关闭
- CentOS 6, CentOS 7 安装mysql数据库
- CentOS 6.6 系统升级到 CentOS 6.7
CentOS 一键安装Cacti 1.2.3脚本(centos安装插件)
#!/bin/bash echo "this script requires git" yum install -y git echo "This script will download all Cacti dependecies and download the chosen cacti version from the cacti github" echo "Dont forget to support cacti @ cacti.net!" echo "set selinux to disabled" setenforce 0 sed -i ‘s/enforcing/disabled/g‘ /etc/selinux/config /etc/selinux/config #Download chosen release echo "here are some of the current cacti release versions \n release/1.2.3 release/1.2.2 release/1.2.1 release/1.2.0 " echo "which release would you like to download ? Hit enter for latest" read version if [ "$version" == "" ] then git clone https://github.com/Cacti/cacti.git else yum install -y wget unzip wget https://github.com/Cacti/cacti/archive/release/$version.zip unzip $version mv cacti-release-$version cacti fi echo "will you be using the spine poller enter 1 for yes 2 for no" read answer if [ $answer == "1" ] then ##Download packages needed for spine yum install -y gcc MysqL-devel net-snmp-devel autoconf automake libtool dos2unix help2man echo "downloading and compling spine" git clone https://github.com/Cacti/spine.git cd spine ./bootstrap ./configure make make install chown root:root /usr/local/spine/bin/spine chmod u+s /usr/local/spine/bin/spine cd .. else echo "spine dependecies will not be installed" fi echo "On Centos systems we need to enable EPEL repos" yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y yum install yum-utils -y yum-config-manager --enable remi-PHP72 echo "Downloading PHP modules needed for Cacti install" yum install -y rrdtool mariadb-server net-snmp-utils net-snmp snmpd PHP PHP-MysqL PHP-snmp PHP-xml PHP-mbstring PHP-json PHP-gd PHP-gmp PHP-zip PHP-ldap PHP-mc PHP-posix ###Start services systemctl enable httpd systemctl enable mariadb systemctl start mariadb systemctl start httpd ####Open Port 80 and 443 on firewalld echo "Open http and https ports on firewalld" firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload ##Timezone settings needed for cacti echo "Enter your PHP time zone i.e America/Toronto Default is US/Central " read timezone if [ $timezone == "" ] then echo "date.timezone =" US/Central >> /etc/PHP.ini else echo "date.timezone =" $timezone >> /etc/PHP.ini fi echo "Where would you like to install cacti default location is /var/www/html hit enter for default location" read location if [$location = ""] then location="/var/www/html" mv cacti /var/www/html else mv cacti $location fi #Create cacti user and change permission of directory echo "Which user would you like to run Cacti under (Default is www-data) hit enter for default" read user if [$user = ""] then user="apache" echo "cacti will be run under apache" chown -R apache:apache $location/cacti else useradd $user chown -R $user:$user $location/cacti fi #assign permissions for cacti installation chown -R apache:apache $location/cacti/resource/snmp_queries/ chown -R apache:apache $location/cacti/resource/script_server/ chown -R apache:apache $location/cacti/resource/script_queries/ chown -R apache:apache $location/cacti/scripts/ chown -R apache:apache $location/cacti/cache/boost/ chown -R apache:apache $location/cacti/cache/mibcache/ chown -R apache:apache $location/cacti/cache/realtime/ chown -R apache:apache $location/cacti/cache/spikekill/ touch $location/cacti/log/cacti.log chmod 777 $location/cacti/log/cacti.log chown -R apache:apache $location/cacti/log/ cp $location/cacti/include/config.PHP.dist $location/cacti/include/config.PHP ##Create database echo "would you like to customize the database name and user ? hit enter for defaults" read customize if [[ $customize = "" ]] then MysqL -uroot <<MysqL_SCRIPT CREATE DATABASE cacti DEFAULT CHaraCTER SET utf8 COLLATE utf8_unicode_ci ; GRANT ALL PRIVILEGES ON cacti.* TO ‘cacti‘@‘localhost‘ IDENTIFIED BY ‘cacti‘; ; GRANT SELECT ON MysqL.time_zone_name TO [email protected]; USE MysqL; ALTER DATABASE cacti CHaraCTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; FLUSH PRIVILEGES; MysqL_SCRIPT #pre populate cacti db MysqL -u root cacti < $location/cacti/cacti.sql MysqL_tzinfo_to_sql /usr/share/zoneinfo | MysqL -u root MysqL sed -i -e ‘[email protected]^$database_type.*@$database_type = "MysqL";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_default.*@$database_default = "cacti";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_hostname.*@$database_hostname = "127.0.0.1";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_username.*@$database_username = "cacti";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_password.*@$database_password = "cacti";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_port.*@$database_port = "3306";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_ssl.*@$database_ssl = "false";@g‘ /var/www/html/cacti/include/config.PHP sed -i -e ‘[email protected]^//[email protected][email protected]‘ /var/www/html/cacti/include/config.PHP echo "default database setup with following details" echo "database name cacti\n database username cacti\n database password cacti" else echo "enter db name" read customdbname echo "enter db user" read customdbuser echo "enter db password" read customdbpassword MysqL -u root <<MysqL_SCRIPT CREATE DATABASE $customdbname; GRANT ALL PRIVILEGES ON $customdbname.* TO ‘$customdbuser‘@‘localhost‘ IDENTIFIED BY ‘$customdbpassword‘; GRANT SELECT ON MysqL.time_zone_name TO [email protected]; ALTER DATABASE $customdbname CHaraCTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; FLUSH PRIVILEGES; MysqL_SCRIPT echo "Pre-populating cacti DB" MysqL -u root $customdbname < $location/cacti/cacti.sql MysqL_tzinfo_to_sql /usr/share/zoneinfo | MysqL -u root MysqL sed -i -e ‘[email protected]^$database_type.*@$database_type = "MysqL";@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_default.*@$database_default = ‘$customdbname‘\;@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_hostname.*@$database_hostname = "127.0.0.1";@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_username.*@$database_username = ‘$customdbuser‘;@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_password.*@$database_password = ‘$customdbpassword‘;@g‘ $location/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_port.*@$database_port = "3306";@g‘ "$location"/cacti/include/config.PHP sed -i -e ‘[email protected]^$database_ssl.*@$database_ssl = "false";@g‘ "$location"/cacti/include/config.PHP sed -i -e ‘[email protected]^//[email protected][email protected]‘ $location/cacti/include/config.PHP fi ###Adding recomended PHP settings sed -e ‘s/max_execution_time = 30/max_execution_time = 60/‘ -i /etc/PHP.ini sed -e ‘s/memory_limit = 128M/memory_limit = 400M/‘ -i /etc/PHP.ini echo "Applying recommended DB settings" echo " innodb_file_format = Barracuda character_set_client = utf8mb4 max_allowed_packet = 16777777 join_buffer_size = 32M innodb_file_per_table = ON innodb_large_prefix = 1 innodb_buffer_pool_size = 250M innodb_additional_mem_pool_size = 90M innodb_flush_log_at_trx_commit = 2 " >> /etc/my.cnf.d/server.cnf echo "this script can download the following plugins monitor,thold would you like to install them ? type yes to download hit enter to skip" read plugins if [ $plugins == "yes" ] then git clone https://github.com/Cacti/plugin_thold.git git clone https://github.com/Cacti/plugin_monitor.git mv plugin_thold thold mv plugin_monitor monitor chown -R $user:$user thold chown -R $user:$user monitor mv thold $location/cacti/plugins mv monitor $location/cacti/plugins else echo "plugins will not be installed" fi touch /etc/cron.d/$user echo "*/5 * * * * $user PHP $location/cacti/poller.PHP > /dev/null 2>&1" > /etc/cron.d/$user echo "refreshing services" systemctl restart httpd systemctl restart mariadb echo "Installation completed !"
CentOS 6 升级到 CentOS 7
注意
非必要情况,请使用重新安装系统的方式升级,原因如下:
- 并非所有的系统都能顺利从 6 升级到 7,安装的软件越少,升级成功的可能性越大;
- 只支持 6.5 及以上系统升级到不高于 7.2 系统;
- 升级的耗时完全不比重新安装少,绝大多数情况下会耗费更长的时间和更多精力;
- 升级完成后处理各种依赖是一个非常头大的问题。
本人在同一天升级了两台电脑,一个成功一个失败。成功的那台电脑额外花了一天时间处理各种依赖和问题,失败的电脑半小时装好系统和必备软件,用得爽歪歪。所以如非必要,建议采用备份数据后直接重装系统的方式。
操作
通过软件方式从 6 升级到 7,请参考下面的步骤:
-
升级当前系统到最新版本:
yum update -y
-
安装旧版
openscap
:yum remove -y openscap && yum install -y http://dev.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
; -
添加
upgradetool
源:cat <<EOF >/etc/yum.repos.d/upgradetool.repo [upgrade] name=CentOS-$releasever - Upgrade Tool baseurl=http://dev.centos.org/centos/6/upg/x86_64/ gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 EOF
-
安装升级工具:
yum install -y redhat-upgrade-tool preupgrade-assistant preupgrade-assistant-contents
; -
执行升级可行性分析:
preupg -l
,该命令会耗费几分钟到几十分钟时间。如果出现preupg: error: [Errno 2] No such file or directory: ''/root/preupgrade/result.html''
的错误,请参考第一步安装openscap
的旧版; -
使用清华大学的
centos-vault
源安装 7.2 版本:centos-upgrade-tool-cli --network 7 --instrepo=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.2.1511/os/x86_64/
。** 注意:**7.2 是支持升级的最高版本,升级其他版本将会出现
Downloading failed: invalid data in .treeinfo: No section: ''checksums''
的错误提示; -
如果升级成功,用
reboot
命令重启系统;如果提示The requested URL returned error: 404 Not Found
等错误,基本上说明当前系统不支持直接升级。果断采用重装系统的正道吧,少年! -
系统重启后,有可能因为依赖库确实导致
ssh
无法启动,grep
不能正常使用等问题。基本功底够好的手动排查,然后一个个问题解决;搞不懂错误原因或者觉得处理麻烦的,备份数据后重装系统吧! -
使用
rpm -qa | grep el6
查看系统上残留的软件包。如果能手动清理掉,让系统update
无障碍,耐心一个个处理掉。如果觉得依赖太麻烦或者搞不定,备份数据后重装系统吧!
参考
- https://blog.51cto.com/moerjinrong/2340656
CentOS 6 和 CentOS 7 防火墙的关闭
CentOS6.5 查看防火墙的状态:
[linuxidc@localhost ~]$service iptable status 显示结果: [linuxidc@localhost ~]$service iptable status Redirecting to /bin/systemctl status iptable.service
● iptable.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) -- 表示防火墙已经关闭 CentOS 6.5 关闭防火墙
[root@localhost ~]#servcie iptables stop -- 临时关闭防火墙 [root@localhost ~]#chkconfig iptables off -- 永久关闭防火墙
CentOS 7.2 关闭防火墙
CentOS 7.0 默认使用的是 firewall 作为防火墙,这里改为 iptables 防火墙步骤。 firewall-cmd --state #查看默认防火墙状态(关闭后显示 notrunning,开启后显示 running)
[root@localhost ~]#firewall-cmd --state not running 检查防火墙的状态:
从 centos7 开始使用 systemctl 来管理服务和程序,包括了 service 和 chkconfig。
[root@localhost ~]#systemctl list-unit-files|grep firewalld.service -- 防火墙处于关闭状态 firewalld.service disabled 或者
[root@localhost ~]#systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) 关闭防火墙:
systemctl stop firewalld.service #停止 firewall systemctl disable firewalld.service #禁止 firewall 开机启动
[root@localhost ~]#systemctl stop firewalld.service [root@localhost ~]#systemctl disable firewalld.service
启动一个服务:systemctl start firewalld.service 关闭一个服务:systemctl stop firewalld.service 重启一个服务:systemctl restart firewalld.service 显示一个服务的状态:systemctl status firewalld.service 在开机时启用一个服务:systemctl enable firewalld.service 在开机时禁用一个服务:systemctl disable firewalld.service 查看服务是否开机启动:systemctl is-enabled firewalld.service;echo $? 查看已启动的服务列表:systemctl list-unit-files|grep enabled Centos 7 firewall 命令: 查看已经开放的端口:
firewall-cmd --list-ports 开启端口
firewall-cmd --zone=public --add-port=80/tcp --permanent 命令含义:
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口 / 通讯协议
–permanent #永久生效,没有此参数重启后失效
重启防火墙
firewall-cmd --reload #重启 firewall systemctl stop firewalld.service #停止 firewall systemctl disable firewalld.service #禁止 firewall 开机启动 firewall-cmd --state #查看默认防火墙状态(关闭后显示 notrunning,开启后显示 running) CentOS 7 以下版本 iptables 命令 如要开放 80,22,8080 端口,输入以下命令即可
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT 然后保存:
/etc/rc.d/init.d/iptables save 查看打开的端口:
/etc/init.d/iptables status 关闭防火墙 1) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
查看防火墙状态: service iptables status
下面说下 CentOS7 和 6 的默认防火墙的区别
CentOS 7 默认使用的是 firewall 作为防火墙,使用 iptables 必须重新设置一下
1、直接关闭防火墙
systemctl stop firewalld.service #停止 firewall
systemctl disable firewalld.service #禁止 firewall 开机启动
2、设置 iptables service
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口 3306
vi /etc/sysconfig/iptables
增加规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
最后重启系统使设置生效即可。
systemctl start iptables.service #打开防火墙
systemctl stop iptables.service #关闭防火墙
解决主机不能访问虚拟机 CentOS 中的站点 前阵子在虚拟机上装好了 CentOS6.2,并配好了 apache+php+mysql,但是本机就是无法访问。一直就没去折腾了。
具体情况如下
- 本机能 ping 通虚拟机
- 虚拟机也能 ping 通本机 3. 虚拟机能访问自己的 web 4. 本机无法访问虚拟机的 web
后来发现是防火墙将 80 端口屏蔽了的缘故。
检查是不是服务器的 80 端口被防火墙堵了,可以通过命令:telnet server_ip 80 来测试。
解决方法如下: /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 然后保存: /etc/rc.d/init.d/iptables save 重启防火墙 /etc/init.d/iptables restart
CentOS 防火墙的关闭,关闭其服务即可: 查看 CentOS 防火墙信息:/etc/init.d/iptables status 关闭 CentOS 防火墙服务:/etc/init.d/iptables stop
CentOS 6, CentOS 7 安装mysql数据库
#!/bin/sh
# CentOs 6
#使用sohu镜像,速度快
wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-server-5.6.35-1.el6.x86_64.rpm
wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-client-5.6.35-1.el6.x86_64.rpm
wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-shared-5.6.35-1.el6.x86_64.rpm
#删除默认安装包
rpm -qa| grep mysql-libs | xargs rpm -e --nodeps
#安装依赖包
yum -y install numactl
rpm -ivh MySQL-shared-5.6.35-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.35-1.el6.x86_64.rpm
rpm -ivh MySQL-server-5.6.35-1.el6.x86_64.rpm
#获取默认root密码
sqlpasswd=`cat /root/.mysql_secret | awk -F''): '' {''print $2''}`
echo "MySQL root passwd: $sqlpasswd"
#设置数据库服务端编码为utf8
echo character_set_server=utf8 >> /usr/my.cnf
#重启数据库
service mysql restart
#!/bin/sh
# CentOS 7
wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-server-5.6.35-1.el7.x86_64.rpm
wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-client-5.6.35-1.el7.x86_64.rpm
wget http://mirrors.sohu.com/mysql/MySQL-5.6/MySQL-shared-5.6.35-1.el7.x86_64.rpm
rpm -ivh MySQL-shared-5.6.35-1.el7.x86_64.rpm
rpm -ivh MySQL-client-5.6.35-1.el7.x86_64.rpm
rpm -ivh MySQL-server-5.6.35-1.el7.x86_64.rpm
#获取默认root密码
sqlpasswd=`cat /root/.mysql_secret | awk -F''): '' {''print $2''}`
echo "MySQL root passwd: $sqlpasswd"
#设置数据库服务端编码为utf8
echo character_set_server=utf8 >> /usr/my.cnf
SET PASSWORD FOR ''root''@''localhost''=PASSWORD(''newpass'');
CentOS 6.6 系统升级到 CentOS 6.7
1、利用 Centos6.7 ISO 镜像挂载为本地镜像
创建一个挂载目录 CentOS 6.6 系统升级到 CentOS 6.7
mkdir /mnt/data
2、挂载镜像(远程镜像)
mount -t nfs 172.16.2.100://iso /mnt/data
3、yum 源配置文件
vim CentOS-Media.repo
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/data
gpgcheck=1
enabled=1
gpgkey=file:///mnt/data/RPM-GPG-KEY-CentOS-6
4、清除 yum 缓存进行更新
yum clean all
yum makecache
5、系统更新:
yum -y update
(如有报错看依赖进行安装,或者依赖版本问题需要重新安装)
rpm -e kernel-2.6.32-504.el6.x86_64
rpm -e kernel-devel-2.6.32-504.el6.x86_64
重启:
reboot
可能会遇到的依赖提示:
rpm -e libreport
yum remove libreport
yum -y install libreport
yum remove libreport-filesystem
yum -y install libreport
关于CentOS 一键安装Cacti 1.2.3脚本和centos安装插件的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于CentOS 6 升级到 CentOS 7、CentOS 6 和 CentOS 7 防火墙的关闭、CentOS 6, CentOS 7 安装mysql数据库、CentOS 6.6 系统升级到 CentOS 6.7等相关知识的信息别忘了在本站进行查找喔。
本文标签: