1. 程式人生 > 實用技巧 >Cacti1.2.16最新版安裝和配置(Shell一鍵安裝)

Cacti1.2.16最新版安裝和配置(Shell一鍵安裝)

一、Cacati一鍵安裝指令碼介紹

如果你對系統操作不是很熟悉,剛開始安裝這種軟體可能會比較麻煩,手動安裝各個步驟一不小心經常出錯,但是出於為了熟悉環境,還是建議手動安裝一次兩次,這樣可以熟悉各個元件的安裝和配置。

二、環境要求

  • Centos 7.x以上,網路正常
  • PHP 7.x以上
  • MariaDB或者Mysql5.7版本以上

三、使用

指令碼下載: https://cloud.mefj.com.cn/#/s/EjfE 密碼:qwerty

下載解壓縮到root根目錄-----賦權和執行,如下:

[root@brace ~]# chmod +x auto.sh
[root@brace 
~]# ./ auto.sh

參考shell

#!/bin/bash
#
# OS:CENTOS 7 X86_64
#
version=1.2.16
std_dir=$(pwd)
function Idendify()
{
    
    if [ $UID -ne 0 ];then
        echo "Must run as root!"
        cd
        rm -rf $std_dir
        exit 1
    fi
}
#禁用selinux
function Disable_selinux()
{
    setenforce 0
#
    
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config # } #建立mariadb10源 function Rebuild_repo() { echo -e "[mariadb]nname = MariaDBnbaseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64ngpgkey = https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDBngpgcheck = 1" >/etc/yum.repos.d/CentOS-MariaDB.repo #重建軟體源快取
yum clean all yum makecache } #安裝依賴 function Install_base_env() { yum -y install gcc make automake httpd php php-mysql php-snmp php-xml php-gd php-ldap php-mbstring php-posix MariaDB-client MariaDB-server MariaDB-devel MariaDB-compat MariaDB-common pcre-devel pango pango-devel cairo-devel libxml2-devel pixman-devel perl-devel fontconfig-devel freetype libpng-devel binutils cpp net-snmp net-snmp-utils net-snmp-devel openssl-devel autoconf binutils dos2unix libtool glibc-devel glibc-headers kernel-headers wget patch fontconfig ttmkfdir } # #安裝rrdtool function Install_rrdtool() { tar -xzvf rrdtool-1.7.2.tar.gz cd rrdtool-1.7.2/ sed -i 's/RRDTOOL / TOBI OETIKER/YUNWEI PASSWD / Based on cacti/' src/rrd_graph.c ./configure make && make install cd ../ cp /opt/rrdtool-1.7.2/bin/* /usr/bin/ } # #啟動SNMP function Start_snmp() { systemctl enable snmpd systemctl start snmpd } #安裝cacti-spine function Install_spine() { tar zxvf cacti-spine-$version.tar.gz cd cacti-spine-$version/ ./bootstrap ./configure make cp spine /usr/bin/spine cp spine.conf.dist /etc/spine.conf cd ../ chown apache.apache /etc/spine.conf sed -i '/^DB_Pass/cDB_Pass am9pbmRhdGEubmV0Cg' /etc/spine.conf } # #啟動資料庫 # function Start_mariadb() { systemctl enable mariadb systemctl start mariadb } # function Create_db() { mysqladmin -uroot password 'am9pbmRhdGEubmV0Cg' # mysql -uroot -pam9pbmRhdGEubmV0Cg -e "create database cacti;" # mysql -uroot -pam9pbmRhdGEubmV0Cg -e "grant all on cacti.* to cactiuser@'localhost' identified by 'am9pbmRhdGEubmV0Cg';" # mysql -uroot -pam9pbmRhdGEubmV0Cg -e "flush privileges;" # mysql -uroot -pam9pbmRhdGEubmV0Cg -e "ALTER DATABASE cacti CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" } # #安裝cacti function Install_cacti() { tar zxvf cacti-$version.tar.gz mv cacti-$version /var/www/html/cacti # chmod -R a-w /var/www/html/cacti/ chown -R apache /var/www/html/cacti/resource/snmp_queries/ chown -R apache /var/www/html/cacti/resource/script_server/ chown -R apache /var/www/html/cacti/resource/script_queries/ chown -R apache /var/www/html/cacti/scripts/ chown -R apache /var/www/html/cacti/cache/boost/ chown -R apache /var/www/html/cacti/cache/mibcache/ chown -R apache /var/www/html/cacti/cache/realtime/ chown -R apache /var/www/html/cacti/cache/spikekill/ # chmod -R u+w /var/www/html/cacti/resource/snmp_queries/ chmod -R u+w /var/www/html/cacti/resource/script_server/ chmod -R u+w /var/www/html/cacti/resource/script_queries/ chmod -R u+w /var/www/html/cacti/scripts/ chmod -R u+w /var/www/html/cacti/cache/boost/ chmod -R u+w /var/www/html/cacti/cache/mibcache/ chmod -R u+w /var/www/html/cacti/cache/realtime/ chmod -R u+w /var/www/html/cacti/cache/spikekill/ # #匯入資料庫 # mysql -u cactiuser -pam9pbmRhdGEubmV0Cg cacti</var/www/html/cacti/cacti.sql # chmod -R 777 /var/www/html/cacti/rra chmod -R 777 /var/www/html/cacti/log chown -R apache.apache /var/www/html/cacti/rra chown -R apache.apache /var/www/html/cacti/log # } #測試一下spine # function Test_spine() { /usr/bin/spine # } #修改cacti全域性配置檔案 # function Config_cacti() { sed -i '/^$database_default/c$database_default = '''cacti''';' /var/www/html/cacti/include/config.php # sed -i '/^$database_username/c$database_username = '''cactiuser''';' /var/www/html/cacti/include/config.php # sed -i '/^$database_password/c$database_password = '''am9pbmRhdGEubmV0Cg''';' /var/www/html/cacti/include/config.php # #修改時區 sed -i '24adate_default_timezone_set('''Asia/Shanghai''');' /var/www/html/cacti/include/global.php # } #新增計劃任務 # function Add_cron() { echo "*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php >> /tmp/cacti_rrdtool.log 2>&1" |crontab # } #修改php.ini # function Config_php() { sed -i '/memory_limit/cmemory_limit = 1536M' /etc/php.ini # sed -i '/max_execution_time/cmax_execution_time = 100' /etc/php.ini # sed -i '/date.timezone =/cdate.timezone = "Asia/Shanghai"' /etc/php.ini } # #配置資料庫特性 # function config_mariadb() { sed -i '/[mysqld]/acharacter_set_server=utf8mb4' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/acharacter_set_client=utf8mb4' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/acollation_server=utf8mb4_unicode_ci' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/amax_heap_table_size=768M' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/atmp_table_size=768M' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ajoin_buffer_size=1024M' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_file_format=Barracuda' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_large_prefix=1' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_buffer_pool_size=8192M' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_flush_log_at_timeout=3' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_read_io_threads=32' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_write_io_threads=16' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_buffer_pool_instances=64' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_io_capacity=400' /etc/my.cnf.d/server.cnf sed -i '/[mysqld]/ainnodb_io_capacity_max=4000' /etc/my.cnf.d/server.cnf # #匯入mysql時區 # cd /bin mysql_tzinfo_to_sql /usr/share/zoneinfo |mysql -uroot -pam9pbmRhdGEubmV0Cg mysql # mysql -uroot -pam9pbmRhdGEubmV0Cg -e "grant select on mysql.time_zone_name to cactiuser@'localhost';" # systemctl restart mariadb } #上傳字型 # function config_font() { cd /usr/share/fonts/ mkdir chinese # cp $std_dir/FZHTK.TTF chinese/ # ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir # fc-cache # } function Install_plugins() { cd $std_dir tar xzvf plugin_monitor-2.3.6.tar.gz tar xzvf plugin_thold-1.3.2.tar.gz mv plugin_monitor-2.3.6 /var/www/html/cacti/plugins/monitor mv plugin_thold-develop /var/www/html/cacti/plugins/thold } #啟動httpd # function Start_httpd() { systemctl enable httpd systemctl start httpd # } # function Config_firewall() { firewall-cmd --permanent --add-service http firewall-cmd --add-service http } # Idendify # Disable_selinux # Rebuild_repo # Install_base_env # Install_rrdtool # Start_snmp # Install_spine # Start_mariadb # Create_db # Install_cacti # Test_spine # Config_cacti # Add_cron # Config_php # config_mariadb # config_font # Install_plugins # Start_httpd # Config_firewall # exit 0 #

來源:https://mefj.com.cn/lur2873.html