0%

Linux下,Oracle 11g的自动内存管理不能指定大于这个/dev/shm的总量内存。否则就会出现如下错误:

1
ORA-00845: MEMORY_TARGET not supported on this system

修改/etc/fstab,修改tmpfs大小,如果没有则需要自己添加:

1
2
3
# vi /etc/fstab

tmpfs /dev/shm tmpfs defaults,size=10240M 0 0

重新挂载:

1
2
3
4
5
6
# mount -o remount /dev/shm
# df -h

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.7G 4.6G 4.7G 50% /
tmpfs 10.0G 228K 10.0G 1% /dev/shm

此脚本为zabbix4.4和grafana6.7.4的一键部署脚本,脚本运行完成即可通过web页面进行管理配置,只适用于RHEL7.X版本,可用于最小化安装的版本,脚本中使用了case语句做了菜单,可自行选择安装zabbix或grafana,脚本中yum源使用的是清华源,可自行更改为阿里源或者其它yum源,脚本中已将zabbix和grafana所需要的端口放通,未关闭防火墙的情况下也可以正常访问。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
#此脚本用于RHCL7安装Zabbix4.4和Grafana6.7.4

cat << EOF
********请选择需要安装的组件:********
(1) Install Zabbix 4.4
(2) Install Grafana 6.7.4
EOF

read -p "请选择需要安装的组件:" digit

case $digit in
"1" )
echo "Install Zabbix 4.4"

#关闭SELinux
if [ $(getenforce) = "Enforcing" ]; then
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
echo "Selinux已关闭!"
fi

#安装zabbix的repo源
if [ $(curl -sL -w "%{http_code}" "https://mirror.tuna.tsinghua.edu.cn/" -o /dev/null) -eq 200 ];then
echo "地址通畅,继续安装!!!"
rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
sed -i -e 's/repo.zabbix.com/mirror.tuna.tsinghua.edu.cn\/zabbix/g' /etc/yum.repos.d/zabbix.repo
yum clean all
else
echo "地址不通畅,请检查网络!!!"
exit
fi

#安装zabbix和mariadb
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb mariadb-server
systemctl start mariadb.service
systemctl enable mariadb.service
mysql -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
mysql -e "flush privileges;"
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix

#修改zabbix-server配置文件
cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak
sed -i 's/# DBHost=localhost/DBHost=localhost/' /etc/zabbix/zabbix_server.conf
sed -i 's/# DBPassword=/DBPassword=zabbix/' /etc/zabbix/zabbix_server.conf
sed -i 's/# StartPollers=5/StartPollers=40/' /etc/zabbix/zabbix_server.conf
sed -i 's/# StartPreprocessors=3/StartPreprocessors=20/' /etc/zabbix/zabbix_server.conf
sed -i 's/# StartPollersUnreachable=1/StartPollersUnreachable=10/' /etc/zabbix/zabbix_server.conf
sed -i 's/# StartPingers=1/StartPingers=15/' /etc/zabbix/zabbix_server.conf
sed -i 's/# StartDiscoverers=1/StartDiscoverers=5/' /etc/zabbix/zabbix_server.conf
sed -i 's/# HousekeepingFrequency=1/HousekeepingFrequency=24/' /etc/zabbix/zabbix_server.conf
sed -i 's/# MaxHousekeeperDelete=5000/MaxHousekeeperDelete=10000/' /etc/zabbix/zabbix_server.conf
sed -i 's/# CacheSize=8M/CacheSize=4G/' /etc/zabbix/zabbix_server.conf
sed -i 's/# ValueCacheSize=8M/ValueCacheSize=2G/' /etc/zabbix/zabbix_server.conf

#修改zabbix-web配置文件
cp /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf.bak
sed -i 's/memory_limit 128M/memory_limit 512M/' /etc/httpd/conf.d/zabbix.conf
sed -i 's/# php_value date.timezone Europe\/Riga/php_value date.timezone Asia\/Shanghai/' /etc/httpd/conf.d/zabbix.conf
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd

#开放端口
firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --zone=public --add-port=10051/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

#判断zabbix网页是否正常打开
if [ $(curl -sL -w "%{http_code}" "http://127.0.0.1/zabbix" -o /dev/null) -eq 200 ]; then
echo "Zabbix安装成功!!!"
else
echo "Zabbix异常,请检查!!!"
fi
;;
"2" )
echo "Install Grafana 6.7.4"

#判断wget是否安装
command -v wget
if [ $? -ne 0 ]; then
yum -y install wget
echo "wget安装成功!!!"
else
echo "wget已存在!!!"
fi

#判断地址是否通畅,通畅则下载rpm包
if [ $(curl -sL -w "%{http_code}" "https://mirror.tuna.tsinghua.edu.cn/" -o /dev/null) -eq 200 ];then
echo "地址通畅,继续安装!!!"
wget https://mirror.tuna.tsinghua.edu.cn/grafana/yum/rpm/grafana-6.7.4-1.x86_64.rpm
else
echo "地址不通畅,请检查网络!!!"
exit
fi

#安装Grafana
yum -y install fontconfig freetype* urw-fonts
rpm -ivh /root/grafana-6.7.4-1.x86_64.rpm
grafana-cli plugins install alexanderzobnin-zabbix-app
systemctl enable grafana-server
systemctl start grafana-server

#开放端口
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --reload

#判断grafana网页是否正常打开
if [ $(curl -sL -w "%{http_code}" "http://127.0.0.1:3000" -o /dev/null) -eq 200 ]; then
echo "Grafana安装成功!!!"
else
echo "Grafana异常,请检查!!!"
fi
;;
"*" )
echo "Error"
;;
esac

在MySQL服务启动后,默认的密码被保存在错误日志文件中,可以通过以下命令查看:

1
2
shell> sudo grep 'temporary password' /var/log/mysqld.log
2018-06-03T10:15:57.448920Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 0xxXxxXx?xXX

通过默认密码登录MySQL服务器,并马上修改密码(强烈建议)!!!。
用默认密码(0xxXxxXx?xXX)登录:

1
shell> mysql -uroot -p

修改密码:

1
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '*{your-password}*';

退出MySQL并用新密码重新登录,然后就可以在MySQL中尽情发挥想象了。

在配置mysql主从同步的时候通常需要设置主库为只读,可以通过以下方式实现。

设置命令:

1
mysql> set global read_only=1;

查看设置结果:

1
mysql> show global variables like "%read_only%";

恢复命令:

1
mysql> set global read_only=0;

首先查看mysql的sql_mode:

1
2
3
4
5
6
7
mysql> select @@sql_mode;
+----------------------------------------------------------------------------------------------------+
| @@sql_mode |
+----------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------------------------------------------+
1 row in set (0.25 sec)

可以看到ONLY_FULL_GROUP_BY,我们需要关闭它。

1
2
3
4
5
vi /etc/mysql/conf.d/custom.cnf

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
#没有only_full_group_by

最后重启mysql。